@mux/mux-video 0.12.1 → 0.13.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.
- package/README.md +56 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +3 -3
- package/dist/mux-video.js +30 -29
- package/dist/mux-video.js.map +4 -4
- package/dist/mux-video.mjs +30 -29
- package/dist/mux-video.mjs.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +14 -2
- package/dist/types-ts3.4/index.d.ts +14 -2
- package/package.json +3 -3
package/dist/mux-video.mjs
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
var Fn=Object.create;var kr=Object.defineProperty;var kn=Object.getOwnPropertyDescriptor;var Bn=Object.getOwnPropertyNames;var Un=Object.getPrototypeOf,Nn=Object.prototype.hasOwnProperty;var Kn=(j,b,n)=>b in j?kr(j,b,{enumerable:!0,configurable:!0,writable:!0,value:n}):j[b]=n;var pi=(j,b)=>()=>(b||j((b={exports:{}}).exports,b),b.exports);var jn=(j,b,n,I)=>{if(b&&typeof b=="object"||typeof b=="function")for(let L of Bn(b))!Nn.call(j,L)&&L!==n&&kr(j,L,{get:()=>b[L],enumerable:!(I=kn(b,L))||I.enumerable});return j};var pr=(j,b,n)=>(n=j!=null?Fn(Un(j)):{},jn(b||!j||!j.__esModule?kr(n,"default",{value:j,enumerable:!0}):n,j));var zt=(j,b,n)=>(Kn(j,typeof b!="symbol"?b+"":b,n),n),Br=(j,b,n)=>{if(!b.has(j))throw TypeError("Cannot "+n)};var se=(j,b,n)=>(Br(j,b,"read from private field"),n?n.call(j):b.get(j)),xe=(j,b,n)=>{if(b.has(j))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(j):b.set(j,n)},be=(j,b,n,I)=>(Br(j,b,"write to private field"),I?I.call(j,n):b.set(j,n),n);var Ie=(j,b,n)=>(Br(j,b,"access private method"),n);var Ti=pi((Er,jr)=>{(function(){var j,b;j=this,b=function(){return function(){var n={80:function(D,w,R){D.exports=R(728).default},728:function(D,w,R){"use strict";R.d(w,{default:function(){return Mn}});var O=R(48),_=R.n(O),y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(F){var C=16*Math.random()|0;return(F==="x"?C:3&C|8).toString(16)})},T=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},A=function(F){return F&&F.nodeName!==void 0?(F.muxId||(F.muxId=F.id||T()),F.muxId):F},E=function(F){var C;F&&F.nodeName!==void 0?F=A(C=F):C=document.querySelector(F);var M=C&&C.nodeName?C.nodeName.toLowerCase():"";return[C,F,M]},m=R(640),p=R.n(m),d=p().methodFactory;p().methodFactory=function(F,C,M){var N=d(F,C,M);return function(){for(var K=["[mux]"],V=0;V<arguments.length;V++)K.push(arguments[V]);N.apply(void 0,K)}},p().setLevel(p().getLevel());var e=p();function o(){return(_().doNotTrack||_().navigator&&_().navigator.doNotTrack)==="1"}var h={now:function(){var F=_().performance,C=F&&F.timing,M=C&&C.navigationStart,N=typeof M=="number"&&typeof F.now=="function"?M+F.now():Date.now();return Math.round(N)}},g=R(678),i=R.n(g),r=function(F){return l(F)[0]},l=function(F){if(typeof F!="string"||F==="")return["localhost"];var C,M=(F.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return M&&(C=(M.match(/[^\.]+\.[^\.]+$/)||[])[0]),[M,C]},c={exists:function(){var F=_().performance;return(F&&F.timing)!==void 0},domContentLoadedEventEnd:function(){var F=_().performance,C=F&&F.timing;return C&&C.domContentLoadedEventEnd},navigationStart:function(){var F=_().performance,C=F&&F.timing;return C&&C.navigationStart}};function t(F,C,M){M=M===void 0?1:M,F[C]=F[C]||0,F[C]+=M}var a=["x-cdn","content-type","x-request-id"];function u(F){var C={};return(F=F||"").trim().split(/[\r\n]+/).forEach(function(M){if(M){var N=M.split(": "),K=N.shift();K&&(a.indexOf(K.toLowerCase())>=0||K.toLowerCase().indexOf("x-litix-")===0)&&(C[K]=N.join(": "))}}),C}var s=function(F){var C={};for(var M in F){var N=F[M];N["DATA-ID"].search("io.litix.data.")!==-1&&(C[N["DATA-ID"].replace("io.litix.data.","")]=N.VALUE)}return C};function f(F,C){var M=Object.keys(F);if(Object.getOwnPropertySymbols){var N=Object.getOwnPropertySymbols(F);C&&(N=N.filter(function(K){return Object.getOwnPropertyDescriptor(F,K).enumerable})),M.push.apply(M,N)}return M}function v(F){for(var C=1;C<arguments.length;C++){var M=arguments[C]!=null?arguments[C]:{};C%2?f(Object(M),!0).forEach(function(N){S(F,N,M[N])}):Object.getOwnPropertyDescriptors?Object.defineProperties(F,Object.getOwnPropertyDescriptors(M)):f(Object(M)).forEach(function(N){Object.defineProperty(F,N,Object.getOwnPropertyDescriptor(M,N))})}return F}function S(F,C,M){return C in F?Object.defineProperty(F,C,{value:M,enumerable:!0,configurable:!0,writable:!0}):F[C]=M,F}var x=function(F){if(!F)return{};var C=c.navigationStart(),M=F.loading,N=M?M.start:F.trequest,K=M?M.first:F.tfirst,V=M?M.end:F.tload;return{bytesLoaded:F.total,requestStart:Math.round(C+N),responseStart:Math.round(C+K),responseEnd:Math.round(C+V)}},P=function(F){if(F&&typeof F.getAllResponseHeaders=="function")return u(F.getAllResponseHeaders())};function B(F,C){var M=Object.keys(F);if(Object.getOwnPropertySymbols){var N=Object.getOwnPropertySymbols(F);C&&(N=N.filter(function(K){return Object.getOwnPropertyDescriptor(F,K).enumerable})),M.push.apply(M,N)}return M}function k(F){for(var C=1;C<arguments.length;C++){var M=arguments[C]!=null?arguments[C]:{};C%2?B(Object(M),!0).forEach(function(N){U(F,N,M[N])}):Object.getOwnPropertyDescriptors?Object.defineProperties(F,Object.getOwnPropertyDescriptors(M)):B(Object(M)).forEach(function(N){Object.defineProperty(F,N,Object.getOwnPropertyDescriptor(M,N))})}return F}function U(F,C,M){return C in F?Object.defineProperty(F,C,{value:M,enumerable:!0,configurable:!0,writable:!0}):F[C]=M,F}var W=function(F,C){if(!F||typeof F.getRequests!="function")return{};var M=F.getRequests({state:"executed"});if(M.length===0)return{};var N,K=M[M.length-1],V=r(K.url),G=K.url,Q=K.bytesLoaded,Z=new Date(K.requestStartDate).getTime(),$=new Date(K.firstByteDate).getTime(),ee=new Date(K.requestEndDate).getTime(),me=isNaN(K.duration)?0:K.duration,ue=typeof C.getMetricsFor=="function"?C.getMetricsFor(K.mediaType).HttpList:C.getDashMetrics().getHttpRequests(K.mediaType);return ue.length>0&&(N=u(ue[ue.length-1]._responseHeaders||"")),{requestStart:Z,requestResponseStart:$,requestResponseEnd:ee,requestBytesLoaded:Q,requestResponseHeaders:N,requestMediaDuration:me,requestHostname:V,requestUrl:G}},H=function(F,C){var M=C.getQualityFor(F),N=C.getCurrentTrackFor(F).bitrateList;return N?{currentLevel:M,renditionWidth:N[M].width||null,renditionHeight:N[M].height||null,renditionBitrate:N[M].bandwidth}:{}},z=function(F){var C;return(C=F.match(/.*codecs\*?="(.*)"/))===null||C===void 0?void 0:C[1]};function Y(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var J=0,te=function(){function F(){(function(K,V){if(!(K instanceof V))throw new TypeError("Cannot call a class as a function")})(this,F)}var C,M,N;return C=F,M=[{key:"on",value:function(K,V,G){return V._eventEmitterGuid=V._eventEmitterGuid||++J,this._listeners=this._listeners||{},this._listeners[K]=this._listeners[K]||[],G&&(V=V.bind(G)),this._listeners[K].push(V),V}},{key:"off",value:function(K,V){var G=this._listeners&&this._listeners[K];G&&G.forEach(function(Q,Z){Q._eventEmitterGuid===V._eventEmitterGuid&&G.splice(Z,1)})}},{key:"one",value:function(K,V,G){var Q=this;V._eventEmitterGuid=V._eventEmitterGuid||++J;var Z=function $(){Q.off(K,$),V.apply(G||this,arguments)};Z._eventEmitterGuid=V._eventEmitterGuid,this.on(K,Z)}},{key:"emit",value:function(K,V){var G=this;if(this._listeners){V=V||{};var Q=this._listeners["before*"]||[],Z=this._listeners[K]||[],$=this._listeners["after"+K]||[],ee=function(me,ue){(me=me.slice()).forEach(function(he){he.call(G,{type:K},ue)})};ee(Q,V),ee(Z,V),ee($,V)}}}],M&&Y(C.prototype,M),N&&Y(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}(),X=te;function q(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var ne=function(){function F(K){var V=this;(function(G,Q){if(!(G instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,K.on("playing",function(){V._playheadShouldBeProgressing=!0}),K.on("play",this._startPlaybackHeartbeatInterval.bind(this)),K.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),K.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),K.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),K.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),K.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),K.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),K.on("seeked",function(){K.data.player_is_paused?V._stopPlaybackHeartbeatInterval():V._startPlaybackHeartbeatInterval()}),K.on("timeupdate",function(){V._playbackHeartbeatInterval!==null&&K.emit("playbackheartbeat")}),K.on("devicesleep",function(G,Q){V._playbackHeartbeatInterval!==null&&(_().clearInterval(V._playbackHeartbeatInterval),K.emit("playbackheartbeatend",{viewer_time:Q.viewer_time}),V._playbackHeartbeatInterval=null)})}var C,M,N;return C=F,(M=[{key:"_startPlaybackHeartbeatInterval",value:function(){var K=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=_().setInterval(function(){K.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(_().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&q(C.prototype,M),N&&q(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function ae(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function re(F,C,M){return C&&ae(F.prototype,C),M&&ae(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var le=re(function F(C){var M=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,F),C.on("viewinit",function(){M.viewErrored=!1}),C.on("error",function(N,K){try{var V=C.errorTranslator({player_error_code:K.player_error_code,player_error_message:K.player_error_message,player_error_context:K.player_error_context});V?(C.data.player_error_code=V.player_error_code||K.player_error_code,C.data.player_error_message=V.player_error_message||K.player_error_message,C.data.player_error_context=V.player_error_context||K.player_error_context,M.viewErrored=!0):(delete C.data.player_error_code,delete C.data.player_error_message,delete C.data.player_error_context)}catch(G){C.mux.log.warn("Exception in error translator callback.",G),M.viewErrored=!0}})});function fe(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var ie=function(){function F(K){(function(V,G){if(!(V instanceof G))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K,this._watchTimeTrackerLastCheckedTime=null,K.on("playbackheartbeat",this._updateWatchTime.bind(this)),K.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var C,M,N;return C=F,(M=[{key:"_updateWatchTime",value:function(K,V){var G=V.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=G),t(this.pm.data,"view_watch_time",G-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=G}},{key:"_clearWatchTimeState",value:function(K,V){this._updateWatchTime(K,V),this._watchTimeTrackerLastCheckedTime=null}}])&&fe(C.prototype,M),N&&fe(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function ge(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var pe=function(){function F(K){(function(V,G){if(!(V instanceof G))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K,this._playbackTimeTrackerLastPlayheadPosition=-1,K.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),K.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),K.on("seeking",this._clearPlaybackTimeState.bind(this))}var C,M,N;return C=F,(M=[{key:"_updatePlaybackTime",value:function(){var K=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&K>this._playbackTimeTrackerLastPlayheadPosition){var V=K-this._playbackTimeTrackerLastPlayheadPosition;V<=1e3&&t(this.pm.data,"view_content_playback_time",V)}this._playbackTimeTrackerLastPlayheadPosition=K}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&ge(C.prototype,M),N&&ge(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function De(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var Me=function(){function F(K){(function(G,Q){if(!(G instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K;var V=this._updatePlayheadTime.bind(this);K.on("playbackheartbeat",V),K.on("playbackheartbeatend",V),K.on("timeupdate",V),K.on("destroy",function(){K.off("timeupdate",V)})}var C,M,N;return C=F,(M=[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=this.pm.data.view_max_playhead_position===void 0?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(K,V){var G=this,Q=function(){G.pm.currentFragmentPDT&&G.pm.currentFragmentStart&&(G.pm.data.player_program_time=G.pm.currentFragmentPDT+G.pm.data.player_playhead_time-G.pm.currentFragmentStart)};if(V&&V.player_playhead_time)this.pm.data.player_playhead_time=V.player_playhead_time,Q(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var Z=this.pm.getPlayheadTime();Z!==void 0&&(this.pm.data.player_playhead_time=Z,Q(),this._updateMaxPlayheadPosition())}}}])&&De(C.prototype,M),N&&De(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function Oe(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function je(F,C,M){return C&&Oe(F.prototype,C),M&&Oe(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var Pe=je(function F(C){if(function(V,G){if(!(V instanceof G))throw new TypeError("Cannot call a class as a function")}(this,F),!C.disableRebufferTracking){var M,N=function(V,G){K(G),M=void 0},K=function(V){if(M){var G=V.viewer_time-M;t(C.data,"view_rebuffer_duration",G),M=V.viewer_time}C.data.view_watch_time>=0&&C.data.view_rebuffer_count>0&&(C.data.view_rebuffer_frequency=C.data.view_rebuffer_count/C.data.view_watch_time,C.data.view_rebuffer_percentage=C.data.view_rebuffer_duration/C.data.view_watch_time)};C.on("playbackheartbeat",function(V,G){return K(G)}),C.on("rebufferstart",function(V,G){M||(t(C.data,"view_rebuffer_count",1),M=G.viewer_time,C.one("rebufferend",N))}),C.on("viewinit",function(){M=void 0,C.off("rebufferend",N)})}});function Be(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var Ee=function(){function F(K){var V=this;(function(G,Q){if(!(G instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K,K.disableRebufferTracking||K.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,K.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),K.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),K.on("seeking",function(){V._cleanupRebufferTracker(null,{viewer_time:h.now()})}))}var C,M,N;return C=F,M=[{key:"_checkIfRebuffering",value:function(K,V){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(K,V);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var G=V.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&G>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=V.viewer_time}else this._cleanupRebufferTracker(K,V,!0);else this._prepareRebufferTrackerState(V.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(K){this._lastCheckedTime=K,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=K}},{key:"_cleanupRebufferTracker",value:function(K,V){var G=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:V.viewer_time});else{if(this._lastCheckedTime===null)return;var Q=this.pm.data.player_playhead_time-this._lastPlayheadTime,Z=V.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&Q>0&&Z-Q>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+Z-Q}))}G?this._prepareRebufferTrackerState(V.viewer_time):this._clearRebufferTrackerState()}}],M&&Be(C.prototype,M),N&&Be(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}(),we=Ee;function Ue(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var Ye=function(){function F(K){var V=this;(function(G,Q){if(!(G instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K,K.on("viewinit",function(){var G=K.data,Q=G.view_id;if(!G.view_program_changed){var Z=function($,ee){var me=ee.viewer_time;$.type==="playing"&&K.data.view_time_to_first_frame===void 0?V.calculateTimeToFirstFrame(me||h.now(),Q):$.type!=="adplaying"||K.data.view_time_to_first_frame!==void 0&&!V._inPrerollPosition()||V.calculateTimeToFirstFrame(me||h.now(),Q)};K.one("playing",Z),K.one("adplaying",Z),K.one("viewend",function(){K.off("playing",Z),K.off("adplaying",Z)})}})}var C,M,N;return C=F,(M=[{key:"_inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(K,V){V===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:K}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}])&&Ue(C.prototype,M),N&&Ue(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function Ne(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function Je(F,C,M){return C&&Ne(F.prototype,C),M&&Ne(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var Ge=Je(function F(C){var M=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,F),C.on("viewinit",function(){M._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(N){C.on(N,function(){if(M._lastPlayheadPosition>=0&&C.data.player_playhead_time>=0&&M._lastPlayerWidth>=0&&M._lastSourceWidth>0&&M._lastPlayerHeight>=0&&M._lastSourceHeight>0){var K=C.data.player_playhead_time-M._lastPlayheadPosition;if(K<0)return void(M._lastPlayheadPosition=-1);var V=Math.min(M._lastPlayerWidth/M._lastSourceWidth,M._lastPlayerHeight/M._lastSourceHeight),G=Math.max(0,V-1),Q=Math.max(0,1-V);C.data.view_max_upscale_percentage=Math.max(C.data.view_max_upscale_percentage||0,G),C.data.view_max_downscale_percentage=Math.max(C.data.view_max_downscale_percentage||0,Q),t(C.data,"view_total_content_playback_time",K),t(C.data,"view_total_upscaling",G*K),t(C.data,"view_total_downscaling",Q*K)}M._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(N){C.on(N,function(){M._lastPlayheadPosition=C.data.player_playhead_time,M._lastPlayerWidth=C.data.player_width,M._lastPlayerHeight=C.data.player_height,M._lastSourceWidth=C.data.video_source_width,M._lastSourceHeight=C.data.video_source_height})})});function ot(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function Fe(F,C,M){return C&&ot(F.prototype,C),M&&ot(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var We=Fe(function F(C){var M=this;(function(N,K){if(!(N instanceof K))throw new TypeError("Cannot call a class as a function")})(this,F),this.isSeeking=!1,C.on("seeking",function(N,K){i()(C.data,K),M._lastSeekingTime=h.now(),M.isSeeking===!1&&(M.isSeeking=!0,C.send("seeking"))}),C.on("seeked",function(){M.isSeeking=!1;var N=M._lastSeekingTime||h.now(),K=h.now()-N;t(C.data,"view_seek_count",1),t(C.data,"view_seek_duration",K);var V=C.data.view_max_seek_time||0;C.data.view_max_seek_time=Math.max(V,K)}),C.on("viewend",function(){M.isSeeking=!1})});function Ze(F,C){return function(M){if(Array.isArray(M))return M}(F)||function(M,N){var K=M==null?null:typeof Symbol!="undefined"&&M[Symbol.iterator]||M["@@iterator"];if(K!=null){var V,G,Q=[],Z=!0,$=!1;try{for(K=K.call(M);!(Z=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);Z=!0);}catch(ee){$=!0,G=ee}finally{try{Z||K.return==null||K.return()}finally{if($)throw G}}return Q}}(F,C)||function(M,N){if(M){if(typeof M=="string")return ke(M,N);var K=Object.prototype.toString.call(M).slice(8,-1);return K==="Object"&&M.constructor&&(K=M.constructor.name),K==="Map"||K==="Set"?Array.from(M):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?ke(M,N):void 0}}(F,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function ke(F,C){(C==null||C>F.length)&&(C=F.length);for(var M=0,N=new Array(C);M<C;M++)N[M]=F[M];return N}function Re(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}var lt=function(F,C){F.push(C),F.sort(function(M,N){return M.viewer_time-N.viewer_time})},qe=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],yt=function(){function F(K){var V=this;(function(Q,Z){if(!(Q instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,F),this.pm=K,K.on("viewinit",function(){V.isAdBreak=!1,V._currentAdRequestNumber=0,V._currentAdResponseNumber=0,V._adRequests=[],V._adResponses=[],V._adHasPlayed=!1,V._wouldBeNewAdPlay=!0,V._prerollPlayTime=void 0}),qe.forEach(function(Q){return K.on(Q,V._updateAdData.bind(V))});var G=function(){V.isAdBreak=!1};K.on("adbreakstart",function(){V.isAdBreak=!0}),K.on("play",G),K.on("playing",G),K.on("viewend",G),K.on("adrequest",function(Q,Z){Z=i()({ad_request_id:"generatedAdRequestId"+V._currentAdRequestNumber++},Z),lt(V._adRequests,Z),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,Z){Z=i()({ad_request_id:"generatedAdRequestId"+V._currentAdResponseNumber++},Z),lt(V._adResponses,Z);var $=V.findAdRequest(Z.ad_request_id);$&&t(K.data,"view_ad_request_time",Math.max(0,Z.viewer_time-$.viewer_time))}),K.on("adplay",function(Q,Z){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,Z.viewer_time-V._adRequests[0].viewer_time)),K.data.view_start&&(K.data.view_startup_preroll_request_time=Math.max(0,Z.viewer_time-K.data.view_start)),V._prerollPlayTime=Z.viewer_time)}),K.on("adplaying",function(Q,Z){V.inPrerollPosition()&&K.data.view_preroll_load_time===void 0&&V._prerollPlayTime!==void 0&&(K.data.view_preroll_load_time=Z.viewer_time-V._prerollPlayTime,K.data.view_startup_preroll_load_time=Z.viewer_time-V._prerollPlayTime)}),K.on("adended",function(){V._wouldBeNewAdPlay=!0}),K.on("aderror",function(){V._wouldBeNewAdPlay=!0})}var C,M,N;return C=F,(M=[{key:"inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(K){for(var V=0;V<this._adRequests.length;V++)if(this._adRequests[V].ad_request_id===K)return this._adRequests[V]}},{key:"_updateAdData",value:function(K,V){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&V.ad_tag_url){var G=Ze(l(V.ad_tag_url),2),Q=G[0],Z=G[1];this.pm.data.view_preroll_ad_tag_domain=Z,this.pm.data.view_preroll_ad_tag_hostname=Q}if(!this.pm.data.view_preroll_ad_asset_hostname&&V.ad_asset_url){var $=Ze(l(V.ad_asset_url),2),ee=$[0],me=$[1];this.pm.data.view_preroll_ad_asset_domain=me,this.pm.data.view_preroll_ad_asset_hostname=ee}}}}])&&Re(C.prototype,M),N&&Re(C,N),Object.defineProperty(C,"prototype",{writable:!1}),F}();function Dt(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function at(F,C,M){return C&&Dt(F.prototype,C),M&&Dt(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var Kt=at(function F(C){var M,N;(function(Q,Z){if(!(Q instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,F);var K=function(){C.disableRebufferTracking||M&&(t(C.data,"view_waiting_rebuffer_duration",h.now()-M),M=!1,_().clearInterval(N))},V=!1,G=function(){V=!1,K()};C.on("waiting",function(){V&&(C.disableRebufferTracking||(t(C.data,"view_waiting_rebuffer_count",1),M=h.now(),N=_().setInterval(function(){if(M){var Q=h.now();t(C.data,"view_waiting_rebuffer_duration",Q-M),M=Q}},250)))}),C.on("playing",function(){K(),V=!0}),C.on("pause",G),C.on("seeking",G)});function At(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function ht(F,C,M){return C&&At(F.prototype,C),M&&At(F,M),Object.defineProperty(F,"prototype",{writable:!1}),F}var Tt=ht(function F(C){var M=this;(function(V,G){if(!(V instanceof G))throw new TypeError("Cannot call a class as a function")})(this,F);var N=function(){M.lastWallClockTime=h.now(),C.on("before*",K)},K=function(V){var G=h.now(),Q=M.lastWallClockTime;M.lastWallClockTime=G,G-Q>3e4&&(C.emit("devicesleep",{viewer_time:Q}),i()(C.data,{viewer_time:Q}),C.send("devicesleep"),C.emit("devicewake",{viewer_time:G}),i()(C.data,{viewer_time:G}),C.send("devicewake"))};C.one("playbackheartbeat",N),C.on("playbackheartbeatend",function(){C.off("before*",K),C.one("playbackheartbeat",N)})}),ct=R(375),Rt=R(655),xt=R.n(Rt),lr="muxData",jt=function(){var F;try{F=ct.parse(xt().get(lr)||"")}catch{F={}}return F},Pt=function(F){try{xt().set(lr,ct.stringify(F),{expires:7300})}catch{}},st=function(){var F=jt();return F.mux_viewer_id=F.mux_viewer_id||y(),F.msn=F.msn||Math.random(),Pt(F),{mux_viewer_id:F.mux_viewer_id,mux_sample_number:F.msn}};function ur(F,C){var M=C.beaconCollectionDomain,N=C.beaconDomain;if(M)return"https://"+M;var K=N||"litix.io";return(F=F||"inferred").match(/^[a-z0-9]+$/)?"https://"+F+"."+K:"https://img.litix.io/a.gif"}var Wt=function(){var F;switch(dr()){case"cellular":F="cellular";break;case"ethernet":F="wired";break;case"wifi":F="wifi";break;case void 0:break;default:F="other"}return F},dr=function(){var F=_().navigator,C=F&&(F.connection||F.mozConnection||F.webkitConnection);return C&&C.type};Wt.getConnectionFromAPI=dr;var _r=Wt,br=cr({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"}),fr=cr({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function cr(F){var C={};for(var M in F)F.hasOwnProperty(M)&&(C[F[M]]=M);return C}function _t(F){var C={},M={};return Object.keys(F).forEach(function(N){var K=!1;if(F.hasOwnProperty(N)&&F[N]!==void 0){var V=N.split("_"),G=V[0],Q=br[G];Q||(e.info("Data key word `"+V[0]+"` not expected in "+N),Q=G+"_"),V.splice(1).forEach(function(Z){Z==="url"&&(K=!0),fr[Z]?Q+=fr[Z]:Number(Z)&&Math.floor(Number(Z))===Number(Z)?Q+=Z:(e.info("Data key word `"+Z+"` not expected in "+N),Q+="_"+Z+"_")}),K?M[Q]=F[N]:C[Q]=F[N]}}),i()(C,M)}var hr={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Or=["hb","requestcompleted","requestfailed","requestcanceled"],Rr="https://img.litix.io",St=function(F){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=F||Rr,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=i()({},hr,C)};St.prototype.queueEvent=function(F,C){var M=i()({},C);return(this._eventQueue.length<=this._options.maxQueueLength||F==="eventrateexceeded")&&(this._eventQueue.push(M),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},St.prototype.flushEvents=function(){var F=arguments.length>0&&arguments[0]!==void 0&&arguments[0];F&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},St.prototype.destroy=function(){var F=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,F?this._clearBeaconQueue():this.flushEvents(),_().clearTimeout(this._sendTimeout)},St.prototype._clearBeaconQueue=function(){var F=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,C=this._eventQueue.slice(F);F>0&&i()(C[C.length-1],_t({mux_view_message:"event queue truncated"}));var M=this._createPayload(C);ai(this._beaconUrl,M,!0,function(){})},St.prototype._sendBeaconQueue=function(){var F=this;if(!this._postInFlight){var C=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var M=this._createPayload(C),N=h.now();ai(this._beaconUrl,M,!1,function(K,V){V?(F._eventQueue=C.concat(F._eventQueue),F._failureCount+=1,e.info("Error sending beacon: "+V)):F._failureCount=0,F._roundTripTime=h.now()-N,F._postInFlight=!1})}},St.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var F=Math.pow(2,this._failureCount-1);return(1+(F*=Math.random()))*this._options.baseTimeBetweenBeacons},St.prototype._startBeaconSending=function(){var F=this;_().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=_().setTimeout(function(){F._eventQueue.length&&F._sendBeaconQueue(),F._startBeaconSending()},this._getNextBeaconTime()))},St.prototype._createPayload=function(F){var C,M,N,K=this,V={transmission_timestamp:Math.round(h.now())};this._roundTripTime&&(V.rtt_ms=Math.round(this._roundTripTime));var G=function(){C=JSON.stringify({metadata:V,events:M||F}),N=C.length/1024},Q=function(){return N<=K._options.maxPayloadKBSize};return G(),Q()||(e.info("Payload size is too big ("+N+" kb). Removing unnecessary events."),M=F.filter(function(Z){return Or.indexOf(Z.e)===-1}),G()),Q()||(e.info("Payload size still too big ("+N+" kb). Cropping fields.."),M.forEach(function(Z){for(var $ in Z){var ee=Z[$];typeof ee=="string"&&ee.length>51200&&(Z[$]=ee.substring(0,51200))}}),G()),C};var ai=function(F,C,M,N){if(M&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(F,C))N();else if(_().fetch)_().fetch(F,{method:"POST",body:C,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(V){return N(null,V.ok?null:"Error")}).catch(function(V){return N(null,V)});else{if(_().XMLHttpRequest){var K=new(_()).XMLHttpRequest;return K.onreadystatechange=function(){if(K.readyState===4)return N(null,K.status!==200?"error":void 0)},K.open("POST",F),K.setRequestHeader("Content-Type","text/plain"),void K.send(C)}N()}},Qi=St;function $i(F,C){return function(M){if(Array.isArray(M))return M}(F)||function(M,N){var K=M==null?null:typeof Symbol!="undefined"&&M[Symbol.iterator]||M["@@iterator"];if(K!=null){var V,G,Q=[],Z=!0,$=!1;try{for(K=K.call(M);!(Z=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);Z=!0);}catch(ee){$=!0,G=ee}finally{try{Z||K.return==null||K.return()}finally{if($)throw G}}return Q}}(F,C)||function(M,N){if(M){if(typeof M=="string")return si(M,N);var K=Object.prototype.toString.call(M).slice(8,-1);return K==="Object"&&M.constructor&&(K=M.constructor.name),K==="Map"||K==="Set"?Array.from(M):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?si(M,N):void 0}}(F,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function
|
|
4
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function fi(F,C){(C==null||C>F.length)&&(C=F.length);for(var M=0,N=new Array(C);M<C;M++)N[M]=F[M];return N}function ci(F,C){for(var M=0;M<C.length;M++){var N=C[M];N.enumerable=N.enumerable||!1,N.configurable=!0,"value"in N&&(N.writable=!0),Object.defineProperty(F,N.key,N)}}function Ir(F,C){return Ir=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(M,N){return M.__proto__=N,M},Ir(F,C)}function ln(F){var C=function(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var M,N=gr(F);if(C){var K=gr(this).constructor;M=Reflect.construct(N,arguments,K)}else M=N.apply(this,arguments);return un(this,M)}}function un(F,C){if(C&&(Pr(C)==="object"||typeof C=="function"))return C;if(C!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return He(F)}function He(F){if(F===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return F}function gr(F){return gr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(C){return C.__proto__||Object.getPrototypeOf(C)},gr(F)}var dn=["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"],fn=function(F){(function(G,Q){if(typeof Q!="function"&&Q!==null)throw new TypeError("Super expression must either be null or a function");G.prototype=Object.create(Q&&Q.prototype,{constructor:{value:G,writable:!0,configurable:!0}}),Object.defineProperty(G,"prototype",{writable:!1}),Q&&Ir(G,Q)})(V,F);var C,M,N,K=ln(V);function V(G,Q,Z){var $;(function(oe,ve){if(!(oe instanceof ve))throw new TypeError("Cannot call a class as a function")})(this,V),($=K.call(this)).DOM_CONTENT_LOADED_EVENT_END=c.domContentLoadedEventEnd(),$.NAVIGATION_START=c.navigationStart(),$.mux=G,$.id=Q,(Z=i()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(oe){return oe}},Z)).data=Z.data||{},Z.data.property_key&&(Z.data.env_key=Z.data.property_key,delete Z.data.property_key),e.setLevel(Z.debug?"debug":"warn"),$.getPlayheadTime=Z.getPlayheadTime,$.getStateData=Z.getStateData||function(){return{}},$.getAdData=Z.getAdData||function(){},$.minimumRebufferDuration=Z.minimumRebufferDuration,$.sustainedRebufferThreshold=Z.sustainedRebufferThreshold,$.playbackHeartbeatTime=Z.playbackHeartbeatTime,$.disableRebufferTracking=Z.disableRebufferTracking,$.disableRebufferTracking&&$.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."),$.disablePlayheadRebufferTracking=Z.disablePlayheadRebufferTracking,$.errorTranslator=Z.errorTranslator,$.playbackEventDispatcher=new tn(G,Z.data.env_key,Z),$.data={player_instance_id:y(),mux_sample_rate:Z.sampleRate,beacon_domain:Z.beaconCollectionDomain?Z.beaconCollectionDomain:Z.beaconDomain},$.data.view_sequence_number=1,$.data.player_sequence_number=1,$.oldEmit=$.emit,$.emit=function(oe,ve){ve=i()({viewer_time:this.mux.utils.now()},ve),this.oldEmit(oe,ve)};var ee=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(He($));$.on("viewinit",function(oe,ve){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),i()(this.data,ve),this._initializeViewData(),this.one("play",ee),this.one("adbreakstart",ee)});var me=function(oe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",oe)}.bind(He($));if($.on("videochange",function(oe,ve){me(ve)}),$.on("programchange",function(oe,ve){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."),me(i()(ve,{view_program_changed:!0})),ee(),this.emit("play"),this.emit("playing")}),$.on("fragmentchange",function(oe,ve){this.currentFragmentPDT=ve.currentFragmentPDT,this.currentFragmentStart=ve.currentFragmentStart}),$.on("destroy",$.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ue=function(){var oe=$.data.view_start!==void 0;$.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",oe&&$.mux.WINDOW_HIDDEN&&($.data.player_is_paused||$.emit("hb"))};window.addEventListener("visibilitychange",ue,!1);var he=function(oe){oe.persisted||$.destroy()};window.addEventListener("pagehide",he,!1),$.on("destroy",function(){window.removeEventListener("visibilitychange",ue),window.removeEventListener("pagehide",he)})}return $.on("playerready",function(oe,ve){i()(this.data,ve)}),dn.forEach(function(oe){$.on(oe,function(ve,_e){oe.indexOf("ad")!==0&&this._updateStateData(),i()(this.data,_e),this._sanitizeData()}),$.on("after"+oe,function(){(oe!=="error"||this.errorTracker.viewErrored)&&this.send(oe)})}),$.on("viewend",function(oe,ve){i()($.data,ve)}),$.one("playerready",function(oe){var ve=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=ve-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}),$.longResumeTracker=new sn(He($)),$.errorTracker=new le(He($)),new Tt(He($)),$.seekingTracker=new We(He($)),$.playheadTime=new Me(He($)),$.playbackHeartbeat=new ne(He($)),new Ge(He($)),$.watchTimeTracker=new ie(He($)),new pe(He($)),$.adTracker=new yt(He($)),new we(He($)),new Pe(He($)),new Ye(He($)),new Kt(He($)),new nn(He($)),Z.hlsjs&&$.addHLSJS(Z),Z.dashjs&&$.addDashJS(Z),$.emit("viewinit",Z.data),$}return C=V,M=[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(G){var 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(me){Q[me]=void 0}),Q.video_source_url=Q.video_source_url||Q.player_source_url,Q.video_source_url){var Z=on(l(Q.video_source_url),2),$=Z[0],ee=Z[1];Q.video_source_domain=ee,Q.video_source_hostname=$}delete Q.ad_request_id,this.playbackEventDispatcher.send(G,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 G=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(Q){var Z=parseInt(G.data[Q],10);G.data[Q]=isNaN(Z)?void 0:Z}),["player_source_url","video_source_url"].forEach(function(Q){if(G.data[Q]){var Z=G.data[Q].toLowerCase();Z.indexOf("data:")!==0&&Z.indexOf("blob:")!==0||(G.data[Q]="MSE style URL")}})}},{key:"_resetVideoData",value:function(G,Q){var Z=this;Object.keys(this.data).forEach(function($){$.indexOf("video_")===0&&delete Z.data[$]})}},{key:"_resetViewData",value:function(){var G=this;Object.keys(this.data).forEach(function(Q){Q.indexOf("view_")===0&&delete G.data[Q]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(G,Q){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var G=this,Q=this.data.view_id=y(),Z=function(){Q===G.data.view_id&&t(G.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",Z):Z()}},{key:"_restartHeartBeat",value:function(){var G=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){G.data.player_is_paused||G.emit("hb")},1e4))}},{key:"addHLSJS",value:function(G){G.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=G.hlsjs,function(Q,Z,$){var ee=arguments.length>4?arguments[4]:void 0,me=Q.log,ue=Q.utils.secondsToMs,he=function(Le){var ce,ye=parseInt(ee.version);return ye===1&&Le.programDateTime!==null&&(ce=Le.programDateTime),ye===0&&Le.pdt!==null&&(ce=Le.pdt),ce};if(c.exists()){var oe=function(Le,ce){return Q.emit(Z,Le,ce)},ve=function(Le,ce){var ye=ce.levels,de=ce.audioTracks,Te=ce.url,Ce=ce.stats,Ke=ce.networkDetails,rt=ce.sessionData,et={},dt={};ye.forEach(function(gt,Yt){et[Yt]={width:gt.width,height:gt.height,bitrate:gt.bitrate,attrs:gt.attrs}}),de.forEach(function(gt,Yt){dt[Yt]={name:gt.name,language:gt.lang,bitrate:gt.bitrate}});var it=x(Ce),vt=it.bytesLoaded,Ve=it.requestStart,ft=it.responseStart,Fr=it.responseEnd;oe("requestcompleted",v(v({},s(rt)),{},{request_event_type:Le,request_bytes_loaded:vt,request_start:Ve,request_response_start:ft,request_response_end:Fr,request_type:"manifest",request_hostname:r(Te),request_response_headers:P(Ke),request_rendition_lists:{media:et,audio:dt,video:{}}}))};$.on(ee.Events.MANIFEST_LOADED,ve);var _e=function(Le,ce){var ye=ce.details,de=ce.level,Te=ce.networkDetails,Ce=ce.stats,Ke=x(Ce),rt=Ke.bytesLoaded,et=Ke.requestStart,dt=Ke.responseStart,it=Ke.responseEnd,vt=ye.fragments[ye.fragments.length-1],Ve=he(vt)+ue(vt.duration);oe("requestcompleted",{request_event_type:Le,request_bytes_loaded:rt,request_start:et,request_response_start:dt,request_response_end:it,request_current_level:de,request_type:"manifest",request_hostname:r(ye.url),request_response_headers:P(Te),video_holdback:ye.holdBack&&ue(ye.holdBack),video_part_holdback:ye.partHoldBack&&ue(ye.partHoldBack),video_part_target_duration:ye.partTarget&&ue(ye.partTarget),video_target_duration:ye.targetduration&&ue(ye.targetduration),video_source_is_live:ye.live,player_manifest_newest_program_time:isNaN(Ve)?void 0:Ve})};$.on(ee.Events.LEVEL_LOADED,_e);var ze=function(Le,ce){var ye=ce.details,de=ce.networkDetails,Te=ce.stats,Ce=x(Te),Ke=Ce.bytesLoaded,rt=Ce.requestStart,et=Ce.responseStart,dt=Ce.responseEnd;oe("requestcompleted",{request_event_type:Le,request_bytes_loaded:Ke,request_start:rt,request_response_start:et,request_response_end:dt,request_type:"manifest",request_hostname:r(ye.url),request_response_headers:P(de)})};$.on(ee.Events.AUDIO_TRACK_LOADED,ze);var Xe=function(Le,ce){var ye=ce.stats,de=ce.networkDetails,Te=ce.frag;ye=ye||Te.stats;var Ce=x(ye),Ke=Ce.bytesLoaded,rt=Ce.requestStart,et=Ce.responseStart,dt=Ce.responseEnd,it=P(de),vt=it==null?void 0:it["x-request-id"],Ve={request_event_type:Le,request_bytes_loaded:Ke,request_start:rt,request_response_start:et,request_response_end:dt,request_hostname:de?r(de.responseURL):void 0,request_id:vt,request_response_headers:it,request_media_duration:Te.duration,request_url:de==null?void 0:de.responseURL};Te.type==="main"?(Ve.request_type="media",Ve.request_current_level=Te.level,Ve.request_video_width=($.levels[Te.level]||{}).width,Ve.request_video_height=($.levels[Te.level]||{}).height,Ve.request_labeled_bitrate=($.levels[Te.level]||{}).bitrate):Ve.request_type=Te.type,oe("requestcompleted",Ve)};$.on(ee.Events.FRAG_LOADED,Xe);var tt=function(Le,ce){var ye=ce.frag,de=ye.start,Te={currentFragmentPDT:he(ye),currentFragmentStart:ue(de)};oe("fragmentchange",Te)};$.on(ee.Events.FRAG_CHANGED,tt);var Ae=function(Le,ce){var ye=ce.type,de=ce.details,Te=ce.response,Ce=ce.fatal,Ke=ce.context,rt=ce.frag;if(de===ee.ErrorDetails.MANIFEST_LOAD_ERROR||de===ee.ErrorDetails.MANIFEST_LOAD_TIMEOUT||de===ee.ErrorDetails.FRAG_LOAD_ERROR||de===ee.ErrorDetails.FRAG_LOAD_TIMEOUT||de===ee.ErrorDetails.LEVEL_LOAD_ERROR||de===ee.ErrorDetails.LEVEL_LOAD_TIMEOUT){var et=rt&&rt.url||Ke&&Ke.url||"";oe("requestfailed",{request_error:de,request_url:et,request_hostname:r(et),request_type:de===ee.ErrorDetails.FRAG_LOAD_ERROR||de===ee.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:Te&&Te.code,request_error_text:Te&&Te.text})}Ce&&oe("error",{player_error_code:ye,player_error_message:de})};$.on(ee.Events.ERROR,Ae);var Qe=function(Le,ce){var ye=ce.frag,de=ye&&ye._url||"";oe("requestcanceled",{request_event_type:Le,request_url:de,request_type:"media",request_hostname:r(de)})};$.on(ee.Events.FRAG_LOAD_EMERGENCY_ABORTED,Qe);var $e=function(Le,ce){var ye=ce.level,de=$.levels[ye];if(de&&de.attrs&&de.attrs.BANDWIDTH){var Te,Ce=de.attrs.BANDWIDTH,Ke=parseFloat(de.attrs["FRAME-RATE"]);isNaN(Ke)||(Te=Ke),Ce?oe("renditionchange",{video_source_fps:Te,video_source_bitrate:Ce,video_source_width:de.width,video_source_height:de.height,video_source_rendition_name:de.name,video_source_codec:de==null?void 0:de.videoCodec}):me.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};$.on(ee.Events.LEVEL_SWITCHED,$e),$._stopMuxMonitor=function(){$.off(ee.Events.MANIFEST_LOADED,ve),$.off(ee.Events.LEVEL_LOADED,_e),$.off(ee.Events.AUDIO_TRACK_LOADED,ze),$.off(ee.Events.FRAG_LOADED,Xe),$.off(ee.Events.FRAG_CHANGED,tt),$.off(ee.Events.ERROR,Ae),$.off(ee.Events.FRAG_LOAD_EMERGENCY_ABORTED,Qe),$.off(ee.Events.LEVEL_SWITCHED,$e),$.off(ee.Events.DESTROYING,$._stopMuxMonitor),delete $._stopMuxMonitor},$.on(ee.Events.DESTROYING,$._stopMuxMonitor)}else me.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,G.hlsjs,{},G.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var G;this.hlsjs&&((G=this.hlsjs)&&typeof G._stopMuxMonitor=="function"&&G._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(G){G.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=G.dashjs,function(Q,Z,$){var ee=Q.log;if($&&$.on){var me=function(Ae,Qe){return Q.emit(Z,Ae,Qe)},ue=function(Ae){var Qe=Ae.type,$e=(Ae.data||{}).url;me("requestcompleted",{request_event_type:Qe,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:r($e),request_url:$e})};$.on("manifestLoaded",ue);var he={},oe=function(Ae){var Qe=Ae.type,$e=Ae.fragmentModel,Le=(Ae.chunk||{}).mediaInfo||{},ce=Le.type,ye=Le.bitrateList,de={};(ye=ye||[]).forEach(function(Ve,ft){de[ft]={},de[ft].width=Ve.width,de[ft].height=Ve.height,de[ft].bitrate=Ve.bandwidth,de[ft].attrs={}}),ce==="video"?he.video=de:ce==="audio"?he.audio=de:he.media=de;var Te=W($e,$),Ce=Te.requestStart,Ke=Te.requestResponseStart,rt=Te.requestResponseEnd,et=Te.requestResponseHeaders,dt=Te.requestMediaDuration,it=Te.requestHostname,vt=Te.requestUrl;me("requestcompleted",{request_event_type:Qe,request_start:Ce,request_response_start:Ke,request_response_end:rt,request_bytes_loaded:-1,request_type:ce+"_init",request_response_headers:et,request_hostname:it,request_url:vt,request_media_duration:dt,request_rendition_lists:he})};$.on("initFragmentLoaded",oe);var ve=function(Ae){var Qe=Ae.type,$e=Ae.fragmentModel,Le=Ae.chunk||{},ce=Le.mediaInfo,ye=Le.start,de=(ce||{}).type,Te=W($e,$),Ce=Te.requestStart,Ke=Te.requestResponseStart,rt=Te.requestResponseEnd,et=Te.requestBytesLoaded,dt=Te.requestResponseHeaders,it=Te.requestMediaDuration,vt=Te.requestHostname,Ve=Te.requestUrl,ft=H(de,$),Fr=ft.currentLevel,gt=ft.renditionWidth,Yt=ft.renditionHeight,wn=ft.renditionBitrate;me("requestcompleted",{request_event_type:Qe,request_start:Ce,request_response_start:Ke,request_response_end:rt,request_bytes_loaded:et,request_type:de,request_response_headers:dt,request_hostname:vt,request_url:Ve,request_media_start_time:ye,request_media_duration:it,request_current_level:Fr,request_labeled_bitrate:wn,request_video_width:gt,request_video_height:Yt})};$.on("mediaFragmentLoaded",ve);var _e={video:void 0,audio:void 0,totalBitrate:void 0},ze=function(){if(_e.video&&typeof _e.video.bitrate=="number"){if(_e.video.width&&_e.video.height){var Ae=_e.video.bitrate;return _e.audio&&typeof _e.audio.bitrate=="number"&&(Ae+=_e.audio.bitrate),Ae!==_e.totalBitrate?(_e.totalBitrate=Ae,{video_source_bitrate:Ae,video_source_height:_e.video.height,video_source_width:_e.video.width,video_source_codec:z(_e.video.codec)}):void 0}ee.warn("have bitrate info for video but missing width/height")}},Xe=function(Ae,Qe,$e){if(typeof Ae.newQuality=="number"){var Le=Ae.mediaType;if(Le==="audio"||Le==="video"){var ce=$.getBitrateInfoListFor(Le).find(function(de){return de.qualityIndex===Ae.newQuality});if(ce&&typeof ce.bitrate=="number"){_e[Le]=k(k({},ce),{},{codec:$.getCurrentTrackFor(Le).codec});var ye=ze();ye&&me("renditionchange",ye)}else ee.warn("missing bitrate info for ".concat(Le))}}else ee.warn("missing evt.newQuality in qualityChangeRendered event",Ae)};$.on("qualityChangeRendered",Xe);var tt=function(Ae){var Qe=Ae.error,$e=Ae.event,Le=($e=$e||{}).request||{},ce=_().event&&_().event.currentTarget||{};me("requestfailed",{request_error:Qe+"_"+$e.id+"_"+Le.type,request_url:$e.url,request_hostname:r($e.url),request_type:Le.mediaType,request_error_code:ce.status,request_error_type:ce.statusText})};$.on("error",tt),$._stopMuxMonitor=function(){$.off("manifestLoaded",ue),$.off("initFragmentLoaded",oe),$.off("mediaFragmentLoaded",ve),$.off("qualityChangeRendered",Xe),$.off("error",tt),delete $._stopMuxMonitor}}else ee.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,G.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var G;this.dashjs&&((G=this.dashjs)&&typeof G._stopMuxMonitor=="function"&&G._stopMuxMonitor(),this.dashjs=void 0)}}],M&&ci(C.prototype,M),N&&ci(C,N),Object.defineProperty(C,"prototype",{writable:!1}),V}(X),cn=fn,hn=R(153),Ht=R.n(hn);function Cr(F){return Cr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},Cr(F)}function hi(F,C){return function(M){if(Array.isArray(M))return M}(F)||function(M,N){var K=M==null?null:typeof Symbol!="undefined"&&M[Symbol.iterator]||M["@@iterator"];if(K!=null){var V,G,Q=[],Z=!0,$=!1;try{for(K=K.call(M);!(Z=(V=K.next()).done)&&(Q.push(V.value),!N||Q.length!==N);Z=!0);}catch(ee){$=!0,G=ee}finally{try{Z||K.return==null||K.return()}finally{if($)throw G}}return Q}}(F,C)||function(M,N){if(M){if(typeof M=="string")return vi(M,N);var K=Object.prototype.toString.call(M).slice(8,-1);return K==="Object"&&M.constructor&&(K=M.constructor.name),K==="Map"||K==="Set"?Array.from(M):K==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(K)?vi(M,N):void 0}}(F,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function
|
|
1
|
+
var Hn=Object.create;var Kr=Object.defineProperty;var jn=Object.getOwnPropertyDescriptor;var Vn=Object.getOwnPropertyNames;var Yn=Object.getPrototypeOf,Xn=Object.prototype.hasOwnProperty;var zn=($,X,V)=>X in $?Kr($,X,{enumerable:!0,configurable:!0,writable:!0,value:V}):$[X]=V;var Ai=($,X)=>()=>(X||$((X={exports:{}}).exports,X),X.exports);var Qn=($,X,V,ie)=>{if(X&&typeof X=="object"||typeof X=="function")for(let Q of Vn(X))!Xn.call($,Q)&&Q!==V&&Kr($,Q,{get:()=>X[Q],enumerable:!(ie=jn(X,Q))||ie.enumerable});return $};var Er=($,X,V)=>(V=$!=null?Hn(Yn($)):{},Qn(X||!$||!$.__esModule?Kr(V,"default",{value:$,enumerable:!0}):V,$));var qt=($,X,V)=>(zn($,typeof X!="symbol"?X+"":X,V),V),Wr=($,X,V)=>{if(!X.has($))throw TypeError("Cannot "+V)};var he=($,X,V)=>(Wr($,X,"read from private field"),V?V.call($):X.get($)),Ae=($,X,V)=>{if(X.has($))throw TypeError("Cannot add the same private member more than once");X instanceof WeakSet?X.add($):X.set($,V)},Fe=($,X,V,ie)=>(Wr($,X,"write to private field"),ie?ie.call($,V):X.set($,V),V);var Ke=($,X,V)=>(Wr($,X,"access private method"),V);var Li=Ai((_r,Vr)=>{(function(){var $,X;$=this,X=function(){return function(){var V={80:function(B,T,O){B.exports=O(728).default},728:function(B,T,O){"use strict";O.d(T,{default:function(){return Wn}});var D=O(48),M=O.n(D),P=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(N){var C=16*Math.random()|0;return(N==="x"?C:3&C|8).toString(16)})},U=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},b=function(N){return N&&N.nodeName!==void 0?(N.muxId||(N.muxId=N.id||U()),N.muxId):N},A=function(N){var C;N&&N.nodeName!==void 0?N=b(C=N):C=document.querySelector(N);var w=C&&C.nodeName?C.nodeName.toLowerCase():"";return[C,N,w]},S=O(640),E=O.n(S),x=E().methodFactory;E().methodFactory=function(N,C,w){var G=x(N,C,w);return function(){for(var j=["[mux]"],J=0;J<arguments.length;J++)j.push(arguments[J]);G.apply(void 0,j)}},E().setLevel(E().getLevel());var f=E();function _(){return(M().doNotTrack||M().navigator&&M().navigator.doNotTrack)==="1"}var p={now:function(){var N=M().performance,C=N&&N.timing,w=C&&C.navigationStart,G=typeof w=="number"&&typeof N.now=="function"?w+N.now():Date.now();return Math.round(G)}},v=O(678),a=O.n(v),s=function(N){return n(N)[0]},n=function(N){if(typeof N!="string"||N==="")return["localhost"];var C,w=(N.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return w&&(C=(w.match(/[^\.]+\.[^\.]+$/)||[])[0]),[w,C]},d={exists:function(){var N=M().performance;return(N&&N.timing)!==void 0},domContentLoadedEventEnd:function(){var N=M().performance,C=N&&N.timing;return C&&C.domContentLoadedEventEnd},navigationStart:function(){var N=M().performance,C=N&&N.timing;return C&&C.navigationStart}};function l(N,C,w){w=w===void 0?1:w,N[C]=N[C]||0,N[C]+=w}var i=["x-cdn","content-type","x-request-id"];function u(N){var C={};return(N=N||"").trim().split(/[\r\n]+/).forEach(function(w){if(w){var G=w.split(": "),j=G.shift();j&&(i.indexOf(j.toLowerCase())>=0||j.toLowerCase().indexOf("x-litix-")===0)&&(C[j]=G.join(": "))}}),C}var g=function(N){var C={};for(var w in N){var G=N[w];G["DATA-ID"].search("io.litix.data.")!==-1&&(C[G["DATA-ID"].replace("io.litix.data.","")]=G.VALUE)}return C};function c(N,C){var w=Object.keys(N);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(N);C&&(G=G.filter(function(j){return Object.getOwnPropertyDescriptor(N,j).enumerable})),w.push.apply(w,G)}return w}function m(N){for(var C=1;C<arguments.length;C++){var w=arguments[C]!=null?arguments[C]:{};C%2?c(Object(w),!0).forEach(function(G){e(N,G,w[G])}):Object.getOwnPropertyDescriptors?Object.defineProperties(N,Object.getOwnPropertyDescriptors(w)):c(Object(w)).forEach(function(G){Object.defineProperty(N,G,Object.getOwnPropertyDescriptor(w,G))})}return N}function e(N,C,w){return C in N?Object.defineProperty(N,C,{value:w,enumerable:!0,configurable:!0,writable:!0}):N[C]=w,N}var r=function(N){if(!N)return{};var C=d.navigationStart(),w=N.loading,G=w?w.start:N.trequest,j=w?w.first:N.tfirst,J=w?w.end:N.tload;return{bytesLoaded:N.total,requestStart:Math.round(C+G),responseStart:Math.round(C+j),responseEnd:Math.round(C+J)}},t=function(N){if(N&&typeof N.getAllResponseHeaders=="function")return u(N.getAllResponseHeaders())};function o(N,C){var w=Object.keys(N);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(N);C&&(G=G.filter(function(j){return Object.getOwnPropertyDescriptor(N,j).enumerable})),w.push.apply(w,G)}return w}function y(N){for(var C=1;C<arguments.length;C++){var w=arguments[C]!=null?arguments[C]:{};C%2?o(Object(w),!0).forEach(function(G){h(N,G,w[G])}):Object.getOwnPropertyDescriptors?Object.defineProperties(N,Object.getOwnPropertyDescriptors(w)):o(Object(w)).forEach(function(G){Object.defineProperty(N,G,Object.getOwnPropertyDescriptor(w,G))})}return N}function h(N,C,w){return C in N?Object.defineProperty(N,C,{value:w,enumerable:!0,configurable:!0,writable:!0}):N[C]=w,N}var L=function(N,C){if(!N||typeof N.getRequests!="function")return{};var w=N.getRequests({state:"executed"});if(w.length===0)return{};var G,j=w[w.length-1],J=s(j.url),z=j.url,Z=j.bytesLoaded,ne=new Date(j.requestStartDate).getTime(),te=new Date(j.firstByteDate).getTime(),oe=new Date(j.requestEndDate).getTime(),Te=isNaN(j.duration)?0:j.duration,ge=typeof C.getMetricsFor=="function"?C.getMetricsFor(j.mediaType).HttpList:C.getDashMetrics().getHttpRequests(j.mediaType);return ge.length>0&&(G=u(ge[ge.length-1]._responseHeaders||"")),{requestStart:ne,requestResponseStart:te,requestResponseEnd:oe,requestBytesLoaded:Z,requestResponseHeaders:G,requestMediaDuration:Te,requestHostname:J,requestUrl:z}},R=function(N,C){var w=C.getQualityFor(N),G=C.getCurrentTrackFor(N).bitrateList;return G?{currentLevel:w,renditionWidth:G[w].width||null,renditionHeight:G[w].height||null,renditionBitrate:G[w].bandwidth}:{}},I=function(N){var C;return(C=N.match(/.*codecs\*?="(.*)"/))===null||C===void 0?void 0:C[1]};function k(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var F=0,W=function(){function N(){(function(j,J){if(!(j instanceof J))throw new TypeError("Cannot call a class as a function")})(this,N)}var C,w,G;return C=N,w=[{key:"on",value:function(j,J,z){return J._eventEmitterGuid=J._eventEmitterGuid||++F,this._listeners=this._listeners||{},this._listeners[j]=this._listeners[j]||[],z&&(J=J.bind(z)),this._listeners[j].push(J),J}},{key:"off",value:function(j,J){var z=this._listeners&&this._listeners[j];z&&z.forEach(function(Z,ne){Z._eventEmitterGuid===J._eventEmitterGuid&&z.splice(ne,1)})}},{key:"one",value:function(j,J,z){var Z=this;J._eventEmitterGuid=J._eventEmitterGuid||++F;var ne=function te(){Z.off(j,te),J.apply(z||this,arguments)};ne._eventEmitterGuid=J._eventEmitterGuid,this.on(j,ne)}},{key:"emit",value:function(j,J){var z=this;if(this._listeners){J=J||{};var Z=this._listeners["before*"]||[],ne=this._listeners[j]||[],te=this._listeners["after"+j]||[],oe=function(Te,ge){(Te=Te.slice()).forEach(function(Ee){Ee.call(z,{type:j},ge)})};oe(Z,J),oe(ne,J),oe(te,J)}}}],w&&k(C.prototype,w),G&&k(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}(),K=W;function H(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var Y=function(){function N(j){var J=this;(function(z,Z){if(!(z instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,j.on("playing",function(){J._playheadShouldBeProgressing=!0}),j.on("play",this._startPlaybackHeartbeatInterval.bind(this)),j.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),j.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),j.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),j.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),j.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),j.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),j.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),j.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),j.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("seeked",function(){j.data.player_is_paused?J._stopPlaybackHeartbeatInterval():J._startPlaybackHeartbeatInterval()}),j.on("timeupdate",function(){J._playbackHeartbeatInterval!==null&&j.emit("playbackheartbeat")}),j.on("devicesleep",function(z,Z){J._playbackHeartbeatInterval!==null&&(M().clearInterval(J._playbackHeartbeatInterval),j.emit("playbackheartbeatend",{viewer_time:Z.viewer_time}),J._playbackHeartbeatInterval=null)})}var C,w,G;return C=N,(w=[{key:"_startPlaybackHeartbeatInterval",value:function(){var j=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=M().setInterval(function(){j.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(M().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&H(C.prototype,w),G&&H(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}();function q(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function ee(N,C,w){return C&&q(N.prototype,C),w&&q(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var ae=ee(function N(C){var w=this;(function(G,j){if(!(G instanceof j))throw new TypeError("Cannot call a class as a function")})(this,N),C.on("viewinit",function(){w.viewErrored=!1}),C.on("error",function(G,j){try{var J=C.errorTranslator({player_error_code:j.player_error_code,player_error_message:j.player_error_message,player_error_context:j.player_error_context});J?(C.data.player_error_code=J.player_error_code||j.player_error_code,C.data.player_error_message=J.player_error_message||j.player_error_message,C.data.player_error_context=J.player_error_context||j.player_error_context,w.viewErrored=!0):(delete C.data.player_error_code,delete C.data.player_error_message,delete C.data.player_error_context)}catch(z){C.mux.log.warn("Exception in error translator callback.",z),w.viewErrored=!0}})});function re(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var se=function(){function N(j){(function(J,z){if(!(J instanceof z))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j,this._watchTimeTrackerLastCheckedTime=null,j.on("playbackheartbeat",this._updateWatchTime.bind(this)),j.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var C,w,G;return C=N,(w=[{key:"_updateWatchTime",value:function(j,J){var z=J.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=z),l(this.pm.data,"view_watch_time",z-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=z}},{key:"_clearWatchTimeState",value:function(j,J){this._updateWatchTime(j,J),this._watchTimeTrackerLastCheckedTime=null}}])&&re(C.prototype,w),G&&re(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}();function le(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var de=function(){function N(j){(function(J,z){if(!(J instanceof z))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j,this._playbackTimeTrackerLastPlayheadPosition=-1,j.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),j.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),j.on("seeking",this._clearPlaybackTimeState.bind(this))}var C,w,G;return C=N,(w=[{key:"_updatePlaybackTime",value:function(){var j=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&j>this._playbackTimeTrackerLastPlayheadPosition){var J=j-this._playbackTimeTrackerLastPlayheadPosition;J<=1e3&&l(this.pm.data,"view_content_playback_time",J)}this._playbackTimeTrackerLastPlayheadPosition=j}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&le(C.prototype,w),G&&le(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}();function ue(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var fe=function(){function N(j){(function(z,Z){if(!(z instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j;var J=this._updatePlayheadTime.bind(this);j.on("playbackheartbeat",J),j.on("playbackheartbeatend",J),j.on("timeupdate",J),j.on("destroy",function(){j.off("timeupdate",J)})}var C,w,G;return C=N,(w=[{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(j,J){var z=this,Z=function(){z.pm.currentFragmentPDT&&z.pm.currentFragmentStart&&(z.pm.data.player_program_time=z.pm.currentFragmentPDT+z.pm.data.player_playhead_time-z.pm.currentFragmentStart)};if(J&&J.player_playhead_time)this.pm.data.player_playhead_time=J.player_playhead_time,Z(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var ne=this.pm.getPlayheadTime();ne!==void 0&&(this.pm.data.player_playhead_time=ne,Z(),this._updateMaxPlayheadPosition())}}}])&&ue(C.prototype,w),G&&ue(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}();function ce(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function be(N,C,w){return C&&ce(N.prototype,C),w&&ce(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var Pe=be(function N(C){if(function(J,z){if(!(J instanceof z))throw new TypeError("Cannot call a class as a function")}(this,N),!C.disableRebufferTracking){var w,G=function(J,z){j(z),w=void 0},j=function(J){if(w){var z=J.viewer_time-w;l(C.data,"view_rebuffer_duration",z),w=J.viewer_time}C.data.view_watch_time>=0&&C.data.view_rebuffer_count>0&&(C.data.view_rebuffer_frequency=C.data.view_rebuffer_count/C.data.view_watch_time,C.data.view_rebuffer_percentage=C.data.view_rebuffer_duration/C.data.view_watch_time)};C.on("playbackheartbeat",function(J,z){return j(z)}),C.on("rebufferstart",function(J,z){w||(l(C.data,"view_rebuffer_count",1),w=z.viewer_time,C.one("rebufferend",G))}),C.on("viewinit",function(){w=void 0,C.off("rebufferend",G)})}});function we(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var pe=function(){function N(j){var J=this;(function(z,Z){if(!(z instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j,j.disableRebufferTracking||j.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,j.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),j.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),j.on("seeking",function(){J._cleanupRebufferTracker(null,{viewer_time:p.now()})}))}var C,w,G;return C=N,w=[{key:"_checkIfRebuffering",value:function(j,J){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(j,J);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var z=J.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&z>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=J.viewer_time}else this._cleanupRebufferTracker(j,J,!0);else this._prepareRebufferTrackerState(J.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(j){this._lastCheckedTime=j,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=j}},{key:"_cleanupRebufferTracker",value:function(j,J){var z=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:J.viewer_time});else{if(this._lastCheckedTime===null)return;var Z=this.pm.data.player_playhead_time-this._lastPlayheadTime,ne=J.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&Z>0&&ne-Z>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+ne-Z}))}z?this._prepareRebufferTrackerState(J.viewer_time):this._clearRebufferTrackerState()}}],w&&we(C.prototype,w),G&&we(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}(),Me=pe;function Re(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var ke=function(){function N(j){var J=this;(function(z,Z){if(!(z instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j,j.on("viewinit",function(){var z=j.data,Z=z.view_id;if(!z.view_program_changed){var ne=function(te,oe){var Te=oe.viewer_time;te.type==="playing"&&j.data.view_time_to_first_frame===void 0?J.calculateTimeToFirstFrame(Te||p.now(),Z):te.type!=="adplaying"||j.data.view_time_to_first_frame!==void 0&&!J._inPrerollPosition()||J.calculateTimeToFirstFrame(Te||p.now(),Z)};j.one("playing",ne),j.one("adplaying",ne),j.one("viewend",function(){j.off("playing",ne),j.off("adplaying",ne)})}})}var C,w,G;return C=N,(w=[{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(j,J){J===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:j}),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(C.prototype,w),G&&Re(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}();function Le(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function Ue(N,C,w){return C&&Le(N.prototype,C),w&&Le(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var He=Ue(function N(C){var w=this;(function(G,j){if(!(G instanceof j))throw new TypeError("Cannot call a class as a function")})(this,N),C.on("viewinit",function(){w._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(G){C.on(G,function(){if(w._lastPlayheadPosition>=0&&C.data.player_playhead_time>=0&&w._lastPlayerWidth>=0&&w._lastSourceWidth>0&&w._lastPlayerHeight>=0&&w._lastSourceHeight>0){var j=C.data.player_playhead_time-w._lastPlayheadPosition;if(j<0)return void(w._lastPlayheadPosition=-1);var J=Math.min(w._lastPlayerWidth/w._lastSourceWidth,w._lastPlayerHeight/w._lastSourceHeight),z=Math.max(0,J-1),Z=Math.max(0,1-J);C.data.view_max_upscale_percentage=Math.max(C.data.view_max_upscale_percentage||0,z),C.data.view_max_downscale_percentage=Math.max(C.data.view_max_downscale_percentage||0,Z),l(C.data,"view_total_content_playback_time",j),l(C.data,"view_total_upscaling",z*j),l(C.data,"view_total_downscaling",Z*j)}w._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(G){C.on(G,function(){w._lastPlayheadPosition=C.data.player_playhead_time,w._lastPlayerWidth=C.data.player_width,w._lastPlayerHeight=C.data.player_height,w._lastSourceWidth=C.data.video_source_width,w._lastSourceHeight=C.data.video_source_height})})});function Be(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function Je(N,C,w){return C&&Be(N.prototype,C),w&&Be(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var qe=Je(function N(C){var w=this;(function(G,j){if(!(G instanceof j))throw new TypeError("Cannot call a class as a function")})(this,N),this.isSeeking=!1,C.on("seeking",function(G,j){a()(C.data,j),w._lastSeekingTime=p.now(),w.isSeeking===!1&&(w.isSeeking=!0,C.send("seeking"))}),C.on("seeked",function(){w.isSeeking=!1;var G=w._lastSeekingTime||p.now(),j=p.now()-G;l(C.data,"view_seek_count",1),l(C.data,"view_seek_duration",j);var J=C.data.view_max_seek_time||0;C.data.view_max_seek_time=Math.max(J,j)}),C.on("viewend",function(){w.isSeeking=!1})});function st(N,C){return function(w){if(Array.isArray(w))return w}(N)||function(w,G){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var J,z,Z=[],ne=!0,te=!1;try{for(j=j.call(w);!(ne=(J=j.next()).done)&&(Z.push(J.value),!G||Z.length!==G);ne=!0);}catch(oe){te=!0,z=oe}finally{try{ne||j.return==null||j.return()}finally{if(te)throw z}}return Z}}(N,C)||function(w,G){if(w){if(typeof w=="string")return Ze(w,G);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?Ze(w,G):void 0}}(N,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Ze(N,C){(C==null||C>N.length)&&(C=N.length);for(var w=0,G=new Array(C);w<C;w++)G[w]=N[w];return G}function ot(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var lt=function(N,C){N.push(C),N.sort(function(w,G){return w.viewer_time-G.viewer_time})},tt=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],je=function(){function N(j){var J=this;(function(Z,ne){if(!(Z instanceof ne))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j,j.on("viewinit",function(){J.isAdBreak=!1,J._currentAdRequestNumber=0,J._currentAdResponseNumber=0,J._adRequests=[],J._adResponses=[],J._adHasPlayed=!1,J._wouldBeNewAdPlay=!0,J._prerollPlayTime=void 0}),tt.forEach(function(Z){return j.on(Z,J._updateAdData.bind(J))});var z=function(){J.isAdBreak=!1};j.on("adbreakstart",function(){J.isAdBreak=!0}),j.on("play",z),j.on("playing",z),j.on("viewend",z),j.on("adrequest",function(Z,ne){ne=a()({ad_request_id:"generatedAdRequestId"+J._currentAdRequestNumber++},ne),lt(J._adRequests,ne),l(j.data,"view_ad_request_count"),J.inPrerollPosition()&&(j.data.view_preroll_requested=!0,J._adHasPlayed||l(j.data,"view_preroll_request_count"))}),j.on("adresponse",function(Z,ne){ne=a()({ad_request_id:"generatedAdRequestId"+J._currentAdResponseNumber++},ne),lt(J._adResponses,ne);var te=J.findAdRequest(ne.ad_request_id);te&&l(j.data,"view_ad_request_time",Math.max(0,ne.viewer_time-te.viewer_time))}),j.on("adplay",function(Z,ne){J._adHasPlayed=!0,J._wouldBeNewAdPlay&&(J._wouldBeNewAdPlay=!1,l(j.data,"view_ad_played_count")),J.inPrerollPosition()&&!j.data.view_preroll_played&&(j.data.view_preroll_played=!0,J._adRequests.length>0&&(j.data.view_preroll_request_time=Math.max(0,ne.viewer_time-J._adRequests[0].viewer_time)),j.data.view_start&&(j.data.view_startup_preroll_request_time=Math.max(0,ne.viewer_time-j.data.view_start)),J._prerollPlayTime=ne.viewer_time)}),j.on("adplaying",function(Z,ne){J.inPrerollPosition()&&j.data.view_preroll_load_time===void 0&&J._prerollPlayTime!==void 0&&(j.data.view_preroll_load_time=ne.viewer_time-J._prerollPlayTime,j.data.view_startup_preroll_load_time=ne.viewer_time-J._prerollPlayTime)}),j.on("adended",function(){J._wouldBeNewAdPlay=!0}),j.on("aderror",function(){J._wouldBeNewAdPlay=!0})}var C,w,G;return C=N,(w=[{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(j){for(var J=0;J<this._adRequests.length;J++)if(this._adRequests[J].ad_request_id===j)return this._adRequests[J]}},{key:"_updateAdData",value:function(j,J){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&J.ad_tag_url){var z=st(n(J.ad_tag_url),2),Z=z[0],ne=z[1];this.pm.data.view_preroll_ad_tag_domain=ne,this.pm.data.view_preroll_ad_tag_hostname=Z}if(!this.pm.data.view_preroll_ad_asset_hostname&&J.ad_asset_url){var te=st(n(J.ad_asset_url),2),oe=te[0],Te=te[1];this.pm.data.view_preroll_ad_asset_domain=Te,this.pm.data.view_preroll_ad_asset_hostname=oe}}}}])&&ot(C.prototype,w),G&&ot(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}();function Ve(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function rt(N,C,w){return C&&Ve(N.prototype,C),w&&Ve(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var gt=rt(function N(C){var w,G;(function(Z,ne){if(!(Z instanceof ne))throw new TypeError("Cannot call a class as a function")})(this,N);var j=function(){C.disableRebufferTracking||w&&(l(C.data,"view_waiting_rebuffer_duration",p.now()-w),w=!1,M().clearInterval(G))},J=!1,z=function(){J=!1,j()};C.on("waiting",function(){J&&(C.disableRebufferTracking||(l(C.data,"view_waiting_rebuffer_count",1),w=p.now(),G=M().setInterval(function(){if(w){var Z=p.now();l(C.data,"view_waiting_rebuffer_duration",Z-w),w=Z}},250)))}),C.on("playing",function(){j(),J=!0}),C.on("pause",z),C.on("seeking",z)});function Ne(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function it(N,C,w){return C&&Ne(N.prototype,C),w&&Ne(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var nt=it(function N(C){var w=this;(function(J,z){if(!(J instanceof z))throw new TypeError("Cannot call a class as a function")})(this,N);var G=function(){w.lastWallClockTime=p.now(),C.on("before*",j)},j=function(J){var z=p.now(),Z=w.lastWallClockTime;w.lastWallClockTime=z,z-Z>3e4&&(C.emit("devicesleep",{viewer_time:Z}),a()(C.data,{viewer_time:Z}),C.send("devicesleep"),C.emit("devicewake",{viewer_time:z}),a()(C.data,{viewer_time:z}),C.send("devicewake"))};C.one("playbackheartbeat",G),C.on("playbackheartbeatend",function(){C.off("before*",j),C.one("playbackheartbeat",G)})}),Lt=O(375),At=O(655),Dt=O.n(At),Gt="muxData",Pt=function(){var N;try{N=Lt.parse(Dt().get(Gt)||"")}catch{N={}}return N},hr=function(N){try{Dt().set(Gt,Lt.stringify(N),{expires:7300})}catch{}},Ht=function(){var N=Pt();return N.mux_viewer_id=N.mux_viewer_id||P(),N.msn=N.msn||Math.random(),hr(N),{mux_viewer_id:N.mux_viewer_id,mux_sample_number:N.msn}};function Pr(N,C){var w=C.beaconCollectionDomain,G=C.beaconDomain;if(w)return"https://"+w;var j=G||"litix.io";return(N=N||"inferred").match(/^[a-z0-9]+$/)?"https://"+N+"."+j:"https://img.litix.io/a.gif"}var jt=function(){var N;switch(Ot()){case"cellular":N="cellular";break;case"ethernet":N="wired";break;case"wifi":N="wifi";break;case void 0:break;default:N="other"}return N},Ot=function(){var N=M().navigator,C=N&&(N.connection||N.mozConnection||N.webkitConnection);return C&&C.type};jt.getConnectionFromAPI=Ot;var ht=jt,vr=gr({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"}),Vt=gr({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function gr(N){var C={};for(var w in N)N.hasOwnProperty(w)&&(C[N[w]]=w);return C}function Yt(N){var C={},w={};return Object.keys(N).forEach(function(G){var j=!1;if(N.hasOwnProperty(G)&&N[G]!==void 0){var J=G.split("_"),z=J[0],Z=vr[z];Z||(f.info("Data key word `"+J[0]+"` not expected in "+G),Z=z+"_"),J.splice(1).forEach(function(ne){ne==="url"&&(j=!0),Vt[ne]?Z+=Vt[ne]:Number(ne)&&Math.floor(Number(ne))===Number(ne)?Z+=ne:(f.info("Data key word `"+ne+"` not expected in "+G),Z+="_"+ne+"_")}),j?w[Z]=N[G]:C[Z]=N[G]}}),a()(C,w)}var Rr={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Ir=["hb","requestcompleted","requestfailed","requestcanceled"],Or="https://img.litix.io",vt=function(N){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=N||Or,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=a()({},Rr,C)};vt.prototype.queueEvent=function(N,C){var w=a()({},C);return(this._eventQueue.length<=this._options.maxQueueLength||N==="eventrateexceeded")&&(this._eventQueue.push(w),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},vt.prototype.flushEvents=function(){var N=arguments.length>0&&arguments[0]!==void 0&&arguments[0];N&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},vt.prototype.destroy=function(){var N=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,N?this._clearBeaconQueue():this.flushEvents(),M().clearTimeout(this._sendTimeout)},vt.prototype._clearBeaconQueue=function(){var N=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,C=this._eventQueue.slice(N);N>0&&a()(C[C.length-1],Yt({mux_view_message:"event queue truncated"}));var w=this._createPayload(C);Xt(this._beaconUrl,w,!0,function(){})},vt.prototype._sendBeaconQueue=function(){var N=this;if(!this._postInFlight){var C=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var w=this._createPayload(C),G=p.now();Xt(this._beaconUrl,w,!1,function(j,J){J?(N._eventQueue=C.concat(N._eventQueue),N._failureCount+=1,f.info("Error sending beacon: "+J)):N._failureCount=0,N._roundTripTime=p.now()-G,N._postInFlight=!1})}},vt.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var N=Math.pow(2,this._failureCount-1);return(1+(N*=Math.random()))*this._options.baseTimeBetweenBeacons},vt.prototype._startBeaconSending=function(){var N=this;M().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=M().setTimeout(function(){N._eventQueue.length&&N._sendBeaconQueue(),N._startBeaconSending()},this._getNextBeaconTime()))},vt.prototype._createPayload=function(N){var C,w,G,j=this,J={transmission_timestamp:Math.round(p.now())};this._roundTripTime&&(J.rtt_ms=Math.round(this._roundTripTime));var z=function(){C=JSON.stringify({metadata:J,events:w||N}),G=C.length/1024},Z=function(){return G<=j._options.maxPayloadKBSize};return z(),Z()||(f.info("Payload size is too big ("+G+" kb). Removing unnecessary events."),w=N.filter(function(ne){return Ir.indexOf(ne.e)===-1}),z()),Z()||(f.info("Payload size still too big ("+G+" kb). Cropping fields.."),w.forEach(function(ne){for(var te in ne){var oe=ne[te];typeof oe=="string"&&oe.length>51200&&(ne[te]=oe.substring(0,51200))}}),z()),C};var Xt=function(N,C,w,G){if(w&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(N,C))G();else if(M().fetch)M().fetch(N,{method:"POST",body:C,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(J){return G(null,J.ok?null:"Error")}).catch(function(J){return G(null,J)});else{if(M().XMLHttpRequest){var j=new(M()).XMLHttpRequest;return j.onreadystatechange=function(){if(j.readyState===4)return G(null,j.status!==200?"error":void 0)},j.open("POST",N),j.setRequestHeader("Content-Type","text/plain"),void j.send(C)}G()}},Cr=vt;function Mr(N,C){return function(w){if(Array.isArray(w))return w}(N)||function(w,G){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var J,z,Z=[],ne=!0,te=!1;try{for(j=j.call(w);!(ne=(J=j.next()).done)&&(Z.push(J.value),!G||Z.length!==G);ne=!0);}catch(oe){te=!0,z=oe}finally{try{ne||j.return==null||j.return()}finally{if(te)throw z}}return Z}}(N,C)||function(w,G){if(w){if(typeof w=="string")return hi(w,G);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?hi(w,G):void 0}}(N,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function hi(N,C){(C==null||C>N.length)&&(C=N.length);for(var w=0,G=new Array(C);w<C;w++)G[w]=N[w];return G}function vi(N,C){var w=Object.keys(N);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(N);C&&(G=G.filter(function(j){return Object.getOwnPropertyDescriptor(N,j).enumerable})),w.push.apply(w,G)}return w}function Ct(N){for(var C=1;C<arguments.length;C++){var w=arguments[C]!=null?arguments[C]:{};C%2?vi(Object(w),!0).forEach(function(G){mr(N,G,w[G])}):Object.getOwnPropertyDescriptors?Object.defineProperties(N,Object.getOwnPropertyDescriptors(w)):vi(Object(w)).forEach(function(G){Object.defineProperty(N,G,Object.getOwnPropertyDescriptor(w,G))})}return N}function zt(N){return zt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},zt(N)}function sn(N,C){if(!(N instanceof C))throw new TypeError("Cannot call a class as a function")}function gi(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function mr(N,C,w){return C in N?Object.defineProperty(N,C,{value:w,enumerable:!0,configurable:!0,writable:!0}):N[C]=w,N}var on=["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"],ln=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended"],un=["viewstart","error","ended","viewend"],dn=function(){function N(j,J){var z,Z,ne,te,oe,Te,ge,Ee,ve,_e,Ce,ze,Qe,ut,Ie,$e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};sn(this,N),mr(this,"previousBeaconData",null),mr(this,"lastEventTime",0),mr(this,"rateLimited",!1),this.mux=j,this.envKey=J,this.options=$e,this.eventQueue=new Cr(Pr(this.envKey,this.options)),this.sampleRate=(z=this.options.sampleRate)!==null&&z!==void 0?z:1,this.disableCookies=(Z=this.options.disableCookies)!==null&&Z!==void 0&&Z,this.respectDoNotTrack=(ne=this.options.respectDoNotTrack)!==null&&ne!==void 0&&ne,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(te=this.options.platform)===null||te===void 0?void 0:te.name,viewer_application_version:(oe=this.options.platform)===null||oe===void 0?void 0:oe.version,viewer_application_engine:(Te=this.options.platform)===null||Te===void 0?void 0:Te.layout,viewer_device_name:(ge=this.options.platform)===null||ge===void 0?void 0:ge.product,viewer_device_category:"",viewer_device_manufacturer:(Ee=this.options.platform)===null||Ee===void 0?void 0:Ee.manufacturer,viewer_os_family:(ve=this.options.platform)===null||ve===void 0||(_e=ve.os)===null||_e===void 0?void 0:_e.family,viewer_os_architecture:(Ce=this.options.platform)===null||Ce===void 0||(ze=Ce.os)===null||ze===void 0?void 0:ze.architecture,viewer_os_version:(Qe=this.options.platform)===null||Qe===void 0||(ut=Qe.os)===null||ut===void 0?void 0:ut.version,viewer_connection_type:ht(),page_url:M()===null||M()===void 0||(Ie=M().location)===null||Ie===void 0?void 0:Ie.href},this.viewerData=this.disableCookies?{}:Ht()}var C,w,G;return C=N,(w=[{key:"send",value:function(j,J){var z;if(j){if(this.respectDoNotTrack&&_())return f.info("Not sending `"+j+"` because Do Not Track is enabled");if(!J||zt(J)!=="object")return f.error("A data object was expected in send() but was not provided");var Z,ne,te=this.disableCookies?{}:(Z=Pt(),ne=p.now(),Z.session_start&&(Z.sst=Z.session_start,delete Z.session_start),Z.session_id&&(Z.sid=Z.session_id,delete Z.session_id),Z.session_expires&&(Z.sex=Z.session_expires,delete Z.session_expires),(!Z.sex||Z.sex<ne)&&(Z.sid=P(),Z.sst=ne),Z.sex=ne+15e5,hr(Z),{session_id:Z.sid,session_start:Z.sst,session_expires:Z.sex}),oe=Ct(Ct(Ct(Ct(Ct({},this.pageLevelData),J),te),this.viewerData),{},{event:j,env_key:this.envKey});oe.user_id&&(oe.viewer_user_id=oe.user_id,delete oe.user_id);var Te=((z=oe.mux_sample_number)!==null&&z!==void 0?z:0)>=this.sampleRate,ge=Yt(this._deduplicateBeaconData(j,oe));if(this.lastEventTime=this.mux.utils.now(),Te)return f.info("Not sending event due to sample rate restriction",j,oe,ge);if(this.envKey||f.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",j,oe,ge),!this.rateLimited){if(f.info("Sending event",j,oe,ge),this.rateLimited=!this.eventQueue.queueEvent(j,ge),this.mux.WINDOW_UNLOADING&&j==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&j==="hb"?this.eventQueue.flushEvents(!0):un.indexOf(j)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return oe.event="eventrateexceeded",ge=Yt(oe),this.eventQueue.queueEvent(oe.event,ge),f.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(j,J){var z=this,Z={},ne=J.view_id;if(!ne||j==="viewstart"||j==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)Z=Ct({},J),ne&&(this.previousBeaconData=Z),ne&&j==="viewend"&&(this.previousBeaconData=null);else{var te=j.indexOf("request")===0;Object.entries(J).forEach(function(oe){var Te=Mr(oe,2),ge=Te[0],Ee=Te[1];z.previousBeaconData&&(Ee!==z.previousBeaconData[ge]||on.indexOf(ge)>-1||z.objectHasChanged(te,ge,Ee,z.previousBeaconData[ge])||z.eventRequiresKey(j,ge))&&(Z[ge]=Ee,z.previousBeaconData[ge]=Ee)})}return Z}},{key:"objectHasChanged",value:function(j,J,z,Z){return!(!j||J.indexOf("request_")!==0||J!=="request_response_headers"&&zt(z)==="object"&&zt(Z)==="object"&&Object.keys(z||{}).length===Object.keys(Z||{}).length)}},{key:"eventRequiresKey",value:function(j,J){return j==="renditionchange"&&J.indexOf("video_source_")===0||!(J.indexOf("ad_")!==0||!ln.includes(j))}}])&&gi(C.prototype,w),G&&gi(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}();function mi(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function fn(N,C,w){return C&&mi(N.prototype,C),w&&mi(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var cn=fn(function N(C){(function(te,oe){if(!(te instanceof oe))throw new TypeError("Cannot call a class as a function")})(this,N);var w=0,G=0,j=0,J=0,z=0,Z=0,ne=0;C.on("requestcompleted",function(te,oe){var Te,ge,Ee=oe.request_start,ve=oe.request_response_start,_e=oe.request_response_end,Ce=oe.request_bytes_loaded;if(J++,ve?(Te=ve-Ee,ge=_e-ve):ge=_e-Ee,ge>0&&Ce>0){var ze=Ce/ge*8e3;z++,G+=Ce,j+=ge,C.data.view_min_request_throughput=Math.min(C.data.view_min_request_throughput||1/0,ze),C.data.view_average_request_throughput=G/j*8e3,C.data.view_request_count=J,Te>0&&(w+=Te,C.data.view_max_request_latency=Math.max(C.data.view_max_request_latency||0,Te),C.data.view_average_request_latency=w/z)}}),C.on("requestfailed",function(te,oe){J++,Z++,C.data.view_request_count=J,C.data.view_request_failed_count=Z}),C.on("requestcanceled",function(te,oe){J++,ne++,C.data.view_request_count=J,C.data.view_request_canceled_count=ne})});function pi(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function hn(N,C,w){return C&&pi(N.prototype,C),w&&pi(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var vn=hn(function N(C){var w=this;(function(G,j){if(!(G instanceof j))throw new TypeError("Cannot call a class as a function")})(this,N),C.on("before*",function(G,j){var J=j.viewer_time,z=p.now(),Z=w._lastEventTime;if(w._lastEventTime=z,Z&&z-Z>36e5){var ne=Object.keys(C.data).reduce(function(te,oe){return oe.indexOf("video_")===0?a()(te,function(Te,ge,Ee){return ge in Te?Object.defineProperty(Te,ge,{value:Ee,enumerable:!0,configurable:!0,writable:!0}):Te[ge]=Ee,Te}({},oe,C.data[oe])):te},{});C.mux.log.info("Received event after at least an hour inactivity, creating a new view"),C.emit("viewinit",a()({viewer_time:J},ne)),C.playbackHeartbeat._playheadShouldBeProgressing&&G.type!=="play"&&G.type!=="adbreakstart"&&(C.emit("play",{viewer_time:J}),G.type!=="playing"&&C.emit("playing",{viewer_time:J}))}})});function wr(N){return wr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},wr(N)}function gn(N,C){return function(w){if(Array.isArray(w))return w}(N)||function(w,G){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var J,z,Z=[],ne=!0,te=!1;try{for(j=j.call(w);!(ne=(J=j.next()).done)&&(Z.push(J.value),!G||Z.length!==G);ne=!0);}catch(oe){te=!0,z=oe}finally{try{ne||j.return==null||j.return()}finally{if(te)throw z}}return Z}}(N,C)||function(w,G){if(w){if(typeof w=="string")return yi(w,G);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?yi(w,G):void 0}}(N,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function yi(N,C){(C==null||C>N.length)&&(C=N.length);for(var w=0,G=new Array(C);w<C;w++)G[w]=N[w];return G}function Ei(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function kr(N,C){return kr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(w,G){return w.__proto__=G,w},kr(N,C)}function mn(N){var C=function(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var w,G=pr(N);if(C){var j=pr(this).constructor;w=Reflect.construct(G,arguments,j)}else w=G.apply(this,arguments);return pn(this,w)}}function pn(N,C){if(C&&(wr(C)==="object"||typeof C=="function"))return C;if(C!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ye(N)}function Ye(N){if(N===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return N}function pr(N){return pr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(C){return C.__proto__||Object.getPrototypeOf(C)},pr(N)}var yn=["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"],En=function(N){(function(z,Z){if(typeof Z!="function"&&Z!==null)throw new TypeError("Super expression must either be null or a function");z.prototype=Object.create(Z&&Z.prototype,{constructor:{value:z,writable:!0,configurable:!0}}),Object.defineProperty(z,"prototype",{writable:!1}),Z&&kr(z,Z)})(J,N);var C,w,G,j=mn(J);function J(z,Z,ne){var te;(function(ve,_e){if(!(ve instanceof _e))throw new TypeError("Cannot call a class as a function")})(this,J),(te=j.call(this)).DOM_CONTENT_LOADED_EVENT_END=d.domContentLoadedEventEnd(),te.NAVIGATION_START=d.navigationStart(),te.mux=z,te.id=Z,(ne=a()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(ve){return ve}},ne)).data=ne.data||{},ne.data.property_key&&(ne.data.env_key=ne.data.property_key,delete ne.data.property_key),f.setLevel(ne.debug?"debug":"warn"),te.getPlayheadTime=ne.getPlayheadTime,te.getStateData=ne.getStateData||function(){return{}},te.getAdData=ne.getAdData||function(){},te.minimumRebufferDuration=ne.minimumRebufferDuration,te.sustainedRebufferThreshold=ne.sustainedRebufferThreshold,te.playbackHeartbeatTime=ne.playbackHeartbeatTime,te.disableRebufferTracking=ne.disableRebufferTracking,te.disableRebufferTracking&&te.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."),te.disablePlayheadRebufferTracking=ne.disablePlayheadRebufferTracking,te.errorTranslator=ne.errorTranslator,te.playbackEventDispatcher=new dn(z,ne.data.env_key,ne),te.data={player_instance_id:P(),mux_sample_rate:ne.sampleRate,beacon_domain:ne.beaconCollectionDomain?ne.beaconCollectionDomain:ne.beaconDomain},te.data.view_sequence_number=1,te.data.player_sequence_number=1,te.oldEmit=te.emit,te.emit=function(ve,_e){_e=a()({viewer_time:this.mux.utils.now()},_e),this.oldEmit(ve,_e)};var oe=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Ye(te));te.on("viewinit",function(ve,_e){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),a()(this.data,_e),this._initializeViewData(),this.one("play",oe),this.one("adbreakstart",oe)});var Te=function(ve){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",ve)}.bind(Ye(te));if(te.on("videochange",function(ve,_e){Te(_e)}),te.on("programchange",function(ve,_e){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."),Te(a()(_e,{view_program_changed:!0})),oe(),this.emit("play"),this.emit("playing")}),te.on("fragmentchange",function(ve,_e){this.currentFragmentPDT=_e.currentFragmentPDT,this.currentFragmentStart=_e.currentFragmentStart}),te.on("destroy",te.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ge=function(){var ve=te.data.view_start!==void 0;te.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",ve&&te.mux.WINDOW_HIDDEN&&(te.data.player_is_paused||te.emit("hb"))};window.addEventListener("visibilitychange",ge,!1);var Ee=function(ve){ve.persisted||te.destroy()};window.addEventListener("pagehide",Ee,!1),te.on("destroy",function(){window.removeEventListener("visibilitychange",ge),window.removeEventListener("pagehide",Ee)})}return te.on("playerready",function(ve,_e){a()(this.data,_e)}),yn.forEach(function(ve){te.on(ve,function(_e,Ce){ve.indexOf("ad")!==0&&this._updateStateData(),a()(this.data,Ce),this._sanitizeData()}),te.on("after"+ve,function(){(ve!=="error"||this.errorTracker.viewErrored)&&this.send(ve)})}),te.on("viewend",function(ve,_e){a()(te.data,_e)}),te.one("playerready",function(ve){var _e=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=_e-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}),te.longResumeTracker=new vn(Ye(te)),te.errorTracker=new ae(Ye(te)),new nt(Ye(te)),te.seekingTracker=new qe(Ye(te)),te.playheadTime=new fe(Ye(te)),te.playbackHeartbeat=new Y(Ye(te)),new He(Ye(te)),te.watchTimeTracker=new se(Ye(te)),new de(Ye(te)),te.adTracker=new je(Ye(te)),new Me(Ye(te)),new Pe(Ye(te)),new ke(Ye(te)),new gt(Ye(te)),new cn(Ye(te)),ne.hlsjs&&te.addHLSJS(ne),ne.dashjs&&te.addDashJS(ne),te.emit("viewinit",ne.data),te}return C=J,w=[{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(z){var Z=a()({},this.data);if(Z.video_source_is_live===void 0&&(Z.player_source_duration===1/0||Z.video_source_duration===1/0?Z.video_source_is_live=!0:(Z.player_source_duration>0||Z.video_source_duration>0)&&(Z.video_source_is_live=!1)),Z.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(Te){Z[Te]=void 0}),Z.video_source_url=Z.video_source_url||Z.player_source_url,Z.video_source_url){var ne=gn(n(Z.video_source_url),2),te=ne[0],oe=ne[1];Z.video_source_domain=oe,Z.video_source_hostname=te}delete Z.ad_request_id,this.playbackEventDispatcher.send(z,Z),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){a()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var z=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(Z){var ne=parseInt(z.data[Z],10);z.data[Z]=isNaN(ne)?void 0:ne}),["player_source_url","video_source_url"].forEach(function(Z){if(z.data[Z]){var ne=z.data[Z].toLowerCase();ne.indexOf("data:")!==0&&ne.indexOf("blob:")!==0||(z.data[Z]="MSE style URL")}})}},{key:"_resetVideoData",value:function(z,Z){var ne=this;Object.keys(this.data).forEach(function(te){te.indexOf("video_")===0&&delete ne.data[te]})}},{key:"_resetViewData",value:function(){var z=this;Object.keys(this.data).forEach(function(Z){Z.indexOf("view_")===0&&delete z.data[Z]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(z,Z){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var z=this,Z=this.data.view_id=P(),ne=function(){Z===z.data.view_id&&l(z.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",ne):ne()}},{key:"_restartHeartBeat",value:function(){var z=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){z.data.player_is_paused||z.emit("hb")},1e4))}},{key:"addHLSJS",value:function(z){z.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=z.hlsjs,function(Z,ne,te){var oe=arguments.length>4?arguments[4]:void 0,Te=Z.log,ge=Z.utils.secondsToMs,Ee=function(Oe){var ye,Se=parseInt(oe.version);return Se===1&&Oe.programDateTime!==null&&(ye=Oe.programDateTime),Se===0&&Oe.pdt!==null&&(ye=Oe.pdt),ye};if(d.exists()){var ve=function(Oe,ye){return Z.emit(ne,Oe,ye)},_e=function(Oe,ye){var Se=ye.levels,me=ye.audioTracks,xe=ye.url,We=ye.stats,Ge=ye.networkDetails,dt=ye.sessionData,at={},pt={};Se.forEach(function(_t,Jt){at[Jt]={width:_t.width,height:_t.height,bitrate:_t.bitrate,attrs:_t.attrs}}),me.forEach(function(_t,Jt){pt[Jt]={name:_t.name,language:_t.lang,bitrate:_t.bitrate}});var ft=r(We),Et=ft.bytesLoaded,Xe=ft.requestStart,yt=ft.responseStart,Br=ft.responseEnd;ve("requestcompleted",m(m({},g(dt)),{},{request_event_type:Oe,request_bytes_loaded:Et,request_start:Xe,request_response_start:yt,request_response_end:Br,request_type:"manifest",request_hostname:s(xe),request_response_headers:t(Ge),request_rendition_lists:{media:at,audio:pt,video:{}}}))};te.on(oe.Events.MANIFEST_LOADED,_e);var Ce=function(Oe,ye){var Se=ye.details,me=ye.level,xe=ye.networkDetails,We=ye.stats,Ge=r(We),dt=Ge.bytesLoaded,at=Ge.requestStart,pt=Ge.responseStart,ft=Ge.responseEnd,Et=Se.fragments[Se.fragments.length-1],Xe=Ee(Et)+ge(Et.duration);ve("requestcompleted",{request_event_type:Oe,request_bytes_loaded:dt,request_start:at,request_response_start:pt,request_response_end:ft,request_current_level:me,request_type:"manifest",request_hostname:s(Se.url),request_response_headers:t(xe),video_holdback:Se.holdBack&&ge(Se.holdBack),video_part_holdback:Se.partHoldBack&&ge(Se.partHoldBack),video_part_target_duration:Se.partTarget&&ge(Se.partTarget),video_target_duration:Se.targetduration&&ge(Se.targetduration),video_source_is_live:Se.live,player_manifest_newest_program_time:isNaN(Xe)?void 0:Xe})};te.on(oe.Events.LEVEL_LOADED,Ce);var ze=function(Oe,ye){var Se=ye.details,me=ye.networkDetails,xe=ye.stats,We=r(xe),Ge=We.bytesLoaded,dt=We.requestStart,at=We.responseStart,pt=We.responseEnd;ve("requestcompleted",{request_event_type:Oe,request_bytes_loaded:Ge,request_start:dt,request_response_start:at,request_response_end:pt,request_type:"manifest",request_hostname:s(Se.url),request_response_headers:t(me)})};te.on(oe.Events.AUDIO_TRACK_LOADED,ze);var Qe=function(Oe,ye){var Se=ye.stats,me=ye.networkDetails,xe=ye.frag;Se=Se||xe.stats;var We=r(Se),Ge=We.bytesLoaded,dt=We.requestStart,at=We.responseStart,pt=We.responseEnd,ft=t(me),Et=ft==null?void 0:ft["x-request-id"],Xe={request_event_type:Oe,request_bytes_loaded:Ge,request_start:dt,request_response_start:at,request_response_end:pt,request_hostname:me?s(me.responseURL):void 0,request_id:Et,request_response_headers:ft,request_media_duration:xe.duration,request_url:me==null?void 0:me.responseURL};xe.type==="main"?(Xe.request_type="media",Xe.request_current_level=xe.level,Xe.request_video_width=(te.levels[xe.level]||{}).width,Xe.request_video_height=(te.levels[xe.level]||{}).height,Xe.request_labeled_bitrate=(te.levels[xe.level]||{}).bitrate):Xe.request_type=xe.type,ve("requestcompleted",Xe)};te.on(oe.Events.FRAG_LOADED,Qe);var ut=function(Oe,ye){var Se=ye.frag,me=Se.start,xe={currentFragmentPDT:Ee(Se),currentFragmentStart:ge(me)};ve("fragmentchange",xe)};te.on(oe.Events.FRAG_CHANGED,ut);var Ie=function(Oe,ye){var Se=ye.type,me=ye.details,xe=ye.response,We=ye.fatal,Ge=ye.context,dt=ye.frag;if(me===oe.ErrorDetails.MANIFEST_LOAD_ERROR||me===oe.ErrorDetails.MANIFEST_LOAD_TIMEOUT||me===oe.ErrorDetails.FRAG_LOAD_ERROR||me===oe.ErrorDetails.FRAG_LOAD_TIMEOUT||me===oe.ErrorDetails.LEVEL_LOAD_ERROR||me===oe.ErrorDetails.LEVEL_LOAD_TIMEOUT){var at=dt&&dt.url||Ge&&Ge.url||"";ve("requestfailed",{request_error:me,request_url:at,request_hostname:s(at),request_type:me===oe.ErrorDetails.FRAG_LOAD_ERROR||me===oe.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:xe&&xe.code,request_error_text:xe&&xe.text})}We&&ve("error",{player_error_code:Se,player_error_message:me})};te.on(oe.Events.ERROR,Ie);var $e=function(Oe,ye){var Se=ye.frag,me=Se&&Se._url||"";ve("requestcanceled",{request_event_type:Oe,request_url:me,request_type:"media",request_hostname:s(me)})};te.on(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,$e);var et=function(Oe,ye){var Se=ye.level,me=te.levels[Se];if(me&&me.attrs&&me.attrs.BANDWIDTH){var xe,We=me.attrs.BANDWIDTH,Ge=parseFloat(me.attrs["FRAME-RATE"]);isNaN(Ge)||(xe=Ge),We?ve("renditionchange",{video_source_fps:xe,video_source_bitrate:We,video_source_width:me.width,video_source_height:me.height,video_source_rendition_name:me.name,video_source_codec:me==null?void 0:me.videoCodec}):Te.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};te.on(oe.Events.LEVEL_SWITCHED,et),te._stopMuxMonitor=function(){te.off(oe.Events.MANIFEST_LOADED,_e),te.off(oe.Events.LEVEL_LOADED,Ce),te.off(oe.Events.AUDIO_TRACK_LOADED,ze),te.off(oe.Events.FRAG_LOADED,Qe),te.off(oe.Events.FRAG_CHANGED,ut),te.off(oe.Events.ERROR,Ie),te.off(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,$e),te.off(oe.Events.LEVEL_SWITCHED,et),te.off(oe.Events.DESTROYING,te._stopMuxMonitor),delete te._stopMuxMonitor},te.on(oe.Events.DESTROYING,te._stopMuxMonitor)}else Te.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,z.hlsjs,{},z.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var z;this.hlsjs&&((z=this.hlsjs)&&typeof z._stopMuxMonitor=="function"&&z._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(z){z.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=z.dashjs,function(Z,ne,te){var oe=Z.log;if(te&&te.on){var Te=function(Ie,$e){return Z.emit(ne,Ie,$e)},ge=function(Ie){var $e=Ie.type,et=(Ie.data||{}).url;Te("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:s(et),request_url:et})};te.on("manifestLoaded",ge);var Ee={},ve=function(Ie){var $e=Ie.type,et=Ie.fragmentModel,Oe=(Ie.chunk||{}).mediaInfo||{},ye=Oe.type,Se=Oe.bitrateList,me={};(Se=Se||[]).forEach(function(Xe,yt){me[yt]={},me[yt].width=Xe.width,me[yt].height=Xe.height,me[yt].bitrate=Xe.bandwidth,me[yt].attrs={}}),ye==="video"?Ee.video=me:ye==="audio"?Ee.audio=me:Ee.media=me;var xe=L(et,te),We=xe.requestStart,Ge=xe.requestResponseStart,dt=xe.requestResponseEnd,at=xe.requestResponseHeaders,pt=xe.requestMediaDuration,ft=xe.requestHostname,Et=xe.requestUrl;Te("requestcompleted",{request_event_type:$e,request_start:We,request_response_start:Ge,request_response_end:dt,request_bytes_loaded:-1,request_type:ye+"_init",request_response_headers:at,request_hostname:ft,request_url:Et,request_media_duration:pt,request_rendition_lists:Ee})};te.on("initFragmentLoaded",ve);var _e=function(Ie){var $e=Ie.type,et=Ie.fragmentModel,Oe=Ie.chunk||{},ye=Oe.mediaInfo,Se=Oe.start,me=(ye||{}).type,xe=L(et,te),We=xe.requestStart,Ge=xe.requestResponseStart,dt=xe.requestResponseEnd,at=xe.requestBytesLoaded,pt=xe.requestResponseHeaders,ft=xe.requestMediaDuration,Et=xe.requestHostname,Xe=xe.requestUrl,yt=R(me,te),Br=yt.currentLevel,_t=yt.renditionWidth,Jt=yt.renditionHeight,Gn=yt.renditionBitrate;Te("requestcompleted",{request_event_type:$e,request_start:We,request_response_start:Ge,request_response_end:dt,request_bytes_loaded:at,request_type:me,request_response_headers:pt,request_hostname:Et,request_url:Xe,request_media_start_time:Se,request_media_duration:ft,request_current_level:Br,request_labeled_bitrate:Gn,request_video_width:_t,request_video_height:Jt})};te.on("mediaFragmentLoaded",_e);var Ce={video:void 0,audio:void 0,totalBitrate:void 0},ze=function(){if(Ce.video&&typeof Ce.video.bitrate=="number"){if(Ce.video.width&&Ce.video.height){var Ie=Ce.video.bitrate;return Ce.audio&&typeof Ce.audio.bitrate=="number"&&(Ie+=Ce.audio.bitrate),Ie!==Ce.totalBitrate?(Ce.totalBitrate=Ie,{video_source_bitrate:Ie,video_source_height:Ce.video.height,video_source_width:Ce.video.width,video_source_codec:I(Ce.video.codec)}):void 0}oe.warn("have bitrate info for video but missing width/height")}},Qe=function(Ie,$e,et){if(typeof Ie.newQuality=="number"){var Oe=Ie.mediaType;if(Oe==="audio"||Oe==="video"){var ye=te.getBitrateInfoListFor(Oe).find(function(me){return me.qualityIndex===Ie.newQuality});if(ye&&typeof ye.bitrate=="number"){Ce[Oe]=y(y({},ye),{},{codec:te.getCurrentTrackFor(Oe).codec});var Se=ze();Se&&Te("renditionchange",Se)}else oe.warn("missing bitrate info for ".concat(Oe))}}else oe.warn("missing evt.newQuality in qualityChangeRendered event",Ie)};te.on("qualityChangeRendered",Qe);var ut=function(Ie){var $e=Ie.error,et=Ie.event,Oe=(et=et||{}).request||{},ye=M().event&&M().event.currentTarget||{};Te("requestfailed",{request_error:$e+"_"+et.id+"_"+Oe.type,request_url:et.url,request_hostname:s(et.url),request_type:Oe.mediaType,request_error_code:ye.status,request_error_type:ye.statusText})};te.on("error",ut),te._stopMuxMonitor=function(){te.off("manifestLoaded",ge),te.off("initFragmentLoaded",ve),te.off("mediaFragmentLoaded",_e),te.off("qualityChangeRendered",Qe),te.off("error",ut),delete te._stopMuxMonitor}}else oe.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,z.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var z;this.dashjs&&((z=this.dashjs)&&typeof z._stopMuxMonitor=="function"&&z._stopMuxMonitor(),this.dashjs=void 0)}}],w&&Ei(C.prototype,w),G&&Ei(C,G),Object.defineProperty(C,"prototype",{writable:!1}),J}(K),_n=En,Tn=O(153),Qt=O.n(Tn);function Fr(N){return Fr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},Fr(N)}function _i(N,C){return function(w){if(Array.isArray(w))return w}(N)||function(w,G){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var J,z,Z=[],ne=!0,te=!1;try{for(j=j.call(w);!(ne=(J=j.next()).done)&&(Z.push(J.value),!G||Z.length!==G);ne=!0);}catch(oe){te=!0,z=oe}finally{try{ne||j.return==null||j.return()}finally{if(te)throw z}}return Z}}(N,C)||function(w,G){if(w){if(typeof w=="string")return Ti(w,G);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?Ti(w,G):void 0}}(N,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Ti(N,C){(C==null||C>N.length)&&(C=N.length);for(var w=0,G=new Array(C);w<C;w++)G[w]=N[w];return G}var Mt,Sn=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],xn={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};M()&&M().WeakMap&&(Mt=new WeakMap);var An="#EXT-X-TARGETDURATION",Dn="#EXT-X-PART-INF",bn="#EXT-X-SERVER-CONTROL",Ln="#EXTINF",Pn="#EXT-X-PROGRAM-DATE-TIME",Rn="#EXT-X-VERSION",In="#EXT-X-SESSION-DATA",yr=function(N){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(N),this.manifest};yr.prototype.process=function(N){var C;for(this.buffer+=N,C=this.buffer.indexOf(`
|
|
6
6
|
`);C>-1;C=this.buffer.indexOf(`
|
|
7
|
-
`))this.processLine(this.buffer.substring(0,C)),this.buffer=this.buffer.substring(C+1)},
|
|
8
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function mi(F,C){(C==null||C>F.length)&&(C=F.length);for(var M=0,N=new Array(C);M<C;M++)N[M]=F[M];return N}var ut={},Vt=function F(C){var M=arguments;typeof C=="string"?F.hasOwnProperty(C)?_().setTimeout(function(){M=Array.prototype.splice.call(M,1),F[C].apply(null,M)},0):e.warn("`"+C+"` is an unknown task"):typeof C=="function"?_().setTimeout(function(){C(F)},0):e.warn("`"+C+"` is invalid.")},Cn={loaded:h.now(),NAME:"mux-embed",VERSION:"4.17.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(F,C){return function(M,N,K){var V=hi(E(N),3),G=V[0],Q=V[1],Z=V[2],$=M.log,ee=M.utils.getComputedStyle,me=M.utils.secondsToMs;if(!G)return $.error("No element was found with the `"+Q+"` query selector.");if(Z!=="video"&&Z!=="audio")return $.error("The element of `"+Q+"` was not a media element.");G.mux&&(G.mux.destroy(),delete G.mux,$.warn("Already monitoring this video element, replacing existing event listeners")),(K=i()({automaticErrorTracking:!0},K)).data=i()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:M.VERSION},K.data),K.getPlayheadTime=function(){return me(G.currentTime)},K.getStateData=function(){var he,oe,ve=this.hlsjs&&this.hlsjs.url,_e=this.dashjs&&Cr(this.dashjs.getSource==="function")&&this.dashjs.getSource(),ze={player_is_paused:G.paused,player_playhead_time:me(G.currentTime),player_width:parseInt(ee(G,"width")),player_height:parseInt(ee(G,"height")),player_autoplay_on:G.autoplay,player_preload_on:G.preload,player_language_code:G.lang,player_is_fullscreen:Ht()&&!!(Ht().fullscreenElement||Ht().webkitFullscreenElement||Ht().mozFullScreenElement||Ht().msFullscreenElement),video_poster_url:G.poster,video_source_url:ve||_e||G.currentSrc,video_source_duration:me(G.duration),video_source_height:G.videoHeight,video_source_width:G.videoWidth,view_dropped_frame_count:(he=G)===null||he===void 0||(oe=he.getVideoPlaybackQuality)===null||oe===void 0?void 0:oe.call(he).droppedVideoFrames},Xe=K.getPlayheadTime();if(G.getStartDate&&Xe>0){var tt=G.getStartDate();if(tt&&typeof tt.getTime=="function"&&tt.getTime()){var Ae=tt.getTime();if(ze.player_program_time=Ae+Xe,G.seekable.length>0){var Qe=Ae+G.seekable.end(G.seekable.length-1);ze.player_live_edge_program_time=Qe}}}return ze},G.mux=G.mux||{},G.mux.deleted=!1,G.mux.emit=function(he,oe){M.emit(Q,he,oe)};var ue=function(){$.error("The monitor for this video element has already been destroyed.")};G.mux.destroy=function(){Object.keys(G.mux.listeners).forEach(function(he){G.removeEventListener(he,G.mux.listeners[he],!1)}),delete G.mux.listeners,G.mux.destroy=ue,G.mux.swapElement=ue,G.mux.emit=ue,G.mux.addHLSJS=ue,G.mux.addDashJS=ue,G.mux.removeHLSJS=ue,G.mux.removeDashJS=ue,G.mux.deleted=!0,M.emit(Q,"destroy")},G.mux.swapElement=function(he){var oe=hi(E(he),3),ve=oe[0],_e=oe[1],ze=oe[2];return ve?ze!=="video"&&ze!=="audio"?M.log.error("The element of `"+_e+"` was not a media element."):(ve.muxId=G.muxId,delete G.muxId,ve.mux=ve.mux||{},ve.mux.listeners=i()({},G.mux.listeners),delete G.mux.listeners,Object.keys(ve.mux.listeners).forEach(function(Xe){G.removeEventListener(Xe,ve.mux.listeners[Xe],!1),ve.addEventListener(Xe,ve.mux.listeners[Xe],!1)}),ve.mux.swapElement=G.mux.swapElement,ve.mux.destroy=G.mux.destroy,delete G.mux,void(G=ve)):M.log.error("No element was found with the `"+_e+"` query selector.")},G.mux.addHLSJS=function(he){M.addHLSJS(Q,he)},G.mux.addDashJS=function(he){M.addDashJS(Q,he)},G.mux.removeHLSJS=function(){M.removeHLSJS(Q)},G.mux.removeDashJS=function(){M.removeDashJS(Q)},M.init(Q,K),M.emit(Q,"playerready"),G.paused||(M.emit(Q,"play"),G.readyState>2&&M.emit(Q,"playing")),G.mux.listeners={},vn.forEach(function(he){(he!=="error"||K.automaticErrorTracking)&&(G.mux.listeners[he]=function(){var oe={};if(he==="error"){if(!G.error||G.error.code===1)return;oe.player_error_code=G.error.code,oe.player_error_message=gn[G.error.code]||G.error.message}M.emit(Q,he,oe)},G.addEventListener(he,G.mux.listeners[he],!1))})}(Vt,F,C)},destroyMonitor:function(F){var C=In(E(F),1)[0];C&&C.mux&&typeof C.mux.destroy=="function"?C.mux.destroy():e.error("A video element monitor for `"+F+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(F,C){var M=A(F);ut[M]?ut[M].addHLSJS(C):e.error("A monitor for `"+M+"` has not been initialized.")},addDashJS:function(F,C){var M=A(F);ut[M]?ut[M].addDashJS(C):e.error("A monitor for `"+M+"` has not been initialized.")},removeHLSJS:function(F){var C=A(F);ut[C]?ut[C].removeHLSJS():e.error("A monitor for `"+C+"` has not been initialized.")},removeDashJS:function(F){var C=A(F);ut[C]?ut[C].removeDashJS():e.error("A monitor for `"+C+"` has not been initialized.")},init:function(F,C){o()&&C&&C.respectDoNotTrack&&e.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var M=A(F);ut[M]=new cn(Vt,M,C)},emit:function(F,C,M){var N=A(F);ut[N]?(ut[N].emit(C,M),C==="destroy"&&delete ut[N]):e.error("A monitor for `"+N+"` has not been initialized.")},checkDoNotTrack:o,log:e,utils:Rn,events:Pn,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Vt,Cn),_()!==void 0&&typeof _().addEventListener=="function"&&_().addEventListener("pagehide",function(F){F.persisted||(Vt.WINDOW_UNLOADING=!0)},!1);var Mn=Vt},655:function(D,w,R){var O,_;function y(T){return y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},y(T);}(function(T){var A=!1;if((_=typeof(O=T)=="function"?O.call(w,R,w,D):O)===void 0||(D.exports=_),A=!0,y(w)==="object"&&(D.exports=T(),A=!0),!A){var E=window.Cookies,m=window.Cookies=T();m.noConflict=function(){return window.Cookies=E,m}}})(function(){var T=function(){for(var A=0,E={};A<arguments.length;A++){var m=arguments[A];for(var p in m)E[p]=m[p]}return E};return function A(E){function m(p,d,e){var o;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(e=T({path:"/"},m.defaults,e)).expires=="number"){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*e.expires),e.expires=h}try{o=JSON.stringify(d),/^[\{\[]/.test(o)&&(d=o)}catch{}return d=E.write?E.write(d,p):encodeURIComponent(String(d)).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,"=",d,e.expires?"; expires="+e.expires.toUTCString():"",e.path?"; path="+e.path:"",e.domain?"; domain="+e.domain:"",e.secure?"; secure":""].join("")}p||(o={});for(var g=document.cookie?document.cookie.split("; "):[],i=/(%[0-9A-Z]{2})+/g,r=0;r<g.length;r++){var l=g[r].split("="),c=l.slice(1).join("=");c.charAt(0)==='"'&&(c=c.slice(1,-1));try{var t=l[0].replace(i,decodeURIComponent);if(c=E.read?E.read(c,t):E(c,t)||c.replace(i,decodeURIComponent),this.json)try{c=JSON.parse(c)}catch{}if(p===t){o=c;break}p||(o[t]=c)}catch{}}return o}}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,d){m(p,"",T(d,{expires:-1}))},m.withConverter=A,m}(function(){})})},153:function(D,w,R){var O,_=R.g!==void 0?R.g:typeof window!="undefined"?window:{},y=R(558);typeof document!="undefined"?O=document:(O=_["__GLOBAL_DOCUMENT_CACHE@4"])||(O=_["__GLOBAL_DOCUMENT_CACHE@4"]=y),D.exports=O},48:function(D,w,R){var O;O=typeof window!="undefined"?window:R.g!==void 0?R.g:typeof self!="undefined"?self:{},D.exports=O},678:function(D){var w=9007199254740991,R="[object Arguments]",O="[object Function]",_="[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 A,E,m=Object.prototype,p=m.hasOwnProperty,d=m.toString,e=m.propertyIsEnumerable,o=(A=Object.keys,E=Object,function(S){return A(E(S))}),h=Math.max,g=!e.call({valueOf:1},"valueOf");function i(S,x){var P=a(S)||function(W){return function(H){return function(z){return!!z&&typeof z=="object"}(H)&&u(H)}(W)&&p.call(W,"callee")&&(!e.call(W,"callee")||d.call(W)==R)}(S)?function(W,H){for(var z=-1,Y=Array(W);++z<W;)Y[z]=H(z);return Y}(S.length,String):[],B=P.length,k=!!B;for(var U in S)!x&&!p.call(S,U)||k&&(U=="length"||l(U,B))||P.push(U);return P}function r(S,x,P){var B=S[x];p.call(S,x)&&t(B,P)&&(P!==void 0||x in S)||(S[x]=P)}function l(S,x){return!!(x=x==null?w:x)&&(typeof S=="number"||y.test(S))&&S>-1&&S%1==0&&S<x}function c(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 a=Array.isArray;function u(S){return S!=null&&function(x){return typeof x=="number"&&x>-1&&x%1==0&&x<=w}(S.length)&&!function(x){var P=s(x)?d.call(x):"";return P==O||P==_}(S)}function s(S){var x=typeof S;return!!S&&(x=="object"||x=="function")}var f,v=(f=function(S,x){if(g||c(x)||u(x))(function(B,k,U,W){U||(U={});for(var H=-1,z=k.length;++H<z;){var Y=k[H],J=W?W(U[Y],B[Y],Y,U,B):void 0;r(U,Y,J===void 0?B[Y]:J)}})(x,function(B){return u(B)?i(B):function(k){if(!c(k))return o(k);var U=[];for(var W in Object(k))p.call(k,W)&&W!="constructor"&&U.push(W);return U}(B)}(x),S);else for(var P in x)p.call(x,P)&&r(S,P,x[P])},function(S,x){return x=h(x===void 0?S.length-1:x,0),function(){for(var P=arguments,B=-1,k=h(P.length-x,0),U=Array(k);++B<k;)U[B]=P[x+B];B=-1;for(var W=Array(x+1);++B<x;)W[B]=P[B];return W[x]=U,T(S,this,W)}}(function(S,x){var P=-1,B=x.length,k=B>1?x[B-1]:void 0,U=B>2?x[2]:void 0;for(k=f.length>3&&typeof k=="function"?(B--,k):void 0,U&&function(H,z,Y){if(!s(Y))return!1;var J=typeof z;return!!(J=="number"?u(Y)&&l(z,Y.length):J=="string"&&z in Y)&&t(Y[z],H)}(x[0],x[1],U)&&(k=B<3?void 0:k,B=1),S=Object(S);++P<B;){var W=x[P];W&&f(S,W,P,k)}return S}));D.exports=v},640:function(D,w,R){var O,_;(function(y,T){"use strict";O=function(){var A=function(){},E="undefined",m=typeof window!==E&&typeof window.navigator!==E&&/Trident\/|MSIE /.test(window.navigator.userAgent),p=["trace","debug","info","warn","error"];function d(a,u){var s=a[u];if(typeof s.bind=="function")return s.bind(a);try{return Function.prototype.bind.call(s,a)}catch{return function(){return Function.prototype.apply.apply(s,[a,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 o(a){return a==="debug"&&(a="log"),typeof console!==E&&(a==="trace"&&m?e:console[a]!==void 0?d(console,a):console.log!==void 0?d(console,"log"):A)}function h(a,u){for(var s=0;s<p.length;s++){var f=p[s];this[f]=s<a?A:this.methodFactory(f,a,u)}this.log=this.debug}function g(a,u,s){return function(){typeof console!==E&&(h.call(this,u,s),this[a].apply(this,arguments))}}function i(a,u,s){return o(a)||g.apply(this,arguments)}function r(a,u,s){var f,v=this;u=u==null?"WARN":u;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,H=W.indexOf(encodeURIComponent(S)+"=");H!==-1&&(U=/^([^;]+)/.exec(W.slice(H))[1])}catch{}return v.levels[U]===void 0&&(U=void 0),U}}function B(){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 a=="string"?S+=":"+a:typeof a=="symbol"&&(S=void 0),v.name=a,v.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},v.methodFactory=s||i,v.getLevel=function(){return f},v.setLevel=function(U,W){if(typeof U=="string"&&v.levels[U.toUpperCase()]!==void 0&&(U=v.levels[U.toUpperCase()]),!(typeof U=="number"&&U>=0&&U<=v.levels.SILENT))throw"log.setLevel() called with invalid level: "+U;if(f=U,W!==!1&&x(U),h.call(v,U,a),typeof console===E&&U<v.levels.SILENT)return"No console available for logging"},v.setDefaultLevel=function(U){u=U,P()||v.setLevel(U,!1)},v.resetLevel=function(){v.setLevel(u,!1),B()},v.enableAll=function(U){v.setLevel(v.levels.TRACE,U)},v.disableAll=function(U){v.setLevel(v.levels.SILENT,U)};var k=P();k==null&&(k=u),v.setLevel(k,!1)}var l=new r,c={};l.getLogger=function(a){if(typeof a!="symbol"&&typeof a!="string"||a==="")throw new TypeError("You must supply a name when creating a logger.");var u=c[a];return u||(u=c[a]=new r(a,l.getLevel(),l.methodFactory)),u};var t=typeof window!==E?window.log:void 0;return l.noConflict=function(){return typeof window!==E&&window.log===l&&(window.log=t),l},l.getLoggers=function(){return c},l.default=l,l},(_=typeof O=="function"?O.call(w,R,w,D):O)===void 0||(D.exports=_)})()},375:function(D,w){"use strict";var R=Object.prototype.hasOwnProperty;function O(y){try{return decodeURIComponent(y.replace(/\+/g," "))}catch{return null}}function _(y){try{return encodeURIComponent(y)}catch{return null}}w.stringify=function(y,T){T=T||"";var A,E,m=[];for(E in typeof T!="string"&&(T="?"),y)if(R.call(y,E)){if((A=y[E])||A!=null&&!isNaN(A)||(A=""),E=_(E),A=_(A),E===null||A===null)continue;m.push(E+"="+A)}return m.length?T+m.join("&"):""},w.parse=function(y){for(var T,A=/([^=?#&]+)=?([^&]*)/g,E={};T=A.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(){}},I={};function L(D){var w=I[D];if(w!==void 0)return w.exports;var R=I[D]={exports:{}};return n[D].call(R.exports,R,R.exports,L),R.exports}return L.n=function(D){var w=D&&D.__esModule?function(){return D.default}:function(){return D};return L.d(w,{a:w}),w},L.d=function(D,w){for(var R in w)L.o(w,R)&&!L.o(D,R)&&Object.defineProperty(D,R,{enumerable:!0,get:w[R]})},L.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),L.o=function(D,w){return Object.prototype.hasOwnProperty.call(D,w)},L(80)}()},typeof Er=="object"&&typeof jr=="object"?jr.exports=b():typeof Er=="object"?Er.mux=b():j.mux=b()})()});var yr=pi(($t,Wr)=>{typeof window!="undefined"&&function(b,n){typeof $t=="object"&&typeof Wr=="object"?Wr.exports=n():typeof define=="function"&&define.amd?define([],n):typeof $t=="object"?$t.Hls=n():b.Hls=n()}($t,function(){return function(j){var b={};function n(I){if(b[I])return b[I].exports;var L=b[I]={i:I,l:!1,exports:{}};return j[I].call(L.exports,L,L.exports,n),L.l=!0,L.exports}return n.m=j,n.c=b,n.d=function(I,L,D){n.o(I,L)||Object.defineProperty(I,L,{enumerable:!0,get:D})},n.r=function(I){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(I,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(I,"__esModule",{value:!0})},n.t=function(I,L){if(L&1&&(I=n(I)),L&8||L&4&&typeof I=="object"&&I&&I.__esModule)return I;var D=Object.create(null);if(n.r(D),Object.defineProperty(D,"default",{enumerable:!0,value:I}),L&2&&typeof I!="string")for(var w in I)n.d(D,w,function(R){return I[R]}.bind(null,w));return D},n.n=function(I){var L=I&&I.__esModule?function(){return I.default}:function(){return I};return n.d(L,"a",L),L},n.o=function(I,L){return Object.prototype.hasOwnProperty.call(I,L)},n.p="/dist/",n(n.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(j,b,n){"use strict";var I=Object.prototype.hasOwnProperty,L="~";function D(){}Object.create&&(D.prototype=Object.create(null),new D().__proto__||(L=!1));function w(y,T,A){this.fn=y,this.context=T,this.once=A||!1}function R(y,T,A,E,m){if(typeof A!="function")throw new TypeError("The listener must be a function");var p=new w(A,E||y,m),d=L?L+T:T;return y._events[d]?y._events[d].fn?y._events[d]=[y._events[d],p]:y._events[d].push(p):(y._events[d]=p,y._eventsCount++),y}function O(y,T){--y._eventsCount===0?y._events=new D:delete y._events[T]}function _(){this._events=new D,this._eventsCount=0}_.prototype.eventNames=function(){var T=[],A,E;if(this._eventsCount===0)return T;for(E in A=this._events)I.call(A,E)&&T.push(L?E.slice(1):E);return Object.getOwnPropertySymbols?T.concat(Object.getOwnPropertySymbols(A)):T},_.prototype.listeners=function(T){var A=L?L+T:T,E=this._events[A];if(!E)return[];if(E.fn)return[E.fn];for(var m=0,p=E.length,d=new Array(p);m<p;m++)d[m]=E[m].fn;return d},_.prototype.listenerCount=function(T){var A=L?L+T:T,E=this._events[A];return E?E.fn?1:E.length:0},_.prototype.emit=function(T,A,E,m,p,d){var e=L?L+T:T;if(!this._events[e])return!1;var o=this._events[e],h=arguments.length,g,i;if(o.fn){switch(o.once&&this.removeListener(T,o.fn,void 0,!0),h){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,A),!0;case 3:return o.fn.call(o.context,A,E),!0;case 4:return o.fn.call(o.context,A,E,m),!0;case 5:return o.fn.call(o.context,A,E,m,p),!0;case 6:return o.fn.call(o.context,A,E,m,p,d),!0}for(i=1,g=new Array(h-1);i<h;i++)g[i-1]=arguments[i];o.fn.apply(o.context,g)}else{var r=o.length,l;for(i=0;i<r;i++)switch(o[i].once&&this.removeListener(T,o[i].fn,void 0,!0),h){case 1:o[i].fn.call(o[i].context);break;case 2:o[i].fn.call(o[i].context,A);break;case 3:o[i].fn.call(o[i].context,A,E);break;case 4:o[i].fn.call(o[i].context,A,E,m);break;default:if(!g)for(l=1,g=new Array(h-1);l<h;l++)g[l-1]=arguments[l];o[i].fn.apply(o[i].context,g)}}return!0},_.prototype.on=function(T,A,E){return R(this,T,A,E,!1)},_.prototype.once=function(T,A,E){return R(this,T,A,E,!0)},_.prototype.removeListener=function(T,A,E,m){var p=L?L+T:T;if(!this._events[p])return this;if(!A)return O(this,p),this;var d=this._events[p];if(d.fn)d.fn===A&&(!m||d.once)&&(!E||d.context===E)&&O(this,p);else{for(var e=0,o=[],h=d.length;e<h;e++)(d[e].fn!==A||m&&!d[e].once||E&&d[e].context!==E)&&o.push(d[e]);o.length?this._events[p]=o.length===1?o[0]:o:O(this,p)}return this},_.prototype.removeAllListeners=function(T){var A;return T?(A=L?L+T:T,this._events[A]&&O(this,A)):(this._events=new D,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=L,_.EventEmitter=_,j.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(j,b,n){(function(I){var L=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,D=/^(?=([^\/?#]*))\1([^]*)$/,w=/(?:\/|^)\.(?=\/)/g,R=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(_,y,T){if(T=T||{},_=_.trim(),y=y.trim(),!y){if(!T.alwaysNormalize)return _;var A=O.parseURL(_);if(!A)throw new Error("Error trying to parse base URL.");return A.path=O.normalizePath(A.path),O.buildURLFromParts(A)}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(_);if(!m)throw new Error("Error trying to parse base URL.");if(!m.netLoc&&m.path&&m.path[0]!=="/"){var p=D.exec(m.path);m.netLoc=p[1],m.path=p[2]}m.netLoc&&!m.path&&(m.path="/");var d={scheme:m.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(d.netLoc=m.netLoc,E.path[0]!=="/"))if(!E.path)d.path=m.path,E.params||(d.params=m.params,E.query||(d.query=m.query));else{var e=m.path,o=e.substring(0,e.lastIndexOf("/")+1)+E.path;d.path=O.normalizePath(o)}return d.path===null&&(d.path=T.alwaysNormalize?O.normalizePath(E.path):E.path),O.buildURLFromParts(d)},parseURL:function(_){var y=L.exec(_);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(w,"");_.length!==(_=_.replace(R,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};j.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(j,b,n){function I(T){var A={};function E(p){if(A[p])return A[p].exports;var d=A[p]={i:p,l:!1,exports:{}};return T[p].call(d.exports,d,d.exports,E),d.l=!0,d.exports}E.m=T,E.c=A,E.i=function(p){return p},E.d=function(p,d,e){E.o(p,d)||Object.defineProperty(p,d,{configurable:!1,enumerable:!0,get:e})},E.r=function(p){Object.defineProperty(p,"__esModule",{value:!0})},E.n=function(p){var d=p&&p.__esModule?function(){return p.default}:function(){return p};return E.d(d,"a",d),d},E.o=function(p,d){return Object.prototype.hasOwnProperty.call(p,d)},E.p="/",E.oe=function(p){throw console.error(p),p};var m=E(E.s=ENTRY_MODULE);return m.default||m}var L="[\\.|\\-|\\+|\\w|/|@]+",D="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+L+").*?\\)";function w(T){return(T+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function R(T){return!isNaN(1*T)}function O(T,A,E){var m={};m[E]=[];var p=A.toString(),d=p.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!d)return m;for(var e=d[1],o=new RegExp("(\\\\n|\\W)"+w(e)+D,"g"),h;h=o.exec(p);)h[3]!=="dll-reference"&&m[E].push(h[3]);for(o=new RegExp("\\("+w(e)+'\\("(dll-reference\\s('+L+'))"\\)\\)'+D,"g");h=o.exec(p);)T[h[2]]||(m[E].push(h[1]),T[h[2]]=n(h[1]).m),m[h[2]]=m[h[2]]||[],m[h[2]].push(h[4]);for(var g=Object.keys(m),i=0;i<g.length;i++)for(var r=0;r<m[g[i]].length;r++)R(m[g[i]][r])&&(m[g[i]][r]=1*m[g[i]][r]);return m}function _(T){var A=Object.keys(T);return A.reduce(function(E,m){return E||T[m].length>0},!1)}function y(T,A){for(var E={main:[A]},m={main:[]},p={main:{}};_(E);)for(var d=Object.keys(E),e=0;e<d.length;e++){var o=d[e],h=E[o],g=h.pop();if(p[o]=p[o]||{},!(p[o][g]||!T[o][g])){p[o][g]=!0,m[o]=m[o]||[],m[o].push(g);for(var i=O(T,T[o][g],o),r=Object.keys(i),l=0;l<r.length;l++)E[r[l]]=E[r[l]]||[],E[r[l]]=E[r[l]].concat(i[r[l]])}}return m}j.exports=function(T,A){A=A||{};var E={main:n.m},m=A.all?{main:Object.keys(E.main)}:y(E,T),p="";Object.keys(m).filter(function(g){return g!=="main"}).forEach(function(g){for(var i=0;m[g][i];)i++;m[g].push(i),E[g][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",p=p+"var "+g+" = ("+I.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+m[g].map(function(r){return""+JSON.stringify(r)+": "+E[g][r].toString()}).join(",")+`});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Estimated load time for
|
|
12
|
-
Estimated load time for the next fragment: `+B.toFixed(3)+` s
|
|
13
|
-
Time to underbuffer: `+P.toFixed(3)+" s"),o.nextLoadLevel=k,this.bwEstimator.sample(c,r.loaded),this.clearTimer(),d.loader&&(this.fragCurrent=this.partCurrent=null,d.loader.abort()),o.trigger(D.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:d,part:e,stats:r})}}}}}},m.onFragLoaded=function(d,e){var o=e.frag,h=e.part;if(o.type===O.PlaylistLevelType.MAIN&&Object(I.isFiniteNumber)(o.sn)){var g=h?h.stats:o.stats,i=h?h.duration:o.duration;if(this.clearTimer(),this.lastLoadedFragLevel=o.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[o.level],l=(r.loaded?r.loaded.bytes:0)+g.loaded,c=(r.loaded?r.loaded.duration:0)+i;r.loaded={bytes:l,duration:c},r.realBitrate=Math.round(8*l/c)}if(o.bitrateTest){var t={stats:g,frag:o,part:h,id:o.type};this.onFragBuffered(D.Events.FRAG_BUFFERED,t)}}},m.onFragBuffered=function(d,e){var o=e.frag,h=e.part,g=h?h.stats:o.stats;if(!g.aborted&&!(o.type!==O.PlaylistLevelType.MAIN||o.sn==="initSegment")){var i=g.parsing.end-g.loading.start;this.bwEstimator.sample(i,g.loaded),g.bwEstimate=this.bwEstimator.getEstimate(),o.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},m.onError=function(d,e){switch(e.details){case R.ErrorDetails.FRAG_LOAD_ERROR:case R.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},m.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},m.getNextABRAutoLevel=function(){var d=this.fragCurrent,e=this.partCurrent,o=this.hls,h=o.maxAutoLevel,g=o.config,i=o.minAutoLevel,r=o.media,l=e?e.duration:d?d.duration:0,c=r?r.currentTime:0,t=r&&r.playbackRate!==0?Math.abs(r.playbackRate):1,a=this.bwEstimator?this.bwEstimator.getEstimate():g.abrEwmaDefaultEstimate,u=(w.BufferHelper.bufferInfo(r,c,g.maxBufferHole).end-c)/t,s=this.findBestLevel(a,i,h,u,g.abrBandWidthFactor,g.abrBandWidthUpFactor);if(s>=0)return s;_.logger.trace((u?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var f=l?Math.min(l,g.maxStarvationDelay):g.maxStarvationDelay,v=g.abrBandWidthFactor,S=g.abrBandWidthUpFactor;if(!u){var x=this.bitrateTestDelay;if(x){var P=l?Math.min(l,g.maxLoadingDelay):g.maxLoadingDelay;f=P-x,_.logger.trace("bitrate test took "+Math.round(1e3*x)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*f)+" ms"),v=S=1}}return s=this.findBestLevel(a,i,h,u+f,v,S),Math.max(s,0)},m.findBestLevel=function(d,e,o,h,g,i){for(var r,l=this.fragCurrent,c=this.partCurrent,t=this.lastLoadedFragLevel,a=this.hls.levels,u=a[t],s=!!(u!=null&&(r=u.details)!==null&&r!==void 0&&r.live),f=u==null?void 0:u.codecSet,v=c?c.duration:l?l.duration:0,S=o;S>=e;S--){var x=a[S];if(!(!x||f&&x.codecSet!==f)){var P=x.details,B=(c?P==null?void 0:P.partTarget:P==null?void 0:P.averagetargetduration)||v,k=void 0;S<=t?k=g*d:k=i*d;var U=a[S].maxBitrate,W=U*B/k;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+S+"/"+Math.round(k)+"/"+U+"/"+B+"/"+h+"/"+W),k>U&&(!W||s&&!this.bitrateTestDelay||W<h))return S}}return-1},T(E,[{key:"nextAutoLevel",get:function(){var d=this._nextAutoLevel,e=this.bwEstimator;if(d!==-1&&!e.canEstimate())return d;var o=this.getNextABRAutoLevel();return d!==-1&&this.hls.levels[o].loadError?d:(d!==-1&&(o=Math.min(d,o)),o)},set:function(d){this._nextAutoLevel=d}}]),E}();b.default=A},"./src/controller/audio-stream-controller.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/polyfills/number.ts"),L=n("./src/controller/base-stream-controller.ts"),D=n("./src/events.ts"),w=n("./src/utils/buffer-helper.ts"),R=n("./src/controller/fragment-tracker.ts"),O=n("./src/types/level.ts"),_=n("./src/types/loader.ts"),y=n("./src/loader/fragment.ts"),T=n("./src/demux/chunk-cache.ts"),A=n("./src/demux/transmuxer-interface.ts"),E=n("./src/types/transmuxer.ts"),m=n("./src/controller/fragment-finders.ts"),p=n("./src/utils/discontinuities.ts"),d=n("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(r){for(var l=1;l<arguments.length;l++){var c=arguments[l];for(var t in c)Object.prototype.hasOwnProperty.call(c,t)&&(r[t]=c[t])}return r},e.apply(this,arguments)}function o(r,l){r.prototype=Object.create(l.prototype),r.prototype.constructor=r,h(r,l)}function h(r,l){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,a){return t.__proto__=a,t},h(r,l)}var g=100,i=function(r){o(l,r);function l(t,a){var u;return u=r.call(this,t,a,"[audio-stream-controller]")||this,u.videoBuffer=null,u.videoTrackCC=-1,u.waitingVideoCC=-1,u.audioSwitch=!1,u.trackId=-1,u.waitingData=null,u.mainDetails=null,u.bufferFlushed=!1,u.cachedTrackLoadedData=null,u._registerListeners(),u}var c=l.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._registerListeners=function(){var a=this.hls;a.on(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.on(D.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),a.on(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),a.on(D.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.on(D.Events.ERROR,this.onError,this),a.on(D.Events.BUFFER_RESET,this.onBufferReset,this),a.on(D.Events.BUFFER_CREATED,this.onBufferCreated,this),a.on(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),a.on(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),a.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var a=this.hls;a.off(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.off(D.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),a.off(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),a.off(D.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.off(D.Events.ERROR,this.onError,this),a.off(D.Events.BUFFER_RESET,this.onBufferReset,this),a.off(D.Events.BUFFER_CREATED,this.onBufferCreated,this),a.off(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),a.off(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),a.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(a,u){var s=u.frag,f=u.id,v=u.initPTS;if(f==="main"){var S=s.cc;this.initPTS[s.cc]=v,this.log("InitPTS for cc: "+S+" found from main: "+v),this.videoTrackCC=S,this.state===L.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(a){if(!this.levels){this.startPosition=a,this.state=L.State.STOPPED;return}var u=this.lastCurrentTime;this.stopLoad(),this.setInterval(g),this.fragLoadError=0,u>0&&a===-1?(this.log("Override startPosition with lastCurrentTime @"+u.toFixed(3)),a=u,this.state=L.State.IDLE):(this.loadedmetadata=!1,this.state=L.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=a,this.tick()},c.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_TRACK:{var a,u=this.levels,s=this.trackId,f=u==null||(a=u[s])===null||a===void 0?void 0:a.details;if(f){if(this.waitForCdnTuneIn(f))break;this.state=L.State.WAITING_INIT_PTS}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var v,S=performance.now(),x=this.retryDate;(!x||S>=x||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=L.State.IDLE);break}case L.State.WAITING_INIT_PTS:{var P=this.waitingData;if(P){var B=P.frag,k=P.part,U=P.cache,W=P.complete;if(this.initPTS[B.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.FRAG_LOADING;var H=U.flush(),z={frag:B,part:k,payload:H,networkDetails:null};this._handleFragmentLoadProgress(z),W&&r.prototype._handleFragmentLoadComplete.call(this,z)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+B.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var Y=this.getLoadPosition(),J=w.BufferHelper.bufferInfo(this.mediaBuffer,Y,this.config.maxBufferHole),te=Object(m.fragmentWithinToleranceTest)(J.end,this.config.maxFragLookUpTolerance,B);te<0&&(this.log("Waiting fragment cc ("+B.cc+") @ "+B.start+" cancelled because another fragment at "+J.end+" is needed"),this.clearWaitingFragment())}}else this.state=L.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var a=this.waitingData;a&&(this.fragmentTracker.removeFragment(a.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=L.State.IDLE)},c.resetLoadingState=function(){this.clearWaitingFragment(),r.prototype.resetLoadingState.call(this)},c.onTickEnd=function(){var a=this.media;if(!(!a||!a.readyState)){var u=this.mediaBuffer?this.mediaBuffer:a,s=u.buffered;!this.loadedmetadata&&s.length&&(this.loadedmetadata=!0),this.lastCurrentTime=a.currentTime}},c.doTickIdle=function(){var a,u,s=this.hls,f=this.levels,v=this.media,S=this.trackId,x=s.config;if(!(!f||!f[S])&&!(!v&&(this.startFragRequested||!x.startFragPrefetch))){var P=f[S],B=P.details;if(!B||B.live&&this.levelLastLoaded!==S||this.waitForCdnTuneIn(B)){this.state=L.State.WAITING_TRACK;return}var k=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&k&&(this.bufferFlushed=!1,this.afterBufferFlushed(k,y.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var U=this.getFwdBufferInfo(k,_.PlaylistLevelType.AUDIO);if(U!==null){var W=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN),H=U.len,z=this.getMaxBufferLength(W==null?void 0:W.len),Y=this.audioSwitch;if(!(H>=z&&!Y)){if(!Y&&this._streamEnded(U,B)){s.trigger(D.Events.BUFFER_EOS,{type:"audio"}),this.state=L.State.ENDED;return}var J=B.fragments,te=J[0].start,X=U.end;if(Y&&v){var q=this.getLoadPosition();X=q,B.PTSKnown&&q<te&&(U.end>te||U.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),v.currentTime=te+.05)}if(!(W&&X>W.end+B.targetduration)&&!((!W||!W.len)&&U.len)){var ne=this.getNextFragment(X,B);if(!ne){this.bufferFlushed=!0;return}((a=ne.decryptdata)===null||a===void 0?void 0:a.keyFormat)==="identity"&&!((u=ne.decryptdata)!==null&&u!==void 0&&u.key)?this.loadKey(ne,B):this.loadFragment(ne,B,X)}}}}},c.getMaxBufferLength=function(a){var u=r.prototype.getMaxBufferLength.call(this);return a?Math.max(u,a):u},c.onMediaDetaching=function(){this.videoBuffer=null,r.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(a,u){var s=u.audioTracks;this.resetTransmuxer(),this.levels=s.map(function(f){return new O.Level(f)})},c.onAudioTrackSwitching=function(a,u){var s=!!u.url;this.trackId=u.id;var f=this.fragCurrent;f!=null&&f.loader&&f.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),s?this.setInterval(g):this.resetTransmuxer(),s?(this.audioSwitch=!0,this.state=L.State.IDLE):this.state=L.State.STOPPED,this.tick()},c.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},c.onLevelLoaded=function(a,u){this.mainDetails=u.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(D.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},c.onAudioTrackLoaded=function(a,u){var s;if(this.mainDetails==null){this.cachedTrackLoadedData=u;return}var f=this.levels,v=u.details,S=u.id;if(!f){this.warn("Audio tracks were reset while loading level "+S);return}this.log("Track "+S+" loaded ["+v.startSN+","+v.endSN+"],duration:"+v.totalduration);var x=f[S],P=0;if(v.live||(s=x.details)!==null&&s!==void 0&&s.live){var B=this.mainDetails;if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed||!B)return;!x.details&&v.hasProgramDateTime&&B.hasProgramDateTime?(Object(p.alignMediaPlaylistByPDT)(v,B),P=v.fragments[0].start):P=this.alignPlaylists(v,x.details)}x.details=v,this.levelLastLoaded=S,!this.startFragRequested&&(this.mainDetails||!v.live)&&this.setStartPosition(x.details,P),this.state===L.State.WAITING_TRACK&&!this.waitForCdnTuneIn(v)&&(this.state=L.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(a){var u,s=a.frag,f=a.part,v=a.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 "+s.sn+" of level "+s.level+" will not be buffered");return}var B=P[x];console.assert(B,"Audio track is defined on fragment load progress");var k=B.details;console.assert(k,"Audio track details are defined on fragment load progress");var U=S.defaultAudioCodec||B.audioCodec||"mp4a.40.2",W=this.transmuxer;W||(W=this.transmuxer=new A.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var H=this.initPTS[s.cc],z=(u=s.initSegment)===null||u===void 0?void 0:u.data;if(H!==void 0){var Y=!1,J=f?f.index:-1,te=J!==-1,X=new E.ChunkMetadata(s.level,s.sn,s.stats.chunkCount,v.byteLength,J,te);W.push(v,z,U,"",s,f,k.totalduration,Y,X,H)}else{this.log("Unknown video PTS for cc "+s.cc+", waiting for video PTS before demuxing audio frag "+s.sn+" of ["+k.startSN+" ,"+k.endSN+"],track "+x);var q=this.waitingData=this.waitingData||{frag:s,part:f,cache:new T.default,complete:!1},ne=q.cache;ne.push(new Uint8Array(v)),this.waitingVideoCC=this.videoTrackCC,this.state=L.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(a){if(this.waitingData){this.waitingData.complete=!0;return}r.prototype._handleFragmentLoadComplete.call(this,a)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(a,u){var s=u.tracks.audio;s&&(this.mediaBuffer=s.buffer||null),u.tracks.video&&(this.videoBuffer=u.tracks.video.buffer||null)},c.onFragBuffered=function(a,u){var s=u.frag,f=u.part;if(s.type===_.PlaylistLevelType.AUDIO){if(this.fragContextChanged(s)){this.warn("Fragment "+s.sn+(f?" p: "+f.index:"")+" of level "+s.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}s.sn!=="initSegment"&&(this.fragPrevious=s,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(s,f)}},c.onError=function(a,u){switch(u.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,u);break;case d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==L.State.ERROR&&this.state!==L.State.STOPPED&&(this.state=u.fatal?L.State.ERROR:L.State.IDLE,this.warn(u.details+" while loading frag, switching to "+this.state+" state"));break;case d.ErrorDetails.BUFFER_FULL_ERROR:if(u.parent==="audio"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var s=!0,f=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);f&&f.len>.5&&(s=!this.reduceMaxBufferLength(f.len)),s&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},c.onBufferFlushed=function(a,u){var s=u.type;s===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},c._handleTransmuxComplete=function(a){var u,s="audio",f=this.hls,v=a.remuxResult,S=a.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,B=x.part,k=x.level.details,U=v.audio,W=v.text,H=v.id3,z=v.initSegment;if(!(this.fragContextChanged(P)||!k)){if(this.state=L.State.PARSING,this.audioSwitch&&U&&this.completeAudioSwitch(),z!=null&&z.tracks&&(this._bufferInitSegment(z.tracks,P,S),f.trigger(D.Events.FRAG_PARSING_INIT_SEGMENT,{frag:P,id:s,tracks:z.tracks})),U){var Y=U.startPTS,J=U.endPTS,te=U.startDTS,X=U.endDTS;B&&(B.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:Y,endPTS:J,startDTS:te,endDTS:X}),P.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,Y,J,te,X),this.bufferFragmentData(U,P,B,S)}if(H!=null&&(u=H.samples)!==null&&u!==void 0&&u.length){var q=e({id:s,frag:P,details:k},H);f.trigger(D.Events.FRAG_PARSING_METADATA,q)}if(W){var ne=e({id:s,frag:P,details:k},W);f.trigger(D.Events.FRAG_PARSING_USERDATA,ne)}}},c._bufferInitSegment=function(a,u,s){if(this.state===L.State.PARSING){a.video&&delete a.video;var f=a.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(D.Events.BUFFER_CODECS,a);var v=f.initSegment;if(v!=null&&v.byteLength){var S={type:"audio",frag:u,part:null,chunkMeta:s,parent:u.type,data:v};this.hls.trigger(D.Events.BUFFER_APPENDING,S)}this.tick()}}},c.loadFragment=function(a,u,s){var f=this.fragmentTracker.getState(a);this.fragCurrent=a,(this.audioSwitch||f===R.FragmentState.NOT_LOADED||f===R.FragmentState.PARTIAL)&&(a.sn==="initSegment"?this._loadInitSegment(a):u.live&&!Object(I.isFiniteNumber)(this.initPTS[a.cc])?(this.log("Waiting for video PTS in continuity counter "+a.cc+" of live stream before loading audio fragment "+a.sn+" of level "+this.trackId),this.state=L.State.WAITING_INIT_PTS):(this.startFragRequested=!0,r.prototype.loadFragment.call(this,a,u,s)))},c.completeAudioSwitch=function(){var a=this.hls,u=this.media,s=this.trackId;u&&(this.log("Switching audio track : flushing all audio"),r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,a.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:s})},l}(L.default);b.default=i},"./src/controller/audio-track-controller.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/events.ts"),L=n("./src/errors.ts"),D=n("./src/controller/base-playlist-controller.ts"),w=n("./src/types/loader.ts");function R(A,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(A,p.key,p)}}function O(A,E,m){return E&&R(A.prototype,E),m&&R(A,m),Object.defineProperty(A,"prototype",{writable:!1}),A}function _(A,E){A.prototype=Object.create(E.prototype),A.prototype.constructor=A,y(A,E)}function y(A,E){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,d){return p.__proto__=d,p},y(A,E)}var T=function(A){_(E,A);function E(p){var d;return d=A.call(this,p,"[audio-track-controller]")||this,d.tracks=[],d.groupId=null,d.tracksInGroup=[],d.trackId=-1,d.trackName="",d.selectDefaultTrack=!0,d.registerListeners(),d}var m=E.prototype;return m.registerListeners=function(){var d=this.hls;d.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),d.on(I.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.on(I.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.on(I.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var d=this.hls;d.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.off(I.Events.LEVEL_LOADING,this.onLevelLoading,this),d.off(I.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.off(I.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.off(I.Events.ERROR,this.onError,this)},m.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,A.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(d,e){this.tracks=e.audioTracks||[]},m.onAudioTrackLoaded=function(d,e){var o=e.id,h=e.details,g=this.tracksInGroup[o];if(!g){this.warn("Invalid audio track id "+o);return}var i=g.details;g.details=e.details,this.log("audioTrack "+o+" loaded ["+h.startSN+"-"+h.endSN+"]"),o===this.trackId&&(this.retryCount=0,this.playlistLoaded(o,e,i))},m.onLevelLoading=function(d,e){this.switchLevel(e.level)},m.onLevelSwitching=function(d,e){this.switchLevel(e.level)},m.switchLevel=function(d){var e=this.hls.levels[d];if(!!(e!=null&&e.audioGroupIds)){var o=e.audioGroupIds[e.urlId];if(this.groupId!==o){this.groupId=o;var h=this.tracks.filter(function(i){return!o||i.groupId===o});this.selectDefaultTrack&&!h.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var g={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(I.Events.AUDIO_TRACKS_UPDATED,g),this.selectInitialTrack()}}},m.onError=function(d,e){A.prototype.onError.call(this,d,e),!(e.fatal||!e.context)&&e.context.type===w.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},m.setAudioTrack=function(d){var e=this.tracksInGroup;if(d<0||d>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var o=e[this.trackId];this.log("Now switching to audio-track index "+d);var h=e[d],g=h.id,i=h.groupId,r=i===void 0?"":i,l=h.name,c=h.type,t=h.url;if(this.trackId=d,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(I.Events.AUDIO_TRACK_SWITCHING,{id:g,groupId:r,name:l,type:c,url:t}),!(h.details&&!h.details.live)){var a=this.switchParams(h.url,o==null?void 0:o.details);this.loadPlaylist(a)}},m.selectInitialTrack=function(){var d=this.tracksInGroup;console.assert(d.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,o=this.findTrackId(e)||this.findTrackId();o!==-1?this.setAudioTrack(o):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},m.findTrackId=function(d){for(var e=this.tracksInGroup,o=0;o<e.length;o++){var h=e[o];if((!this.selectDefaultTrack||h.default)&&(!d||d===h.name))return h.id}return-1},m.loadPlaylist=function(d){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var o=e.id,h=e.groupId,g=e.url;if(d)try{g=d.addDirectives(g)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+o),this.clearTimer(),this.hls.trigger(I.Events.AUDIO_TRACK_LOADING,{url:g,id:o,groupId:h,deliveryDirectives:d||null})}},O(E,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(d){this.selectDefaultTrack=!1,this.setAudioTrack(d)}}]),E}(D.default);b.default=T},"./src/controller/base-playlist-controller.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return O});var I=n("./src/polyfills/number.ts"),L=n("./src/types/level.ts"),D=n("./src/controller/level-helper.ts"),w=n("./src/utils/logger.ts"),R=n("./src/errors.ts"),O=function(){function _(T,A){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=w.logger.log.bind(w.logger,A+":"),this.warn=w.logger.warn.bind(w.logger,A+":"),this.hls=T}var y=_.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(A,E){E.fatal&&E.type===R.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(A,E){var m=E==null?void 0:E.renditionReports;if(m)for(var p=0;p<m.length;p++){var d=m[p],e=""+d.URI;if(e===A.slice(-e.length)){var o=parseInt(d["LAST-MSN"]),h=parseInt(d["LAST-PART"]);if(E&&this.hls.config.lowLatencyMode){var g=Math.min(E.age-E.partTarget,E.targetduration);h!==void 0&&g>E.partTarget&&(h+=1)}if(Object(I.isFiniteNumber)(o))return new L.HlsUrlParameters(o,Object(I.isFiniteNumber)(h)?h:void 0,L.HlsSkip.No)}}},y.loadPlaylist=function(A){},y.shouldLoadTrack=function(A){return this.canLoad&&A&&!!A.url&&(!A.details||A.details.live)},y.playlistLoaded=function(A,E,m){var p=this,d=E.details,e=E.stats,o=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(d.advancedDateTime=Date.now()-o,d.live||m!=null&&m.live){if(d.reloaded(m),m&&this.log("live playlist "+A+" "+(d.advanced?"REFRESHED "+d.lastPartSn+"-"+d.lastPartIndex:"MISSED")),m&&d.fragments.length>0&&Object(D.mergeDetails)(m,d),!this.canLoad||!d.live)return;var h,g=void 0,i=void 0;if(d.canBlockReload&&d.endSN&&d.advanced){var r=this.hls.config.lowLatencyMode,l=d.lastPartSn,c=d.endSN,t=d.lastPartIndex,a=t!==-1,u=l===c,s=r?0:t;a?(g=u?c+1:l,i=u?s:t+1):g=c+1;var f=d.age,v=f+d.ageHeader,S=Math.min(v-d.partTarget,d.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: "+d.age),S=0;else{var x=Math.floor(S/d.targetduration);if(g+=x,i!==void 0){var P=Math.round(S%d.targetduration/d.partTarget);i+=P}this.log("CDN Tune-in age: "+d.ageHeader+"s last advanced "+f.toFixed(2)+"s goal: "+S+" skip sn "+x+" to part "+i)}d.tuneInGoal=S}if(h=this.getDeliveryDirectives(d,E.deliveryDirectives,g,i),r||!u){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(d,E.deliveryDirectives,g,i);var B=Object(D.computeReloadInterval)(d,e);g!==void 0&&d.canBlockReload&&(B-=d.partTarget||1),this.log("reload live playlist "+A+" in "+Math.round(B)+" ms"),this.timer=self.setTimeout(function(){return p.loadPlaylist(h)},B)}else this.clearTimer()},y.getDeliveryDirectives=function(A,E,m,p){var d=Object(L.getSkipValue)(A,m);return E!=null&&E.skip&&A.deltaUpdateFailed&&(m=E.msn,p=E.part,d=L.HlsSkip.No),new L.HlsUrlParameters(m,p,d)},y.retryLoadingOrFail=function(A){var E=this,m=this.hls.config,p=this.retryCount<m.levelLoadingMaxRetry;if(p){var d;if(this.retryCount++,A.details.indexOf("LoadTimeOut")>-1&&(d=A.context)!==null&&d!==void 0&&d.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+A.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 "'+A.details+'"')}}else this.warn('cannot recover from error "'+A.details+'"'),this.clearTimer(),A.fatal=!0;return p},_}()},"./src/controller/base-stream-controller.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"State",function(){return c}),n.d(b,"default",function(){return t});var I=n("./src/polyfills/number.ts"),L=n("./src/task-loop.ts"),D=n("./src/controller/fragment-tracker.ts"),w=n("./src/utils/buffer-helper.ts"),R=n("./src/utils/logger.ts"),O=n("./src/events.ts"),_=n("./src/errors.ts"),y=n("./src/types/transmuxer.ts"),T=n("./src/utils/mp4-tools.ts"),A=n("./src/utils/discontinuities.ts"),E=n("./src/controller/fragment-finders.ts"),m=n("./src/controller/level-helper.ts"),p=n("./src/loader/fragment-loader.ts"),d=n("./src/crypt/decrypter.ts"),e=n("./src/utils/time-ranges.ts"),o=n("./src/types/loader.ts");function h(a,u){for(var s=0;s<u.length;s++){var f=u[s];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(a,f.key,f)}}function g(a,u,s){return u&&h(a.prototype,u),s&&h(a,s),Object.defineProperty(a,"prototype",{writable:!1}),a}function i(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function r(a,u){a.prototype=Object.create(u.prototype),a.prototype.constructor=a,l(a,u)}function l(a,u){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,v){return f.__proto__=v,f},l(a,u)}var c={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},t=function(a){r(u,a);function u(f,v,S){var x;return x=a.call(this)||this,x.hls=void 0,x.fragPrevious=null,x.fragCurrent=null,x.fragmentTracker=void 0,x.transmuxer=null,x._state=c.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=R.logger.log.bind(R.logger,S+":"),x.warn=R.logger.warn.bind(R.logger,S+":"),x.hls=f,x.fragmentLoader=new p.default(f.config),x.fragmentTracker=v,x.config=f.config,x.decrypter=new d.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 s=u.prototype;return s.doTick=function(){this.onTickEnd()},s.onTickEnd=function(){},s.startLoad=function(v){},s.stopLoad=function(){this.fragmentLoader.abort();var v=this.fragCurrent;v&&this.fragmentTracker.removeFragment(v),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=c.STOPPED},s._streamEnded=function(v,S){var x=this.fragCurrent,P=this.fragmentTracker;if(!S.live&&x&&this.media&&x.sn>=S.endSN&&!v.nextStart){var B=S.partList;if(B!=null&&B.length){var k=B[B.length-1],U=w.BufferHelper.isBuffered(this.media,k.start+k.duration/2);return U}var W=P.getState(x);return W===D.FragmentState.PARTIAL||W===D.FragmentState.OK}return!1},s.onMediaAttached=function(v,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===c.STOPPED&&this.startLoad(P.startPosition)},s.onMediaDetaching=function(){var v=this.media;v!=null&&v.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),v&&this.onvseeking&&this.onvended&&(v.removeEventListener("seeking",this.onvseeking),v.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},s.onMediaSeeking=function(){var v=this.config,S=this.fragCurrent,x=this.media,P=this.mediaBuffer,B=this.state,k=x?x.currentTime:0,U=w.BufferHelper.bufferInfo(P||x,k,v.maxBufferHole);if(this.log("media seeking to "+(Object(I.isFiniteNumber)(k)?k.toFixed(3):k)+", state: "+B),B===c.ENDED)this.resetLoadingState();else if(S&&!U.len){var W=v.maxFragLookUpTolerance,H=S.start-W,z=S.start+S.duration+W,Y=k>z;(k<H||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=k),!this.loadedmetadata&&!U.len&&(this.nextLoadPosition=this.startPosition=k),this.tickImmediate()},s.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},s.onKeyLoaded=function(v,S){if(!(this.state!==c.KEY_LOADING||S.frag!==this.fragCurrent||!this.levels)){this.state=c.IDLE;var x=this.levels[S.frag.level].details;x&&this.loadFragment(S.frag,x,S.frag.start)}},s.onLevelSwitching=function(v,S){this.fragLoadError=0},s.onHandlerDestroying=function(){this.stopLoad(),a.prototype.onHandlerDestroying.call(this)},s.onHandlerDestroyed=function(){this.state=c.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,a.prototype.onHandlerDestroyed.call(this)},s.loadKey=function(v,S){this.log("Loading key for "+v.sn+" of ["+S.startSN+"-"+S.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level),this.state=c.KEY_LOADING,this.fragCurrent=v,this.hls.trigger(O.Events.KEY_LOADING,{frag:v})},s.loadFragment=function(v,S,x){this._loadFragForPlayback(v,S,x)},s._loadFragForPlayback=function(v,S,x){var P=this,B=function(U){if(P.fragContextChanged(v)){P.warn("Fragment "+v.sn+(U.part?" p: "+U.part.index:"")+" of level "+v.level+" was dropped during download."),P.fragmentTracker.removeFragment(v);return}v.stats.chunkCount++,P._handleFragmentLoadProgress(U)};this._doFragLoad(v,S,x,B).then(function(k){if(!!k){P.fragLoadError=0;var U=P.state;if(P.fragContextChanged(v)){(U===c.FRAG_LOADING||!P.fragCurrent&&U===c.PARSING)&&(P.fragmentTracker.removeFragment(v),P.state=c.IDLE);return}"payload"in k&&(P.log("Loaded fragment "+v.sn+" of level "+v.level),P.hls.trigger(O.Events.FRAG_LOADED,k)),P._handleFragmentLoadComplete(k)}}).catch(function(k){P.state===c.STOPPED||P.state===c.ERROR||(P.warn(k),P.resetFragmentLoading(v))})},s.flushMainBuffer=function(v,S,x){if(x===void 0&&(x=null),!!(v-S)){var P={startOffset:v,endOffset:S,type:x};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,P)}},s._loadInitSegment=function(v){var S=this;this._doFragLoad(v).then(function(x){if(!x||S.fragContextChanged(v)||!S.levels)throw new Error("init load aborted");return x}).then(function(x){var P=S.hls,B=x.payload,k=v.decryptdata;if(B&&B.byteLength>0&&k&&k.key&&k.iv&&k.method==="AES-128"){var U=self.performance.now();return S.decrypter.webCryptoDecrypt(new Uint8Array(B),k.key.buffer,k.iv.buffer).then(function(W){var H=self.performance.now();return P.trigger(O.Events.FRAG_DECRYPTED,{frag:v,payload:W,stats:{tstart:U,tdecrypt:H}}),x.payload=W,x})}return x}).then(function(x){var P=S.fragCurrent,B=S.hls,k=S.levels;if(!k)throw new Error("init load aborted, missing levels");var U=k[v.level].details;console.assert(U,"Level details are defined when init segment is loaded");var W=v.stats;S.state=c.IDLE,S.fragLoadError=0,v.data=new Uint8Array(x.payload),W.parsing.start=W.buffering.start=self.performance.now(),W.parsing.end=W.buffering.end=self.performance.now(),x.frag===P&&B.trigger(O.Events.FRAG_BUFFERED,{stats:W,frag:P,part:null,id:v.type}),S.tick()}).catch(function(x){S.state===c.STOPPED||S.state===c.ERROR||(S.warn(x),S.resetFragmentLoading(v))})},s.fragContextChanged=function(v){var S=this.fragCurrent;return!v||!S||v.level!==S.level||v.sn!==S.sn||v.urlId!==S.urlId},s.fragBufferedComplete=function(v,S){var x=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+v.type+" sn: "+v.sn+(S?" part: "+S.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+v.level+" "+(x?e.default.toString(w.BufferHelper.getBuffered(x)):"(detached)")),this.state=c.IDLE,x&&(!this.loadedmetadata&&x.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},s.seekToStartPos=function(){},s._handleFragmentLoadComplete=function(v){var S=this.transmuxer;if(!!S){var x=v.frag,P=v.part,B=v.partsLoaded,k=!B||B.length===0||B.some(function(W){return!W}),U=new y.ChunkMetadata(x.level,x.sn,x.stats.chunkCount+1,0,P?P.index:-1,!k);S.flush(U)}},s._handleFragmentLoadProgress=function(v){},s._doFragLoad=function(v,S,x,P){var B=this;if(x===void 0&&(x=null),!this.levels)throw new Error("frag load aborted, missing levels");if(x=Math.max(v.start,x||0),this.config.lowLatencyMode&&S){var k=S.partList;if(k&&P){x>v.end&&S.fragmentHint&&(v=S.fragmentHint);var U=this.getNextPart(k,v,x);if(U>-1){var W=k[U];return this.log("Loading part sn: "+v.sn+" p: "+W.index+" cc: "+v.cc+" of playlist ["+S.startSN+"-"+S.endSN+"] parts [0-"+U+"-"+(k.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(x.toFixed(3))),this.nextLoadPosition=W.start+W.duration,this.state=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:v,part:k[U],targetBufferTime:x}),this.doFragPartsLoad(v,k,U,P).catch(function(H){return B.handleFragLoadError(H)})}else if(!v.url||this.loadedEndOfParts(k,x))return Promise.resolve(null)}}return this.log("Loading fragment "+v.sn+" cc: "+v.cc+" "+(S?"of ["+S.startSN+"-"+S.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+v.level+", target: "+parseFloat(x.toFixed(3))),Object(I.isFiniteNumber)(v.sn)&&!this.bitrateTest&&(this.nextLoadPosition=v.start+v.duration),this.state=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:v,targetBufferTime:x}),this.fragmentLoader.load(v,P).catch(function(H){return B.handleFragLoadError(H)})},s.doFragPartsLoad=function(v,S,x,P){var B=this;return new Promise(function(k,U){var W=[],H=function z(Y){var J=S[Y];B.fragmentLoader.loadPart(v,J,P).then(function(te){W[J.index]=te;var X=te.part;B.hls.trigger(O.Events.FRAG_LOADED,te);var q=S[Y+1];if(q&&q.fragment===v)z(Y+1);else return k({frag:v,part:X,partsLoaded:W})}).catch(U)};H(x)})},s.handleFragLoadError=function(v){var S=v.data;return S&&S.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(S.frag,S.part):this.hls.trigger(O.Events.ERROR,S),null},s._handleTransmuxerFlush=function(v){var S=this.getCurrentContext(v);if(!S||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var x=S.frag,P=S.part,B=S.level,k=self.performance.now();x.stats.parsing.end=k,P&&(P.stats.parsing.end=k),this.updateLevelTiming(x,P,B,v.partial)},s.getCurrentContext=function(v){var S=this.levels,x=v.level,P=v.sn,B=v.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 k=S[x],U=B>-1?Object(m.getPartWith)(k,P,B):null,W=U?U.fragment:Object(m.getFragmentWithSN)(k,P,this.fragCurrent);return W?{frag:W,part:U,level:k}:null},s.bufferFragmentData=function(v,S,x,P){if(!(!v||this.state!==c.PARSING)){var B=v.data1,k=v.data2,U=B;if(B&&k&&(U=Object(T.appendUint8Array)(B,k)),!(!U||!U.length)){var W={type:v.type,frag:S,part:x,chunkMeta:P,parent:S.type,data:U};this.hls.trigger(O.Events.BUFFER_APPENDING,W),v.dropped&&v.independent&&!x&&this.flushBufferGap(S)}}},s.flushBufferGap=function(v){var S=this.media;if(!!S){if(!w.BufferHelper.isBuffered(S,S.currentTime)){this.flushMainBuffer(0,v.start);return}var x=S.currentTime,P=w.BufferHelper.bufferInfo(S,x,0),B=v.duration,k=Math.min(this.config.maxFragLookUpTolerance*2,B*.25),U=Math.max(Math.min(v.start-k,P.end-k),x+k);v.start-U>k&&this.flushMainBuffer(U,v.start)}},s.getFwdBufferInfo=function(v,S){var x=this.config,P=this.getLoadPosition();if(!Object(I.isFiniteNumber)(P))return null;var B=w.BufferHelper.bufferInfo(v,P,x.maxBufferHole);if(B.len===0&&B.nextStart!==void 0){var k=this.fragmentTracker.getBufferedFrag(P,S);if(k&&B.nextStart<k.end)return w.BufferHelper.bufferInfo(v,P,Math.max(B.nextStart,x.maxBufferHole))}return B},s.getMaxBufferLength=function(v){var S=this.config,x;return v?x=Math.max(8*S.maxBufferSize/v,S.maxBufferLength):x=S.maxBufferLength,Math.min(x,S.maxMaxBufferLength)},s.reduceMaxBufferLength=function(v){var S=this.config,x=v||S.maxBufferLength;return S.maxMaxBufferLength>=x?(S.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+S.maxMaxBufferLength+"s"),!0):!1},s.getNextFragment=function(v,S){var x=S.fragments,P=x.length;if(!P)return null;var B=this.config,k=x[0].start,U;if(S.live){var W=B.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:v)}else v<=k&&(U=x[0]);if(!U){var H=B.lowLatencyMode?S.partEnd:S.fragmentEnd;U=this.getFragmentAtPosition(v,H,S)}return this.mapToInitFragWhenRequired(U)},s.mapToInitFragWhenRequired=function(v){return v!=null&&v.initSegment&&!(v!=null&&v.initSegment.data)&&!this.bitrateTest?v.initSegment:v},s.getNextPart=function(v,S,x){for(var P=-1,B=!1,k=!0,U=0,W=v.length;U<W;U++){var H=v[U];if(k=k&&!H.independent,P>-1&&x<H.start)break;var z=H.loaded;!z&&(B||H.independent||k)&&H.fragment===S&&(P=U),B=z}return P},s.loadedEndOfParts=function(v,S){var x=v[v.length-1];return x&&S>x.start&&x.loaded},s.getInitialLiveFragment=function(v,S){var x=this.fragPrevious,P=null;if(x){if(v.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 B=x.sn+1;if(B>=v.startSN&&B<=v.endSN){var k=S[B-v.startSN];x.cc===k.cc&&(P=k,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?v.fragmentEnd:v.edge,v))}return P},s.getFragmentAtPosition=function(v,S,x){var P=this.config,B=this.fragPrevious,k=x.fragments,U=x.endSN,W=x.fragmentHint,H=P.maxFragLookUpTolerance,z=!!(P.lowLatencyMode&&x.partList&&W);z&&W&&!this.bitrateTest&&(k=k.concat(W),U=W.sn);var Y;if(v<S){var J=v>S-H?0:H;Y=Object(E.findFragmentByPTS)(B,k,v,J)}else Y=k[k.length-1];if(Y){var te=Y.sn-x.startSN;if(B&&Y.sn===B.sn&&!z){var X=B&&Y.level===B.level;if(X){var q=k[te+1];Y.sn<U&&this.fragmentTracker.getState(q)!==D.FragmentState.OK?(this.log("SN "+Y.sn+" just loaded, load next one: "+q.sn),Y=q):Y=null}}}return Y},s.synchronizeToLiveEdge=function(v){var S=this.config,x=this.media;if(!!x){var P=this.hls.liveSyncPosition,B=x.currentTime,k=v.fragments[0].start,U=v.edge,W=B>=k-S.maxFragLookUpTolerance&&B<=U;if(P!==null&&x.duration>P&&(B<P||!W)){var H=S.liveMaxLatencyDuration!==void 0?S.liveMaxLatencyDuration:S.liveMaxLatencyDurationCount*v.targetduration;(!W&&x.readyState<4||B<U-H)&&(this.loadedmetadata||(this.nextLoadPosition=P),x.readyState&&(this.warn("Playback: "+B.toFixed(3)+" is located too far from the end of live sliding playlist: "+U+", reset currentTime to : "+P.toFixed(3)),x.currentTime=P))}}},s.alignPlaylists=function(v,S){var x=this.levels,P=this.levelLastLoaded,B=this.fragPrevious,k=P!==null?x[P]:null,U=v.fragments.length;if(!U)return this.warn("No fragments in live playlist"),0;var W=v.fragments[0].start,H=!S,z=v.alignedSliding&&Object(I.isFiniteNumber)(W);if(H||!z&&!W){Object(A.alignStream)(B,k,v);var Y=v.fragments[0].start;return this.log("Live playlist sliding: "+Y.toFixed(2)+" start-sn: "+(S?S.startSN:"na")+"->"+v.startSN+" prev-sn: "+(B?B.sn:"na")+" fragments: "+U),Y}return W},s.waitForCdnTuneIn=function(v){var S=3;return v.live&&v.canBlockReload&&v.partTarget&&v.tuneInGoal>Math.max(v.partHoldBack,v.partTarget*S)},s.setStartPosition=function(v,S){var x=this.startPosition;if(x<S&&(x=-1),x===-1||this.lastCurrentTime===-1){var P=v.startTimeOffset;Object(I.isFiniteNumber)(P)?(x=S+P,P<0&&(x+=v.totalduration),x=Math.min(Math.max(S,x),S+v.totalduration),this.log("Start time offset "+P+" found in playlist, adjust startPosition to "+x),this.startPosition=x):v.live?x=this.hls.liveSyncPosition||S:this.startPosition=x=0,this.lastCurrentTime=x}this.nextLoadPosition=x},s.getLoadPosition=function(){var v=this.media,S=0;return this.loadedmetadata&&v?S=v.currentTime:this.nextLoadPosition&&(S=this.nextLoadPosition),S},s.handleFragLoadAborted=function(v,S){this.transmuxer&&v.sn!=="initSegment"&&v.stats.aborted&&(this.warn("Fragment "+v.sn+(S?" part"+S.index:"")+" of level "+v.level+" was aborted"),this.resetFragmentLoading(v))},s.resetFragmentLoading=function(v){(!this.fragCurrent||!this.fragContextChanged(v)&&this.state!==c.FRAG_LOADING_WAITING_RETRY)&&(this.state=c.IDLE)},s.onFragmentOrKeyLoadError=function(v,S){if(!S.fatal){var x=S.frag;if(!(!x||x.type!==v)){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 B=this.config;if(this.fragLoadError+1<=B.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var k=Math.min(Math.pow(2,this.fragLoadError)*B.fragLoadingRetryDelay,B.fragLoadingMaxRetryTimeout);this.warn("Fragment "+x.sn+" of "+v+" "+x.level+" failed to load, retrying in "+k+"ms"),this.retryDate=self.performance.now()+k,this.fragLoadError++,this.state=c.FRAG_LOADING_WAITING_RETRY}else S.levelRetry?(v===o.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(R.logger.error(S.details+" reaches max retry, redispatch as fatal ..."),S.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)}}},s.afterBufferFlushed=function(v,S,x){if(!!v){var P=w.BufferHelper.getBuffered(v);this.fragmentTracker.detectEvictedFragments(S,P,x),this.state===c.ENDED&&this.resetLoadingState()}},s.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE},s.resetStartWhenNotLoaded=function(v){if(!this.loadedmetadata){this.startFragRequested=!1;var S=this.levels?this.levels[v].details:null;S!=null&&S.live?(this.startPosition=-1,this.setStartPosition(S,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},s.updateLevelTiming=function(v,S,x,P){var B=this,k=x.details;console.assert(!!k,"level.details must be defined");var U=Object.keys(v.elementaryStreams).reduce(function(W,H){var z=v.elementaryStreams[H];if(z){var Y=z.endPTS-z.startPTS;if(Y<=0)return B.warn("Could not parse fragment "+v.sn+" "+H+" duration reliably ("+Y+")"),W||!1;var J=P?0:Object(m.updateFragPTSDTS)(k,v,z.startPTS,z.endPTS,z.startDTS,z.endDTS);return B.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:k,level:x,drift:J,type:H,frag:v,start:z.startPTS,end:z.endPTS}),!0}return W},!1);U||(this.warn("Found no media in fragment "+v.sn+" of level "+x.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=c.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:v,part:S})},s.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},g(u,[{key:"state",get:function(){return this._state},set:function(v){var S=this._state;S!==v&&(this._state=v,this.log(S+"->"+v))}}]),u}(L.default)},"./src/controller/buffer-controller.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return E});var I=n("./src/polyfills/number.ts"),L=n("./src/events.ts"),D=n("./src/utils/logger.ts"),w=n("./src/errors.ts"),R=n("./src/utils/buffer-helper.ts"),O=n("./src/utils/mediasource-helper.ts"),_=n("./src/loader/fragment.ts"),y=n("./src/controller/buffer-operation-queue.ts"),T=Object(O.getMediaSource)(),A=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function m(d){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 o=e.hls,h=e.media,g=e.mediaSource;D.logger.log("[buffer-controller]: Media source opened"),h&&(e.updateMediaElementDuration(),o.trigger(L.Events.MEDIA_ATTACHED,{media:h})),g&&g.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){D.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){D.logger.log("[buffer-controller]: Media source ended")},this.hls=d,this._initSourceBuffer(),this.registerListeners()}var p=m.prototype;return p.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},p.destroy=function(){this.unregisterListeners(),this.details=null},p.registerListeners=function(){var e=this.hls;e.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(L.Events.BUFFER_RESET,this.onBufferReset,this),e.on(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(L.Events.BUFFER_EOS,this.onBufferEos,this),e.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(L.Events.FRAG_PARSED,this.onFragParsed,this),e.on(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var e=this.hls;e.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(L.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(L.Events.BUFFER_RESET,this.onBufferReset,this),e.off(L.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(L.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(L.Events.BUFFER_EOS,this.onBufferEos,this),e.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(L.Events.FRAG_PARSED,this.onFragParsed,this),e.off(L.Events.FRAG_CHANGED,this.onFragChanged,this)},p._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},p.onManifestParsed=function(e,o){var h=2;(o.audio&&!o.video||!o.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,D.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(e,o){var h=this.media=o.media;if(h&&T){var g=this.mediaSource=new T;g.addEventListener("sourceopen",this._onMediaSourceOpen),g.addEventListener("sourceended",this._onMediaSourceEnded),g.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(g),this._objectUrl=h.src}},p.onMediaDetaching=function(){var e=this.media,o=this.mediaSource,h=this._objectUrl;if(o){if(D.logger.log("[buffer-controller]: media source detaching"),o.readyState==="open")try{o.endOfStream()}catch(g){D.logger.warn("[buffer-controller]: onMediaDetaching: "+g.message+" while calling endOfStream")}this.onBufferReset(),o.removeEventListener("sourceopen",this._onMediaSourceOpen),o.removeEventListener("sourceended",this._onMediaSourceEnded),o.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(h&&self.URL.revokeObjectURL(h),e.src===h?(e.removeAttribute("src"),e.load()):D.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(L.Events.MEDIA_DETACHED,void 0)},p.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(o){var h=e.sourceBuffer[o];try{h&&(e.removeBufferListeners(o),e.mediaSource&&e.mediaSource.removeSourceBuffer(h),e.sourceBuffer[o]=void 0)}catch(g){D.logger.warn("[buffer-controller]: Failed to reset the "+o+" buffer",g)}}),this._initSourceBuffer()},p.onBufferCodecs=function(e,o){var h=this,g=this.getSourceBufferTypes().length;Object.keys(o).forEach(function(i){if(g){var r=h.tracks[i];if(r&&typeof r.buffer.changeType=="function"){var l=o[i],c=l.id,t=l.codec,a=l.levelCodec,u=l.container,s=l.metadata,f=(r.levelCodec||r.codec).replace(A,"$1"),v=(a||t).replace(A,"$1");if(f!==v){var S=u+";codecs="+(a||t);h.appendChangeType(i,S),D.logger.log("[buffer-controller]: switching codec "+f+" to "+v),h.tracks[i]={buffer:r.buffer,codec:t,container:u,levelCodec:a,metadata:s,id:c}}}}else h.pendingTracks[i]=o[i]}),!g&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(e,o){var h=this,g=this.operationQueue,i={execute:function(){var l=h.sourceBuffer[e];l&&(D.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+o),l.changeType(o)),g.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(l){D.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",l)}};g.append(i,e)},p.onBufferAppending=function(e,o){var h=this,g=this.hls,i=this.operationQueue,r=this.tracks,l=o.data,c=o.type,t=o.frag,a=o.part,u=o.chunkMeta,s=u.buffering[c],f=self.performance.now();s.start=f;var v=t.stats.buffering,S=a?a.stats.buffering:null;v.start===0&&(v.start=f),S&&S.start===0&&(S.start=f);var x=r.audio,P=c==="audio"&&u.id===1&&(x==null?void 0:x.container)==="audio/mpeg",B={execute:function(){if(s.executeStart=self.performance.now(),P){var U=h.sourceBuffer[c];if(U){var W=t.start-U.timestampOffset;Math.abs(W)>=.1&&(D.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+t.start+" (delta: "+W+") sn: "+t.sn+")"),U.timestampOffset=t.start)}}h.appendExecutor(l,c)},onStart:function(){},onComplete:function(){var U=self.performance.now();s.executeEnd=s.end=U,v.first===0&&(v.first=U),S&&S.first===0&&(S.first=U);var W=h.sourceBuffer,H={};for(var z in W)H[z]=R.BufferHelper.getBuffered(W[z]);h.appendError=0,h.hls.trigger(L.Events.BUFFER_APPENDED,{type:c,frag:t,part:a,chunkMeta:u,parent:t.type,timeRanges:H})},onError:function(U){D.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",U);var W={type:w.ErrorTypes.MEDIA_ERROR,parent:t.type,details:w.ErrorDetails.BUFFER_APPEND_ERROR,err:U,fatal:!1};U.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=w.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,W.details=w.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>g.config.appendErrorMaxRetry&&(D.logger.error("[buffer-controller]: Failed "+g.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0,g.stopLoad())),g.trigger(L.Events.ERROR,W)}};i.append(B,c)},p.onBufferFlushing=function(e,o){var h=this,g=this.operationQueue,i=function(l){return{execute:h.removeExecutor.bind(h,l,o.startOffset,o.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(L.Events.BUFFER_FLUSHED,{type:l})},onError:function(t){D.logger.warn("[buffer-controller]: Failed to remove from "+l+" SourceBuffer",t)}}};o.type?g.append(i(o.type),o.type):this.getSourceBufferTypes().forEach(function(r){g.append(i(r),r)})},p.onFragParsed=function(e,o){var h=this,g=o.frag,i=o.part,r=[],l=i?i.elementaryStreams:g.elementaryStreams;l[_.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(l[_.ElementaryStreamTypes.AUDIO]&&r.push("audio"),l[_.ElementaryStreamTypes.VIDEO]&&r.push("video"));var c=function(){var a=self.performance.now();g.stats.buffering.end=a,i&&(i.stats.buffering.end=a);var u=i?i.stats:g.stats;h.hls.trigger(L.Events.FRAG_BUFFERED,{frag:g,part:i,stats:u,id:g.type})};r.length===0&&D.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+g.type+" level: "+g.level+" sn: "+g.sn),this.blockBuffers(c,r)},p.onFragChanged=function(e,o){this.flushBackBuffer()},p.onBufferEos=function(e,o){var h=this,g=this.getSourceBufferTypes().reduce(function(i,r){var l=h.sourceBuffer[r];return(!o.type||o.type===r)&&l&&!l.ended&&(l.ended=!0,D.logger.log("[buffer-controller]: "+r+" sourceBuffer now EOS")),i&&!!(!l||l.ended)},!0);g&&this.blockBuffers(function(){var i=h.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},p.onLevelUpdated=function(e,o){var h=o.details;!h.fragments.length||(this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var e=this.hls,o=this.details,h=this.media,g=this.sourceBuffer;if(!(!h||o===null)){var i=this.getSourceBufferTypes();if(!!i.length){var r=o.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(I.isFiniteNumber)(r)||r<0)){var l=h.currentTime,c=o.levelTargetDuration,t=Math.max(r,c),a=Math.floor(l/c)*c-t;i.forEach(function(u){var s=g[u];if(s){var f=R.BufferHelper.getBuffered(s);f.length>0&&a>f.start(0)&&(e.trigger(L.Events.BACK_BUFFER_REACHED,{bufferEnd:a}),o.live&&e.trigger(L.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:a}),e.trigger(L.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:a,type:u}))}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,o=this.hls,h=this.media,g=this.mediaSource,i=e.fragments[0].start+e.totalduration,r=h.duration,l=Object(I.isFiniteNumber)(g.duration)?g.duration:0;e.live&&o.config.liveDurationInfinity?(D.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),g.duration=1/0,this.updateSeekableRange(e)):(i>l&&i>r||!Object(I.isFiniteNumber)(r))&&(D.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),g.duration=i)}},p.updateSeekableRange=function(e){var o=this.mediaSource,h=e.fragments,g=h.length;if(g&&e.live&&o!==null&&o!==void 0&&o.setLiveSeekableRange){var i=Math.max(0,h[0].start),r=Math.max(i,i+e.totalduration);o.setLiveSeekableRange(i,r)}},p.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,o=this.operationQueue,h=this.pendingTracks,g=Object.keys(h).length;if(g&&!e||g===2){this.createSourceBuffers(h),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(L.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}i.forEach(function(r){o.executeNext(r)})}},p.createSourceBuffers=function(e){var o=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var g=0;for(var i in e)if(!o[i]){var r=e[i];if(!r)throw Error("source buffer exists for track "+i+", however track does not");var l=r.levelCodec||r.codec,c=r.container+";codecs="+l;D.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var t=o[i]=h.addSourceBuffer(c),a=i;this.addBufferListener(a,"updatestart",this._onSBUpdateStart),this.addBufferListener(a,"updateend",this._onSBUpdateEnd),this.addBufferListener(a,"error",this._onSBUpdateError),this.tracks[i]={buffer:t,codec:l,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id},g++}catch(u){D.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+u.message),this.hls.trigger(L.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:u,mimeType:c})}}g&&this.hls.trigger(L.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(e){var o=this.operationQueue,h=o.current(e);h.onStart()},p._onSBUpdateEnd=function(e){var o=this.operationQueue,h=o.current(e);h.onComplete(),o.shiftAndExecuteNext(e)},p._onSBUpdateError=function(e,o){D.logger.error("[buffer-controller]: "+e+" SourceBuffer error",o),this.hls.trigger(L.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(e);h&&h.onError(o)},p.removeExecutor=function(e,o,h){var g=this.media,i=this.mediaSource,r=this.operationQueue,l=this.sourceBuffer,c=l[e];if(!g||!i||!c){D.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),r.shiftAndExecuteNext(e);return}var t=Object(I.isFiniteNumber)(g.duration)?g.duration:1/0,a=Object(I.isFiniteNumber)(i.duration)?i.duration:1/0,u=Math.max(0,o),s=Math.min(h,t,a);s>u?(D.logger.log("[buffer-controller]: Removing ["+u+","+s+"] from the "+e+" SourceBuffer"),console.assert(!c.updating,e+" sourceBuffer must not be updating"),c.remove(u,s)):r.shiftAndExecuteNext(e)},p.appendExecutor=function(e,o){var h=this.operationQueue,g=this.sourceBuffer,i=g[o];if(!i){D.logger.warn("[buffer-controller]: Attempting to append to the "+o+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(o);return}i.ended=!1,console.assert(!i.updating,o+" sourceBuffer must not be updating"),i.appendBuffer(e)},p.blockBuffers=function(e,o){var h=this;if(o===void 0&&(o=this.getSourceBufferTypes()),!o.length){D.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var g=this.operationQueue,i=o.map(function(r){return g.appendBlocker(r)});Promise.all(i).then(function(){e(),o.forEach(function(r){var l=h.sourceBuffer[r];(!l||!l.updating)&&g.shiftAndExecuteNext(r)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(e,o,h){var g=this.sourceBuffer[e];if(!!g){var i=h.bind(this,e);this.listeners[e].push({event:o,listener:i}),g.addEventListener(o,i)}},p.removeBufferListeners=function(e){var o=this.sourceBuffer[e];!o||this.listeners[e].forEach(function(h){o.removeEventListener(h.event,h.listener)})},m}()},"./src/controller/buffer-operation-queue.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return L});var I=n("./src/utils/logger.ts"),L=function(){function D(R){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=R}var w=D.prototype;return w.append=function(O,_){var y=this.queues[_];y.push(O),y.length===1&&this.buffers[_]&&this.executeNext(_)},w.insertAbort=function(O,_){var y=this.queues[_];y.unshift(O),this.executeNext(_)},w.appendBlocker=function(O){var _,y=new Promise(function(A){_=A}),T={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(T,O),y},w.executeNext=function(O){var _=this.buffers,y=this.queues,T=_[O],A=y[O];if(A.length){var E=A[0];try{E.execute()}catch(m){I.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),E.onError(m),(!T||!T.updating)&&(A.shift(),this.executeNext(O))}}},w.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},w.current=function(O){return this.queues[O][0]},D}()},"./src/controller/cap-level-controller.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/events.ts");function L(R,O){for(var _=0;_<O.length;_++){var y=O[_];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(R,y.key,y)}}function D(R,O,_){return O&&L(R.prototype,O),_&&L(R,_),Object.defineProperty(R,"prototype",{writable:!1}),R}var w=function(){function R(_){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=_,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var O=R.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(I.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var y=this.hls;y.off(I.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(y,T){R.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 A=this.hls;this.restrictedLevels=[],this.firstLevel=T.firstLevel,A.config.capLevelToPlayerSize&&T.video&&this.startCapping()},O.onBufferCodecs=function(y,T){var A=this.hls;A.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,A=this.hls.levels;if(!A.length)return-1;var E=A.filter(function(m,p){return R.isLevelAllowed(p,T.restrictedLevels)&&p<=y});return this.clientRect=null,R.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 A=y.getBoundingClientRect();T.width=A.width,T.height=A.height,!T.width&&!T.height&&(T.width=A.right-A.left||y.width||0,T.height=A.bottom-A.top||y.height||0)}return this.clientRect=T,T},R.isLevelAllowed=function(y,T){return T===void 0&&(T=[]),T.indexOf(y)===-1},R.getMaxLevelByMediaSize=function(y,T,A){if(!y||!y.length)return-1;for(var E=function(o,h){return h?o.width!==h.width||o.height!==h.height:!0},m=y.length-1,p=0;p<y.length;p+=1){var d=y[p];if((d.width>=T||d.height>=A)&&E(d,y[p+1])){m=p;break}}return m},D(R,[{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}}]),R}();b.default=w},"./src/controller/cmcd-controller.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return E});var I=n("./src/events.ts"),L=n("./src/types/cmcd.ts"),D=n("./src/utils/buffer-helper.ts"),w=n("./src/utils/logger.ts");function R(m,p){for(var d=0;d<p.length;d++){var e=p[d];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(m,e.key,e)}}function O(m,p,d){return p&&R(m.prototype,p),d&&R(m,d),Object.defineProperty(m,"prototype",{writable:!1}),m}function _(m,p){var d=typeof Symbol!="undefined"&&m[Symbol.iterator]||m["@@iterator"];if(d)return(d=d.call(m)).next.bind(d);if(Array.isArray(m)||(d=y(m))||p&&m&&typeof m.length=="number"){d&&(m=d);var e=0;return function(){return e>=m.length?{done:!0}:{done:!1,value:m[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
14
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y(m,p){if(!!m){if(typeof m=="string")return T(m,p);var d=Object.prototype.toString.call(m).slice(8,-1);if(d==="Object"&&m.constructor&&(d=m.constructor.name),d==="Map"||d==="Set")return Array.from(m);if(d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d))return T(m,p)}}function T(m,p){(p==null||p>m.length)&&(p=m.length);for(var d=0,e=new Array(p);d<p;d++)e[d]=m[d];return e}function A(){return A=Object.assign?Object.assign.bind():function(m){for(var p=1;p<arguments.length;p++){var d=arguments[p];for(var e in d)Object.prototype.hasOwnProperty.call(d,e)&&(m[e]=d[e])}return m},A.apply(this,arguments)}var E=function(){function m(d){var e=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(g){try{e.apply(g,{ot:L.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){w.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(g){try{var i=g.frag,r=e.hls.levels[i.level],l=e.getObjectType(i),c={d:i.duration*1e3,ot:l};(l===L.CMCDObjectType.VIDEO||l===L.CMCDObjectType.AUDIO||l==L.CMCDObjectType.MUXED)&&(c.br=r.bitrate/1e3,c.tb=e.getTopBandwidth(l)/1e3,c.bl=e.getBufferLength(l)),e.apply(g,c)}catch(t){w.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=d;var o=this.config=d.config,h=o.cmcd;h!=null&&(o.pLoader=this.createPlaylistLoader(),o.fLoader=this.createFragmentLoader(),this.sid=h.sessionId||m.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var p=m.prototype;return p.registerListeners=function(){var e=this.hls;e.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(I.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(I.Events.BUFFER_CREATED,this.onBufferCreated,this)},p.unregisterListeners=function(){var e=this.hls;e.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(I.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(I.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,o){this.media=o.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,o){var h,g;this.audioBuffer=(h=o.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(g=o.tracks.video)===null||g===void 0?void 0:g.buffer},p.createData=function(){var e;return{v:L.CMCDVersion,sf:L.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},p.apply=function(e,o){o===void 0&&(o={}),A(o,this.createData());var h=o.ot===L.CMCDObjectType.INIT||o.ot===L.CMCDObjectType.VIDEO||o.ot===L.CMCDObjectType.MUXED;if(this.starved&&h&&(o.bs=!0,o.su=!0,this.starved=!1),o.su==null&&(o.su=this.buffering),this.useHeaders){var g=m.toHeaders(o);if(!Object.keys(g).length)return;e.headers||(e.headers={}),A(e.headers,g)}else{var i=m.toQuery(o);if(!i)return;e.url=m.appendQueryToUri(e.url,i)}},p.getObjectType=function(e){var o=e.type;if(o==="subtitle")return L.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return L.CMCDObjectType.INIT;if(o==="audio")return L.CMCDObjectType.AUDIO;if(o==="main")return this.hls.audioTracks.length?L.CMCDObjectType.VIDEO:L.CMCDObjectType.MUXED},p.getTopBandwidth=function(e){var o=0,h,g=this.hls;if(e===L.CMCDObjectType.AUDIO)h=g.audioTracks;else{var i=g.maxAutoLevel,r=i>-1?i+1:g.levels.length;h=g.levels.slice(0,r)}for(var l=_(h),c;!(c=l()).done;){var t=c.value;t.bitrate>o&&(o=t.bitrate)}return o>0?o:NaN},p.getBufferLength=function(e){var o=this.hls.media,h=e===L.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!o)return NaN;var g=D.BufferHelper.bufferInfo(h,o.currentTime,this.config.maxBufferHole);return g.len*1e3},p.createPlaylistLoader=function(){var e=this.config.pLoader,o=this.applyPlaylistData,h=e||this.config.loader;return function(){function g(r){this.loader=void 0,this.loader=new h(r)}var i=g.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(l,c,t){o(l),this.loader.load(l,c,t)},O(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},p.createFragmentLoader=function(){var e=this.config.fLoader,o=this.applyFragmentData,h=e||this.config.loader;return function(){function g(r){this.loader=void 0,this.loader=new h(r)}var i=g.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(l,c,t){o(l),this.loader.load(l,c,t)},O(g,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),g}()},m.uuid=function(){var e=URL.createObjectURL(new Blob),o=e.toString();return URL.revokeObjectURL(e),o.slice(o.lastIndexOf("/")+1)},m.serialize=function(e){for(var o=[],h=function(P){return!Number.isNaN(P)&&P!=null&&P!==""&&P!==!1},g=function(P){return Math.round(P)},i=function(P){return g(P/100)*100},r=function(P){return encodeURIComponent(P)},l={br:g,d:g,bl:i,dl:i,mtp:i,nor:r,rtp:i,tb:g},c=Object.keys(e||{}).sort(),t=_(c),a;!(a=t()).done;){var u=a.value,s=e[u];if(!!h(s)&&!(u==="v"&&s===1)&&!(u=="pr"&&s===1)){var f=l[u];f&&(s=f(s));var v=typeof s,S=void 0;u==="ot"||u==="sf"||u==="st"?S=u+"="+s:v==="boolean"?S=u:v==="number"?S=u+"="+s:S=u+"="+JSON.stringify(s),o.push(S)}}return o.join(",")},m.toHeaders=function(e){for(var o=Object.keys(e),h={},g=["Object","Request","Session","Status"],i=[{},{},{},{}],r={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},l=0,c=o;l<c.length;l++){var t=c[l],a=r[t]!=null?r[t]:1;i[a][t]=e[t]}for(var u=0;u<i.length;u++){var s=m.serialize(i[u]);s&&(h["CMCD-"+g[u]]=s)}return h},m.toQuery=function(e){return"CMCD="+encodeURIComponent(m.serialize(e))},m.appendQueryToUri=function(e,o){if(!o)return e;var h=e.includes("?")?"&":"?";return""+e+h+o},m}()},"./src/controller/eme-controller.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/events.ts"),L=n("./src/errors.ts"),D=n("./src/utils/logger.ts"),w=n("./src/utils/mediakeys-helper.ts");function R(E,m){for(var p=0;p<m.length;p++){var d=m[p];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(E,d.key,d)}}function O(E,m,p){return m&&R(E.prototype,m),p&&R(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}var _=3,y=function(m,p,d){var e={audioCapabilities:[],videoCapabilities:[]};return m.forEach(function(o){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+o+'"',robustness:d.audioRobustness||""})}),p.forEach(function(o){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+o+'"',robustness:d.videoRobustness||""})}),[e]},T=function(m,p,d,e){switch(m){case w.KeySystems.WIDEVINE:return y(p,d,e);default:throw new Error("Unknown key-system: "+m)}},A=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(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(I.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m._unregisterListeners=function(){this.hls.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(I.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this)},m.getLicenseServerUrl=function(d){switch(d){case w.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+d+'"')},m._attemptKeySystemAccess=function(d,e,o){var h=this,g=T(d,e,o,this._drmSystemOptions);D.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(d,g);this.mediaKeysPromise=i.then(function(r){return h._onMediaKeySystemAccessObtained(d,r)}),i.catch(function(r){D.logger.error('Failed to obtain key-system "'+d+'" access:',r)})},m._onMediaKeySystemAccessObtained=function(d,e){var o=this;D.logger.log('Access for key-system "'+d+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:d};this._mediaKeysList.push(h);var g=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return h.mediaKeys=i,D.logger.log('Media-keys created for key-system "'+d+'"'),o._onMediaKeysCreated(),i});return g.catch(function(i){D.logger.error("Failed to create media-keys:",i)}),g},m._onMediaKeysCreated=function(){var d=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),d._onNewMediaKeySession(e.mediaKeysSession))})},m._onNewMediaKeySession=function(d){var e=this;D.logger.log("New key-system session "+d.sessionId),d.addEventListener("message",function(o){e._onKeySessionMessage(d,o.message)},!1)},m._onKeySessionMessage=function(d,e){D.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(o){D.logger.log("Received license data (length: "+(o&&o.byteLength)+"), updating key-session"),d.update(o).catch(function(h){D.logger.warn("Updating key-session failed: "+h)})})},m.onMediaEncrypted=function(d){var e=this;if(D.logger.log('Media is encrypted using "'+d.initDataType+'" init data type'),!this.mediaKeysPromise){D.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var o=function(g){!e._media||(e._attemptSetMediaKeys(g),e._generateRequestWithPreferredKeySession(d.initDataType,d.initData))};this.mediaKeysPromise.then(o).catch(o)},m._attemptSetMediaKeys=function(d){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){D.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}D.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},m._generateRequestWithPreferredKeySession=function(d,e){var o=this,h=this._mediaKeysList[0];if(!h){D.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){D.logger.warn("Key-Session already initialized but requested again");return}var g=h.mediaKeysSession;if(!g){D.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){D.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}D.logger.log('Generating key-session request for "'+d+'" init data type'),h.mediaKeysSessionInitialized=!0,g.generateRequest(d,e).then(function(){D.logger.debug("Key-session generation succeeded")}).catch(function(i){D.logger.error("Error generating key-session request:",i),o.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},m._createLicenseXhr=function(d,e,o){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,d,e,o);var g=this._licenseXhrSetup;if(g)try{g.call(this.hls,h,d),g=void 0}catch(i){D.logger.error(i)}try{h.readyState||h.open("POST",d,!0),g&&g.call(this.hls,h,d)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return h},m._onLicenseRequestReadyStageChange=function(d,e,o,h){switch(d.readyState){case 4:if(d.status===200){this._requestLicenseFailureCount=0,D.logger.log("License request succeeded");var g=d.response,i=this._licenseResponseCallback;if(i)try{g=i.call(this.hls,d,e)}catch(l){D.logger.error(l)}h(g)}else{if(D.logger.error("License Request XHR failed ("+e+"). Status: "+d.status+" ("+d.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var r=_-this._requestLicenseFailureCount+1;D.logger.warn("Retrying license request, "+r+" attempts left"),this._requestLicense(o,h)}break}},m._generateLicenseRequestChallenge=function(d,e){switch(d.mediaKeySystemDomain){case w.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+d.mediaKeySystemDomain)},m._requestLicense=function(d,e){D.logger.log("Requesting content license for key-system");var o=this._mediaKeysList[0];if(!o){D.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(o.mediaKeySystemDomain),g=this._createLicenseXhr(h,d,e);D.logger.log("Sending license request to URL: "+h);var i=this._generateLicenseRequestChallenge(o,d);g.send(i)}catch(r){D.logger.error("Failure requesting DRM license: "+r),this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.KEY_SYSTEM_ERROR,details:L.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},m.onMediaAttached=function(d,e){if(!!this._emeEnabled){var o=e.media;this._media=o,o.addEventListener("encrypted",this._onMediaEncrypted)}},m.onMediaDetached=function(){var d=this._media,e=this._mediaKeysList;!d||(d.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(o){if(o.mediaKeysSession)return o.mediaKeysSession.close().catch(function(){})})).then(function(){return d.setMediaKeys(null)}).catch(function(){}))},m.onManifestParsed=function(d,e){if(!!this._emeEnabled){var o=e.levels.map(function(g){return g.audioCodec}).filter(function(g){return!!g}),h=e.levels.map(function(g){return g.videoCodec}).filter(function(g){return!!g});this._attemptKeySystemAccess(w.KeySystems.WIDEVINE,o,h)}},O(E,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),E}();b.default=A},"./src/controller/fps-controller.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/events.ts"),L=n("./src/utils/logger.ts"),D=function(){function w(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 R=w.prototype;return R.setStreamController=function(_){this.streamController=_},R.registerListeners=function(){this.hls.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},R.unregisterListeners=function(){this.hls.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching)},R.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},R.onMediaAttaching=function(_,y){var T=this.hls.config;if(T.capLevelOnFPSDrop){var A=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=A,A&&typeof A.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),T.fpsDroppedMonitoringPeriod)}},R.checkFPS=function(_,y,T){var A=performance.now();if(y){if(this.lastTime){var E=A-this.lastTime,m=T-this.lastDroppedFrames,p=y-this.lastDecodedFrames,d=1e3*m/E,e=this.hls;if(e.trigger(I.Events.FPS_DROP,{currentDropped:m,currentDecoded:p,totalDroppedFrames:T}),d>0&&m>e.config.fpsDroppedMonitoringThreshold*p){var o=e.currentLevel;L.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+o),o>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=o)&&(o=o-1,e.trigger(I.Events.FPS_DROP_LEVEL_CAPPING,{level:o,droppedLevel:e.currentLevel}),e.autoLevelCapping=o,this.streamController.nextLevelSwitch())}}this.lastTime=A,this.lastDroppedFrames=T,this.lastDecodedFrames=y}},R.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var y=_.getVideoPlaybackQuality();this.checkFPS(_,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},w}();b.default=D},"./src/controller/fragment-finders.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"findFragmentByPDT",function(){return D}),n.d(b,"findFragmentByPTS",function(){return w}),n.d(b,"fragmentWithinToleranceTest",function(){return R}),n.d(b,"pdtWithinToleranceTest",function(){return O}),n.d(b,"findFragWithCC",function(){return _});var I=n("./src/polyfills/number.ts"),L=n("./src/utils/binary-search.ts");function D(y,T,A){if(T===null||!Array.isArray(y)||!y.length||!Object(I.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;A=A||0;for(var p=0;p<y.length;++p){var d=y[p];if(O(T,A,d))return d}return null}function w(y,T,A,E){A===void 0&&(A=0),E===void 0&&(E=0);var m=null;if(y?m=T[y.sn-T[0].sn+1]||null:A===0&&T[0].start===0&&(m=T[0]),m&&R(A,E,m)===0)return m;var p=L.default.search(T,R.bind(null,A,E));return p||m}function R(y,T,A){y===void 0&&(y=0),T===void 0&&(T=0);var E=Math.min(T,A.duration+(A.deltaPTS?A.deltaPTS:0));return A.start+A.duration-E<=y?1:A.start-E>y&&A.start?-1:0}function O(y,T,A){var E=Math.min(T,A.duration+(A.deltaPTS?A.deltaPTS:0))*1e3,m=A.endProgramDateTime||0;return m-E>y}function _(y,T){return L.default.search(y,function(A){return A.cc<T?1:A.cc>T?-1:0})}},"./src/controller/fragment-tracker.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"FragmentState",function(){return D}),n.d(b,"FragmentTracker",function(){return w});var I=n("./src/events.ts"),L=n("./src/types/loader.ts"),D;(function(_){_.NOT_LOADED="NOT_LOADED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(D||(D={}));var w=function(){function _(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=_.prototype;return y._registerListeners=function(){var A=this.hls;A.on(I.Events.BUFFER_APPENDED,this.onBufferAppended,this),A.on(I.Events.FRAG_BUFFERED,this.onFragBuffered,this),A.on(I.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var A=this.hls;A.off(I.Events.BUFFER_APPENDED,this.onBufferAppended,this),A.off(I.Events.FRAG_BUFFERED,this.onFragBuffered,this),A.off(I.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(A,E){if(E===L.PlaylistLevelType.MAIN){var m=this.activeFragment,p=this.activeParts;if(!m)return null;if(p)for(var d=p.length;d--;){var e=p[d],o=e?e.end:m.appendedPTS;if(e.start<=A&&o!==void 0&&A<=o)return d>9&&(this.activeParts=p.slice(d-9)),e}else if(m.start<=A&&m.appendedPTS!==void 0&&A<=m.appendedPTS)return m}return this.getBufferedFrag(A,E)},y.getBufferedFrag=function(A,E){for(var m=this.fragments,p=Object.keys(m),d=p.length;d--;){var e=m[p[d]];if((e==null?void 0:e.body.type)===E&&e.buffered){var o=e.body;if(o.start<=A&&A<=o.end)return o}}return null},y.detectEvictedFragments=function(A,E,m){var p=this;Object.keys(this.fragments).forEach(function(d){var e=p.fragments[d];if(!!e){if(!e.buffered){e.body.type===m&&p.removeFragment(e.body);return}var o=e.range[A];!o||o.time.some(function(h){var g=!p.isTimeBuffered(h.startPTS,h.endPTS,E);return g&&p.removeFragment(e.body),g})}})},y.detectPartialFragments=function(A){var E=this,m=this.timeRanges,p=A.frag,d=A.part;if(!(!m||p.sn==="initSegment")){var e=O(p),o=this.fragments[e];!o||(Object.keys(m).forEach(function(h){var g=p.elementaryStreams[h];if(!!g){var i=m[h],r=d!==null||g.partial===!0;o.range[h]=E.getBufferedTimes(p,d,r,i)}}),o.loaded=null,Object.keys(o.range).length?o.buffered=!0:this.removeFragment(o.body))}},y.fragBuffered=function(A){var E=O(A),m=this.fragments[E];m&&(m.loaded=null,m.buffered=!0)},y.getBufferedTimes=function(A,E,m,p){for(var d={time:[],partial:m},e=E?E.start:A.start,o=E?E.end:A.end,h=A.minEndPTS||o,g=A.maxStartPTS||e,i=0;i<p.length;i++){var r=p.start(i)-this.bufferPadding,l=p.end(i)+this.bufferPadding;if(g>=r&&h<=l){d.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(o,p.end(i))});break}else if(e<l&&o>r)d.partial=!0,d.time.push({startPTS:Math.max(e,p.start(i)),endPTS:Math.min(o,p.end(i))});else if(o<=r)break}return d},y.getPartialFragment=function(A){var E=null,m,p,d,e=0,o=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(g){var i=h[g];!i||R(i)&&(p=i.body.start-o,d=i.body.end+o,A>=p&&A<=d&&(m=Math.min(A-p,d-A),e<=m&&(E=i.body,e=m)))}),E},y.getState=function(A){var E=O(A),m=this.fragments[E];return m?m.buffered?R(m)?D.PARTIAL:D.OK:D.APPENDING:D.NOT_LOADED},y.isTimeBuffered=function(A,E,m){for(var p,d,e=0;e<m.length;e++){if(p=m.start(e)-this.bufferPadding,d=m.end(e)+this.bufferPadding,A>=p&&E<=d)return!0;if(E<=p)return!1}return!1},y.onFragLoaded=function(A,E){var m=E.frag,p=E.part;if(!(m.sn==="initSegment"||m.bitrateTest||p)){var d=O(m);this.fragments[d]={body:m,loaded:E,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(A,E){var m=this,p=E.frag,d=E.part,e=E.timeRanges;if(p.type===L.PlaylistLevelType.MAIN)if(this.activeFragment=p,d){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(d)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(h){var g=e[h];if(m.detectEvictedFragments(h,g),!d)for(var i=0;i<g.length;i++)p.appendedPTS=Math.max(g.end(i),p.appendedPTS||0)})},y.onFragBuffered=function(A,E){this.detectPartialFragments(E)},y.hasFragment=function(A){var E=O(A);return!!this.fragments[E]},y.removeFragmentsInRange=function(A,E,m){var p=this;Object.keys(this.fragments).forEach(function(d){var e=p.fragments[d];if(!!e&&e.buffered){var o=e.body;o.type===m&&o.start<E&&o.end>A&&p.removeFragment(o)}})},y.removeFragment=function(A){var E=O(A);A.stats.loaded=0,A.clearElementaryStreamInfo(),delete this.fragments[E]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function R(_){var y,T;return _.buffered&&(((y=_.range.video)===null||y===void 0?void 0:y.partial)||((T=_.range.audio)===null||T===void 0?void 0:T.partial))}function O(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"STALL_MINIMUM_DURATION_MS",function(){return R}),n.d(b,"MAX_START_GAP_JUMP",function(){return O}),n.d(b,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),n.d(b,"SKIP_BUFFER_RANGE_START",function(){return y}),n.d(b,"default",function(){return T});var I=n("./src/utils/buffer-helper.ts"),L=n("./src/errors.ts"),D=n("./src/events.ts"),w=n("./src/utils/logger.ts"),R=250,O=2,_=.1,y=.05,T=function(){function A(m,p,d,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=d,this.hls=e}var E=A.prototype;return E.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},E.poll=function(p,d){var e=this.config,o=this.media,h=this.stalled;if(o!==null){var g=o.currentTime,i=o.seeking,r=this.seeking&&!i,l=!this.seeking&&i;if(this.seeking=i,g!==p){if(this.moved=!0,h!==null){if(this.stallReported){var c=self.performance.now()-h;w.logger.warn("playback not stuck anymore @"+g+", after "+Math.round(c)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((l||r)&&(this.stalled=null),!(o.paused&&!i||o.ended||o.playbackRate===0||!I.BufferHelper.getBuffered(o).length)){var t=I.BufferHelper.bufferInfo(o,g,0),a=t.len>0,u=t.nextStart||0;if(!(!a&&!u)){if(i){var s=t.len>O,f=!u||d&&d.start<=g||u-g>O&&!this.fragmentTracker.getPartialFragment(g);if(s||f)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var v,S=Math.max(u,t.start||0)-g,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=x==null||(v=x.details)===null||v===void 0?void 0:v.live,B=P?x.details.targetduration*2:O;if(S>0&&S<=B){this._trySkipBufferHole(null);return}}var k=self.performance.now();if(h===null){this.stalled=k;return}var U=k-h;if(!(!i&&U>=R&&(this._reportStall(t),!this.media))){var W=I.BufferHelper.bufferInfo(o,g,e.maxBufferHole);this._tryFixBufferStall(W,U)}}}}},E._tryFixBufferStall=function(p,d){var e=this.config,o=this.fragmentTracker,h=this.media;if(h!==null){var g=h.currentTime,i=o.getPartialFragment(g);if(i){var r=this._trySkipBufferHole(i);if(r||!this.media)return}p.len>e.maxBufferHole&&d>e.highBufferWatchdogPeriod*1e3&&(w.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},E._reportStall=function(p){var d=this.hls,e=this.media,o=this.stallReported;!o&&e&&(this.stallReported=!0,w.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(p)+")"),d.trigger(D.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p.len}))},E._trySkipBufferHole=function(p){var d=this.config,e=this.hls,o=this.media;if(o===null)return 0;for(var h=o.currentTime,g=0,i=I.BufferHelper.getBuffered(o),r=0;r<i.length;r++){var l=i.start(r);if(h+d.maxBufferHole>=g&&h<l){var c=Math.max(l+y,o.currentTime+_);return w.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+c),this.moved=!0,this.stalled=null,o.currentTime=c,p&&e.trigger(D.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+c,frag:p}),c}g=i.end(r)}return 0},E._tryNudgeBuffer=function(){var p=this.config,d=this.hls,e=this.media,o=this.nudgeRetry;if(e!==null){var h=e.currentTime;if(this.nudgeRetry++,o<p.nudgeMaxRetry){var g=h+(o+1)*p.nudgeOffset;w.logger.warn("Nudging 'currentTime' from "+h+" to "+g),e.currentTime=g,d.trigger(D.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else w.logger.error("Playhead still not moving while enough data buffered @"+h+" after "+p.nudgeMaxRetry+" nudges"),d.trigger(D.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},A}()},"./src/controller/id3-track-controller.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/polyfills/number.ts"),L=n("./src/events.ts"),D=n("./src/utils/texttrack-utils.ts"),w=n("./src/demux/id3.ts"),R=n("./src/loader/date-range.ts"),O=n("./src/types/demuxer.ts"),_=.25;function y(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function T(m,p){return m.getTime()/1e3-p}function A(m){return Uint8Array.from(m.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var E=function(){function m(d){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=d,this._registerListeners()}var p=m.prototype;return p.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},p._registerListeners=function(){var e=this.hls;e.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p._unregisterListeners=function(){var e=this.hls;e.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(L.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},p.onMediaAttached=function(e,o){this.media=o.media},p.onMediaDetaching=function(){!this.id3Track||(Object(D.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},p.onManifestLoading=function(){this.dateRangeCuesAppended={}},p.createTrack=function(e){var o=this.getID3Track(e.textTracks);return o.mode="hidden",o},p.getID3Track=function(e){if(!!this.media){for(var o=0;o<e.length;o++){var h=e[o];if(h.kind==="metadata"&&h.label==="id3")return Object(D.sendAddTrackEvent)(h,this.media),h}return this.media.addTextTrack("metadata","id3")}},p.onFragParsingMetadata=function(e,o){if(!!this.media){var h=this.hls.config,g=h.enableEmsgMetadataCues,i=h.enableID3MetadataCues;if(!(!g&&!i)){var r=o.frag,l=o.samples,c=o.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var t=c.edge||r.end,a=y(),u=!1,s={},f=0;f<l.length;f++){var v=l[f].type;if(!(v===O.MetadataSchema.emsg&&!g||!i)){var S=w.getID3Frames(l[f].data);if(S){var x=l[f].pts,P=t,B=P-x;B<=0&&(P=x+_);for(var k=0;k<S.length;k++){var U=S[k];if(!w.isTimeStampFrame(U)){var W=new a(x,P,"");W.value=U,v&&(W.type=v),this.id3Track.addCue(W),s[U.key]=null,u=!0}}}}}u&&this.updateId3CueEnds(s)}}},p.updateId3CueEnds=function(e){var o,h=(o=this.id3Track)===null||o===void 0?void 0:o.cues;if(h)for(var g=h.length;g--;){var i,r=h[g],l=(i=r.value)===null||i===void 0?void 0:i.key;if(l&&l in e){var c=e[l];c&&r.endTime!==c&&(r.endTime=c),e[l]=r.startTime}}},p.onBufferFlushing=function(e,o){var h=o.startOffset,g=o.endOffset,i=o.type,r=this.id3Track,l=this.hls;if(!!l){var c=l.config,t=c.enableEmsgMetadataCues,a=c.enableID3MetadataCues;if(r&&(t||a)){var u;i==="audio"?u=function(f){return f.type===O.MetadataSchema.audioId3&&a}:i==="video"?u=function(f){return f.type===O.MetadataSchema.emsg&&t}:u=function(f){return f.type===O.MetadataSchema.audioId3&&a||f.type===O.MetadataSchema.emsg&&t},Object(D.removeCuesInRange)(r,h,g,u)}}},p.onLevelUpdated=function(e,o){var h=this,g=o.details;if(!(!this.media||!g.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,r=this.id3Track,l=g.dateRanges,c=Object.keys(l);if(r)for(var t=Object.keys(i).filter(function(B){return!c.includes(B)}),a=function(k){var U=t[k];Object.keys(i[U].cues).forEach(function(W){r.removeCue(i[U].cues[W])}),delete i[U]},u=t.length;u--;)a(u);var s=g.fragments[g.fragments.length-1];if(!(c.length===0||!Object(I.isFiniteNumber)(s==null?void 0:s.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f=s.programDateTime/1e3-s.start,v=g.edge||s.end,S=y(),x=function(k){var U=c[k],W=l[U],H=i[U],z=(H==null?void 0:H.cues)||{},Y=(H==null?void 0:H.durationKnown)||!1,J=T(W.startDate,f),te=v,X=W.endDate;if(X)te=T(X,f),Y=!0;else if(W.endOnNext&&!Y){var q=c.reduce(function(ie,ge){var pe=l[ge];return pe.class===W.class&&pe.id!==ge&&pe.startDate>W.startDate&&ie.push(pe),ie},[]).sort(function(ie,ge){return ie.startDate.getTime()-ge.startDate.getTime()})[0];q&&(te=T(q.startDate,f),Y=!0)}for(var ne=Object.keys(W.attr),ae=0;ae<ne.length;ae++){var re=ne[ae];if(!(re===R.DateRangeAttribute.ID||re===R.DateRangeAttribute.CLASS||re===R.DateRangeAttribute.START_DATE||re===R.DateRangeAttribute.DURATION||re===R.DateRangeAttribute.END_DATE||re===R.DateRangeAttribute.END_ON_NEXT)){var le=z[re];if(le)Y&&!H.durationKnown&&(le.endTime=te);else{var fe=W.attr[re];le=new S(J,te,""),(re===R.DateRangeAttribute.SCTE35_OUT||re===R.DateRangeAttribute.SCTE35_IN)&&(fe=A(fe)),le.value={key:re,data:fe},le.type=O.MetadataSchema.dateRange,h.id3Track.addCue(le),z[re]=le}}}i[U]={cues:z,dateRange:W,durationKnown:Y}},P=0;P<c.length;P++)x(P)}}},m}();b.default=E},"./src/controller/latency-controller.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return O});var I=n("./src/errors.ts"),L=n("./src/events.ts"),D=n("./src/utils/logger.ts");function w(_,y){for(var T=0;T<y.length;T++){var A=y[T];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(_,A.key,A)}}function R(_,y,T){return y&&w(_.prototype,y),T&&w(_,T),Object.defineProperty(_,"prototype",{writable:!1}),_}var O=function(){function _(T){var A=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 A.timeupdate()},this.hls=T,this.config=T.config,this.registerListeners()}var y=_.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(L.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(L.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(L.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(L.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(L.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(L.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(L.Events.ERROR,this.onError)},y.onMediaAttached=function(A,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(A,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(A,E){E.details===I.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,D.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},y.timeupdate=function(){var A=this.media,E=this.levelDetails;if(!(!A||!E)){this.currentTime=A.currentTime;var m=this.computeLatency();if(m!==null){this._latency=m;var p=this.config,d=p.lowLatencyMode,e=p.maxLiveSyncPlaybackRate;if(!(!d||e===1)){var o=this.targetLatency;if(o!==null){var h=m-o,g=Math.min(this.maxLatency,o+E.targetduration),i=h<g;if(E.live&&i&&h>.05&&this.forwardBufferLength>1){var r=Math.min(2,Math.max(1,e)),l=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;A.playbackRate=Math.min(r,Math.max(1,l))}else A.playbackRate!==1&&A.playbackRate!==0&&(A.playbackRate=1)}}}}},y.estimateLiveEdge=function(){var A=this.levelDetails;return A===null?null:A.edge+A.age},y.computeLatency=function(){var A=this.estimateLiveEdge();return A===null?null:A-this.currentTime},R(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var A=this.config,E=this.levelDetails;return A.liveMaxLatencyDuration!==void 0?A.liveMaxLatencyDuration:E?A.liveMaxLatencyDurationCount*E.targetduration:0}},{key:"targetLatency",get:function(){var A=this.levelDetails;if(A===null)return null;var E=A.holdBack,m=A.partHoldBack,p=A.targetduration,d=this.config,e=d.liveSyncDuration,o=d.liveSyncDurationCount,h=d.lowLatencyMode,g=this.hls.userConfig,i=h&&m||E;(g.liveSyncDuration||g.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:o*p);var r=p,l=1;return i+Math.min(this.stallCount*l,r)}},{key:"liveSyncPosition",get:function(){var A=this.estimateLiveEdge(),E=this.targetLatency,m=this.levelDetails;if(A===null||E===null||m===null)return null;var p=m.edge,d=A-E-this.edgeStalled,e=p-m.totalduration,o=p-(this.config.lowLatencyMode&&m.partTarget||m.targetduration);return Math.min(Math.max(e,d),o)}},{key:"drift",get:function(){var A=this.levelDetails;return A===null?1:A.drift}},{key:"edgeStalled",get:function(){var A=this.levelDetails;if(A===null)return 0;var E=(this.config.lowLatencyMode&&A.partTarget||A.targetduration)*3;return Math.max(A.age-E,0)}},{key:"forwardBufferLength",get:function(){var A=this.media,E=this.levelDetails;if(!A||!E)return 0;var m=A.buffered.length;return(m?A.buffered.end(m-1):E.edge)-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return d});var I=n("./src/types/level.ts"),L=n("./src/events.ts"),D=n("./src/errors.ts"),w=n("./src/utils/codecs.ts"),R=n("./src/controller/level-helper.ts"),O=n("./src/controller/base-playlist-controller.ts"),_=n("./src/types/loader.ts");function y(){return y=Object.assign?Object.assign.bind():function(e){for(var o=1;o<arguments.length;o++){var h=arguments[o];for(var g in h)Object.prototype.hasOwnProperty.call(h,g)&&(e[g]=h[g])}return e},y.apply(this,arguments)}function T(e,o){for(var h=0;h<o.length;h++){var g=o[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(e,g.key,g)}}function A(e,o,h){return o&&T(e.prototype,o),h&&T(e,h),Object.defineProperty(e,"prototype",{writable:!1}),e}function E(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,m(e,o)}function m(e,o){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,i){return g.__proto__=i,g},m(e,o)}var p=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),d=function(e){E(o,e);function o(g){var i;return i=e.call(this,g,"[level-controller]")||this,i._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.onParsedComplete=void 0,i._registerListeners(),i}var h=o.prototype;return h._registerListeners=function(){var i=this.hls;i.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(L.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var i=this.hls;i.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(L.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(L.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(L.Events.ERROR,this.onError,this)},h.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},h.startLoad=function(){var i=this._levels;i.forEach(function(r){r.loadError=0}),e.prototype.startLoad.call(this)},h.onManifestLoaded=function(i,r){var l=[],c=[],t=[],a,u={},s,f=!1,v=!1,S=!1;if(r.levels.forEach(function(k){var U=k.attrs;f=f||!!(k.width&&k.height),v=v||!!k.videoCodec,S=S||!!k.audioCodec,p&&k.audioCodec&&k.audioCodec.indexOf("mp4a.40.34")!==-1&&(k.audioCodec=void 0);var W=k.bitrate+"-"+k.attrs.RESOLUTION+"-"+k.attrs.CODECS;s=u[W],s?s.url.push(k.url):(s=new I.Level(k),u[W]=s,l.push(s)),U&&(U.AUDIO&&Object(R.addGroupId)(s,"audio",U.AUDIO),U.SUBTITLES&&Object(R.addGroupId)(s,"text",U.SUBTITLES))}),(f||v)&&S&&(l=l.filter(function(k){var U=k.videoCodec,W=k.width,H=k.height;return!!U||!!(W&&H)})),l=l.filter(function(k){var U=k.audioCodec,W=k.videoCodec;return(!U||Object(w.isCodecSupportedInMp4)(U,"audio"))&&(!W||Object(w.isCodecSupportedInMp4)(W,"video"))}),r.audioTracks&&(c=r.audioTracks.filter(function(k){return!k.audioCodec||Object(w.isCodecSupportedInMp4)(k.audioCodec,"audio")}),Object(R.assignTrackIdsByGroup)(c)),r.subtitles&&(t=r.subtitles,Object(R.assignTrackIdsByGroup)(t)),l.length>0){a=l[0].bitrate,l.sort(function(k,U){return k.bitrate-U.bitrate}),this._levels=l;for(var x=0;x<l.length;x++)if(l[x].bitrate===a){this._firstLevel=x,this.log("manifest loaded, "+l.length+" level(s) found, first bitrate: "+a);break}var P=S&&!v,B={levels:l,audioTracks:c,subtitleTracks:t,firstLevel:this._firstLevel,stats:r.stats,audio:S,video:v,altAudio:!P&&c.some(function(k){return!!k.url})};this.hls.trigger(L.Events.MANIFEST_PARSED,B),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(L.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(i,r){var l;if(e.prototype.onError.call(this,i,r),!r.fatal){var c=r.context,t=this._levels[this.currentLevelIndex];if(c&&(c.type===_.PlaylistContextType.AUDIO_TRACK&&t.audioGroupIds&&c.groupId===t.audioGroupIds[t.urlId]||c.type===_.PlaylistContextType.SUBTITLE_TRACK&&t.textGroupIds&&c.groupId===t.textGroupIds[t.urlId])){this.redundantFailover(this.currentLevelIndex);return}var a=!1,u=!0,s;switch(r.details){case D.ErrorDetails.FRAG_LOAD_ERROR:case D.ErrorDetails.FRAG_LOAD_TIMEOUT:case D.ErrorDetails.KEY_LOAD_ERROR:case D.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var f=r.frag.type===_.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,v=this._levels[f];v?(v.fragmentError++,v.fragmentError>this.hls.config.fragLoadingMaxRetry&&(s=f)):s=f}break;case D.ErrorDetails.LEVEL_LOAD_ERROR:case D.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(u=!1),s=c.level),a=!0;break;case D.ErrorDetails.REMUX_ALLOC_ERROR:s=(l=r.level)!=null?l:this.currentLevelIndex,a=!0;break}s!==void 0&&this.recoverLevel(r,s,a,u)}},h.recoverLevel=function(i,r,l,c){var t=i.details,a=this._levels[r];if(a.loadError++,l){var u=this.retryLoadingOrFail(i);if(u)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var s=a.url.length;if(s>1&&a.loadError<s)i.levelRetry=!0,this.redundantFailover(r);else if(this.manualLevelIndex===-1){for(var f=-1,v=this._levels,S=v.length;S--;){var x=(S+this.currentLevelIndex)%v.length;if(x!==this.currentLevelIndex&&v[x].loadError===0){f=x;break}}f>-1&&this.currentLevelIndex!==f&&(this.warn(t+": switch to "+f),i.levelRetry=!0,this.hls.nextAutoLevel=f)}}},h.redundantFailover=function(i){var r=this._levels[i],l=r.url.length;if(l>1){var c=(r.urlId+1)%l;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(t){t.urlId=c}),this.level=i}},h.onFragLoaded=function(i,r){var l=r.frag;if(l!==void 0&&l.type===_.PlaylistLevelType.MAIN){var c=this._levels[l.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},h.onLevelLoaded=function(i,r){var l,c=r.level,t=r.details,a=this._levels[c];if(!a){var u;this.warn("Invalid level index "+c),(u=r.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(t.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0,this.retryCount=0),this.playlistLoaded(c,r,a.details)):(l=r.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(t.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(i,r){var l=this.hls.levels[this.currentLevelIndex];if(!!l&&l.audioGroupIds){for(var c=-1,t=this.hls.audioTracks[r.id].groupId,a=0;a<l.audioGroupIds.length;a++)if(l.audioGroupIds[a]===t){c=a;break}c!==l.urlId&&(l.urlId=c,this.startLoad())}},h.loadPlaylist=function(i){var r=this.currentLevelIndex,l=this._levels[r];if(this.canLoad&&l&&l.url.length>0){var c=l.urlId,t=l.url[c];if(i)try{t=i.addDirectives(t)}catch(a){this.warn("Could not construct new URL with HLS Delivery Directives: "+a)}this.log("Attempt loading level index "+r+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+c+" "+t),this.clearTimer(),this.hls.trigger(L.Events.LEVEL_LOADING,{url:t,level:r,id:c,deliveryDirectives:i||null})}},h.removeLevel=function(i,r){var l=function(a,u){return u!==r},c=this._levels.filter(function(t,a){return a!==i?!0:t.url.length>1&&r!==void 0?(t.url=t.url.filter(l),t.audioGroupIds&&(t.audioGroupIds=t.audioGroupIds.filter(l)),t.textGroupIds&&(t.textGroupIds=t.textGroupIds.filter(l)),t.urlId=0,!0):!1}).map(function(t,a){var u=t.details;return u!=null&&u.fragments&&u.fragments.forEach(function(s){s.level=a}),t});this._levels=c,this.hls.trigger(L.Events.LEVELS_UPDATED,{levels:c})},A(o,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(i){var r,l=this._levels;if(l.length!==0&&!(this.currentLevelIndex===i&&(r=l[i])!==null&&r!==void 0&&r.details)){if(i<0||i>=l.length){var c=i<0;if(this.hls.trigger(L.Events.ERROR,{type:D.ErrorTypes.OTHER_ERROR,details:D.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:c,reason:"invalid level idx"}),c)return;i=Math.min(i,l.length-1)}this.clearTimer();var t=this.currentLevelIndex,a=l[t],u=l[i];this.log("switching to level "+i+" from "+t),this.currentLevelIndex=i;var s=y({},u,{level:i,maxBitrate:u.maxBitrate,uri:u.uri,urlId:u.urlId});delete s._urlId,this.hls.trigger(L.Events.LEVEL_SWITCHING,s);var f=u.details;if(!f||f.live){var v=this.switchParams(u.uri,a==null?void 0:a.details);this.loadPlaylist(v)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(i){this.manualLevelIndex=i,this._startLevel===void 0&&(this._startLevel=i),i!==-1&&(this.level=i)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(i){this._firstLevel=i}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var i=this.hls.config.startLevel;return i!==void 0?i:this._firstLevel}else return this._startLevel},set:function(i){this._startLevel=i}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(i){this.level=i,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=i)}}]),o}(O.default)},"./src/controller/level-helper.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"addGroupId",function(){return R}),n.d(b,"assignTrackIdsByGroup",function(){return O}),n.d(b,"updatePTS",function(){return _}),n.d(b,"updateFragPTSDTS",function(){return T}),n.d(b,"mergeDetails",function(){return A}),n.d(b,"mapPartIntersection",function(){return m}),n.d(b,"mapFragmentIntersection",function(){return p}),n.d(b,"adjustSliding",function(){return d}),n.d(b,"addSliding",function(){return e}),n.d(b,"computeReloadInterval",function(){return o}),n.d(b,"getFragmentWithSN",function(){return h}),n.d(b,"getPartWith",function(){return g});var I=n("./src/polyfills/number.ts"),L=n("./src/utils/logger.ts"),D=n("./src/loader/date-range.ts");function w(){return w=Object.assign?Object.assign.bind():function(i){for(var r=1;r<arguments.length;r++){var l=arguments[r];for(var c in l)Object.prototype.hasOwnProperty.call(l,c)&&(i[c]=l[c])}return i},w.apply(this,arguments)}function R(i,r,l){switch(r){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(l);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(l);break}}function O(i){var r={};i.forEach(function(l){var c=l.groupId||"";l.id=r[c]=r[c]||0,r[c]++})}function _(i,r,l){var c=i[r],t=i[l];y(c,t)}function y(i,r){var l=r.startPTS;if(Object(I.isFiniteNumber)(l)){var c=0,t;r.sn>i.sn?(c=l-i.start,t=i):(c=i.start-l,t=r),t.duration!==c&&(t.duration=c)}else if(r.sn>i.sn){var a=i.cc===r.cc;a&&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,l,c,t,a){var u=c-l;u<=0&&(L.logger.warn("Fragment should have a positive duration",r),c=l+r.duration,a=t+r.duration);var s=l,f=c,v=r.startPTS,S=r.endPTS;if(Object(I.isFiniteNumber)(v)){var x=Math.abs(v-l);Object(I.isFiniteNumber)(r.deltaPTS)?r.deltaPTS=Math.max(x,r.deltaPTS):r.deltaPTS=x,s=Math.max(l,v),l=Math.min(l,v),t=Math.min(t,r.startDTS),f=Math.min(c,S),c=Math.max(c,S),a=Math.max(a,r.endDTS)}r.duration=c-l;var P=l-r.start;r.appendedPTS=c,r.start=r.startPTS=l,r.maxStartPTS=s,r.startDTS=t,r.endPTS=c,r.minEndPTS=f,r.endDTS=a;var B=r.sn;if(!i||B<i.startSN||B>i.endSN)return 0;var k,U=B-i.startSN,W=i.fragments;for(W[U]=r,k=U;k>0;k--)y(W[k],W[k-1]);for(k=U;k<W.length-1;k++)y(W[k],W[k+1]);return i.fragmentHint&&y(W[W.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,P}function A(i,r){for(var l=null,c=i.fragments,t=c.length-1;t>=0;t--){var a=c[t].initSegment;if(a){l=a;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var u=0,s;if(p(i,r,function(k,U){k.relurl&&(u=k.cc-U.cc),Object(I.isFiniteNumber)(k.startPTS)&&Object(I.isFiniteNumber)(k.endPTS)&&(U.start=U.startPTS=k.startPTS,U.startDTS=k.startDTS,U.appendedPTS=k.appendedPTS,U.maxStartPTS=k.maxStartPTS,U.endPTS=k.endPTS,U.endDTS=k.endDTS,U.minEndPTS=k.minEndPTS,U.duration=k.endPTS-k.startPTS,U.duration&&(s=U),r.PTSKnown=r.alignedSliding=!0),U.elementaryStreams=k.elementaryStreams,U.loader=k.loader,U.stats=k.stats,U.urlId=k.urlId,k.initSegment&&(U.initSegment=k.initSegment,l=k.initSegment)}),l){var f=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;f.forEach(function(k){var U;(!k.initSegment||k.initSegment.relurl===((U=l)===null||U===void 0?void 0:U.relurl))&&(k.initSegment=l)})}if(r.skippedSegments)if(r.deltaUpdateFailed=r.fragments.some(function(k){return!k}),r.deltaUpdateFailed){L.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var v=r.skippedSegments;v--;)r.fragments.shift();r.startSN=r.fragments[0].sn,r.startCC=r.fragments[0].cc}else r.canSkipDateRanges&&(r.dateRanges=E(i.dateRanges,r.dateRanges,r.recentlyRemovedDateranges));var S=r.fragments;if(u){L.logger.warn("discontinuity sliding from playlist, take drift into account");for(var x=0;x<S.length;x++)S[x].cc+=u}r.skippedSegments&&(r.startCC=r.fragments[0].cc),m(i.partList,r.partList,function(k,U){U.elementaryStreams=k.elementaryStreams,U.stats=k.stats}),s?T(r,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):d(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 B=r.edge;r.driftStart||(r.driftStartTime=P,r.driftStart=B),r.driftEndTime=P,r.driftEnd=B}else r.driftEndTime=i.driftEndTime,r.driftEnd=i.driftEnd,r.advancedDateTime=i.advancedDateTime}function E(i,r,l){var c=w({},i);return l&&l.forEach(function(t){delete c[t]}),Object.keys(r).forEach(function(t){var a=new D.DateRange(r[t].attr,c[t]);a.isValid?c[t]=a:L.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(r[t].attr)+'"')}),c}function m(i,r,l){if(i&&r)for(var c=0,t=0,a=i.length;t<=a;t++){var u=i[t],s=r[t+c];u&&s&&u.index===s.index&&u.fragment.sn===s.fragment.sn?l(u,s):c--}}function p(i,r,l){for(var c=r.skippedSegments,t=Math.max(i.startSN,r.startSN)-r.startSN,a=(i.fragmentHint?1:0)+(c?r.endSN:Math.min(i.endSN,r.endSN))-r.startSN,u=r.startSN-i.startSN,s=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments,f=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,v=t;v<=a;v++){var S=f[u+v],x=s[v];c&&!x&&v<c&&(x=r.fragments[v]=S),S&&x&&l(S,x)}}function d(i,r){var l=r.startSN+r.skippedSegments-i.startSN,c=i.fragments;l<0||l>=c.length||e(r,c[l].start)}function e(i,r){if(r){for(var l=i.fragments,c=i.skippedSegments;c<l.length;c++)l[c].start+=r;i.fragmentHint&&(i.fragmentHint.start+=r)}}function o(i,r){var l=1e3*i.levelTargetDuration,c=l/2,t=i.age,a=t>0&&t<l*3,u=r.loading.end-r.loading.start,s,f=i.availabilityDelay;if(i.updated===!1)if(a){var v=333*i.misses;s=Math.max(Math.min(c,u*2),v),i.availabilityDelay=(i.availabilityDelay||0)+s}else s=c;else a?(f=Math.min(f||l/2,t),i.availabilityDelay=f,s=f+l-t):s=l-u;return Math.round(s)}function h(i,r,l){if(!i||!i.details)return null;var c=i.details,t=c.fragments[r-c.startSN];return t||(t=c.fragmentHint,t&&t.sn===r)?t:r<c.startSN&&l&&l.sn===r?l:null}function g(i,r,l){if(!i||!i.details)return null;var c=i.details.partList;if(c)for(var t=c.length;t--;){var a=c[t];if(a.index===l&&a.fragment.sn===r)return a}return null}},"./src/controller/stream-controller.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return g});var I=n("./src/polyfills/number.ts"),L=n("./src/controller/base-stream-controller.ts"),D=n("./src/is-supported.ts"),w=n("./src/events.ts"),R=n("./src/utils/buffer-helper.ts"),O=n("./src/controller/fragment-tracker.ts"),_=n("./src/types/loader.ts"),y=n("./src/loader/fragment.ts"),T=n("./src/demux/transmuxer-interface.ts"),A=n("./src/types/transmuxer.ts"),E=n("./src/controller/gap-controller.ts"),m=n("./src/errors.ts");function p(i,r){for(var l=0;l<r.length;l++){var c=r[l];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(i,c.key,c)}}function d(i,r,l){return r&&p(i.prototype,r),l&&p(i,l),Object.defineProperty(i,"prototype",{writable:!1}),i}function e(i,r){i.prototype=Object.create(r.prototype),i.prototype.constructor=i,o(i,r)}function o(i,r){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,t){return c.__proto__=t,c},o(i,r)}var h=100,g=function(i){e(r,i);function r(c,t){var a;return a=i.call(this,c,t,"[stream-controller]")||this,a.audioCodecSwap=!1,a.gapController=null,a.level=-1,a._forceStartLoad=!1,a.altAudio=!1,a.audioOnly=!1,a.fragPlaying=null,a.onvplaying=null,a.onvseeked=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a._registerListeners(),a}var l=r.prototype;return l._registerListeners=function(){var t=this.hls;t.on(w.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(w.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(w.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(w.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(w.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(w.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(w.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(w.Events.ERROR,this.onError,this),t.on(w.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(w.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(w.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(w.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(w.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(w.Events.FRAG_BUFFERED,this.onFragBuffered,this)},l._unregisterListeners=function(){var t=this.hls;t.off(w.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(w.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(w.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(w.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(w.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(w.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(w.Events.ERROR,this.onError,this),t.off(w.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(w.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(w.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(w.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(w.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(w.Events.FRAG_BUFFERED,this.onFragBuffered,this)},l.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},l.startLoad=function(t){if(this.levels){var a=this.lastCurrentTime,u=this.hls;if(this.stopLoad(),this.setInterval(h),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var s=u.startLevel;s===-1&&(u.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=u.nextAutoLevel),this.level=u.nextLoadLevel=s,this.loadedmetadata=!1}a>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),t=a),this.state=L.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=L.State.STOPPED},l.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},l.doTick=function(){switch(this.state){case L.State.IDLE:this.doTickIdle();break;case L.State.WAITING_LEVEL:{var t,a=this.levels,u=this.level,s=a==null||(t=a[u])===null||t===void 0?void 0:t.details;if(s&&(!s.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(s))break;this.state=L.State.IDLE;break}break}case L.State.FRAG_LOADING_WAITING_RETRY:{var f,v=self.performance.now(),S=this.retryDate;(!S||v>=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=L.State.IDLE)}break;default:break}this.onTickEnd()},l.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},l.doTickIdle=function(){var t,a,u=this.hls,s=this.levelLastLoaded,f=this.levels,v=this.media,S=u.config,x=u.nextLoadLevel;if(!(s===null||!v&&(this.startFragRequested||!S.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!f||!f[x])){var P=f[x];this.level=u.nextLoadLevel=x;var B=P.details;if(!B||this.state===L.State.WAITING_LEVEL||B.live&&this.levelLastLoaded!==x){this.state=L.State.WAITING_LEVEL;return}var k=this.getMainFwdBufferInfo();if(k!==null){var U=k.len,W=this.getMaxBufferLength(P.maxBitrate);if(!(U>=W)){if(this._streamEnded(k,B)){var H={};this.altAudio&&(H.type="video"),this.hls.trigger(w.Events.BUFFER_EOS,H),this.state=L.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>k.end&&(this.backtrackFragment=null);var z=this.backtrackFragment?this.backtrackFragment.start:k.end,Y=this.getNextFragment(z,B);if(this.couldBacktrack&&!this.fragPrevious&&Y&&Y.sn!=="initSegment"&&this.fragmentTracker.getState(Y)!==O.FragmentState.OK){var J,te=((J=this.backtrackFragment)!=null?J:Y).sn,X=te-B.startSN,q=B.fragments[X-1];q&&Y.cc===q.cc&&(Y=q,this.fragmentTracker.removeFragment(q))}else this.backtrackFragment&&k.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;v&&this.afterBufferFlushed(v,ne,_.PlaylistLevelType.MAIN),Y=this.getNextFragment(this.nextLoadPosition,B)}!Y||(Y.initSegment&&!Y.initSegment.data&&!this.bitrateTest&&(Y=Y.initSegment),((t=Y.decryptdata)===null||t===void 0?void 0:t.keyFormat)==="identity"&&!((a=Y.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(Y,B):this.loadFragment(Y,B,z))}}}},l.loadFragment=function(t,a,u){var s,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,a,u)):f===O.FragmentState.APPENDING?this.reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t):((s=this.media)===null||s===void 0?void 0:s.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},l.getAppendedFrag=function(t){var a=this.fragmentTracker.getAppendedFrag(t,_.PlaylistLevelType.MAIN);return a&&"fragment"in a?a.fragment:a},l.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,_.PlaylistLevelType.MAIN)},l.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},l.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},l.nextLevelSwitch=function(){var t=this.levels,a=this.media;if(a!=null&&a.readyState){var u,s=this.getAppendedFrag(a.currentTime);if(s&&s.start>1&&this.flushMainBuffer(0,s.start-1),!a.paused&&t){var f=this.hls.nextLoadLevel,v=t[f],S=this.fragLastKbps;S&&this.fragCurrent?u=this.fragCurrent.duration*v.maxBitrate/(1e3*S)+1:u=0}else u=0;var x=this.getBufferedFrag(a.currentTime+u);if(x){var P=this.followingBufferedFrag(x);if(P){this.abortCurrentFrag();var B=P.maxStartPTS?P.maxStartPTS:P.start,k=P.duration,U=Math.max(x.end,B+Math.min(Math.max(k-this.config.maxFragLookUpTolerance,k*.5),k*.75));this.flushMainBuffer(U,Number.POSITIVE_INFINITY)}}}},l.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t!=null&&t.loader&&t.loader.abort(),this.state){case L.State.KEY_LOADING:case L.State.FRAG_LOADING:case L.State.FRAG_LOADING_WAITING_RETRY:case L.State.PARSING:case L.State.PARSED:this.state=L.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},l.flushMainBuffer=function(t,a){i.prototype.flushMainBuffer.call(this,t,a,this.altAudio?"video":null)},l.onMediaAttached=function(t,a){i.prototype.onMediaAttached.call(this,t,a);var u=a.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),u.addEventListener("playing",this.onvplaying),u.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,u,this.fragmentTracker,this.hls)},l.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)},l.onMediaPlaying=function(){this.tick()},l.onMediaSeeked=function(){var t=this.media,a=t?t.currentTime:null;Object(I.isFiniteNumber)(a)&&this.log("Media seeked to "+a.toFixed(3)),this.tick()},l.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(w.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},l.onManifestParsed=function(t,a){var u=!1,s=!1,f;a.levels.forEach(function(v){f=v.audioCodec,f&&(f.indexOf("mp4a.40.2")!==-1&&(u=!0),f.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=u&&s&&!Object(D.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=a.levels,this.startFragRequested=!1},l.onLevelLoading=function(t,a){var u=this.levels;if(!(!u||this.state!==L.State.IDLE)){var s=u[a.level];(!s.details||s.details.live&&this.levelLastLoaded!==a.level||this.waitForCdnTuneIn(s.details))&&(this.state=L.State.WAITING_LEVEL)}},l.onLevelLoaded=function(t,a){var u,s=this.levels,f=a.level,v=a.details,S=v.totalduration;if(!s){this.warn("Levels were reset while loading level "+f);return}this.log("Level "+f+" loaded ["+v.startSN+","+v.endSN+"], cc ["+v.startCC+", "+v.endCC+"] duration:"+S);var x=this.fragCurrent;x&&(this.state===L.State.FRAG_LOADING||this.state===L.State.FRAG_LOADING_WAITING_RETRY)&&x.level!==a.level&&x.loader&&(this.state=L.State.IDLE,this.backtrackFragment=null,x.loader.abort());var P=s[f],B=0;if(v.live||(u=P.details)!==null&&u!==void 0&&u.live){if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed)return;B=this.alignPlaylists(v,P.details)}if(P.details=v,this.levelLastLoaded=f,this.hls.trigger(w.Events.LEVEL_UPDATED,{details:v,level:f}),this.state===L.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(v))return;this.state=L.State.IDLE}this.startFragRequested?v.live&&this.synchronizeToLiveEdge(v):this.setStartPosition(v,B),this.tick()},l._handleFragmentLoadProgress=function(t){var a,u=t.frag,s=t.part,f=t.payload,v=this.levels;if(!v){this.warn("Levels were reset while fragment load was in progress. Fragment "+u.sn+" of level "+u.level+" will not be buffered");return}var S=v[u.level],x=S.details;if(!x){this.warn("Dropping fragment "+u.sn+" of level "+u.level+" after level details were reset");return}var P=S.videoCodec,B=x.PTSKnown||!x.live,k=(a=u.initSegment)===null||a===void 0?void 0:a.data,U=this._getAudioCodec(S),W=this.transmuxer=this.transmuxer||new T.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),H=s?s.index:-1,z=H!==-1,Y=new A.ChunkMetadata(u.level,u.sn,u.stats.chunkCount,f.byteLength,H,z),J=this.initPTS[u.cc];W.push(f,k,U,P,u,s,x.totalduration,B,Y,J)},l.onAudioTrackSwitching=function(t,a){var u=this.altAudio,s=!!a.url,f=a.id;if(!s){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var v=this.fragCurrent;v!=null&&v.loader&&(this.log("Switching to main audio track, cancel main fragment load"),v.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var S=this.hls;u&&S.trigger(w.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),S.trigger(w.Events.AUDIO_TRACK_SWITCHED,{id:f})}},l.onAudioTrackSwitched=function(t,a){var u=a.id,s=!!this.hls.audioTracks[u].url;if(s){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=s,this.tick()},l.onBufferCreated=function(t,a){var u=a.tracks,s,f,v=!1;for(var S in u){var x=u[S];if(x.id==="main"){if(f=S,s=x,S==="video"){var P=u[S];P&&(this.videoBuffer=P.buffer)}}else v=!0}v&&s?(this.log("Alternate track found, use "+f+".buffered to schedule main fragment loading"),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media},l.onFragBuffered=function(t,a){var u=a.frag,s=a.part;if(!(u&&u.type!==_.PlaylistLevelType.MAIN)){if(this.fragContextChanged(u)){this.warn("Fragment "+u.sn+(s?" p: "+s.index:"")+" of level "+u.level+" finished buffering, but was aborted. state: "+this.state),this.state===L.State.PARSED&&(this.state=L.State.IDLE);return}var f=s?s.stats:u.stats;this.fragLastKbps=Math.round(8*f.total/(f.buffering.end-f.loading.first)),u.sn!=="initSegment"&&(this.fragPrevious=u),this.fragBufferedComplete(u,s)}},l.onError=function(t,a){switch(a.details){case m.ErrorDetails.FRAG_LOAD_ERROR:case m.ErrorDetails.FRAG_LOAD_TIMEOUT:case m.ErrorDetails.KEY_LOAD_ERROR:case m.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.MAIN,a);break;case m.ErrorDetails.LEVEL_LOAD_ERROR:case m.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==L.State.ERROR&&(a.fatal?(this.warn(""+a.details),this.state=L.State.ERROR):!a.levelRetry&&this.state===L.State.WAITING_LEVEL&&(this.state=L.State.IDLE));break;case m.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="main"&&(this.state===L.State.PARSING||this.state===L.State.PARSED)){var u=!0,s=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);s&&s.len>.5&&(u=!this.reduceMaxBufferLength(s.len)),u&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},l.checkBuffer=function(){var t=this.media,a=this.gapController;if(!(!t||!a||!t.readyState)){if(this.loadedmetadata||!R.BufferHelper.getBuffered(t).length){var u=this.state!==L.State.IDLE?this.fragCurrent:null;a.poll(this.lastCurrentTime,u)}this.lastCurrentTime=t.currentTime}},l.onFragLoadEmergencyAborted=function(){this.state=L.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},l.onBufferFlushed=function(t,a){var u=a.type;if(u!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var s=(u===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(s,u,_.PlaylistLevelType.MAIN)}},l.onLevelsUpdated=function(t,a){this.levels=a.levels},l.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},l.seekToStartPos=function(){var t=this.media;if(!!t){var a=t.currentTime,u=this.startPosition;if(u>=0&&a<u){if(t.seeking){this.log("could not seek to "+u+", already seeking at "+a);return}var s=R.BufferHelper.getBuffered(t),f=s.length?s.start(0):0,v=f-u;v>0&&(v<this.config.maxBufferHole||v<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+v+" to match buffer start"),u+=v,this.startPosition=u),this.log("seek to target start position "+u+" from current time "+a),t.currentTime=u}}},l._getAudioCodec=function(t){var a=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&a&&(this.log("Swapping audio codec"),a.indexOf("mp4a.40.5")!==-1?a="mp4a.40.2":a="mp4a.40.5"),a},l._loadBitrateTestFrag=function(t){var a=this;t.bitrateTest=!0,this._doFragLoad(t).then(function(u){var s=a.hls;if(!(!u||s.nextLoadLevel||a.fragContextChanged(t))){a.fragLoadError=0,a.state=L.State.IDLE,a.startFragRequested=!1,a.bitrateTest=!1;var f=t.stats;f.parsing.start=f.parsing.end=f.buffering.start=f.buffering.end=self.performance.now(),s.trigger(w.Events.FRAG_LOADED,u),t.bitrateTest=!1}})},l._handleTransmuxComplete=function(t){var a,u="main",s=this.hls,f=t.remuxResult,v=t.chunkMeta,S=this.getCurrentContext(v);if(!S){this.warn("The loading context changed while buffering fragment "+v.sn+" of level "+v.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(v.level);return}var x=S.frag,P=S.part,B=S.level,k=f.video,U=f.text,W=f.id3,H=f.initSegment,z=B.details,Y=this.altAudio?void 0:f.audio;if(!this.fragContextChanged(x)){if(this.state=L.State.PARSING,H){H.tracks&&(this._bufferInitSegment(B,H.tracks,x,v),s.trigger(w.Events.FRAG_PARSING_INIT_SEGMENT,{frag:x,id:u,tracks:H.tracks}));var J=H.initPTS,te=H.timescale;Object(I.isFiniteNumber)(J)&&(this.initPTS[x.cc]=J,s.trigger(w.Events.INIT_PTS_FOUND,{frag:x,id:u,initPTS:J,timescale:te}))}if(k&&f.independent!==!1){if(z){var X=k.startPTS,q=k.endPTS,ne=k.startDTS,ae=k.endDTS;if(P)P.elementaryStreams[k.type]={startPTS:X,endPTS:q,startDTS:ne,endDTS:ae};else if(k.firstKeyFrame&&k.independent&&(this.couldBacktrack=!0),k.dropped&&k.independent){var re=this.getMainFwdBufferInfo(),le=(re?re.end:this.getLoadPosition())+this.config.maxBufferHole,fe=k.firstKeyFramePTS?k.firstKeyFramePTS:X;if(le<fe-this.config.maxBufferHole){this.backtrack(x);return}x.setElementaryStreamInfo(k.type,x.start,q,x.start,ae,!0)}x.setElementaryStreamInfo(k.type,X,q,ne,ae),this.backtrackFragment&&(this.backtrackFragment=x),this.bufferFragmentData(k,x,P,v)}}else if(f.independent===!1){this.backtrack(x);return}if(Y){var ie=Y.startPTS,ge=Y.endPTS,pe=Y.startDTS,De=Y.endDTS;P&&(P.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:ie,endPTS:ge,startDTS:pe,endDTS:De}),x.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,ie,ge,pe,De),this.bufferFragmentData(Y,x,P,v)}if(z&&W!==null&&W!==void 0&&(a=W.samples)!==null&&a!==void 0&&a.length){var Me={id:u,frag:x,details:z,samples:W.samples};s.trigger(w.Events.FRAG_PARSING_METADATA,Me)}if(z&&U){var Oe={id:u,frag:x,details:z,samples:U.samples};s.trigger(w.Events.FRAG_PARSING_USERDATA,Oe)}}},l._bufferInitSegment=function(t,a,u,s){var f=this;if(this.state===L.State.PARSING){this.audioOnly=!!a.audio&&!a.video,this.altAudio&&!this.audioOnly&&delete a.audio;var v=a.audio,S=a.video,x=a.audiovideo;if(v){var P=t.audioCodec,B=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(P&&(P.indexOf("mp4a.40.5")!==-1?P="mp4a.40.2":P="mp4a.40.5"),v.metadata.channelCount!==1&&B.indexOf("firefox")===-1&&(P="mp4a.40.5")),B.indexOf("android")!==-1&&v.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+'"'),v.levelCodec=P,v.id="main",this.log("Init audio buffer, container:"+v.container+", codecs[selected/level/parsed]=["+(P||"")+"/"+(t.audioCodec||"")+"/"+v.codec+"]")}S&&(S.levelCodec=t.videoCodec,S.id="main",this.log("Init video buffer, container:"+S.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+S.codec+"]")),x&&this.log("Init audiovideo buffer, container:"+x.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+x.codec+"]"),this.hls.trigger(w.Events.BUFFER_CODECS,a),Object.keys(a).forEach(function(k){var U=a[k],W=U.initSegment;W!=null&&W.byteLength&&f.hls.trigger(w.Events.BUFFER_APPENDING,{type:k,data:W,frag:u,part:null,chunkMeta:s,parent:u.type})}),this.tick()}},l.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.MAIN)},l.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=L.State.IDLE},l.checkFragmentChanged=function(){var t=this.media,a=null;if(t&&t.readyState>1&&t.seeking===!1){var u=t.currentTime;if(R.BufferHelper.isBuffered(t,u)?a=this.getAppendedFrag(u):R.BufferHelper.isBuffered(t,u+.1)&&(a=this.getAppendedFrag(u+.1)),a){this.backtrackFragment=null;var s=this.fragPlaying,f=a.level;(!s||a.sn!==s.sn||s.level!==f||a.urlId!==s.urlId)&&(this.hls.trigger(w.Events.FRAG_CHANGED,{frag:a}),(!s||s.level!==f)&&this.hls.trigger(w.Events.LEVEL_SWITCHED,{level:f}),this.fragPlaying=a)}}},d(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 a=t.currentTime,u=this.currentFrag;if(u&&Object(I.isFiniteNumber)(a)&&Object(I.isFiniteNumber)(u.programDateTime)){var s=u.programDateTime+(a-u.start)*1e3;return new Date(s)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),r}(L.default)},"./src/controller/subtitle-stream-controller.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"SubtitleStreamController",function(){return e});var I=n("./src/events.ts"),L=n("./src/utils/buffer-helper.ts"),D=n("./src/controller/fragment-finders.ts"),w=n("./src/utils/discontinuities.ts"),R=n("./src/controller/level-helper.ts"),O=n("./src/controller/fragment-tracker.ts"),_=n("./src/controller/base-stream-controller.ts"),y=n("./src/types/loader.ts"),T=n("./src/types/level.ts");function A(h,g){for(var i=0;i<g.length;i++){var r=g[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(h,r.key,r)}}function E(h,g,i){return g&&A(h.prototype,g),i&&A(h,i),Object.defineProperty(h,"prototype",{writable:!1}),h}function m(h,g){h.prototype=Object.create(g.prototype),h.prototype.constructor=h,p(h,g)}function p(h,g){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,l){return r.__proto__=l,r},p(h,g)}var d=500,e=function(h){m(g,h);function g(r,l){var c;return c=h.call(this,r,l,"[subtitle-stream-controller]")||this,c.levels=[],c.currentTrackId=-1,c.tracksBuffered=[],c.mainDetails=null,c._registerListeners(),c}var i=g.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var l=this.hls;l.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(I.Events.ERROR,this.onError,this),l.on(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(I.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.on(I.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.on(I.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var l=this.hls;l.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(I.Events.ERROR,this.onError,this),l.off(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.off(I.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.off(I.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.off(I.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=_.State.IDLE,this.setInterval(d),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(l,c){this.mainDetails=c.details},i.onSubtitleFragProcessed=function(l,c){var t=c.frag,a=c.success;if(this.fragPrevious=t,this.state=_.State.IDLE,!!a){var u=this.tracksBuffered[this.currentTrackId];if(!!u){for(var s,f=t.start,v=0;v<u.length;v++)if(f>=u[v].start&&f<=u[v].end){s=u[v];break}var S=t.start+t.duration;s?s.end=S:(s={start:f,end:S},u.push(s)),this.fragmentTracker.fragBuffered(t)}}},i.onBufferFlushing=function(l,c){var t=c.startOffset,a=c.endOffset;if(t===0&&a!==Number.POSITIVE_INFINITY){var u=this.currentTrackId,s=this.levels;if(!s.length||!s[u]||!s[u].details)return;var f=s[u].details,v=f.targetduration,S=a-v;if(S<=0)return;c.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(l,c){var t,a=c.frag;!a||a.type!==y.PlaylistLevelType.SUBTITLE||((t=this.fragCurrent)!==null&&t!==void 0&&t.loader&&this.fragCurrent.loader.abort(),this.state=_.State.IDLE)},i.onSubtitleTracksUpdated=function(l,c){var t=this,a=c.subtitleTracks;this.tracksBuffered=[],this.levels=a.map(function(u){return new T.Level(u)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(u){t.tracksBuffered[u.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(l,c){if(this.currentTrackId=c.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var t=this.levels[this.currentTrackId];t!=null&&t.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,t&&this.setInterval(d)},i.onSubtitleTrackLoaded=function(l,c){var t,a=c.details,u=c.id,s=this.currentTrackId,f=this.levels;if(!!f.length){var v=f[s];if(!(u>=f.length||u!==s||!v)){if(this.mediaBuffer=this.mediaBufferTimeRanges,a.live||(t=v.details)!==null&&t!==void 0&&t.live){var S=this.mainDetails;if(a.deltaUpdateFailed||!S)return;var x=S.fragments[0];if(!v.details)a.hasProgramDateTime&&S.hasProgramDateTime?Object(w.alignMediaPlaylistByPDT)(a,S):x&&Object(R.addSliding)(a,x.start);else{var P=this.alignPlaylists(a,v.details);P===0&&x&&Object(R.addSliding)(a,x.start)}}if(v.details=a,this.levelLastLoaded=u,this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===_.State.IDLE){var B=Object(D.findFragmentByPTS)(null,a.fragments,this.media.currentTime,0);B||(this.warn("Subtitle playlist not aligned with playback"),v.details=void 0)}}}},i._handleFragmentLoadComplete=function(l){var c=l.frag,t=l.payload,a=c.decryptdata,u=this.hls;if(!this.fragContextChanged(c)&&t&&t.byteLength>0&&a&&a.key&&a.iv&&a.method==="AES-128"){var s=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(t),a.key.buffer,a.iv.buffer).then(function(f){var v=performance.now();u.trigger(I.Events.FRAG_DECRYPTED,{frag:c,payload:f,stats:{tstart:s,tdecrypt:v}})})}},i.doTick=function(){if(!this.media){this.state=_.State.IDLE;return}if(this.state===_.State.IDLE){var l=this.currentTrackId,c=this.levels;if(!c.length||!c[l]||!c[l].details)return;var t=c[l].details,a=t.targetduration,u=this.config,s=this.media,f=L.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s.currentTime-a,u.maxBufferHole),v=f.end,S=f.len,x=this.getMaxBufferLength()+a;if(S>x)return;console.assert(t,"Subtitle track details are defined on idle subtitle stream controller tick");var P=t.fragments,B=P.length,k=t.edge,U,W=this.fragPrevious;if(v<k){var H=u.maxFragLookUpTolerance;U=Object(D.findFragmentByPTS)(W,P,Math.max(P[0].start,v),H),!U&&W&&W.start<P[0].start&&(U=P[0])}else U=P[B-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,v)}},i.loadFragment=function(l,c,t){this.fragCurrent=l,l.sn==="initSegment"?this._loadInitSegment(l):h.prototype.loadFragment.call(this,l,c,t)},E(g,[{key:"mediaBufferTimeRanges",get:function(){return new o(this.tracksBuffered[this.currentTrackId]||[])}}]),g}(_.default),o=function(g){this.buffered=void 0;var i=function(l,c,t){if(c=c>>>0,c>t-1)throw new DOMException("Failed to execute '"+l+"' on 'TimeRanges': The index provided ("+c+") is greater than the maximum bound ("+t+")");return g[c][l]};this.buffered={get length(){return g.length},end:function(l){return i("end",l,g.length)},start:function(l){return i("start",l,g.length)}}}},"./src/controller/subtitle-track-controller.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/events.ts"),L=n("./src/utils/texttrack-utils.ts"),D=n("./src/controller/base-playlist-controller.ts"),w=n("./src/types/loader.ts");function R(E,m){for(var p=0;p<m.length;p++){var d=m[p];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(E,d.key,d)}}function O(E,m,p){return m&&R(E.prototype,m),p&&R(E,p),Object.defineProperty(E,"prototype",{writable:!1}),E}function _(E,m){E.prototype=Object.create(m.prototype),E.prototype.constructor=E,y(E,m)}function y(E,m){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(d,e){return d.__proto__=e,d},y(E,m)}var T=function(E){_(m,E);function m(d){var e;return e=E.call(this,d,"[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(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(I.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(I.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(I.Events.ERROR,this.onError,this)},p.unregisterListeners=function(){var e=this.hls;e.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(I.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(I.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(I.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(I.Events.ERROR,this.onError,this)},p.onMediaAttached=function(e,o){this.media=o.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=A(this.media.textTracks);e.forEach(function(o){Object(L.clearCurrentCues)(o)}),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,o){this.tracks=o.subtitleTracks},p.onSubtitleTrackLoaded=function(e,o){var h=o.id,g=o.details,i=this.trackId,r=this.tracksInGroup[i];if(!r){this.warn("Invalid subtitle track id "+h);return}var l=r.details;r.details=o.details,this.log("subtitle track "+h+" loaded ["+g.startSN+"-"+g.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,o,l))},p.onLevelLoading=function(e,o){this.switchLevel(o.level)},p.onLevelSwitching=function(e,o){this.switchLevel(o.level)},p.switchLevel=function(e){var o=this.hls.levels[e];if(!!(o!=null&&o.textGroupIds)){var h=o.textGroupIds[o.urlId];if(this.groupId!==h){var g=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(c){return!h||c.groupId===h});this.tracksInGroup=i;var r=this.findTrackId(g==null?void 0:g.name)||this.findTrackId();this.groupId=h;var l={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(I.Events.SUBTITLE_TRACKS_UPDATED,l),r!==-1&&this.setSubtitleTrack(r,g)}}},p.findTrackId=function(e){for(var o=this.tracksInGroup,h=0;h<o.length;h++){var g=o[h];if((!this.selectDefaultTrack||g.default)&&(!e||e===g.name))return g.id}return-1},p.onError=function(e,o){E.prototype.onError.call(this,e,o),!(o.fatal||!o.context)&&o.context.type===w.PlaylistContextType.SUBTITLE_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},p.loadPlaylist=function(e){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var h=o.id,g=o.groupId,i=o.url;if(e)try{i=e.addDirectives(i)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(I.Events.SUBTITLE_TRACK_LOADING,{url:i,id:h,groupId:g,deliveryDirectives:e||null})}},p.toggleTrackModes=function(e){var o=this,h=this.media,g=this.trackId;if(!!h){var i=A(h.textTracks),r=i.filter(function(t){return t.groupId===o.groupId});if(e===-1)[].slice.call(i).forEach(function(t){t.mode="disabled"});else{var l=r[g];l&&(l.mode="disabled")}var c=r[e];c&&(c.mode=this.subtitleDisplay?"showing":"hidden")}},p.setSubtitleTrack=function(e,o){var h,g=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(h=g[e])!==null&&h!==void 0&&h.details)||e<-1||e>=g.length)){this.clearTimer();var i=g[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var r=i.id,l=i.groupId,c=l===void 0?"":l,t=i.name,a=i.type,u=i.url;this.hls.trigger(I.Events.SUBTITLE_TRACK_SWITCH,{id:r,groupId:c,name:t,type:a,url:u});var s=this.switchParams(i.url,o==null?void 0:o.details);this.loadPlaylist(s)}else this.hls.trigger(I.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,o=A(this.media.textTracks),h=0;h<o.length;h++)if(o[h].mode==="hidden")e=h;else if(o[h].mode==="showing"){e=h;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 o=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,o)}}]),m}(D.default);function A(E){for(var m=[],p=0;p<E.length;p++){var d=E[p];d.kind==="subtitles"&&d.label&&m.push(E[p])}return m}b.default=T},"./src/controller/timeline-controller.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"TimelineController",function(){return E});var I=n("./src/polyfills/number.ts"),L=n("./src/events.ts"),D=n("./src/utils/cea-608-parser.ts"),w=n("./src/utils/output-filter.ts"),R=n("./src/utils/webvtt-parser.ts"),O=n("./src/utils/texttrack-utils.ts"),_=n("./src/utils/imsc1-ttml-parser.ts"),y=n("./src/utils/mp4-tools.ts"),T=n("./src/types/loader.ts"),A=n("./src/utils/logger.ts"),E=function(){function e(h){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=d(),this.captionsProperties=void 0,this.hls=h,this.config=h.config,this.Cues=h.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var g=new w.default(this,"textTrack1"),i=new w.default(this,"textTrack2"),r=new w.default(this,"textTrack3"),l=new w.default(this,"textTrack4");this.cea608Parser1=new D.default(1,g,i),this.cea608Parser2=new D.default(3,r,l)}h.on(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.on(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.on(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.on(L.Events.FRAG_LOADING,this.onFragLoading,this),h.on(L.Events.FRAG_LOADED,this.onFragLoaded,this),h.on(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.on(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.on(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.on(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.on(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=e.prototype;return o.destroy=function(){var g=this.hls;g.off(L.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(L.Events.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),g.off(L.Events.MANIFEST_LOADED,this.onManifestLoaded,this),g.off(L.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),g.off(L.Events.FRAG_LOADING,this.onFragLoading,this),g.off(L.Events.FRAG_LOADED,this.onFragLoaded,this),g.off(L.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),g.off(L.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),g.off(L.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),g.off(L.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),g.off(L.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(g,i,r,l,c){for(var t=!1,a=c.length;a--;){var u=c[a],s=p(u[0],u[1],i,r);if(s>=0&&(u[0]=Math.min(u[0],i),u[1]=Math.max(u[1],r),t=!0,s/(r-i)>.5))return}if(t||c.push([i,r]),this.config.renderTextTracksNatively){var f=this.captionsTracks[g];this.Cues.newCue(f,i,r,l)}else{var v=this.Cues.newCue(null,i,r,l);this.hls.trigger(L.Events.CUES_PARSED,{type:"captions",cues:v,track:g})}},o.onInitPtsFound=function(g,i){var r=this,l=i.frag,c=i.id,t=i.initPTS,a=i.timescale,u=this.unparsedVttFrags;c==="main"&&(this.initPTS[l.cc]=t,this.timescale[l.cc]=a),u.length&&(this.unparsedVttFrags=[],u.forEach(function(s){r.onFragLoaded(L.Events.FRAG_LOADED,s)}))},o.getExistingTrack=function(g){var i=this.media;if(i)for(var r=0;r<i.textTracks.length;r++){var l=i.textTracks[r];if(l[g])return l}return null},o.createCaptionsTrack=function(g){this.config.renderTextTracksNatively?this.createNativeTrack(g):this.createNonNativeTrack(g)},o.createNativeTrack=function(g){if(!this.captionsTracks[g]){var i=this.captionsProperties,r=this.captionsTracks,l=this.media,c=i[g],t=c.label,a=c.languageCode,u=this.getExistingTrack(g);if(u)r[g]=u,Object(O.clearCurrentCues)(r[g]),Object(O.sendAddTrackEvent)(r[g],l);else{var s=this.createTextTrack("captions",t,a);s&&(s[g]=!0,r[g]=s)}}},o.createNonNativeTrack=function(g){if(!this.nonNativeCaptionsTracks[g]){var i=this.captionsProperties[g];if(!!i){var r=i.label,l={_id:g,label:r,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[g]=l,this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[l]})}}},o.createTextTrack=function(g,i,r){var l=this.media;if(!!l)return l.addTextTrack(g,i,r)},o.onMediaAttaching=function(g,i){this.media=i.media,this._cleanTracks()},o.onMediaDetaching=function(){var g=this.captionsTracks;Object.keys(g).forEach(function(i){Object(O.clearCurrentCues)(g[i]),delete g[i]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=d(),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())},o._cleanTracks=function(){var g=this.media;if(!!g){var i=g.textTracks;if(i)for(var r=0;r<i.length;r++)Object(O.clearCurrentCues)(i[r])}},o.onSubtitleTracksUpdated=function(g,i){var r=this;this.textTracks=[];var l=i.subtitleTracks||[],c=l.some(function(s){return s.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||c&&this.config.enableIMSC1){var t=this.tracks&&l&&this.tracks.length===l.length;if(this.tracks=l||[],this.config.renderTextTracksNatively){var a=this.media?this.media.textTracks:[];this.tracks.forEach(function(s,f){var v;if(f<a.length){for(var S=null,x=0;x<a.length;x++)if(m(a[x],s)){S=a[x];break}S&&(v=S)}if(v)Object(O.clearCurrentCues)(v);else{var P=r._captionsOrSubtitlesFromCharacteristics(s);v=r.createTextTrack(P,s.name,s.lang),v&&(v.mode="disabled")}v&&(v.groupId=s.groupId,r.textTracks.push(v))})}else if(!t&&this.tracks&&this.tracks.length){var u=this.tracks.map(function(s){return{label:s.name,kind:s.type.toLowerCase(),default:s.default,subtitleTrack:s}});this.hls.trigger(L.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:u})}}},o._captionsOrSubtitlesFromCharacteristics=function(g){var i;if((i=g.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(g.attrs.CHARACTERISTICS),l=/describes-music-and-sound/gi.test(g.attrs.CHARACTERISTICS);if(r&&l)return"captions"}return"subtitles"},o.onManifestLoaded=function(g,i){var r=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(l){var c=/(?:CC|SERVICE)([1-4])/.exec(l.instreamId);if(!!c){var t="textTrack"+c[1],a=r.captionsProperties[t];!a||(a.label=l.name,l.lang&&(a.languageCode=l.lang),a.media=l)}})},o.onFragLoading=function(g,i){var r=this.cea608Parser1,l=this.cea608Parser2,c=this.lastSn,t=this.lastPartIndex;if(!(!this.enabled||!(r&&l))&&i.frag.type===T.PlaylistLevelType.MAIN){var a,u,s=i.frag.sn,f=(a=i==null||(u=i.part)===null||u===void 0?void 0:u.index)!=null?a:-1;s===c+1||s===c&&f===t+1||(r.reset(),l.reset()),this.lastSn=s,this.lastPartIndex=f}},o.onFragLoaded=function(g,i){var r=i.frag,l=i.payload,c=this.initPTS,t=this.unparsedVttFrags;if(r.type===T.PlaylistLevelType.SUBTITLE)if(l.byteLength){if(!Object(I.isFiniteNumber)(c[r.cc])){t.push(i),c.length&&this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")});return}var a=r.decryptdata,u="stats"in i;if(a==null||a.key==null||a.method!=="AES-128"||u){var s=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),s&&s.textCodec===_.IMSC1_CODEC?this._parseIMSC1(r,l):this._parseVTTs(r,l,f)}}else this.hls.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(g,i){var r=this,l=this.hls;Object(_.parseIMSC1)(i,this.initPTS[g.cc],this.timescale[g.cc],function(c){r._appendCues(c,g.level),l.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:g})},function(c){A.logger.log("Failed to parse IMSC1: "+c),l.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:c})})},o._parseVTTs=function(g,i,r){var l,c=this,t=this.hls,a=(l=g.initSegment)!==null&&l!==void 0&&l.data?Object(y.appendUint8Array)(g.initSegment.data,new Uint8Array(i)):i;Object(R.parseWebVTT)(a,this.initPTS[g.cc],this.timescale[g.cc],r,g.cc,g.start,function(u){c._appendCues(u,g.level),t.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:g})},function(u){c._fallbackToIMSC1(g,i),A.logger.log("Failed to parse VTT cue: "+u),t.trigger(L.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:g,error:u})})},o._fallbackToIMSC1=function(g,i){var r=this,l=this.tracks[g.level];l.textCodec||Object(_.parseIMSC1)(i,this.initPTS[g.cc],this.timescale[g.cc],function(){l.textCodec=_.IMSC1_CODEC,r._parseIMSC1(g,i)},function(){l.textCodec="wvtt"})},o._appendCues=function(g,i){var r=this.hls;if(this.config.renderTextTracksNatively){var l=this.textTracks[i];if(!l||l.mode==="disabled")return;g.forEach(function(a){return Object(O.addCueToTrack)(l,a)})}else{var c=this.tracks[i];if(!c)return;var t=c.default?"default":"subtitles"+i;r.trigger(L.Events.CUES_PARSED,{type:"subtitles",cues:g,track:t})}},o.onFragDecrypted=function(g,i){var r=i.frag;if(r.type===T.PlaylistLevelType.SUBTITLE){if(!Object(I.isFiniteNumber)(this.initPTS[r.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(L.Events.FRAG_LOADED,i)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(g,i){var r=this.cea608Parser1,l=this.cea608Parser2;if(!(!this.enabled||!(r&&l)))for(var c=0;c<i.samples.length;c++){var t=i.samples[c].bytes;if(t){var a=this.extractCea608Data(t);r.addData(i.samples[c].pts,a[0]),l.addData(i.samples[c].pts,a[1])}}},o.onBufferFlushing=function(g,i){var r=i.startOffset,l=i.endOffset,c=i.endOffsetSubtitles,t=i.type,a=this.media;if(!(!a||a.currentTime<l)){if(!t||t==="video"){var u=this.captionsTracks;Object.keys(u).forEach(function(f){return Object(O.removeCuesInRange)(u[f],r,l)})}if(this.config.renderTextTracksNatively&&r===0&&c!==void 0){var s=this.textTracks;Object.keys(s).forEach(function(f){return Object(O.removeCuesInRange)(s[f],r,c)})}}},o.extractCea608Data=function(g){for(var i=[[],[]],r=g[0]&31,l=2,c=0;c<r;c++){var t=g[l++],a=127&g[l++],u=127&g[l++];if(!(a===0&&u===0)){var s=(4&t)!==0;if(s){var f=3&t;(f===0||f===1)&&(i[f].push(a),i[f].push(u))}}}return i},e}();function m(e,o){return e&&e.label===o.name&&!(e.textTrack1||e.textTrack2)}function p(e,o,h,g){return Math.min(o,g)-Math.max(e,h)}function d(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return I});var I=function(){function L(w,R){this.subtle=void 0,this.aesIV=void 0,this.subtle=w,this.aesIV=R}var D=L.prototype;return D.decrypt=function(R,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,R)},L}()},"./src/crypt/aes-decryptor.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"removePadding",function(){return L}),n.d(b,"default",function(){return D});var I=n("./src/utils/typed-array.ts");function L(w){var R=w.byteLength,O=R&&new DataView(w.buffer).getUint8(R-1);return O?Object(I.sliceUint8)(w,0,R-O):w}var D=function(){function w(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var R=w.prototype;return R.uint8ArrayToUint32Array_=function(_){for(var y=new DataView(_),T=new Uint32Array(4),A=0;A<4;A++)T[A]=y.getUint32(A*4);return T},R.initTable=function(){var _=this.sBox,y=this.invSBox,T=this.subMix,A=T[0],E=T[1],m=T[2],p=T[3],d=this.invSubMix,e=d[0],o=d[1],h=d[2],g=d[3],i=new Uint32Array(256),r=0,l=0,c=0;for(c=0;c<256;c++)c<128?i[c]=c<<1:i[c]=c<<1^283;for(c=0;c<256;c++){var t=l^l<<1^l<<2^l<<3^l<<4;t=t>>>8^t&255^99,_[r]=t,y[t]=r;var a=i[r],u=i[a],s=i[u],f=i[t]*257^t*16843008;A[r]=f<<24|f>>>8,E[r]=f<<16|f>>>16,m[r]=f<<8|f>>>24,p[r]=f,f=s*16843009^u*65537^a*257^r*16843008,e[t]=f<<24|f>>>8,o[t]=f<<16|f>>>16,h[t]=f<<8|f>>>24,g[t]=f,r?(r=a^i[i[i[s^a]]],l^=i[i[l]]):r=l=1}},R.expandKey=function(_){for(var y=this.uint8ArrayToUint32Array_(_),T=!0,A=0;A<y.length&&T;)T=y[A]===this.key[A],A++;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,d,e=this.keySchedule=new Uint32Array(m),o=this.invKeySchedule=new Uint32Array(m),h=this.sBox,g=this.rcon,i=this.invSubMix,r=i[0],l=i[1],c=i[2],t=i[3],a,u;for(p=0;p<m;p++){if(p<E){a=e[p]=y[p];continue}u=a,p%E===0?(u=u<<8|u>>>24,u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255],u^=g[p/E|0]<<24):E>6&&p%E===4&&(u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255]),e[p]=a=(e[p-E]^u)>>>0}for(d=0;d<m;d++)p=m-d,d&3?u=e[p]:u=e[p-4],d<4||p<=4?o[d]=u:o[d]=r[h[u>>>24]]^l[h[u>>>16&255]]^c[h[u>>>8&255]]^t[h[u&255]],o[d]=o[d]>>>0}},R.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},R.decrypt=function(_,y,T){for(var A=this.keySize+6,E=this.invKeySchedule,m=this.invSBox,p=this.invSubMix,d=p[0],e=p[1],o=p[2],h=p[3],g=this.uint8ArrayToUint32Array_(T),i=g[0],r=g[1],l=g[2],c=g[3],t=new Int32Array(_),a=new Int32Array(t.length),u,s,f,v,S,x,P,B,k,U,W,H,z,Y,J=this.networkToHostOrderSwap;y<t.length;){for(k=J(t[y]),U=J(t[y+1]),W=J(t[y+2]),H=J(t[y+3]),S=k^E[0],x=H^E[1],P=W^E[2],B=U^E[3],z=4,Y=1;Y<A;Y++)u=d[S>>>24]^e[x>>16&255]^o[P>>8&255]^h[B&255]^E[z],s=d[x>>>24]^e[P>>16&255]^o[B>>8&255]^h[S&255]^E[z+1],f=d[P>>>24]^e[B>>16&255]^o[S>>8&255]^h[x&255]^E[z+2],v=d[B>>>24]^e[S>>16&255]^o[x>>8&255]^h[P&255]^E[z+3],S=u,x=s,P=f,B=v,z=z+4;u=m[S>>>24]<<24^m[x>>16&255]<<16^m[P>>8&255]<<8^m[B&255]^E[z],s=m[x>>>24]<<24^m[P>>16&255]<<16^m[B>>8&255]<<8^m[S&255]^E[z+1],f=m[P>>>24]<<24^m[B>>16&255]<<16^m[S>>8&255]<<8^m[x&255]^E[z+2],v=m[B>>>24]<<24^m[S>>16&255]<<16^m[x>>8&255]<<8^m[P&255]^E[z+3],a[y]=J(u^i),a[y+1]=J(v^r),a[y+2]=J(f^l),a[y+3]=J(s^c),i=k,r=U,l=W,c=H,y=y+4}return a.buffer},w}()},"./src/crypt/decrypter.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return y});var I=n("./src/crypt/aes-crypto.ts"),L=n("./src/crypt/fast-aes-key.ts"),D=n("./src/crypt/aes-decryptor.ts"),w=n("./src/utils/logger.ts"),R=n("./src/utils/mp4-tools.ts"),O=n("./src/utils/typed-array.ts"),_=16,y=function(){function T(E,m,p){var d=p===void 0?{}:p,e=d.removePKCS7Padding,o=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=o,o)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var A=T.prototype;return A.destroy=function(){this.observer=null},A.isSync=function(){return this.config.enableSoftwareAES},A.flush=function(){var m=this.currentResult;if(!m){this.reset();return}var p=new Uint8Array(m);return this.reset(),this.removePKCS7Padding?Object(D.removePadding)(p):p},A.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},A.decrypt=function(m,p,d,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(m),p,d);var o=this.flush();o&&e(o.buffer)}else this.webCryptoDecrypt(new Uint8Array(m),p,d).then(e)},A.softwareDecrypt=function(m,p,d){var e=this.currentIV,o=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(m=Object(R.appendUint8Array)(h,m),this.remainderData=null);var g=this.getValidChunk(m);if(!g.length)return null;e&&(d=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new D.default),i.expandKey(p);var r=o;return this.currentResult=i.decrypt(g.buffer,0,d),this.currentIV=Object(O.sliceUint8)(g,-16).buffer,r||null},A.webCryptoDecrypt=function(m,p,d){var e=this,o=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new L.default(o,p)),this.fastAesKey.expandKey().then(function(h){if(!o)return Promise.reject(new Error("web crypto not initialized"));var g=new I.default(o,d);return g.decrypt(m.buffer,h)}).catch(function(h){return e.onWebCryptoError(h,m,p,d)})},A.onWebCryptoError=function(m,p,d,e){return w.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",m),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(p,d,e)},A.getValidChunk=function(m){var p=m,d=m.length-m.length%_;return d!==m.length&&(p=Object(O.sliceUint8)(m,0,d),this.remainderData=Object(O.sliceUint8)(m,d)),p},A.logOnce=function(m){!this.logEnabled||(w.logger.log("[decrypter.ts]: "+m),this.logEnabled=!1)},T}()},"./src/crypt/fast-aes-key.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return I});var I=function(){function L(w,R){this.subtle=void 0,this.key=void 0,this.subtle=w,this.key=R}var D=L.prototype;return D.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},L}()},"./src/demux/aacdemuxer.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/demux/base-audio-demuxer.ts"),L=n("./src/demux/adts.ts"),D=n("./src/utils/logger.ts"),w=n("./src/demux/id3.ts");function R(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 _=function(y){R(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 A=T.prototype;return A.resetInitSegment=function(m,p,d,e){y.prototype.resetInitSegment.call(this,m,p,d,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=w.getID3Data(m,0)||[],d=p.length,e=m.length;d<e;d++)if(L.probe(m,d))return D.logger.log("ADTS sync word found !"),!0;return!1},A.canParse=function(m,p){return L.canParse(m,p)},A.appendFrame=function(m,p,d){L.initTrackConfig(m,this.observer,p,d,m.manifestCodec);var e=L.appendFrame(m,p,d,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},T}(I.default);b.default=_},"./src/demux/adts.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"getAudioConfig",function(){return w}),n.d(b,"isHeaderPattern",function(){return R}),n.d(b,"getHeaderLength",function(){return O}),n.d(b,"getFullFrameLength",function(){return _}),n.d(b,"canGetFrameLength",function(){return y}),n.d(b,"isHeader",function(){return T}),n.d(b,"canParse",function(){return A}),n.d(b,"probe",function(){return E}),n.d(b,"initTrackConfig",function(){return m}),n.d(b,"getFrameDuration",function(){return p}),n.d(b,"parseFrameHeader",function(){return d}),n.d(b,"appendFrame",function(){return e});var I=n("./src/utils/logger.ts"),L=n("./src/errors.ts"),D=n("./src/events.ts");function w(o,h,g,i){var r,l,c,t,a=navigator.userAgent.toLowerCase(),u=i,s=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((h[g+2]&192)>>>6)+1;var f=(h[g+2]&60)>>>2;if(f>s.length-1){o.trigger(D.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+f});return}return c=(h[g+2]&1)<<2,c|=(h[g+3]&192)>>>6,I.logger.log("manifest codec:"+i+", ADTS type:"+r+", samplingIndex:"+f),/firefox/i.test(a)?f>=6?(r=5,t=new Array(4),l=f-3):(r=2,t=new Array(2),l=f):a.indexOf("android")!==-1?(r=2,t=new Array(2),l=f):(r=5,t=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&f>=6?l=f-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(f>=6&&c===1||/vivaldi/i.test(a))||!i&&c===1)&&(r=2,t=new Array(2)),l=f)),t[0]=r<<3,t[0]|=(f&14)>>1,t[1]|=(f&1)<<7,t[1]|=c<<3,r===5&&(t[1]|=(l&14)>>1,t[2]=(l&1)<<7,t[2]|=2<<2,t[3]=0),{config:t,samplerate:s[f],channelCount:c,codec:"mp4a.40."+r,manifestCodec:u}}function R(o,h){return o[h]===255&&(o[h+1]&246)===240}function O(o,h){return o[h+1]&1?7:9}function _(o,h){return(o[h+3]&3)<<11|o[h+4]<<3|(o[h+5]&224)>>>5}function y(o,h){return h+5<o.length}function T(o,h){return h+1<o.length&&R(o,h)}function A(o,h){return y(o,h)&&R(o,h)&&_(o,h)<=o.length-h}function E(o,h){if(T(o,h)){var g=O(o,h);if(h+g>=o.length)return!1;var i=_(o,h);if(i<=g)return!1;var r=h+i;return r===o.length||T(o,r)}return!1}function m(o,h,g,i,r){if(!o.samplerate){var l=w(h,g,i,r);if(!l)return;o.config=l.config,o.samplerate=l.samplerate,o.channelCount=l.channelCount,o.codec=l.codec,o.manifestCodec=l.manifestCodec,I.logger.log("parsed codec:"+o.codec+", rate:"+l.samplerate+", channels:"+l.channelCount)}}function p(o){return 1024*9e4/o}function d(o,h){var g=O(o,h);if(h+g<=o.length){var i=_(o,h)-g;if(i>0)return{headerLength:g,frameLength:i}}}function e(o,h,g,i,r){var l=p(o.samplerate),c=i+r*l,t=d(h,g),a;if(t){var u=t.frameLength,s=t.headerLength,f=s+u,v=Math.max(0,g+f-h.length);v?(a=new Uint8Array(f-s),a.set(h.subarray(g+s,h.length),0)):a=h.subarray(g+s,g+f);var S={unit:a,pts:c};return v||o.samples.push(S),{sample:S,length:f,missing:v}}var x=h.length-g;a=new Uint8Array(x),a.set(h.subarray(g,h.length),0);var P={unit:a,pts:c};return{sample:P,length:x,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"initPTSFn",function(){return y});var I=n("./src/polyfills/number.ts"),L=n("./src/demux/id3.ts"),D=n("./src/types/demuxer.ts"),w=n("./src/demux/dummy-demuxed-track.ts"),R=n("./src/utils/mp4-tools.ts"),O=n("./src/utils/typed-array.ts"),_=function(){function T(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var A=T.prototype;return A.resetInitSegment=function(m,p,d,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},A.resetTimeStamp=function(m){this.initPTS=m,this.resetContiguity()},A.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},A.canParse=function(m,p){return!1},A.appendFrame=function(m,p,d){},A.demux=function(m,p){this.cachedData&&(m=Object(R.appendUint8Array)(this.cachedData,m),this.cachedData=null);var d=L.getID3Data(m,0),e=d?d.length:0,o,h,g=this._audioTrack,i=this._id3Track,r=d?L.getTimeStamp(d):void 0,l=m.length;for((this.basePTS===null||this.frameIndex===0&&Object(I.isFiniteNumber)(r))&&(this.basePTS=y(r,p,this.initPTS)),d&&d.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:d,type:D.MetadataSchema.audioId3}),h=this.basePTS;e<l;){if(this.canParse(m,e)){var c=this.appendFrame(g,m,e);c?(this.frameIndex++,h=c.sample.pts,e+=c.length,o=e):e=l}else L.canParse(m,e)?(d=L.getID3Data(m,e),i.samples.push({pts:h,dts:h,data:d,type:D.MetadataSchema.audioId3}),e+=d.length,o=e):e++;if(e===l&&o!==l){var t=Object(O.sliceUint8)(m,o);this.cachedData?this.cachedData=Object(R.appendUint8Array)(this.cachedData,t):this.cachedData=t}}return{audioTrack:g,videoTrack:Object(w.dummyTrack)(),id3Track:i,textTrack:Object(w.dummyTrack)()}},A.demuxSampleAes=function(m,p,d){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},A.flush=function(m){var p=this.cachedData;return p&&(this.cachedData=null,this.demux(p,0)),{audioTrack:this._audioTrack,videoTrack:Object(w.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(w.dummyTrack)()}},A.destroy=function(){},T}(),y=function(A,E,m){return Object(I.isFiniteNumber)(A)?A*90:E*9e4+(m||0)};b.default=_},"./src/demux/chunk-cache.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return I});var I=function(){function D(){this.chunks=[],this.dataLength=0}var w=D.prototype;return w.push=function(O){this.chunks.push(O),this.dataLength+=O.length},w.flush=function(){var O=this.chunks,_=this.dataLength,y;if(O.length)O.length===1?y=O[0]:y=L(O,_);else return new Uint8Array(0);return this.reset(),y},w.reset=function(){this.chunks.length=0,this.dataLength=0},D}();function L(D,w){for(var R=new Uint8Array(w),O=0,_=0;_<D.length;_++){var y=D[_];R.set(y,O),O+=y.length}return R}},"./src/demux/dummy-demuxed-track.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"dummyTrack",function(){return I});function I(L,D){return L===void 0&&(L=""),D===void 0&&(D=9e4),{type:L,id:-1,pid:-1,inputTimeScale:D,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/utils/logger.ts"),L=function(){function D(R){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=R,this.bytesAvailable=R.byteLength,this.word=0,this.bitsAvailable=0}var w=D.prototype;return w.loadWord=function(){var O=this.data,_=this.bytesAvailable,y=O.byteLength-_,T=new Uint8Array(4),A=Math.min(4,_);if(A===0)throw new Error("no bytes available");T.set(O.subarray(y,y+A)),this.word=new DataView(T.buffer).getUint32(0),this.bitsAvailable=A*8,this.bytesAvailable-=A},w.skipBits=function(O){var _;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,_=O>>3,O-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},w.readBits=function(O){var _=Math.min(this.bitsAvailable,O),y=this.word>>>32-_;return O>32&&I.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),_=O-_,_>0&&this.bitsAvailable?y<<_|this.readBits(_):y},w.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()},w.skipUEG=function(){this.skipBits(1+this.skipLZ())},w.skipEG=function(){this.skipBits(1+this.skipLZ())},w.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},w.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},w.readBoolean=function(){return this.readBits(1)===1},w.readUByte=function(){return this.readBits(8)},w.readUShort=function(){return this.readBits(16)},w.readUInt=function(){return this.readBits(32)},w.skipScalingList=function(O){for(var _=8,y=8,T,A=0;A<O;A++)y!==0&&(T=this.readEG(),y=(_+T+256)%256),_=y===0?_:y},w.readSPS=function(){var O=0,_=0,y=0,T=0,A,E,m,p=this.readUByte.bind(this),d=this.readBits.bind(this),e=this.readUEG.bind(this),o=this.readBoolean.bind(this),h=this.skipBits.bind(this),g=this.skipEG.bind(this),i=this.skipUEG.bind(this),r=this.skipScalingList.bind(this);p();var l=p();if(d(5),h(3),p(),i(),l===100||l===110||l===122||l===244||l===44||l===83||l===86||l===118||l===128){var c=e();if(c===3&&h(1),i(),i(),h(1),o())for(E=c!==3?8:12,m=0;m<E;m++)o()&&(m<6?r(16):r(64))}i();var t=e();if(t===0)e();else if(t===1)for(h(1),g(),g(),A=e(),m=0;m<A;m++)g();i(),h(1);var a=e(),u=e(),s=d(1);s===0&&h(1),h(1),o()&&(O=e(),_=e(),y=e(),T=e());var f=[1,1];if(o()&&o()){var v=p();switch(v){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((a+1)*16-O*2-_*2),height:(2-s)*(u+1)*16-(s?2:4)*(y+T),pixelRatio:f}},w.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},D}();b.default=L},"./src/demux/id3.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"isHeader",function(){return I}),n.d(b,"isFooter",function(){return L}),n.d(b,"getID3Data",function(){return D}),n.d(b,"canParse",function(){return R}),n.d(b,"getTimeStamp",function(){return O}),n.d(b,"isTimeStampFrame",function(){return _}),n.d(b,"getID3Frames",function(){return T}),n.d(b,"decodeFrame",function(){return A}),n.d(b,"utf8ArrayToStr",function(){return e}),n.d(b,"testables",function(){return o});var I=function(r,l){return l+10<=r.length&&r[l]===73&&r[l+1]===68&&r[l+2]===51&&r[l+3]<255&&r[l+4]<255&&r[l+6]<128&&r[l+7]<128&&r[l+8]<128&&r[l+9]<128},L=function(r,l){return l+10<=r.length&&r[l]===51&&r[l+1]===68&&r[l+2]===73&&r[l+3]<255&&r[l+4]<255&&r[l+6]<128&&r[l+7]<128&&r[l+8]<128&&r[l+9]<128},D=function(r,l){for(var c=l,t=0;I(r,l);){t+=10;var a=w(r,l+6);t+=a,L(r,l+10)&&(t+=10),l+=t}if(t>0)return r.subarray(c,c+t)},w=function(r,l){var c=0;return c=(r[l]&127)<<21,c|=(r[l+1]&127)<<14,c|=(r[l+2]&127)<<7,c|=r[l+3]&127,c},R=function(r,l){return I(r,l)&&w(r,l+6)+10<=r.length-l},O=function(r){for(var l=T(r),c=0;c<l.length;c++){var t=l[c];if(_(t))return d(t)}},_=function(r){return r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp"},y=function(r){var l=String.fromCharCode(r[0],r[1],r[2],r[3]),c=w(r,4),t=10;return{type:l,size:c,data:r.subarray(t,t+c)}},T=function(r){for(var l=0,c=[];I(r,l);){var t=w(r,l+6);l+=10;for(var a=l+t;l+8<a;){var u=y(r.subarray(l)),s=A(u);s&&c.push(s),l+=u.size+10}L(r,l)&&(l+=10)}return c},A=function(r){return r.type==="PRIV"?E(r):r.type[0]==="W"?p(r):m(r)},E=function(r){if(!(r.size<2)){var l=e(r.data,!0),c=new Uint8Array(r.data.subarray(l.length+1));return{key:r.type,info:l,data:c.buffer}}},m=function(r){if(!(r.size<2)){if(r.type==="TXXX"){var l=1,c=e(r.data.subarray(l),!0);l+=c.length+1;var t=e(r.data.subarray(l));return{key:r.type,info:c,data:t}}var a=e(r.data.subarray(1));return{key:r.type,data:a}}},p=function(r){if(r.type==="WXXX"){if(r.size<2)return;var l=1,c=e(r.data.subarray(l),!0);l+=c.length+1;var t=e(r.data.subarray(l));return{key:r.type,info:c,data:t}}var a=e(r.data);return{key:r.type,data:a}},d=function(r){if(r.data.byteLength===8){var l=new Uint8Array(r.data),c=l[3]&1,t=(l[4]<<23)+(l[5]<<15)+(l[6]<<7)+l[7];return t/=45,c&&(t+=4772185884e-2),Math.round(t)}},e=function(r,l){l===void 0&&(l=!1);var c=g();if(c){var t=c.decode(r);if(l){var a=t.indexOf("\0");return a!==-1?t.substring(0,a):t}return t.replace(/\0/g,"")}for(var u=r.length,s,f,v,S="",x=0;x<u;){if(s=r[x++],s===0&&l)return S;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(s);break;case 12:case 13:f=r[x++],S+=String.fromCharCode((s&31)<<6|f&63);break;case 14:f=r[x++],v=r[x++],S+=String.fromCharCode((s&15)<<12|(f&63)<<6|(v&63)<<0);break;default:}}return S},o={decodeTextFrame:m},h;function g(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/demux/base-audio-demuxer.ts"),L=n("./src/demux/id3.ts"),D=n("./src/utils/logger.ts"),w=n("./src/demux/mpegaudio.ts");function R(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 _=function(y){R(T,y);function T(){return y.apply(this,arguments)||this}var A=T.prototype;return A.resetInitSegment=function(m,p,d,e){y.prototype.resetInitSegment.call(this,m,p,d,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=L.getID3Data(m,0)||[],d=p.length,e=m.length;d<e;d++)if(w.probe(m,d))return D.logger.log("MPEG Audio sync word found !"),!0;return!1},A.canParse=function(m,p){return w.canParse(m,p)},A.appendFrame=function(m,p,d){if(this.basePTS!==null)return w.appendFrame(m,p,d,this.basePTS,this.frameIndex)},T}(I.default);b.default=_},"./src/demux/mp4demuxer.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/polyfills/number.ts"),L=n("./src/types/demuxer.ts"),D=n("./src/utils/mp4-tools.ts"),w=n("./src/demux/dummy-demuxed-track.ts"),R=/\/emsg[-/]ID3/i,O=function(){function _(T,A){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=A}var y=_.prototype;return y.resetTimeStamp=function(){},y.resetInitSegment=function(A,E,m,p){var d=Object(D.parseInitSegment)(A),e=this.videoTrack=Object(w.dummyTrack)("video",1),o=this.audioTrack=Object(w.dummyTrack)("audio",1),h=this.txtTrack=Object(w.dummyTrack)("text",1);if(this.id3Track=Object(w.dummyTrack)("id3",1),this.timeOffset=0,d.video){var g=d.video,i=g.id,r=g.timescale,l=g.codec;e.id=i,e.timescale=h.timescale=r,e.codec=l}if(d.audio){var c=d.audio,t=c.id,a=c.timescale,u=c.codec;o.id=t,o.timescale=a,o.codec=u}h.id=D.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=o.duration=p},y.resetContiguity=function(){},_.probe=function(A){return A=A.length>16384?A.subarray(0,16384):A,Object(D.findBox)(A,["moof"]).length>0},y.demux=function(A,E){this.timeOffset=E;var m=A,p=this.videoTrack,d=this.txtTrack;if(this.config.progressive){this.remainderData&&(m=Object(D.appendUint8Array)(this.remainderData,A));var e=Object(D.segmentValidRange)(m);this.remainderData=e.remainder,p.samples=e.valid||new Uint8Array}else p.samples=m;var o=this.extractID3Track(p,E);return d.samples=Object(D.parseSamples)(E,p),{videoTrack:p,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},y.flush=function(){var A=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(D.parseSamples)(A,E),{videoTrack:E,audioTrack:Object(w.dummyTrack)(),id3Track:p,textTrack:Object(w.dummyTrack)()}},y.extractID3Track=function(A,E){var m=this.id3Track;if(A.samples.length){var p=Object(D.findBox)(A.samples,["emsg"]);p&&p.forEach(function(d){var e=Object(D.parseEmsg)(d);if(R.test(e.schemeIdUri)){var o=Object(I.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:E+e.presentationTimeDelta/e.timeScale,h=e.payload;m.samples.push({data:h,len:h.byteLength,dts:o,pts:o,type:L.MetadataSchema.emsg})}})}return m},y.demuxSampleAes=function(A,E,m){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},y.destroy=function(){},_}();b.default=O},"./src/demux/mpegaudio.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"appendFrame",function(){return O}),n.d(b,"parseHeader",function(){return _}),n.d(b,"isHeaderPattern",function(){return y}),n.d(b,"isHeader",function(){return T}),n.d(b,"canParse",function(){return A}),n.d(b,"probe",function(){return E});var I=null,L=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],D=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],w=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],R=[0,1,1,4];function O(m,p,d,e,o){if(!(d+24>p.length)){var h=_(p,d);if(h&&d+h.frameLength<=p.length){var g=h.samplesPerFrame*9e4/h.sampleRate,i=e+o*g,r={unit:p.subarray(d,d+h.frameLength),pts:i,dts:i};return m.config=[],m.channelCount=h.channelCount,m.samplerate=h.sampleRate,m.samples.push(r),{sample:r,length:h.frameLength,missing:0}}}}function _(m,p){var d=m[p+1]>>3&3,e=m[p+1]>>1&3,o=m[p+2]>>4&15,h=m[p+2]>>2&3;if(d!==1&&o!==0&&o!==15&&h!==3){var g=m[p+2]>>1&1,i=m[p+3]>>6,r=d===3?3-e:e===3?3:4,l=L[r*14+o-1]*1e3,c=d===3?0:d===2?1:2,t=D[c*3+h],a=i===3?1:2,u=w[d][e],s=R[e],f=u*8*s,v=Math.floor(u*l/t+g)*s;if(I===null){var S=navigator.userAgent||"",x=S.match(/Chrome\/(\d+)/i);I=x?parseInt(x[1]):0}var P=!!I&&I<=87;return P&&e===2&&l>=224e3&&i===0&&(m[p+3]=m[p+3]|128),{sampleRate:t,channelCount:a,frameLength:v,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 A(m,p){var d=4;return y(m,p)&&d<=m.length-p}function E(m,p){if(p+1<m.length&&y(m,p)){var d=4,e=_(m,p),o=d;e!=null&&e.frameLength&&(o=e.frameLength);var h=p+o;return h===m.length||T(m,h)}return!1}},"./src/demux/sample-aes.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/crypt/decrypter.ts"),L=n("./src/demux/tsdemuxer.ts"),D=function(){function w(O,_,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new I.default(O,_,{removePKCS7Padding:!1})}var R=w.prototype;return R.decryptBuffer=function(_,y){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,y)},R.decryptAacSample=function(_,y,T,A){var E=_[y].unit;if(!(E.length<=16)){var m=E.subarray(16,E.length-E.length%16),p=m.buffer.slice(m.byteOffset,m.byteOffset+m.length),d=this;this.decryptBuffer(p,function(e){var o=new Uint8Array(e);E.set(o,16),A||d.decryptAacSamples(_,y+1,T)})}},R.decryptAacSamples=function(_,y,T){for(;;y++){if(y>=_.length){T();return}if(!(_[y].unit.length<32)){var A=this.decrypter.isSync();if(this.decryptAacSample(_,y,T,A),!A)return}}},R.getAvcEncryptedData=function(_){for(var y=Math.floor((_.length-48)/160)*16+16,T=new Int8Array(y),A=0,E=32;E<_.length-16;E+=160,A+=16)T.set(_.subarray(E,E+16),A);return T},R.getAvcDecryptedUnit=function(_,y){for(var T=new Uint8Array(y),A=0,E=32;E<_.length-16;E+=160,A+=16)_.set(T.subarray(A,A+16),E);return _},R.decryptAvcSample=function(_,y,T,A,E,m){var p=Object(L.discardEPB)(E.data),d=this.getAvcEncryptedData(p),e=this;this.decryptBuffer(d.buffer,function(o){E.data=e.getAvcDecryptedUnit(p,o),m||e.decryptAvcSamples(_,y,T+1,A)})},R.decryptAvcSamples=function(_,y,T,A){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,T=0){if(y>=_.length){A();return}for(var E=_[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(_,y,T,A,m,p),!p)return}}}},w}();b.default=D},"./src/demux/transmuxer-interface.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return E});var I=n("./node_modules/webworkify-webpack/index.js"),L=n.n(I),D=n("./src/events.ts"),w=n("./src/demux/transmuxer.ts"),R=n("./src/utils/logger.ts"),O=n("./src/errors.ts"),_=n("./src/utils/mediasource-helper.ts"),y=n("./node_modules/eventemitter3/index.js"),T=n.n(y),A=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},E=function(){function m(d,e,o,h){var g=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=d,this.id=e,this.onTransmuxComplete=o,this.onFlush=h;var i=d.config,r=function(u,s){s=s||{},s.frag=g.frag,s.id=g.id,d.trigger(u,s)};this.observer=new y.EventEmitter,this.observer.on(D.Events.FRAG_DECRYPTED,r),this.observer.on(D.Events.ERROR,r);var l={mp4:A.isTypeSupported("video/mp4"),mpeg:A.isTypeSupported("audio/mpeg"),mp3:A.isTypeSupported('audio/mp4; codecs="mp3"')},c=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){R.logger.log("demuxing in webworker");var t;try{t=this.worker=I("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),t.addEventListener("message",this.onwmsg),t.onerror=function(a){d.trigger(D.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(a.message+" ("+a.filename+":"+a.lineno+")")})},t.postMessage({cmd:"init",typeSupported:l,vendor:c,id:e,config:JSON.stringify(i)})}catch(a){R.logger.warn("Error in worker:",a),R.logger.error("Error while initializing DemuxerWorker, fallback to inline"),t&&self.URL.revokeObjectURL(t.objectURL),this.transmuxer=new w.default(this.observer,l,i,c,e),this.worker=null}}else this.transmuxer=new w.default(this.observer,l,i,c,e)}var p=m.prototype;return p.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var o=this.transmuxer;o&&(o.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},p.push=function(e,o,h,g,i,r,l,c,t,a){var u,s,f=this;t.transmuxing.start=self.performance.now();var v=this.transmuxer,S=this.worker,x=r?r.start:i.start,P=i.decryptdata,B=this.frag,k=!(B&&i.cc===B.cc),U=!(B&&t.level===B.level),W=B?t.sn-B.sn:-1,H=this.part?t.part-this.part.index:-1,z=W===0&&t.id>1&&t.id===(B==null?void 0:B.stats.chunkCount),Y=!U&&(W===1||W===0&&(H===1||z&&H<=0)),J=self.performance.now();(U||W||i.stats.parsing.start===0)&&(i.stats.parsing.start=J),r&&(H||!Y)&&(r.stats.parsing.start=J);var te=!(B&&((u=i.initSegment)===null||u===void 0?void 0:u.url)===((s=B.initSegment)===null||s===void 0?void 0:s.url)),X=new w.TransmuxState(k,Y,c,U,x,te);if(!Y||k||te){R.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+t.sn+" p: "+t.part+" level: "+t.level+" id: "+t.id+`
|
|
15
|
-
discontinuity: `+
|
|
16
|
-
trackSwitch: `+
|
|
17
|
-
contiguous: `+
|
|
18
|
-
accurateTimeOffset: `+
|
|
19
|
-
timeOffset: `+
|
|
20
|
-
initSegmentChange: `+te);var q=new w.TransmuxConfig(h,g,o,l,a);this.configureTransmuxer(q)}if(this.frag=i,this.part=r,S)S.postMessage({cmd:"demux",data:e,decryptdata:P,chunkMeta:t,state:X},e instanceof ArrayBuffer?[e]:[]);else if(v){var ne=v.push(e,P,t,X);Object(w.isPromise)(ne)?ne.then(function(ae){f.handleTransmuxComplete(ae)}):this.handleTransmuxComplete(ne)}},p.flush=function(e){var o=this;e.transmuxing.start=self.performance.now();var h=this.transmuxer,g=this.worker;if(g)g.postMessage({cmd:"flush",chunkMeta:e});else if(h){var i=h.flush(e);Object(w.isPromise)(i)?i.then(function(r){o.handleFlushResult(r,e)}):this.handleFlushResult(i,e)}},p.handleFlushResult=function(e,o){var h=this;e.forEach(function(g){h.handleTransmuxComplete(g)}),this.onFlush(o)},p.onWorkerMessage=function(e){var o=e.data,h=this.hls;switch(o.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(o.data);break}case"flush":{this.onFlush(o.data);break}case"workerLog":R.logger[o.data.logType]&&R.logger[o.data.logType](o.data.message);break;default:{o.data=o.data||{},o.data.frag=this.frag,o.data.id=this.id,h.trigger(o.event,o.data);break}}},p.configureTransmuxer=function(e){var o=this.worker,h=this.transmuxer;o?o.postMessage({cmd:"configure",config:e}):h&&h.configure(e)},p.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},m}()},"./src/demux/transmuxer-worker.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return O});var I=n("./src/demux/transmuxer.ts"),L=n("./src/events.ts"),D=n("./src/utils/logger.ts"),w=n("./node_modules/eventemitter3/index.js"),R=n.n(w);function O(E){var m=new w.EventEmitter,p=function(o,h){E.postMessage({event:o,data:h})};m.on(L.Events.FRAG_DECRYPTED,p),m.on(L.Events.ERROR,p);var d=function(){var o=function(i){var r=function(c){p("workerLog",{logType:i,message:c})};D.logger[i]=r};for(var h in D.logger)o(h)};E.addEventListener("message",function(e){var o=e.data;switch(o.cmd){case"init":{var h=JSON.parse(o.config);E.transmuxer=new I.default(m,o.typeSupported,h,o.vendor,o.id),Object(D.enableLogs)(h.debug),d(),p("init",null);break}case"configure":{E.transmuxer.configure(o.config);break}case"demux":{var g=E.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(I.isPromise)(g)?g.then(function(l){_(E,l)}):_(E,g);break}case"flush":{var i=o.chunkMeta,r=E.transmuxer.flush(i);Object(I.isPromise)(r)?r.then(function(l){T(E,l,i)}):T(E,r,i);break}default:break}})}function _(E,m){if(A(m.remuxResult))return!1;var p=[],d=m.remuxResult,e=d.audio,o=d.video;return e&&y(p,e),o&&y(p,o),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 d=m.reduce(function(e,o){return _(E,o)||e},!1);d||E.postMessage({event:"transmuxComplete",data:m[0]}),E.postMessage({event:"flush",data:p})}function A(E){return!E.audio&&!E.video&&!E.text&&!E.id3&&!E.initSegment}},"./src/demux/transmuxer.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return p}),n.d(b,"isPromise",function(){return o}),n.d(b,"TransmuxConfig",function(){return h}),n.d(b,"TransmuxState",function(){return g});var I=n("./src/events.ts"),L=n("./src/errors.ts"),D=n("./src/crypt/decrypter.ts"),w=n("./src/demux/aacdemuxer.ts"),R=n("./src/demux/mp4demuxer.ts"),O=n("./src/demux/tsdemuxer.ts"),_=n("./src/demux/mp3demuxer.ts"),y=n("./src/remux/mp4-remuxer.ts"),T=n("./src/remux/passthrough-remuxer.ts"),A=n("./src/utils/logger.ts"),E;try{E=self.performance.now.bind(self.performance)}catch{A.logger.debug("Unable to use Performance API on this environment"),E=self.Date.now}var m=[{demux:O.default,remux:y.default},{demux:R.default,remux:T.default},{demux:w.default,remux:y.default},{demux:_.default,remux:y.default}],p=function(){function i(l,c,t,a,u){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=l,this.typeSupported=c,this.config=t,this.vendor=a,this.id=u}var r=i.prototype;return r.configure=function(c){this.transmuxConfig=c,this.decrypter&&this.decrypter.reset()},r.push=function(c,t,a,u){var s=this,f=a.transmuxing;f.executeStart=E();var v=new Uint8Array(c),S=this.config,x=this.currentTransmuxState,P=this.transmuxConfig;u&&(this.currentTransmuxState=u);var B=u||x,k=B.contiguous,U=B.discontinuity,W=B.trackSwitch,H=B.accurateTimeOffset,z=B.timeOffset,Y=B.initSegmentChange,J=P.audioCodec,te=P.videoCodec,X=P.defaultInitPts,q=P.duration,ne=P.initSegmentData;(U||W||Y)&&this.resetInitSegment(ne,J,te,q),(U||Y)&&this.resetInitialTimestamp(X),k||this.resetContiguity();var ae=d(v,t);if(ae&&ae.method==="AES-128"){var re=this.getDecrypter();if(S.enableSoftwareAES){var le=re.softwareDecrypt(v,ae.key.buffer,ae.iv.buffer);if(!le)return f.executeEnd=E(),e(a);v=new Uint8Array(le)}else return this.decryptionPromise=re.webCryptoDecrypt(v,ae.key.buffer,ae.iv.buffer).then(function(ge){var pe=s.push(ge,null,a);return s.decryptionPromise=null,pe}),this.decryptionPromise}this.needsProbing(v,U,W)&&this.configureTransmuxer(v,P);var fe=this.transmux(v,ae,z,H,a),ie=this.currentTransmuxState;return ie.contiguous=!0,ie.discontinuity=!1,ie.trackSwitch=!1,f.executeEnd=E(),fe},r.flush=function(c){var t=this,a=c.transmuxing;a.executeStart=E();var u=this.decrypter,s=this.currentTransmuxState,f=this.decryptionPromise;if(f)return f.then(function(){return t.flush(c)});var v=[],S=s.timeOffset;if(u){var x=u.flush();x&&v.push(this.push(x,null,c))}var P=this.demuxer,B=this.remuxer;if(!P||!B)return this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),a.executeEnd=E(),[e(c)];var k=P.flush(S);return o(k)?k.then(function(U){return t.flushRemux(v,U,c),v}):(this.flushRemux(v,k,c),v)},r.flushRemux=function(c,t,a){var u=t.audioTrack,s=t.videoTrack,f=t.id3Track,v=t.textTrack,S=this.currentTransmuxState,x=S.accurateTimeOffset,P=S.timeOffset;A.logger.log("[transmuxer.ts]: Flushed fragment "+a.sn+(a.part>-1?" p: "+a.part:"")+" of level "+a.level);var B=this.remuxer.remux(u,s,f,v,P,x,!0,this.id);c.push({remuxResult:B,chunkMeta:a}),a.transmuxing.executeEnd=E()},r.resetInitialTimestamp=function(c){var t=this.demuxer,a=this.remuxer;!t||!a||(t.resetTimeStamp(c),a.resetTimeStamp(c))},r.resetContiguity=function(){var c=this.demuxer,t=this.remuxer;!c||!t||(c.resetContiguity(),t.resetNextTimestamp())},r.resetInitSegment=function(c,t,a,u){var s=this.demuxer,f=this.remuxer;!s||!f||(s.resetInitSegment(c,t,a,u),f.resetInitSegment(c,t,a))},r.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},r.transmux=function(c,t,a,u,s){var f;return t&&t.method==="SAMPLE-AES"?f=this.transmuxSampleAes(c,t,a,u,s):f=this.transmuxUnencrypted(c,a,u,s),f},r.transmuxUnencrypted=function(c,t,a,u){var s=this.demuxer.demux(c,t,!1,!this.config.progressive),f=s.audioTrack,v=s.videoTrack,S=s.id3Track,x=s.textTrack,P=this.remuxer.remux(f,v,S,x,t,a,!1,this.id);return{remuxResult:P,chunkMeta:u}},r.transmuxSampleAes=function(c,t,a,u,s){var f=this;return this.demuxer.demuxSampleAes(c,t,a).then(function(v){var S=f.remuxer.remux(v.audioTrack,v.videoTrack,v.id3Track,v.textTrack,a,u,!1,f.id);return{remuxResult:S,chunkMeta:s}})},r.configureTransmuxer=function(c,t){for(var a=this.config,u=this.observer,s=this.typeSupported,f=this.vendor,v=t.audioCodec,S=t.defaultInitPts,x=t.duration,P=t.initSegmentData,B=t.videoCodec,k,U=0,W=m.length;U<W;U++)if(m[U].demux.probe(c)){k=m[U];break}k||(A.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),k={demux:R.default,remux:T.default});var H=this.demuxer,z=this.remuxer,Y=k.remux,J=k.demux;(!z||!(z instanceof Y))&&(this.remuxer=new Y(u,a,s,f)),(!H||!(H instanceof J))&&(this.demuxer=new J(u,a,s),this.probe=J.probe),this.resetInitSegment(P,v,B,x),this.resetInitialTimestamp(S)},r.needsProbing=function(c,t,a){return!this.demuxer||!this.remuxer||t||a},r.getDecrypter=function(){var c=this.decrypter;return c||(c=this.decrypter=new D.default(this.observer,this.config)),c},i}();function d(i,r){var l=null;return i.byteLength>0&&r!=null&&r.key!=null&&r.iv!==null&&r.method!=null&&(l=r),l}var e=function(r){return{remuxResult:{},chunkMeta:r}};function o(i){return"then"in i&&i.then instanceof Function}var h=function(r,l,c,t,a){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=l,this.initSegmentData=c,this.duration=t,this.defaultInitPts=a},g=function(r,l,c,t,a,u){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=r,this.contiguous=l,this.accurateTimeOffset=c,this.trackSwitch=t,this.timeOffset=a,this.initSegmentChange=u}},"./src/demux/tsdemuxer.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"discardEPB",function(){return h});var I=n("./src/demux/adts.ts"),L=n("./src/demux/mpegaudio.ts"),D=n("./src/demux/exp-golomb.ts"),w=n("./src/demux/sample-aes.ts"),R=n("./src/events.ts"),O=n("./src/utils/mp4-tools.ts"),_=n("./src/utils/logger.ts"),y=n("./src/errors.ts"),T=n("./src/types/demuxer.ts");function A(){return A=Object.assign?Object.assign.bind():function(g){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var l in r)Object.prototype.hasOwnProperty.call(r,l)&&(g[l]=r[l])}return g},A.apply(this,arguments)}var E=function(){function g(r,l,c){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=r,this.config=l,this.typeSupported=c}g.probe=function(l){return l[0]===71&&l[188]===71},g.createTrack=function(l,c){return{container:l==="video"||l==="audio"?"video/mp2t":void 0,type:l,id:O.RemuxerTrackIdConfig[l],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:l==="audio"?c:void 0}};var i=g.prototype;return i.resetInitSegment=function(l,c,t,a){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=g.createTrack("video"),this._audioTrack=g.createTrack("audio",a),this._id3Track=g.createTrack("id3"),this._txtTrack=g.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=c,this.videoCodec=t,this._duration=a},i.resetTimeStamp=function(){},i.resetContiguity=function(){var l=this._audioTrack,c=this._avcTrack,t=this._id3Track;l&&(l.pesData=null),c&&(c.pesData=null),t&&(t.pesData=null),this.aacOverFlow=null},i.demux=function(l,c,t,a){t===void 0&&(t=!1),a===void 0&&(a=!1),t||(this.sampleAes=null);var u,s=this._avcTrack,f=this._audioTrack,v=this._id3Track,S=this._txtTrack,x=s.pid,P=s.pesData,B=f.pid,k=v.pid,U=f.pesData,W=v.pesData,H=null,z=this.pmtParsed,Y=this._pmtId,J=l.length;if(this.remainderData&&(l=Object(O.appendUint8Array)(this.remainderData,l),J=l.length,this.remainderData=null),J<188&&!a)return this.remainderData=l,{audioTrack:f,videoTrack:s,id3Track:v,textTrack:S};J-=J%188,J<l.byteLength&&!a&&(this.remainderData=new Uint8Array(l.buffer,J,l.buffer.byteLength-J));for(var te=0,X=0;X<J;X+=188)if(l[X]===71){var q=!!(l[X+1]&64),ne=((l[X+1]&31)<<8)+l[X+2],ae=(l[X+3]&48)>>4,re=void 0;if(ae>1){if(re=X+5+l[X+4],re===X+188)continue}else re=X+4;switch(ne){case x:q&&(P&&(u=e(P))&&this.parseAVCPES(s,S,u,!1),P={data:[],size:0}),P&&(P.data.push(l.subarray(re,X+188)),P.size+=X+188-re);break;case B:if(q){if(U&&(u=e(U)))switch(f.segmentCodec){case"aac":this.parseAACPES(f,u);break;case"mp3":this.parseMPEGPES(f,u);break}U={data:[],size:0}}U&&(U.data.push(l.subarray(re,X+188)),U.size+=X+188-re);break;case k:q&&(W&&(u=e(W))&&this.parseID3PES(v,u),W={data:[],size:0}),W&&(W.data.push(l.subarray(re,X+188)),W.size+=X+188-re);break;case 0:q&&(re+=l[re]+1),Y=this._pmtId=p(l,re);break;case Y:{q&&(re+=l[re]+1);var le=d(l,re,this.typeSupported,t);x=le.avc,x>0&&(s.pid=x),B=le.audio,B>0&&(f.pid=B,f.segmentCodec=le.segmentCodec),k=le.id3,k>0&&(v.pid=k),H!==null&&!z&&(_.logger.log("unknown PID '"+H+"' in TS found"),H=null),z=this.pmtParsed=!0;break}case 17:case 8191:break;default:H=ne;break}}else te++;te>0&&this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+te+" TS packet/s that do not start with 0x47"}),s.pesData=P,f.pesData=U,v.pesData=W;var fe={audioTrack:f,videoTrack:s,id3Track:v,textTrack:S};return a&&this.extractRemainingSamples(fe),fe},i.flush=function(){var l=this.remainderData;this.remainderData=null;var c;return l?c=this.demux(l,-1,!1,!0):c={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(c),this.sampleAes?this.decrypt(c,this.sampleAes):c},i.extractRemainingSamples=function(l){var c=l.audioTrack,t=l.videoTrack,a=l.id3Track,u=l.textTrack,s=t.pesData,f=c.pesData,v=a.pesData,S;if(s&&(S=e(s))?(this.parseAVCPES(t,u,S,!0),t.pesData=null):t.pesData=s,f&&(S=e(f))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,S);break;case"mp3":this.parseMPEGPES(c,S);break}c.pesData=null}else f!=null&&f.size&&_.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=f;v&&(S=e(v))?(this.parseID3PES(a,S),a.pesData=null):a.pesData=v},i.demuxSampleAes=function(l,c,t){var a=this.demux(l,t,!0,!this.config.progressive),u=this.sampleAes=new w.default(this.observer,this.config,c);return this.decrypt(a,u)},i.decrypt=function(l,c){return new Promise(function(t){var a=l.audioTrack,u=l.videoTrack;a.samples&&a.segmentCodec==="aac"?c.decryptAacSamples(a.samples,0,function(){u.samples?c.decryptAvcSamples(u.samples,0,0,function(){t(l)}):t(l)}):u.samples&&c.decryptAvcSamples(u.samples,0,0,function(){t(l)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(l,c,t,a){var u=this,s=this.parseAVCNALu(l,t.data),f=!1,v=this.avcSample,S,x=!1;t.data=null,v&&s.length&&!l.audFound&&(o(v,l),v=this.avcSample=m(!1,t.pts,t.dts,"")),s.forEach(function(P){switch(P.type){case 1:{S=!0,v||(v=u.avcSample=m(!0,t.pts,t.dts,"")),f&&(v.debug+="NDR "),v.frame=!0;var B=P.data;if(x&&B.length>4){var k=new D.default(B).readSliceType();(k===2||k===4||k===7||k===9)&&(v.key=!0)}break}case 5:S=!0,v||(v=u.avcSample=m(!0,t.pts,t.dts,"")),f&&(v.debug+="IDR "),v.key=!0,v.frame=!0;break;case 6:{S=!0,f&&v&&(v.debug+="SEI "),Object(O.parseSEIMessageFromNALu)(h(P.data),t.pts,c.samples);break}case 7:if(S=!0,x=!0,f&&v&&(v.debug+="SPS "),!l.sps){var U=new D.default(P.data),W=U.readSPS();l.width=W.width,l.height=W.height,l.pixelRatio=W.pixelRatio,l.sps=[P.data],l.duration=u._duration;for(var H=P.data.subarray(1,4),z="avc1.",Y=0;Y<3;Y++){var J=H[Y].toString(16);J.length<2&&(J="0"+J),z+=J}l.codec=z}break;case 8:S=!0,f&&v&&(v.debug+="PPS "),l.pps||(l.pps=[P.data]);break;case 9:S=!1,l.audFound=!0,v&&o(v,l),v=u.avcSample=m(!1,t.pts,t.dts,f?"AUD ":"");break;case 12:S=!0;break;default:S=!1,v&&(v.debug+="unknown NAL "+P.type+" ");break}if(v&&S){var te=v.units;te.push(P)}}),a&&v&&(o(v,l),this.avcSample=null)},i.getLastNalUnit=function(l){var c,t=this.avcSample,a;if((!t||t.units.length===0)&&(t=l[l.length-1]),(c=t)!==null&&c!==void 0&&c.units){var u=t.units;a=u[u.length-1]}return a},i.parseAVCNALu=function(l,c){var t=c.byteLength,a=l.naluState||0,u=a,s=[],f=0,v,S,x,P=-1,B=0;for(a===-1&&(P=0,B=c[0]&31,a=0,f=1);f<t;){if(v=c[f++],!a){a=v?0:1;continue}if(a===1){a=v?0:2;continue}if(!v)a=3;else if(v===1){if(P>=0){var k={data:c.subarray(P,f-a-1),type:B};s.push(k)}else{var U=this.getLastNalUnit(l.samples);if(U&&(u&&f<=4-u&&U.state&&(U.data=U.data.subarray(0,U.data.byteLength-u)),S=f-a-1,S>0)){var W=new Uint8Array(U.data.byteLength+S);W.set(U.data,0),W.set(c.subarray(0,S),U.data.byteLength),U.data=W,U.state=0}}f<t?(x=c[f]&31,P=f,B=x,a=0):a=-1}else a=0}if(P>=0&&a>=0){var H={data:c.subarray(P,t),type:B,state:a};s.push(H)}if(s.length===0){var z=this.getLastNalUnit(l.samples);if(z){var Y=new Uint8Array(z.data.byteLength+c.byteLength);Y.set(z.data,0),Y.set(c,z.data.byteLength),z.data=Y}}return l.naluState=a,s},i.parseAACPES=function(l,c){var t=0,a=this.aacOverFlow,u=c.data;if(a){this.aacOverFlow=null;var s=a.missing,f=a.sample.unit.byteLength;if(s===-1){var v=new Uint8Array(f+u.byteLength);v.set(a.sample.unit,0),v.set(u,f),u=v}else{var S=f-s;a.sample.unit.set(u.subarray(0,s),S),l.samples.push(a.sample),t=a.missing}}var x,P;for(x=t,P=u.length;x<P-1&&!I.isHeader(u,x);x++);if(x!==t){var B,k;if(x<P-1?(B="AAC PES did not start with ADTS header,offset:"+x,k=!1):(B="no ADTS header found in AAC PES",k=!0),_.logger.warn("parsing error:"+B),this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:k,reason:B}),k)return}I.initTrackConfig(l,this.observer,u,x,this.audioCodec);var U;if(c.pts!==void 0)U=c.pts;else if(a){var W=I.getFrameDuration(l.samplerate);U=a.sample.pts+W}else{_.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var H=0,z;x<P;)if(z=I.appendFrame(l,u,x,U,H),x+=z.length,z.missing){this.aacOverFlow=z;break}else for(H++;x<P-1&&!I.isHeader(u,x);x++);},i.parseMPEGPES=function(l,c){var t=c.data,a=t.length,u=0,s=0,f=c.pts;if(f===void 0){_.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;s<a;)if(L.isHeader(t,s)){var v=L.appendFrame(l,t,s,f,u);if(v)s+=v.length,u++;else break}else s++},i.parseID3PES=function(l,c){if(c.pts===void 0){_.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var t=A({},c,{type:this._avcTrack?T.MetadataSchema.emsg:T.MetadataSchema.audioId3});l.samples.push(t)},g}();function m(g,i,r,l){return{key:g,frame:!1,pts:i,dts:r,units:[],debug:l,length:0}}function p(g,i){return(g[i+10]&31)<<8|g[i+11]}function d(g,i,r,l){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},t=(g[i+1]&15)<<8|g[i+2],a=i+3+t-4,u=(g[i+10]&15)<<8|g[i+11];for(i+=12+u;i<a;){var s=(g[i+1]&31)<<8|g[i+2];switch(g[i]){case 207:if(!l){_.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=s);break;case 21:c.id3===-1&&(c.id3=s);break;case 219:if(!l){_.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=s);break;case 3:case 4:r.mpeg!==!0&&r.mp3!==!0?_.logger.log("MPEG audio found, not supported in this browser"):c.audio===-1&&(c.audio=s,c.segmentCodec="mp3");break;case 36:_.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((g[i+3]&15)<<8|g[i+4])+5}return c}function e(g){var i=0,r,l,c,t,a,u=g.data;if(!g||g.size===0)return null;for(;u[0].length<19&&u.length>1;){var s=new Uint8Array(u[0].length+u[1].length);s.set(u[0]),s.set(u[1],u[0].length),u[0]=s,u.splice(1,1)}r=u[0];var f=(r[0]<<16)+(r[1]<<8)+r[2];if(f===1){if(l=(r[4]<<8)+r[5],l&&l>g.size-6)return null;var v=r[7];v&192&&(t=(r[9]&14)*536870912+(r[10]&255)*4194304+(r[11]&254)*16384+(r[12]&255)*128+(r[13]&254)/2,v&64?(a=(r[14]&14)*536870912+(r[15]&255)*4194304+(r[16]&254)*16384+(r[17]&255)*128+(r[18]&254)/2,t-a>60*9e4&&(_.logger.warn(Math.round((t-a)/9e4)+"s delta between PTS and DTS, align them"),t=a)):a=t),c=r[8];var S=c+9;if(g.size<=S)return null;g.size-=S;for(var x=new Uint8Array(g.size),P=0,B=u.length;P<B;P++){r=u[P];var k=r.byteLength;if(S)if(S>k){S-=k;continue}else r=r.subarray(S),k-=S,S=0;x.set(r,i),i+=k}return l&&(l-=c+3),{data:x,pts:t,dts:a,len:l}}return null}function o(g,i){if(g.units.length&&g.frame){if(g.pts===void 0){var r=i.samples,l=r.length;if(l){var c=r[l-1];g.pts=c.pts,g.dts=c.dts}else{i.dropped++;return}}i.samples.push(g)}g.debug.length&&_.logger.log(g.pts+"/"+g.dts+":"+g.debug)}function h(g){for(var i=g.byteLength,r=[],l=1;l<i-2;)g[l]===0&&g[l+1]===0&&g[l+2]===3?(r.push(l+2),l+=2):l++;if(r.length===0)return g;var c=i-r.length,t=new Uint8Array(c),a=0;for(l=0;l<c;a++,l++)a===r[0]&&(a++,r.shift()),t[l]=g[a];return t}b.default=E},"./src/errors.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"ErrorTypes",function(){return I}),n.d(b,"ErrorDetails",function(){return L});var I;(function(D){D.NETWORK_ERROR="networkError",D.MEDIA_ERROR="mediaError",D.KEY_SYSTEM_ERROR="keySystemError",D.MUX_ERROR="muxError",D.OTHER_ERROR="otherError"})(I||(I={}));var L;(function(D){D.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",D.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",D.KEY_SYSTEM_NO_SESSION="keySystemNoSession",D.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",D.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",D.MANIFEST_LOAD_ERROR="manifestLoadError",D.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",D.MANIFEST_PARSING_ERROR="manifestParsingError",D.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",D.LEVEL_EMPTY_ERROR="levelEmptyError",D.LEVEL_LOAD_ERROR="levelLoadError",D.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",D.LEVEL_SWITCH_ERROR="levelSwitchError",D.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",D.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",D.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",D.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",D.FRAG_LOAD_ERROR="fragLoadError",D.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",D.FRAG_DECRYPT_ERROR="fragDecryptError",D.FRAG_PARSING_ERROR="fragParsingError",D.REMUX_ALLOC_ERROR="remuxAllocError",D.KEY_LOAD_ERROR="keyLoadError",D.KEY_LOAD_TIMEOUT="keyLoadTimeOut",D.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",D.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",D.BUFFER_APPEND_ERROR="bufferAppendError",D.BUFFER_APPENDING_ERROR="bufferAppendingError",D.BUFFER_STALLED_ERROR="bufferStalledError",D.BUFFER_FULL_ERROR="bufferFullError",D.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",D.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",D.INTERNAL_EXCEPTION="internalException",D.INTERNAL_ABORTED="aborted",D.UNKNOWN="unknown"})(L||(L={}))},"./src/events.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"Events",function(){return I});var I;(function(L){L.MEDIA_ATTACHING="hlsMediaAttaching",L.MEDIA_ATTACHED="hlsMediaAttached",L.MEDIA_DETACHING="hlsMediaDetaching",L.MEDIA_DETACHED="hlsMediaDetached",L.BUFFER_RESET="hlsBufferReset",L.BUFFER_CODECS="hlsBufferCodecs",L.BUFFER_CREATED="hlsBufferCreated",L.BUFFER_APPENDING="hlsBufferAppending",L.BUFFER_APPENDED="hlsBufferAppended",L.BUFFER_EOS="hlsBufferEos",L.BUFFER_FLUSHING="hlsBufferFlushing",L.BUFFER_FLUSHED="hlsBufferFlushed",L.MANIFEST_LOADING="hlsManifestLoading",L.MANIFEST_LOADED="hlsManifestLoaded",L.MANIFEST_PARSED="hlsManifestParsed",L.LEVEL_SWITCHING="hlsLevelSwitching",L.LEVEL_SWITCHED="hlsLevelSwitched",L.LEVEL_LOADING="hlsLevelLoading",L.LEVEL_LOADED="hlsLevelLoaded",L.LEVEL_UPDATED="hlsLevelUpdated",L.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",L.LEVELS_UPDATED="hlsLevelsUpdated",L.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",L.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",L.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",L.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",L.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",L.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",L.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",L.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",L.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",L.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",L.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",L.CUES_PARSED="hlsCuesParsed",L.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",L.INIT_PTS_FOUND="hlsInitPtsFound",L.FRAG_LOADING="hlsFragLoading",L.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",L.FRAG_LOADED="hlsFragLoaded",L.FRAG_DECRYPTED="hlsFragDecrypted",L.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",L.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",L.FRAG_PARSING_METADATA="hlsFragParsingMetadata",L.FRAG_PARSED="hlsFragParsed",L.FRAG_BUFFERED="hlsFragBuffered",L.FRAG_CHANGED="hlsFragChanged",L.FPS_DROP="hlsFpsDrop",L.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",L.ERROR="hlsError",L.DESTROYING="hlsDestroying",L.KEY_LOADING="hlsKeyLoading",L.KEY_LOADED="hlsKeyLoaded",L.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",L.BACK_BUFFER_REACHED="hlsBackBufferReached"})(I||(I={}))},"./src/hls.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return i});var I=n("./node_modules/url-toolkit/src/url-toolkit.js"),L=n.n(I),D=n("./src/loader/playlist-loader.ts"),w=n("./src/loader/key-loader.ts"),R=n("./src/controller/id3-track-controller.ts"),O=n("./src/controller/latency-controller.ts"),_=n("./src/controller/level-controller.ts"),y=n("./src/controller/fragment-tracker.ts"),T=n("./src/controller/stream-controller.ts"),A=n("./src/is-supported.ts"),E=n("./src/utils/logger.ts"),m=n("./src/config.ts"),p=n("./node_modules/eventemitter3/index.js"),d=n.n(p),e=n("./src/events.ts"),o=n("./src/errors.ts");function h(r,l){for(var c=0;c<l.length;c++){var t=l[c];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,t.key,t)}}function g(r,l,c){return l&&h(r.prototype,l),c&&h(r,c),Object.defineProperty(r,"prototype",{writable:!1}),r}var i=function(){r.isSupported=function(){return Object(A.isSupported)()};function r(c){c===void 0&&(c={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var t=this.config=Object(m.mergeConfig)(r.DefaultConfig,c);this.userConfig=c,Object(E.enableLogs)(t.debug),this._autoLevelCapping=-1,t.progressive&&Object(m.enableStreamingMode)(t);var a=t.abrController,u=t.bufferController,s=t.capLevelController,f=t.fpsController,v=this.abrController=new a(this),S=this.bufferController=new u(this),x=this.capLevelController=new s(this),P=new f(this),B=new D.default(this),k=new w.default(this),U=new R.default(this),W=this.levelController=new _.default(this),H=new y.FragmentTracker(this),z=this.streamController=new T.default(this,H);x.setStreamController(z),P.setStreamController(z);var Y=[B,k,W,z];this.networkControllers=Y;var J=[v,S,x,P,U,H];this.audioTrackController=this.createController(t.audioTrackController,null,Y),this.createController(t.audioStreamController,H,Y),this.subtitleTrackController=this.createController(t.subtitleTrackController,null,Y),this.createController(t.subtitleStreamController,H,Y),this.createController(t.timelineController,null,J),this.emeController=this.createController(t.emeController,null,J),this.cmcdController=this.createController(t.cmcdController,null,J),this.latencyController=this.createController(O.default,null,J),this.coreComponents=J}var l=r.prototype;return l.createController=function(t,a,u){if(t){var s=a?new t(this,a):new t(this);return u&&u.push(s),s}return null},l.on=function(t,a,u){u===void 0&&(u=this),this._emitter.on(t,a,u)},l.once=function(t,a,u){u===void 0&&(u=this),this._emitter.once(t,a,u)},l.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},l.off=function(t,a,u,s){u===void 0&&(u=this),this._emitter.off(t,a,u,s)},l.listeners=function(t){return this._emitter.listeners(t)},l.emit=function(t,a,u){return this._emitter.emit(t,a,u)},l.trigger=function(t,a){if(this.config.debug)return this.emit(t,t,a);try{return this.emit(t,t,a)}catch(u){E.logger.error("An internal error happened while handling event "+t+'. Error message: "'+u.message+'". Here is a stacktrace:',u),this.trigger(e.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:u})}return!1},l.listenerCount=function(t){return this._emitter.listenerCount(t)},l.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},l.attachMedia=function(t){E.logger.log("attachMedia"),this._media=t,this.trigger(e.Events.MEDIA_ATTACHING,{media:t})},l.detachMedia=function(){E.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},l.loadSource=function(t){this.stopLoad();var a=this.media,u=this.url,s=this.url=I.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});E.logger.log("loadSource:"+s),a&&u&&u!==s&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(a)),this.trigger(e.Events.MANIFEST_LOADING,{url:t})},l.startLoad=function(t){t===void 0&&(t=-1),E.logger.log("startLoad("+t+")"),this.networkControllers.forEach(function(a){a.startLoad(t)})},l.stopLoad=function(){E.logger.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},l.swapAudioCodec=function(){E.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},l.recoverMediaError=function(){E.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},l.removeLevel=function(t,a){a===void 0&&(a=0),this.levelController.removeLevel(t,a)},g(r,[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){E.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){E.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){E.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){E.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){E.logger.log("set startLevel:"+t),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var a=!!t;a!==this.config.capLevelToPlayerSize&&(a?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=a)}},{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,a=this.config.minAutoBitrate;if(!t)return 0;for(var u=t.length,s=0;s<u;s++)if(t[s].maxBitrate>=a)return s;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,a=this.autoLevelCapping,u;return a===-1&&t&&t.length?u=t.length-1:u=a,u}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var a=this.audioTrackController;a&&(a.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 a=this.subtitleTrackController;a&&(a.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 a=this.subtitleTrackController;a&&(a.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 o.ErrorTypes}},{key:"ErrorDetails",get:function(){return o.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,b,n){"use strict";n.r(b),n.d(b,"isSupported",function(){return D}),n.d(b,"changeTypeSupported",function(){return w});var I=n("./src/utils/mediasource-helper.ts");function L(){return self.SourceBuffer||self.WebKitSourceBuffer}function D(){var R=Object(I.getMediaSource)();if(!R)return!1;var O=L(),_=R&&typeof R.isTypeSupported=="function"&&R.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!_&&!!y}function w(){var R,O=L();return typeof(O==null||(R=O.prototype)===null||R===void 0?void 0:R.changeType)=="function"}},"./src/loader/date-range.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"DateRangeAttribute",function(){return _}),n.d(b,"DateRange",function(){return y});var I=n("./src/polyfills/number.ts"),L=n("./src/utils/attr-list.ts"),D=n("./src/utils/logger.ts");function w(){return w=Object.assign?Object.assign.bind():function(T){for(var A=1;A<arguments.length;A++){var E=arguments[A];for(var m in E)Object.prototype.hasOwnProperty.call(E,m)&&(T[m]=E[m])}return T},w.apply(this,arguments)}function R(T,A){for(var E=0;E<A.length;E++){var m=A[E];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(T,m.key,m)}}function O(T,A,E){return A&&R(T.prototype,A),E&&R(T,E),Object.defineProperty(T,"prototype",{writable:!1}),T}var _;(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"})(_||(_={}));var y=function(){function T(A,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(A,p)&&A[p]!==m[p]){D.logger.warn('DATERANGE tag attribute: "'+p+'" does not match for tags with ID: "'+A.ID+'"'),this._badValueForSameId=p;break}A=w(new L.AttrList({}),m,A)}if(this.attr=A,this._startDate=new Date(A[_.START_DATE]),_.END_DATE in this.attr){var d=new Date(this.attr[_.END_DATE]);Object(I.isFiniteNumber)(d.getTime())&&(this._endDate=d)}}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(_.DURATION in this.attr){var E=this.attr.decimalFloatingPoint(_.DURATION);if(Object(I.isFiniteNumber)(E))return E}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return _.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(_.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(_.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(I.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),T}()},"./src/loader/fragment-loader.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return E}),n.d(b,"LoadError",function(){return p});var I=n("./src/polyfills/number.ts"),L=n("./src/errors.ts");function D(d,e){d.prototype=Object.create(e.prototype),d.prototype.constructor=d,y(d,e)}function w(d){var e=typeof Map=="function"?new Map:void 0;return w=function(h){if(h===null||!_(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(h))return e.get(h);e.set(h,g)}function g(){return R(h,arguments,T(this).constructor)}return g.prototype=Object.create(h.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),y(g,h)},w(d)}function R(d,e,o){return O()?R=Reflect.construct.bind():R=function(g,i,r){var l=[null];l.push.apply(l,i);var c=Function.bind.apply(g,l),t=new c;return r&&y(t,r.prototype),t},R.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 _(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function y(d,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,g){return h.__proto__=g,h},y(d,e)}function T(d){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},T(d)}var A=Math.pow(2,17),E=function(){function d(o){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=o}var e=d.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(h,g){var i=this,r=h.url;if(!r)return Promise.reject(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(r?"part list":"url")));this.abort();var l=this.config,c=l.fLoader,t=l.loader;return new Promise(function(a,u){i.loader&&i.loader.destroy();var s=i.loader=h.loader=c?new c(l):new t(l),f=m(h),v={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:h.sn==="initSegment"?1/0:A};h.stats=s.stats,s.load(f,v,{onSuccess:function(x,P,B,k){i.resetLoader(h,s),a({frag:h,part:null,payload:x.data,networkDetails:k})},onError:function(x,P,B){i.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:x,networkDetails:B}))},onAbort:function(x,P,B){i.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:B}))},onTimeout:function(x,P,B){i.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:B}))},onProgress:function(x,P,B,k){g&&g({frag:h,part:null,payload:B,networkDetails:k})}})})},e.loadPart=function(h,g,i){var r=this;this.abort();var l=this.config,c=l.fLoader,t=l.loader;return new Promise(function(a,u){r.loader&&r.loader.destroy();var s=r.loader=h.loader=c?new c(l):new t(l),f=m(h,g),v={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:A};g.stats=s.stats,s.load(f,v,{onSuccess:function(x,P,B,k){r.resetLoader(h,s),r.updateStatsFromPart(h,g);var U={frag:h,part:g,payload:x.data,networkDetails:k};i(U),a(U)},onError:function(x,P,B){r.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:g,response:x,networkDetails:B}))},onAbort:function(x,P,B){h.stats.aborted=g.stats.aborted,r.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:g,networkDetails:B}))},onTimeout:function(x,P,B){r.resetLoader(h,s),u(new p({type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:g,networkDetails:B}))}})})},e.updateStatsFromPart=function(h,g){var i=h.stats,r=g.stats,l=r.total;if(i.loaded+=r.loaded,l){var c=Math.round(h.duration/g.duration),t=Math.min(Math.round(i.loaded/l),c),a=c-t,u=a*Math.round(i.loaded/t);i.total=i.loaded+u}else i.total=Math.max(i.loaded,i.total);var s=i.loading,f=r.loading;s.start?s.first+=f.first-f.start:(s.start=f.start,s.first=f.first),s.end=f.end},e.resetLoader=function(h,g){h.loader=null,this.loader===g&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),g.destroy()},d}();function m(d,e){e===void 0&&(e=null);var o=e||d,h={frag:d,part:e,responseType:"arraybuffer",url:o.url,headers:{},rangeStart:0,rangeEnd:0},g=o.byteRangeStartOffset,i=o.byteRangeEndOffset;return Object(I.isFiniteNumber)(g)&&Object(I.isFiniteNumber)(i)&&(h.rangeStart=g,h.rangeEnd=i),h}var p=function(d){D(e,d);function e(o){for(var h,g=arguments.length,i=new Array(g>1?g-1:0),r=1;r<g;r++)i[r-1]=arguments[r];return h=d.call.apply(d,[this].concat(i))||this,h.data=void 0,h.data=o,h}return e}(w(Error))},"./src/loader/fragment.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"ElementaryStreamTypes",function(){return E}),n.d(b,"BaseSegment",function(){return m}),n.d(b,"Fragment",function(){return p}),n.d(b,"Part",function(){return d});var I=n("./src/polyfills/number.ts"),L=n("./node_modules/url-toolkit/src/url-toolkit.js"),D=n.n(L),w=n("./src/utils/logger.ts"),R=n("./src/loader/level-key.ts"),O=n("./src/loader/load-stats.ts");function _(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,y(e,o)}function y(e,o){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,i){return g.__proto__=i,g},y(e,o)}function T(e,o){for(var h=0;h<o.length;h++){var g=o[h];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(e,g.key,g)}}function A(e,o,h){return o&&T(e.prototype,o),h&&T(e,h),Object.defineProperty(e,"prototype",{writable:!1}),e}var E;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(E||(E={}));var m=function(){function e(h){var g;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(g={},g[E.AUDIO]=null,g[E.VIDEO]=null,g[E.AUDIOVIDEO]=null,g),this.baseurl=h}var o=e.prototype;return o.setByteRange=function(g,i){var r=g.split("@",2),l=[];r.length===1?l[0]=i?i.byteRangeEndOffset:0:l[0]=parseInt(r[1]),l[1]=parseInt(r[0])+l[0],this._byteRange=l},A(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(L.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(g){this._url=g}}]),e}(),p=function(e){_(o,e);function o(g,i){var r;return r=e.call(this,i)||this,r._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkey=void 0,r.type=void 0,r.loader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.appendedPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new O.LoadStats,r.urlId=0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.type=g,r}var h=o.prototype;return h.createInitializationVector=function(i){for(var r=new Uint8Array(16),l=12;l<16;l++)r[l]=i>>8*(15-l)&255;return r},h.setDecryptDataFromLevelKey=function(i,r){var l=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(l=R.LevelKey.fromURI(i.uri),l.method=i.method,l.iv=this.createInitializationVector(r),l.keyFormat="identity"),l},h.setElementaryStreamInfo=function(i,r,l,c,t,a){a===void 0&&(a=!1);var u=this.elementaryStreams,s=u[i];if(!s){u[i]={startPTS:r,endPTS:l,startDTS:c,endDTS:t,partial:a};return}s.startPTS=Math.min(s.startPTS,r),s.endPTS=Math.max(s.endPTS,l),s.startDTS=Math.min(s.startDTS,c),s.endDTS=Math.max(s.endDTS,t)},h.clearElementaryStreamInfo=function(){var i=this.elementaryStreams;i[E.AUDIO]=null,i[E.VIDEO]=null,i[E.AUDIOVIDEO]=null},A(o,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var i=this.sn;typeof i!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&w.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),i=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,i)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(I.isFiniteNumber)(this.programDateTime))return null;var i=Object(I.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)}}]),o}(m),d=function(e){_(o,e);function o(h,g,i,r,l){var c;c=e.call(this,i)||this,c.fragOffset=0,c.duration=0,c.gap=!1,c.independent=!1,c.relurl=void 0,c.fragment=void 0,c.index=void 0,c.stats=new O.LoadStats,c.duration=h.decimalFloatingPoint("DURATION"),c.gap=h.bool("GAP"),c.independent=h.bool("INDEPENDENT"),c.relurl=h.enumeratedString("URI"),c.fragment=g,c.index=r;var t=h.enumeratedString("BYTERANGE");return t&&c.setByteRange(t,l),l&&(c.fragOffset=l.fragOffset+l.duration),c}return A(o,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var g=this.elementaryStreams;return!!(g.audio||g.video||g.audiovideo)}}]),o}(m)},"./src/loader/key-loader.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return w});var I=n("./src/events.ts"),L=n("./src/errors.ts"),D=n("./src/utils/logger.ts"),w=function(){function R(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this.registerListeners()}var O=R.prototype;return O.startLoad=function(y){},O.stopLoad=function(){this.destroyInternalLoaders()},O.registerListeners=function(){this.hls.on(I.Events.KEY_LOADING,this.onKeyLoading,this)},O.unregisterListeners=function(){this.hls.off(I.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 A=T.frag,E=A.type,m=this.loaders[E];if(!A.decryptdata){D.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var p=A.decryptdata.uri;if(p!==this.decrypturl||this.decryptkey===null){var d=this.hls.config;if(m&&(D.logger.warn("abort previous key loader for type:"+E),m.abort()),!p){D.logger.warn("key uri is falsy");return}var e=d.loader,o=A.loader=this.loaders[E]=new e(d);this.decrypturl=p,this.decryptkey=null;var h={url:p,frag:A,responseType:"arraybuffer"},g={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:d.fragLoadingRetryDelay,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};o.load(h,g,i)}else this.decryptkey&&(A.decryptdata.key=this.decryptkey,this.hls.trigger(I.Events.KEY_LOADED,{frag:A}))},O.loadsuccess=function(y,T,A){var E=A.frag;if(!E.decryptdata){D.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(I.Events.KEY_LOADED,{frag:E})},O.loaderror=function(y,T){var A=T.frag,E=A.loader;E&&E.abort(),delete this.loaders[A.type],this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:A,response:y})},O.loadtimeout=function(y,T){var A=T.frag,E=A.loader;E&&E.abort(),delete this.loaders[A.type],this.hls.trigger(I.Events.ERROR,{type:L.ErrorTypes.NETWORK_ERROR,details:L.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:A})},R}()},"./src/loader/level-details.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"LevelDetails",function(){return R});var I=n("./src/polyfills/number.ts");function L(O,_){for(var y=0;y<_.length;y++){var T=_[y];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function D(O,_,y){return _&&L(O.prototype,_),y&&L(O,y),Object.defineProperty(O,"prototype",{writable:!1}),O}var w=10,R=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 _=O.prototype;return _.reloaded=function(T){if(!T){this.advanced=!0,this.updated=!0;return}var A=this.lastPartSn-T.lastPartSn,E=this.lastPartIndex-T.lastPartIndex;this.updated=this.endSN!==T.endSN||!!E||!!A,this.advanced=this.endSN>T.endSN||A>0||A===0&&E>0,this.updated||this.advanced?this.misses=Math.floor(T.misses*.6):this.misses=T.misses+1,this.availabilityDelay=T.availabilityDelay},D(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(I.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||w}},{key:"drift",get:function(){var T=this.driftEndTime-this.driftStartTime;if(T>0){var A=this.driftEnd-this.driftStart;return A*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,b,n){"use strict";n.r(b),n.d(b,"LevelKey",function(){return R});var I=n("./node_modules/url-toolkit/src/url-toolkit.js"),L=n.n(I);function D(O,_){for(var y=0;y<_.length;y++){var T=_[y];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function w(O,_,y){return _&&D(O.prototype,_),y&&D(O,y),Object.defineProperty(O,"prototype",{writable:!1}),O}var R=function(){O.fromURL=function(y,T){return new O(y,T)},O.fromURI=function(y){return new O(y)};function O(_,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(I.buildAbsoluteURL)(_,y,{alwaysNormalize:!0}):this._uri=_}return w(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"LoadStats",function(){return I});var I=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,b,n){"use strict";n.r(b),n.d(b,"default",function(){return h});var I=n("./src/polyfills/number.ts"),L=n("./node_modules/url-toolkit/src/url-toolkit.js"),D=n.n(L),w=n("./src/loader/date-range.ts"),R=n("./src/loader/fragment.ts"),O=n("./src/loader/level-details.ts"),_=n("./src/loader/level-key.ts"),y=n("./src/utils/attr-list.ts"),T=n("./src/utils/logger.ts"),A=n("./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"),d=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 o(t){var a,u;return e.test((a=(u=L.parseURL(t))===null||u===void 0?void 0:u.path)!=null?a:"")}var h=function(){function t(){}return t.findGroup=function(u,s){for(var f=0;f<u.length;f++){var v=u[f];if(v.id===s)return v}},t.convertAVC1ToAVCOTI=function(u){var s=u.split(".");if(s.length>2){var f=s.shift()+".";return f+=parseInt(s.shift()).toString(16),f+=("000"+parseInt(s.shift()).toString(16)).slice(-4),f}return u},t.resolve=function(u,s){return L.buildAbsoluteURL(s,u,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(u,s){var f=[],v={},S=!1;E.lastIndex=0;for(var x;(x=E.exec(u))!=null;)if(x[1]){var P=new y.AttrList(x[1]),B={attrs:P,bitrate:P.decimalInteger("AVERAGE-BANDWIDTH")||P.decimalInteger("BANDWIDTH"),name:P.NAME,url:t.resolve(x[2],s)},k=P.decimalResolution("RESOLUTION");k&&(B.width=k.width,B.height=k.height),g((P.CODECS||"").split(/[ ,]+/).filter(function(W){return W}),B),B.videoCodec&&B.videoCodec.indexOf("avc1")!==-1&&(B.videoCodec=t.convertAVC1ToAVCOTI(B.videoCodec)),f.push(B)}else if(x[3]){var U=new y.AttrList(x[3]);U["DATA-ID"]&&(S=!0,v[U["DATA-ID"]]=U)}return{levels:f,sessionData:S?v:null}},t.parseMasterPlaylistMedia=function(u,s,f,v){v===void 0&&(v=[]);var S,x=[],P=0;for(m.lastIndex=0;(S=m.exec(u))!==null;){var B=new y.AttrList(S[1]);if(B.TYPE===f){var k={attrs:B,bitrate:0,id:P++,groupId:B["GROUP-ID"],instreamId:B["INSTREAM-ID"],name:B.NAME||B.LANGUAGE||"",type:f,default:B.bool("DEFAULT"),autoselect:B.bool("AUTOSELECT"),forced:B.bool("FORCED"),lang:B.LANGUAGE,url:B.URI?t.resolve(B.URI,s):""};if(v.length){var U=t.findGroup(v,k.groupId)||v[0];i(k,U,"audioCodec"),i(k,U,"textCodec")}x.push(k)}}return x},t.parseLevelPlaylist=function(u,s,f,v,S){var x=new O.LevelDetails(s),P=x.fragments,B=null,k=0,U=0,W=0,H=0,z=null,Y=new R.Fragment(v,s),J,te,X,q=-1,ne=!1;for(p.lastIndex=0,x.m3u8=u;(J=p.exec(u))!==null;){ne&&(ne=!1,Y=new R.Fragment(v,s),Y.start=W,Y.sn=k,Y.cc=H,Y.level=f,B&&(Y.initSegment=B,Y.rawProgramDateTime=B.rawProgramDateTime,B.rawProgramDateTime=null));var ae=J[1];if(ae){Y.duration=parseFloat(ae);var re=(" "+J[2]).slice(1);Y.title=re||null,Y.tagList.push(re?["INF",ae,re]:["INF",ae])}else if(J[3])Object(I.isFiniteNumber)(Y.duration)&&(Y.start=W,X&&(Y.levelkey=X),Y.sn=k,Y.level=f,Y.cc=H,Y.urlId=S,P.push(Y),Y.relurl=(" "+J[3]).slice(1),l(Y,z),z=Y,W+=Y.duration,k++,U=0,ne=!0);else if(J[4]){var le=(" "+J[4]).slice(1);z?Y.setByteRange(le,z):Y.setByteRange(le)}else if(J[5])Y.rawProgramDateTime=(" "+J[5]).slice(1),Y.tagList.push(["PROGRAM-DATE-TIME",Y.rawProgramDateTime]),q===-1&&(q=P.length);else{if(J=J[0].match(d),!J){T.logger.warn("No matches on slow regex match for level playlist!");continue}for(te=1;te<J.length&&typeof J[te]=="undefined";te++);var fe=(" "+J[te]).slice(1),ie=(" "+J[te+1]).slice(1),ge=J[te+2]?(" "+J[te+2]).slice(1):"";switch(fe){case"PLAYLIST-TYPE":x.type=ie.toUpperCase();break;case"MEDIA-SEQUENCE":k=x.startSN=parseInt(ie);break;case"SKIP":{var pe=new y.AttrList(ie),De=pe.decimalInteger("SKIPPED-SEGMENTS");if(Object(I.isFiniteNumber)(De)){x.skippedSegments=De;for(var Me=De;Me--;)P.unshift(null);k+=De}var Oe=pe.enumeratedString("RECENTLY-REMOVED-DATERANGES");Oe&&(x.recentlyRemovedDateranges=Oe.split(" "));break}case"TARGETDURATION":x.targetduration=parseFloat(ie);break;case"VERSION":x.version=parseInt(ie);break;case"EXTM3U":break;case"ENDLIST":x.live=!1;break;case"#":(ie||ge)&&Y.tagList.push(ge?[ie,ge]:[ie]);break;case"DISCONTINUITY":H++,Y.tagList.push(["DIS"]);break;case"GAP":Y.tagList.push([fe]);break;case"BITRATE":Y.tagList.push([fe,ie]);break;case"DATERANGE":{var je=new y.AttrList(ie),Pe=new w.DateRange(je,x.dateRanges[je.ID]);Pe.isValid||x.skippedSegments?x.dateRanges[Pe.id]=Pe:T.logger.warn('Ignoring invalid DATERANGE tag: "'+ie+'"'),Y.tagList.push(["EXT-X-DATERANGE",ie]);break}case"DISCONTINUITY-SEQUENCE":H=parseInt(ie);break;case"KEY":{var Be,Ee=new y.AttrList(ie),we=Ee.enumeratedString("METHOD"),Ue=Ee.URI,Ye=Ee.hexadecimalInteger("IV"),Ne=Ee.enumeratedString("KEYFORMATVERSIONS"),Je=Ee.enumeratedString("KEYID"),Ge=(Be=Ee.enumeratedString("KEYFORMAT"))!=null?Be:"identity",ot=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(ot.indexOf(Ge)>-1){T.logger.warn("Keyformat "+Ge+" is not supported from the manifest");continue}else if(Ge!=="identity")continue;we&&(X=_.LevelKey.fromURL(s,Ue),Ue&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(we)>=0&&(X.method=we,X.keyFormat=Ge,Je&&(X.keyID=Je),Ne&&(X.keyFormatVersions=Ne),X.iv=Ye));break}case"START":{var Fe=new y.AttrList(ie),We=Fe.decimalFloatingPoint("TIME-OFFSET");Object(I.isFiniteNumber)(We)&&(x.startTimeOffset=We);break}case"MAP":{var Ze=new y.AttrList(ie);if(Y.duration){var ke=new R.Fragment(v,s);c(ke,Ze,f,X),B=ke,Y.initSegment=B,B.rawProgramDateTime&&!Y.rawProgramDateTime&&(Y.rawProgramDateTime=B.rawProgramDateTime)}else c(Y,Ze,f,X),B=Y,ne=!0;break}case"SERVER-CONTROL":{var Re=new y.AttrList(ie);x.canBlockReload=Re.bool("CAN-BLOCK-RELOAD"),x.canSkipUntil=Re.optionalFloat("CAN-SKIP-UNTIL",0),x.canSkipDateRanges=x.canSkipUntil>0&&Re.bool("CAN-SKIP-DATERANGES"),x.partHoldBack=Re.optionalFloat("PART-HOLD-BACK",0),x.holdBack=Re.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var lt=new y.AttrList(ie);x.partTarget=lt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var qe=x.partList;qe||(qe=x.partList=[]);var yt=U>0?qe[qe.length-1]:void 0,Dt=U++,at=new R.Part(new y.AttrList(ie),Y,s,Dt,yt);qe.push(at),Y.duration+=at.duration;break}case"PRELOAD-HINT":{var Kt=new y.AttrList(ie);x.preloadHint=Kt;break}case"RENDITION-REPORT":{var At=new y.AttrList(ie);x.renditionReports=x.renditionReports||[],x.renditionReports.push(At);break}default:T.logger.warn("line parsed but not handled: "+J);break}}}z&&!z.relurl?(P.pop(),W-=z.duration,x.partList&&(x.fragmentHint=z)):x.partList&&(l(Y,z),Y.cc=H,x.fragmentHint=Y);var ht=P.length,Tt=P[0],ct=P[ht-1];if(W+=x.skippedSegments*x.targetduration,W>0&&ht&&ct){x.averagetargetduration=W/ht;var Rt=ct.sn;x.endSN=Rt!=="initSegment"?Rt:0,Tt&&(x.startCC=Tt.cc,Tt.initSegment||x.fragments.every(function(xt){return xt.relurl&&o(xt.relurl)})&&(T.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Y=new R.Fragment(v,s),Y.relurl=ct.relurl,Y.level=f,Y.sn="initSegment",Tt.initSegment=Y,x.needSidxRanges=!0))}else x.endSN=0,x.startCC=0;return x.fragmentHint&&(W+=x.fragmentHint.duration),x.totalduration=W,x.endCC=H,q>0&&r(P,q),x},t}();function g(t,a){["video","audio","text"].forEach(function(u){var s=t.filter(function(v){return Object(A.isCodecType)(v,u)});if(s.length){var f=s.filter(function(v){return v.lastIndexOf("avc1",0)===0||v.lastIndexOf("mp4a",0)===0});a[u+"Codec"]=f.length>0?f[0]:s[0],t=t.filter(function(v){return s.indexOf(v)===-1})}}),a.unknownCodecs=t}function i(t,a,u){var s=a[u];s&&(t[u]=s)}function r(t,a){for(var u=t[a],s=a;s--;){var f=t[s];if(!f)return;f.programDateTime=u.programDateTime-f.duration*1e3,u=f}}function l(t,a){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):a!=null&&a.programDateTime&&(t.programDateTime=a.endProgramDateTime),Object(I.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function c(t,a,u,s){t.relurl=a.URI,a.BYTERANGE&&t.setByteRange(a.BYTERANGE),t.level=u,t.sn="initSegment",s&&(t.levelkey=s),t.initSegment=null}},"./src/loader/playlist-loader.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/polyfills/number.ts"),L=n("./src/events.ts"),D=n("./src/errors.ts"),w=n("./src/utils/logger.ts"),R=n("./src/utils/mp4-tools.ts"),O=n("./src/loader/m3u8-parser.ts"),_=n("./src/types/loader.ts"),y=n("./src/utils/attr-list.ts");function T(m){var p=m.type;switch(p){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function A(m,p){var d=m.url;return(d===void 0||d.indexOf("data:")===0)&&(d=p.url),d}var E=function(){function m(d){this.hls=void 0,this.loaders=Object.create(null),this.hls=d,this.registerListeners()}var p=m.prototype;return p.startLoad=function(e){},p.stopLoad=function(){this.destroyInternalLoaders()},p.registerListeners=function(){var e=this.hls;e.on(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(L.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var e=this.hls;e.off(L.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(L.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(L.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(L.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(e){var o=this.hls.config,h=o.pLoader,g=o.loader,i=h||g,r=new i(o);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 o=this.loaders[e];o&&o.destroy(),this.resetInternalLoader(e)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(e,o){var h=o.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},p.onLevelLoading=function(e,o){var h=o.id,g=o.level,i=o.url,r=o.deliveryDirectives;this.load({id:h,groupId:null,level:g,responseType:"text",type:_.PlaylistContextType.LEVEL,url:i,deliveryDirectives:r})},p.onAudioTrackLoading=function(e,o){var h=o.id,g=o.groupId,i=o.url,r=o.deliveryDirectives;this.load({id:h,groupId:g,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:r})},p.onSubtitleTrackLoading=function(e,o){var h=o.id,g=o.groupId,i=o.url,r=o.deliveryDirectives;this.load({id:h,groupId:g,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:r})},p.load=function(e){var o,h=this.hls.config,g=this.getInternalLoader(e);if(g){var i=g.context;if(i&&i.url===e.url){w.logger.trace("[playlist-loader]: playlist request ongoing");return}w.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),g.abort()}var r,l,c,t;switch(e.type){case _.PlaylistContextType.MANIFEST:r=h.manifestLoadingMaxRetry,l=h.manifestLoadingTimeOut,c=h.manifestLoadingRetryDelay,t=h.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:r=0,l=h.levelLoadingTimeOut;break;default:r=h.levelLoadingMaxRetry,l=h.levelLoadingTimeOut,c=h.levelLoadingRetryDelay,t=h.levelLoadingMaxRetryTimeout;break}if(g=this.createInternalLoader(e),(o=e.deliveryDirectives)!==null&&o!==void 0&&o.part){var a;if(e.type===_.PlaylistContextType.LEVEL&&e.level!==null?a=this.hls.levels[e.level].details:e.type===_.PlaylistContextType.AUDIO_TRACK&&e.id!==null?a=this.hls.audioTracks[e.id].details:e.type===_.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(a=this.hls.subtitleTracks[e.id].details),a){var u=a.partTarget,s=a.targetduration;u&&s&&(l=Math.min(Math.max(u*3,s*.8)*1e3,l))}}var f={timeout:l,maxRetry:r,retryDelay:c,maxRetryDelay:t,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};g.load(e,f,v)},p.loadsuccess=function(e,o,h,g){if(g===void 0&&(g=null),h.isSidxRequest){this.handleSidxRequest(e,h),this.handlePlaylistLoaded(e,o,h,g);return}this.resetInternalLoader(h.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,h,"no EXTM3U delimiter",g);return}o.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,o,h,g):this.handleMasterPlaylist(e,o,h,g)},p.loaderror=function(e,o,h){h===void 0&&(h=null),this.handleNetworkError(o,h,!1,e)},p.loadtimeout=function(e,o,h){h===void 0&&(h=null),this.handleNetworkError(o,h,!0)},p.handleMasterPlaylist=function(e,o,h,g){var i=this.hls,r=e.data,l=A(e,h),c=O.default.parseMasterPlaylist(r,l),t=c.levels,a=c.sessionData;if(!t.length){this.handleManifestParsingError(e,h,"no level found in manifest",g);return}var u=t.map(function(P){return{id:P.attrs.AUDIO,audioCodec:P.audioCodec}}),s=t.map(function(P){return{id:P.attrs.SUBTITLES,textCodec:P.textCodec}}),f=O.default.parseMasterPlaylistMedia(r,l,"AUDIO",u),v=O.default.parseMasterPlaylistMedia(r,l,"SUBTITLES",s),S=O.default.parseMasterPlaylistMedia(r,l,"CLOSED-CAPTIONS");if(f.length){var x=f.some(function(P){return!P.url});!x&&t[0].audioCodec&&!t[0].attrs.AUDIO&&(w.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),f.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}i.trigger(L.Events.MANIFEST_LOADED,{levels:t,audioTracks:f,subtitles:v,captions:S,url:l,stats:o,networkDetails:g,sessionData:a})},p.handleTrackOrLevelPlaylist=function(e,o,h,g){var i=this.hls,r=h.id,l=h.level,c=h.type,t=A(e,h),a=Object(I.isFiniteNumber)(r)?r:0,u=Object(I.isFiniteNumber)(l)?l:a,s=T(h),f=O.default.parseLevelPlaylist(e.data,t,u,s,a);if(!f.fragments.length){i.trigger(L.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:t,reason:"no fragments found in level",level:typeof h.level=="number"?h.level:void 0});return}if(c===_.PlaylistContextType.MANIFEST){var v={attrs:new y.AttrList({}),bitrate:0,details:f,name:"",url:t};i.trigger(L.Events.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:t,stats:o,networkDetails:g,sessionData:null})}if(o.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:c,level:l,levelDetails:f,id:r,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=f,this.handlePlaylistLoaded(e,o,h,g)},p.handleSidxRequest=function(e,o){var h=new Uint8Array(e.data),g=Object(R.findBox)(h,["sidx"])[0];if(!!g){var i=Object(R.parseSegmentIndex)(g);if(!!i){var r=i.references,l=o.levelDetails;r.forEach(function(c,t){var a=c.info,u=l.fragments[t];if(u.byteRange.length===0&&u.setByteRange(String(1+a.end-a.start)+"@"+String(a.start)),u.initSegment){var s=Object(R.findBox)(h,["moov"])[0],f=s?s.length:null;u.initSegment.setByteRange(String(f)+"@0")}})}}},p.handleManifestParsingError=function(e,o,h,g){this.hls.trigger(L.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:o.type===_.PlaylistContextType.MANIFEST,url:e.url,reason:h,response:e,context:o,networkDetails:g})},p.handleNetworkError=function(e,o,h,g){h===void 0&&(h=!1),w.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=D.ErrorDetails.UNKNOWN,r=!1,l=this.getInternalLoader(e);switch(e.type){case _.PlaylistContextType.MANIFEST:i=h?D.ErrorDetails.MANIFEST_LOAD_TIMEOUT:D.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case _.PlaylistContextType.LEVEL:i=h?D.ErrorDetails.LEVEL_LOAD_TIMEOUT:D.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case _.PlaylistContextType.AUDIO_TRACK:i=h?D.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:D.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:i=h?D.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:D.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1;break}l&&this.resetInternalLoader(e.type);var c={type:D.ErrorTypes.NETWORK_ERROR,details:i,fatal:r,url:e.url,loader:l,context:e,networkDetails:o};g&&(c.response=g),this.hls.trigger(L.Events.ERROR,c)},p.handlePlaylistLoaded=function(e,o,h,g){var i=h.type,r=h.level,l=h.id,c=h.groupId,t=h.loader,a=h.levelDetails,u=h.deliveryDirectives;if(!(a!=null&&a.targetduration)){this.handleManifestParsingError(e,h,"invalid target duration",g);return}if(!!t)switch(a.live&&(t.getCacheAge&&(a.ageHeader=t.getCacheAge()||0),(!t.getCacheAge||isNaN(a.ageHeader))&&(a.ageHeader=0)),i){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(L.Events.LEVEL_LOADED,{details:a,level:r||0,id:l||0,stats:o,networkDetails:g,deliveryDirectives:u});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(L.Events.AUDIO_TRACK_LOADED,{details:a,id:l||0,groupId:c||"",stats:o,networkDetails:g,deliveryDirectives:u});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(L.Events.SUBTITLE_TRACK_LOADED,{details:a,id:l||0,groupId:c||"",stats:o,networkDetails:g,deliveryDirectives:u});break}},m}();b.default=E},"./src/polyfills/number.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"isFiniteNumber",function(){return I}),n.d(b,"MAX_SAFE_INTEGER",function(){return L});var I=Number.isFinite||function(D){return typeof D=="number"&&isFinite(D)},L=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(j,b,n){"use strict";n.r(b);var I=function(){function L(){}return L.getSilentFrame=function(w,R){switch(w){case"mp4a.40.2":if(R===1)return new Uint8Array([0,200,0,128,35,128]);if(R===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(R===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(R===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(R===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(R===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(R===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(R===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(R===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},L}();b.default=I},"./src/remux/mp4-generator.ts":function(j,b,n){"use strict";n.r(b);var I=Math.pow(2,32)-1,L=function(){function D(){}return D.init=function(){D.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 R;for(R in D.types)D.types.hasOwnProperty(R)&&(D.types[R]=[R.charCodeAt(0),R.charCodeAt(1),R.charCodeAt(2),R.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]),_=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]);D.HDLR_TYPES={video:O,audio:_};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),T=new Uint8Array([0,0,0,0,0,0,0,0]);D.STTS=D.STSC=D.STCO=T,D.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),D.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),D.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),D.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var A=new Uint8Array([105,115,111,109]),E=new Uint8Array([97,118,99,49]),m=new Uint8Array([0,0,0,1]);D.FTYP=D.box(D.types.ftyp,A,m,A,E),D.DINF=D.box(D.types.dinf,D.box(D.types.dref,y))},D.box=function(R){for(var O=8,_=arguments.length,y=new Array(_>1?_-1:0),T=1;T<_;T++)y[T-1]=arguments[T];for(var A=y.length,E=A;A--;)O+=y[A].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(R,4),A=0,O=8;A<E;A++)m.set(y[A],O),O+=y[A].byteLength;return m},D.hdlr=function(R){return D.box(D.types.hdlr,D.HDLR_TYPES[R])},D.mdat=function(R){return D.box(D.types.mdat,R)},D.mdhd=function(R,O){O*=R;var _=Math.floor(O/(I+1)),y=Math.floor(O%(I+1));return D.box(D.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,R>>24&255,R>>16&255,R>>8&255,R&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},D.mdia=function(R){return D.box(D.types.mdia,D.mdhd(R.timescale,R.duration),D.hdlr(R.type),D.minf(R))},D.mfhd=function(R){return D.box(D.types.mfhd,new Uint8Array([0,0,0,0,R>>24,R>>16&255,R>>8&255,R&255]))},D.minf=function(R){return R.type==="audio"?D.box(D.types.minf,D.box(D.types.smhd,D.SMHD),D.DINF,D.stbl(R)):D.box(D.types.minf,D.box(D.types.vmhd,D.VMHD),D.DINF,D.stbl(R))},D.moof=function(R,O,_){return D.box(D.types.moof,D.mfhd(R),D.traf(_,O))},D.moov=function(R){for(var O=R.length,_=[];O--;)_[O]=D.trak(R[O]);return D.box.apply(null,[D.types.moov,D.mvhd(R[0].timescale,R[0].duration)].concat(_).concat(D.mvex(R)))},D.mvex=function(R){for(var O=R.length,_=[];O--;)_[O]=D.trex(R[O]);return D.box.apply(null,[D.types.mvex].concat(_))},D.mvhd=function(R,O){O*=R;var _=Math.floor(O/(I+1)),y=Math.floor(O%(I+1)),T=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,R>>24&255,R>>16&255,R>>8&255,R&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return D.box(D.types.mvhd,T)},D.sdtp=function(R){var O=R.samples||[],_=new Uint8Array(4+O.length),y,T;for(y=0;y<O.length;y++)T=O[y].flags,_[y+4]=T.dependsOn<<4|T.isDependedOn<<2|T.hasRedundancy;return D.box(D.types.sdtp,_)},D.stbl=function(R){return D.box(D.types.stbl,D.stsd(R),D.box(D.types.stts,D.STTS),D.box(D.types.stsc,D.STSC),D.box(D.types.stsz,D.STSZ),D.box(D.types.stco,D.STCO))},D.avc1=function(R){var O=[],_=[],y,T,A;for(y=0;y<R.sps.length;y++)T=R.sps[y],A=T.byteLength,O.push(A>>>8&255),O.push(A&255),O=O.concat(Array.prototype.slice.call(T));for(y=0;y<R.pps.length;y++)T=R.pps[y],A=T.byteLength,_.push(A>>>8&255),_.push(A&255),_=_.concat(Array.prototype.slice.call(T));var E=D.box(D.types.avcC,new Uint8Array([1,O[3],O[4],O[5],255,224|R.sps.length].concat(O).concat([R.pps.length]).concat(_))),m=R.width,p=R.height,d=R.pixelRatio[0],e=R.pixelRatio[1];return D.box(D.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,D.box(D.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),D.box(D.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&255,e>>24,e>>16&255,e>>8&255,e&255])))},D.esds=function(R){var O=R.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(R.config).concat([6,1,2]))},D.mp4a=function(R){var O=R.samplerate;return D.box(D.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,R.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),D.box(D.types.esds,D.esds(R)))},D.mp3=function(R){var O=R.samplerate;return D.box(D.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,R.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},D.stsd=function(R){return R.type==="audio"?R.segmentCodec==="mp3"&&R.codec==="mp3"?D.box(D.types.stsd,D.STSD,D.mp3(R)):D.box(D.types.stsd,D.STSD,D.mp4a(R)):D.box(D.types.stsd,D.STSD,D.avc1(R))},D.tkhd=function(R){var O=R.id,_=R.duration*R.timescale,y=R.width,T=R.height,A=Math.floor(_/(I+1)),E=Math.floor(_%(I+1));return D.box(D.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,A>>24,A>>16&255,A>>8&255,A&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]))},D.traf=function(R,O){var _=D.sdtp(R),y=R.id,T=Math.floor(O/(I+1)),A=Math.floor(O%(I+1));return D.box(D.types.traf,D.box(D.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),D.box(D.types.tfdt,new Uint8Array([1,0,0,0,T>>24,T>>16&255,T>>8&255,T&255,A>>24,A>>16&255,A>>8&255,A&255])),D.trun(R,_.length+16+20+8+16+8+8),_)},D.trak=function(R){return R.duration=R.duration||4294967295,D.box(D.types.trak,D.tkhd(R),D.mdia(R))},D.trex=function(R){var O=R.id;return D.box(D.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]))},D.trun=function(R,O){var _=R.samples||[],y=_.length,T=12+16*y,A=new Uint8Array(T),E,m,p,d,e,o;for(O+=8+T,A.set([R.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=_[E],p=m.duration,d=m.size,e=m.flags,o=m.cts,A.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,o>>>24&255,o>>>16&255,o>>>8&255,o&255],12+16*E);return D.box(D.types.trun,A)},D.initSegment=function(R){D.types||D.init();var O=D.moov(R),_=new Uint8Array(D.FTYP.byteLength+O.byteLength);return _.set(D.FTYP),_.set(O,D.FTYP.byteLength),_},D}();L.types=void 0,L.HDLR_TYPES=void 0,L.STTS=void 0,L.STSC=void 0,L.STCO=void 0,L.STSZ=void 0,L.VMHD=void 0,L.SMHD=void 0,L.STSD=void 0,L.FTYP=void 0,L.DINF=void 0,b.default=L},"./src/remux/mp4-remuxer.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return e}),n.d(b,"normalizePts",function(){return o}),n.d(b,"flushTextTrackMetadataCueSamples",function(){return g}),n.d(b,"flushTextTrackUserdataCueSamples",function(){return i});var I=n("./src/polyfills/number.ts"),L=n("./src/remux/aac-helper.ts"),D=n("./src/remux/mp4-generator.ts"),w=n("./src/events.ts"),R=n("./src/errors.ts"),O=n("./src/utils/logger.ts"),_=n("./src/types/loader.ts"),y=n("./src/utils/timescale-conversion.ts");function T(){return T=Object.assign?Object.assign.bind():function(c){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&(c[u]=a[u])}return c},T.apply(this,arguments)}var A=10*1e3,E=1024,m=1152,p=null,d=null,e=function(){function c(a,u,s,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=a,this.config=u,this.typeSupported=s,this.ISGenerated=!1,p===null){var v=navigator.userAgent||"",S=v.match(/Chrome\/(\d+)/i);p=S?parseInt(S[1]):0}if(d===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);d=x?parseInt(x[1]):0}}var t=c.prototype;return t.destroy=function(){},t.resetTimeStamp=function(u){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=u},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(u){var s=!1,f=u.reduce(function(v,S){var x=S.pts-v;return x<-4294967296?(s=!0,o(v,S.pts)):x>0?v:S.pts},u[0].pts);return s&&O.logger.debug("PTS rollover detected"),f},t.remux=function(u,s,f,v,S,x,P,B){var k,U,W,H,z,Y,J=S,te=S,X=u.pid>-1,q=s.pid>-1,ne=s.samples.length,ae=u.samples.length>0,re=P&&ne>0||ne>1,le=(!X||ae)&&(!q||re)||this.ISGenerated||P;if(le){this.ISGenerated||(W=this.generateIS(u,s,S));var fe=this.isVideoContiguous,ie=-1,ge;if(re&&(ie=h(s.samples),!fe&&this.config.forceKeyFrameOnDiscontinuity))if(Y=!0,ie>0){O.logger.warn("[mp4-remuxer]: Dropped "+ie+" out of "+ne+" video samples due to a missing keyframe");var pe=this.getVideoStartPts(s.samples);s.samples=s.samples.slice(ie),s.dropped+=ie,te+=(s.samples[0].pts-pe)/s.inputTimeScale,ge=te}else ie===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+ne+" video samples"),Y=!1);if(this.ISGenerated){if(ae&&re){var De=this.getVideoStartPts(s.samples),Me=o(u.samples[0].pts,De)-De,Oe=Me/s.inputTimeScale;J+=Math.max(0,Oe),te+=Math.max(0,-Oe)}if(ae){if(u.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),W=this.generateIS(u,s,S)),U=this.remuxAudio(u,J,this.isAudioContiguous,x,q||re||B===_.PlaylistLevelType.AUDIO?te:void 0),re){var je=U?U.endPTS-U.startPTS:0;s.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),W=this.generateIS(u,s,S)),k=this.remuxVideo(s,te,fe,je)}}else re&&(k=this.remuxVideo(s,te,fe,0));k&&(k.firstKeyFrame=ie,k.independent=ie!==-1,k.firstKeyFramePTS=ge)}}return this.ISGenerated&&(f.samples.length&&(z=g(f,S,this._initPTS,this._initDTS)),v.samples.length&&(H=i(v,S,this._initPTS))),{audio:U,video:k,initSegment:W,independent:Y,text:H,id3:z}},t.generateIS=function(u,s,f){var v=u.samples,S=s.samples,x=this.typeSupported,P={},B=!Object(I.isFiniteNumber)(this._initPTS),k="audio/mp4",U,W,H;if(B&&(U=W=1/0),u.config&&v.length){switch(u.timescale=u.samplerate,u.segmentCodec){case"mp3":x.mpeg?(k="audio/mpeg",u.codec=""):x.mp3&&(u.codec="mp3");break}P.audio={id:"audio",container:k,codec:u.codec,initSegment:u.segmentCodec==="mp3"&&x.mpeg?new Uint8Array(0):D.default.initSegment([u]),metadata:{channelCount:u.channelCount}},B&&(H=u.inputTimeScale,U=W=v[0].pts-Math.round(H*f))}if(s.sps&&s.pps&&S.length&&(s.timescale=s.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:s.codec,initSegment:D.default.initSegment([s]),metadata:{width:s.width,height:s.height}},B)){H=s.inputTimeScale;var z=this.getVideoStartPts(S),Y=Math.round(H*f);W=Math.min(W,o(S[0].dts,z)-Y),U=Math.min(U,z-Y)}if(Object.keys(P).length)return this.ISGenerated=!0,B&&(this._initPTS=U,this._initDTS=W),{tracks:P,initPTS:U,timescale:H}},t.remuxVideo=function(u,s,f,v){var S=u.inputTimeScale,x=u.samples,P=[],B=x.length,k=this._initPTS,U=this.nextAvcDts,W=8,H=this.videoSampleDuration,z,Y,J=Number.POSITIVE_INFINITY,te=Number.NEGATIVE_INFINITY,X=!1;if(!f||U===null){var q=s*S,ne=x[0].pts-o(x[0].dts,x[0].pts);U=q-ne}for(var ae=0;ae<B;ae++){var re=x[ae];re.pts=o(re.pts-k,U),re.dts=o(re.dts-k,U),re.dts<x[ae>0?ae-1:ae].dts&&(X=!0)}X&&x.sort(function(_t,hr){var Or=_t.dts-hr.dts,Rr=_t.pts-hr.pts;return Or||Rr}),z=x[0].dts,Y=x[x.length-1].dts;var le=Y-z,fe=le?Math.round(le/(B-1)):H||u.inputTimeScale/30;if(f){var ie=z-U,ge=ie>fe,pe=ie<-1;if(ge||pe){ge?O.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(ie,!0)+" ms ("+ie+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-ie,!0)+" ms ("+ie+"dts) overlapping between fragments detected"),z=U;var De=x[0].pts-ie;x[0].dts=z,x[0].pts=De,O.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(De,!0)+"/"+Object(y.toMsFromMpegTsClock)(z,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(ie,!0)+" ms")}}z=Math.max(0,z);for(var Me=0,Oe=0,je=0;je<B;je++){for(var Pe=x[je],Be=Pe.units,Ee=Be.length,we=0,Ue=0;Ue<Ee;Ue++)we+=Be[Ue].data.length;Oe+=we,Me+=Ee,Pe.length=we,Pe.dts=Math.max(Pe.dts,z),J=Math.min(Pe.pts,J),te=Math.max(Pe.pts,te)}Y=x[B-1].dts;var Ye=Oe+4*Me+8,Ne;try{Ne=new Uint8Array(Ye)}catch{this.observer.emit(w.Events.ERROR,w.Events.ERROR,{type:R.ErrorTypes.MUX_ERROR,details:R.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ye,reason:"fail allocating video mdat "+Ye});return}var Je=new DataView(Ne.buffer);Je.setUint32(0,Ye),Ne.set(D.default.types.mdat,4);for(var Ge=!1,ot=Number.POSITIVE_INFINITY,Fe=Number.POSITIVE_INFINITY,We=Number.NEGATIVE_INFINITY,Ze=Number.NEGATIVE_INFINITY,ke=0;ke<B;ke++){for(var Re=x[ke],lt=Re.units,qe=0,yt=0,Dt=lt.length;yt<Dt;yt++){var at=lt[yt],Kt=at.data,At=at.data.byteLength;Je.setUint32(W,At),W+=4,Ne.set(Kt,W),W+=At,qe+=4+At}var ht=void 0;if(ke<B-1)H=x[ke+1].dts-Re.dts,ht=x[ke+1].pts-Re.pts;else{var Tt=this.config,ct=ke>0?Re.dts-x[ke-1].dts:fe;if(ht=ke>0?Re.pts-x[ke-1].pts:fe,Tt.stretchShortVideoTrack&&this.nextAudioPts!==null){var Rt=Math.floor(Tt.maxBufferHole*S),xt=(v?J+v*S:this.nextAudioPts)-Re.pts;xt>Rt?(H=xt-ct,H<0?H=ct:Ge=!0,O.logger.log("[mp4-remuxer]: It is approximately "+xt/90+" ms to the next segment; using duration "+H/90+" ms for the last video frame.")):H=ct}else H=ct}var lr=Math.round(Re.pts-Re.dts);ot=Math.min(ot,H),We=Math.max(We,H),Fe=Math.min(Fe,ht),Ze=Math.max(Ze,ht),P.push(new r(Re.key,H,qe,lr))}if(P.length){if(p){if(p<70){var jt=P[0].flags;jt.dependsOn=2,jt.isNonSync=0}}else if(d&&Ze-Fe<We-ot&&fe/We<.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 Pt=z,st=0,ur=P.length;st<ur;st++){var Wt=Pt+P[st].duration,dr=Pt+P[st].cts;if(st<ur-1){var _r=Wt+P[st+1].cts;P[st].duration=_r-dr}else P[st].duration=st?P[st-1].duration:fe;P[st].cts=0,Pt=Wt}}}console.assert(H!==null,"mp4SampleDuration must be computed"),H=Ge||!H?fe:H,this.nextAvcDts=U=Y+H,this.videoSampleDuration=H,this.isVideoContiguous=!0;var br=D.default.moof(u.sequenceNumber++,z,T({},u,{samples:P})),fr="video",cr={data1:br,data2:Ne,startPTS:J/S,endPTS:(te+H)/S,startDTS:z/S,endDTS:U/S,type:fr,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:u.dropped};return u.samples=[],u.dropped=0,console.assert(Ne.length,"MDAT length must not be zero"),cr},t.remuxAudio=function(u,s,f,v,S){var x=u.inputTimeScale,P=u.samplerate?u.samplerate:x,B=x/P,k=u.segmentCodec==="aac"?E:m,U=k*B,W=this._initPTS,H=u.segmentCodec==="mp3"&&this.typeSupported.mpeg,z=[],Y=S!==void 0,J=u.samples,te=H?0:8,X=this.nextAudioPts||-1,q=s*x;if(this.isAudioContiguous=f=f||J.length&&X>0&&(v&&Math.abs(q-X)<9e3||Math.abs(o(J[0].pts-W,q)-X)<20*U),J.forEach(function(at){at.pts=o(at.pts-W,q)}),!f||X<0){if(J=J.filter(function(at){return at.pts>=0}),!J.length)return;S===0?X=0:v&&!Y?X=Math.max(0,q):X=J[0].pts}if(u.segmentCodec==="aac")for(var ne=this.config.maxAudioFramesDrift,ae=0,re=X;ae<J.length;ae++){var le=J[ae],fe=le.pts,ie=fe-re,ge=Math.abs(1e3*ie/x);if(ie<=-ne*U&&Y)ae===0&&(O.logger.warn("Audio frame @ "+(fe/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*ie/x)+" ms."),this.nextAudioPts=X=re=fe);else if(ie>=ne*U&&ge<A&&Y){var pe=Math.round(ie/U);re=fe-pe*U,re<0&&(pe--,re+=U),ae===0&&(this.nextAudioPts=X=re),O.logger.warn("[mp4-remuxer]: Injecting "+pe+" audio frame @ "+(re/x).toFixed(3)+"s due to "+Math.round(1e3*ie/x)+" ms gap.");for(var De=0;De<pe;De++){var Me=Math.max(re,0),Oe=L.default.getSilentFrame(u.manifestCodec||u.codec,u.channelCount);Oe||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Oe=le.unit.subarray()),J.splice(ae,0,{unit:Oe,pts:Me}),re+=U,ae++}}le.pts=re,re+=U}for(var je=null,Pe=null,Be,Ee=0,we=J.length;we--;)Ee+=J[we].unit.byteLength;for(var Ue=0,Ye=J.length;Ue<Ye;Ue++){var Ne=J[Ue],Je=Ne.unit,Ge=Ne.pts;if(Pe!==null){var ot=z[Ue-1];ot.duration=Math.round((Ge-Pe)/B)}else if(f&&u.segmentCodec==="aac"&&(Ge=X),je=Ge,Ee>0){Ee+=te;try{Be=new Uint8Array(Ee)}catch{this.observer.emit(w.Events.ERROR,w.Events.ERROR,{type:R.ErrorTypes.MUX_ERROR,details:R.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ee,reason:"fail allocating audio mdat "+Ee});return}if(!H){var Fe=new DataView(Be.buffer);Fe.setUint32(0,Ee),Be.set(D.default.types.mdat,4)}}else return;Be.set(Je,te);var We=Je.byteLength;te+=We,z.push(new r(!0,k,We,0)),Pe=Ge}var Ze=z.length;if(!!Ze){var ke=z[z.length-1];this.nextAudioPts=X=Pe+B*ke.duration;var Re=H?new Uint8Array(0):D.default.moof(u.sequenceNumber++,je/B,T({},u,{samples:z}));u.samples=[];var lt=je/x,qe=X/x,yt="audio",Dt={data1:Re,data2:Be,startPTS:lt,endPTS:qe,startDTS:lt,endDTS:qe,type:yt,hasAudio:!0,hasVideo:!1,nb:Ze};return this.isAudioContiguous=!0,console.assert(Be.length,"MDAT length must not be zero"),Dt}},t.remuxEmptyAudio=function(u,s,f,v){var S=u.inputTimeScale,x=u.samplerate?u.samplerate:S,P=S/x,B=this.nextAudioPts,k=(B!==null?B:v.startDTS*S)+this._initDTS,U=v.endDTS*S+this._initDTS,W=P*E,H=Math.ceil((U-k)/W),z=L.default.getSilentFrame(u.manifestCodec||u.codec,u.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=[],J=0;J<H;J++){var te=k+J*W;Y.push({unit:z,pts:te,dts:te})}return u.samples=Y,this.remuxAudio(u,s,f,!1)},c}();function o(c,t){var a;if(t===null)return c;for(t<c?a=-8589934592:a=8589934592;Math.abs(c-t)>4294967296;)c+=a;return c}function h(c){for(var t=0;t<c.length;t++)if(c[t].key)return t;return-1}function g(c,t,a,u){var s=c.samples.length;if(!!s){for(var f=c.inputTimeScale,v=0;v<s;v++){var S=c.samples[v];S.pts=o(S.pts-a,t*f)/f,S.dts=o(S.dts-u,t*f)/f}var x=c.samples;return c.samples=[],{samples:x}}}function i(c,t,a){var u=c.samples.length;if(!!u){for(var s=c.inputTimeScale,f=0;f<u;f++){var v=c.samples[f];v.pts=o(v.pts-a,t*s)/s}c.samples.sort(function(x,P){return x.pts-P.pts});var S=c.samples;return c.samples=[],{samples:S}}}var r=function(t,a,u,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=a,this.size=u,this.cts=s,this.flags=new l(t)},l=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,b,n){"use strict";n.r(b);var I=n("./src/polyfills/number.ts"),L=n("./src/remux/mp4-remuxer.ts"),D=n("./src/utils/mp4-tools.ts"),w=n("./src/loader/fragment.ts"),R=n("./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 d=this.initData=Object(D.parseInitSegment)(E);m||(m=_(d.audio,w.ElementaryStreamTypes.AUDIO)),p||(p=_(d.video,w.ElementaryStreamTypes.VIDEO));var e={};d.audio&&d.video?e.audiovideo={container:"video/mp4",codec:m+","+p,initSegment:E,id:"main"}:d.audio?e.audio={container:"audio/mp4",codec:m,initSegment:E,id:"audio"}:d.video?e.video={container:"video/mp4",codec:p,initSegment:E,id:"main"}:R.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},T.remux=function(E,m,p,d,e){var o,h=this.initPTS,g=this.lastEndTime,i={audio:void 0,video:void 0,text:d,id3:p,initSegment:void 0};Object(I.isFiniteNumber)(g)||(g=this.lastEndTime=e||0);var r=m.samples;if(!r||!r.length)return i;var l={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(r),c=this.initData),!c||!c.length)return R.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(l.tracks=this.initTracks,this.emitInitSegment=!1);var t=Object(D.getStartDTS)(c,r);Object(I.isFiniteNumber)(h)||(this.initPTS=l.initPTS=h=t-e);var a=Object(D.getDuration)(r,c),u=E?t-h:g,s=u+a;Object(D.offsetStartDTS)(c,r,h),a>0?this.lastEndTime=s:(R.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var f=!!c.audio,v=!!c.video,S="";f&&(S+="audio"),v&&(S+="video");var x={data1:r,startPTS:u,startDTS:u,endPTS:s,endDTS:s,type:S,hasAudio:f,hasVideo:v,nb:1,dropped:0};i.audio=x.type==="audio"?x:void 0,i.video=x.type!=="audio"?x:void 0,i.initSegment=l;var P=(o=this.initPTS)!=null?o:0;return i.id3=Object(L.flushTextTrackMetadataCueSamples)(p,e,P,P),d.samples.length&&(i.text=Object(L.flushTextTrackUserdataCueSamples)(d,e,P)),i},y}();function _(y,T){var A=y==null?void 0:y.codec;return A&&A.length>4?A:A==="hvc1"||A==="hev1"?"hvc1.1.c.L120.90":A==="av01"?"av01.0.04M.08":A==="avc1"||T===w.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}b.default=O},"./src/task-loop.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return I});var I=function(){function L(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var D=L.prototype;return D.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},D.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},D.onHandlerDestroyed=function(){},D.hasInterval=function(){return!!this._tickInterval},D.hasNextTick=function(){return!!this._tickTimer},D.setInterval=function(R){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,R),!0)},D.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},D.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},D.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},D.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},D.doTick=function(){},L}()},"./src/types/cmcd.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"CMCDVersion",function(){return I}),n.d(b,"CMCDObjectType",function(){return L}),n.d(b,"CMCDStreamingFormat",function(){return D}),n.d(b,"CMCDStreamType",function(){return w});var I=1,L;(function(R){R.MANIFEST="m",R.AUDIO="a",R.VIDEO="v",R.MUXED="av",R.INIT="i",R.CAPTION="c",R.TIMED_TEXT="tt",R.KEY="k",R.OTHER="o"})(L||(L={}));var D;(function(R){R.DASH="d",R.HLS="h",R.SMOOTH="s",R.OTHER="o"})(D||(D={}));var w;(function(R){R.VOD="v",R.LIVE="l"})(w||(w={}))},"./src/types/demuxer.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"MetadataSchema",function(){return I});var I;(function(L){L.audioId3="org.id3",L.dateRange="com.apple.quicktime.HLS",L.emsg="https://aomedia.org/emsg/ID3"})(I||(I={}))},"./src/types/level.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"HlsSkip",function(){return D}),n.d(b,"getSkipValue",function(){return w}),n.d(b,"HlsUrlParameters",function(){return R}),n.d(b,"Level",function(){return O});function I(_,y){for(var T=0;T<y.length;T++){var A=y[T];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(_,A.key,A)}}function L(_,y,T){return y&&I(_.prototype,y),T&&I(_,T),Object.defineProperty(_,"prototype",{writable:!1}),_}var D;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(D||(D={}));function w(_,y){var T=_.canSkipUntil,A=_.canSkipDateRanges,E=_.endSN,m=y!==void 0?y-E:0;return T&&m<T?A?D.v2:D.Yes:D.No}var R=function(){function _(T,A,E){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=T,this.part=A,this.skip=E}var y=_.prototype;return y.addDirectives=function(A){var E=new self.URL(A);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()},_}(),O=function(){function _(y){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(T){return T}).join(",").replace(/\.[^.,]+/g,"")}return L(_,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(T){var A=T%this.url.length;this._urlId!==A&&(this.details=void 0,this._urlId=A)}}]),_}()},"./src/types/loader.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"PlaylistContextType",function(){return I}),n.d(b,"PlaylistLevelType",function(){return L});var I;(function(D){D.MANIFEST="manifest",D.LEVEL="level",D.AUDIO_TRACK="audioTrack",D.SUBTITLE_TRACK="subtitleTrack"})(I||(I={}));var L;(function(D){D.MAIN="main",D.AUDIO="audio",D.SUBTITLE="subtitle"})(L||(L={}))},"./src/types/transmuxer.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"ChunkMetadata",function(){return I});var I=function(w,R,O,_,y,T){_===void 0&&(_=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=L(),this.buffering={audio:L(),video:L(),audiovideo:L()},this.level=w,this.sn=R,this.id=O,this.size=_,this.part=y,this.partial=T};function L(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"AttrList",function(){return D});var I=/^(\d+)x(\d+)$/,L=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,D=function(){function w(O){typeof O=="string"&&(O=w.parseAttrList(O));for(var _ in O)O.hasOwnProperty(_)&&(this[_]=O[_])}var R=w.prototype;return R.decimalInteger=function(_){var y=parseInt(this[_],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},R.hexadecimalInteger=function(_){if(this[_]){var y=(this[_]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var T=new Uint8Array(y.length/2),A=0;A<y.length/2;A++)T[A]=parseInt(y.slice(A*2,A*2+2),16);return T}else return null},R.hexadecimalIntegerAsNumber=function(_){var y=parseInt(this[_],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},R.decimalFloatingPoint=function(_){return parseFloat(this[_])},R.optionalFloat=function(_,y){var T=this[_];return T?parseFloat(T):y},R.enumeratedString=function(_){return this[_]},R.bool=function(_){return this[_]==="YES"},R.decimalResolution=function(_){var y=I.exec(this[_]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},w.parseAttrList=function(_){var y,T={},A='"';for(L.lastIndex=0;(y=L.exec(_))!==null;){var E=y[2];E.indexOf(A)===0&&E.lastIndexOf(A)===E.length-1&&(E=E.slice(1,-1)),T[y[1]]=E}return T},w}()},"./src/utils/binary-search.ts":function(j,b,n){"use strict";n.r(b);var I={search:function(D,w){for(var R=0,O=D.length-1,_=null,y=null;R<=O;){_=(R+O)/2|0,y=D[_];var T=w(y);if(T>0)R=_+1;else if(T<0)O=_-1;else return y}return null}};b.default=I},"./src/utils/buffer-helper.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"BufferHelper",function(){return D});var I=n("./src/utils/logger.ts"),L={length:0,start:function(){return 0},end:function(){return 0}},D=function(){function w(){}return w.isBuffered=function(O,_){try{if(O){for(var y=w.getBuffered(O),T=0;T<y.length;T++)if(_>=y.start(T)&&_<=y.end(T))return!0}}catch{}return!1},w.bufferInfo=function(O,_,y){try{if(O){var T=w.getBuffered(O),A=[],E;for(E=0;E<T.length;E++)A.push({start:T.start(E),end:T.end(E)});return this.bufferedInfo(A,_,y)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},w.bufferedInfo=function(O,_,y){_=Math.max(0,_),O.sort(function(r,l){var c=r.start-l.start;return c||l.end-r.end});var T=[];if(y)for(var A=0;A<O.length;A++){var E=T.length;if(E){var m=T[E-1].end;O[A].start-m<y?O[A].end>m&&(T[E-1].end=O[A].end):T.push(O[A])}else T.push(O[A])}else T=O;for(var p=0,d,e=_,o=_,h=0;h<T.length;h++){var g=T[h].start,i=T[h].end;if(_+y>=g&&_<i)e=g,o=i,p=o-_;else if(_+y<g){d=g;break}}return{len:p,start:e||0,end:o||0,nextStart:d}},w.getBuffered=function(O){try{return O.buffered}catch(_){return I.logger.log("failed to get media.buffered",_),L}},w}()},"./src/utils/cea-608-parser.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"Row",function(){return o}),n.d(b,"CaptionScreen",function(){return h});var I=n("./src/utils/logger.ts"),L={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},D=function(a){var u=a;return L.hasOwnProperty(a)&&(u=L[a]),String.fromCharCode(u)},w=15,R=100,O={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},T={25:2,26:4,29:6,30:8,31:10,27:13,28:15},A=["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 a=t.prototype;return a.log=function(s,f){this.verboseLevel>=s&&I.logger.log(this.time+" ["+s+"] "+f)},t}(),p=function(a){for(var u=[],s=0;s<a.length;s++)u.push(a[s].toString(16));return u},d=function(){function t(u,s,f,v,S){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=u||"white",this.underline=s||!1,this.italics=f||!1,this.background=v||"black",this.flash=S||!1}var a=t.prototype;return a.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},a.setStyles=function(s){for(var f=["foreground","underline","italics","background","flash"],v=0;v<f.length;v++){var S=f[v];s.hasOwnProperty(S)&&(this[S]=s[S])}},a.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},a.equals=function(s){return this.foreground===s.foreground&&this.underline===s.underline&&this.italics===s.italics&&this.background===s.background&&this.flash===s.flash},a.copy=function(s){this.foreground=s.foreground,this.underline=s.underline,this.italics=s.italics,this.background=s.background,this.flash=s.flash},a.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),e=function(){function t(u,s,f,v,S,x){this.uchar=void 0,this.penState=void 0,this.uchar=u||" ",this.penState=new d(s,f,v,S,x)}var a=t.prototype;return a.reset=function(){this.uchar=" ",this.penState.reset()},a.setChar=function(s,f){this.uchar=s,this.penState.copy(f)},a.setPenState=function(s){this.penState.copy(s)},a.equals=function(s){return this.uchar===s.uchar&&this.penState.equals(s.penState)},a.copy=function(s){this.uchar=s.uchar,this.penState.copy(s.penState)},a.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},t}(),o=function(){function t(u){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var s=0;s<R;s++)this.chars.push(new e);this.logger=u,this.pos=0,this.currPenState=new d}var a=t.prototype;return a.equals=function(s){for(var f=!0,v=0;v<R;v++)if(!this.chars[v].equals(s.chars[v])){f=!1;break}return f},a.copy=function(s){for(var f=0;f<R;f++)this.chars[f].copy(s.chars[f])},a.isEmpty=function(){for(var s=!0,f=0;f<R;f++)if(!this.chars[f].isEmpty()){s=!1;break}return s},a.setCursor=function(s){this.pos!==s&&(this.pos=s),this.pos<0?(this.logger.log(E.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>R&&(this.logger.log(E.DEBUG,"Too large cursor position "+this.pos),this.pos=R)},a.moveCursor=function(s){var f=this.pos+s;if(s>1)for(var v=this.pos+1;v<f+1;v++)this.chars[v].setPenState(this.currPenState);this.setCursor(f)},a.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},a.insertChar=function(s){s>=144&&this.backSpace();var f=D(s);if(this.pos>=R){this.logger.log(E.ERROR,"Cannot insert "+s.toString(16)+" ("+f+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(f,this.currPenState),this.moveCursor(1)},a.clearFromPos=function(s){var f;for(f=s;f<R;f++)this.chars[f].reset()},a.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},a.clearToEndOfRow=function(){this.clearFromPos(this.pos)},a.getTextString=function(){for(var s=[],f=!0,v=0;v<R;v++){var S=this.chars[v].uchar;S!==" "&&(f=!1),s.push(S)}return f?"":s.join("")},a.setPenStyles=function(s){this.currPenState.setStyles(s);var f=this.chars[this.pos];f.setPenState(this.currPenState)},t}(),h=function(){function t(u){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var s=0;s<w;s++)this.rows.push(new o(u));this.logger=u,this.currRow=w-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var a=t.prototype;return a.reset=function(){for(var s=0;s<w;s++)this.rows[s].clear();this.currRow=w-1},a.equals=function(s){for(var f=!0,v=0;v<w;v++)if(!this.rows[v].equals(s.rows[v])){f=!1;break}return f},a.copy=function(s){for(var f=0;f<w;f++)this.rows[f].copy(s.rows[f])},a.isEmpty=function(){for(var s=!0,f=0;f<w;f++)if(!this.rows[f].isEmpty()){s=!1;break}return s},a.backSpace=function(){var s=this.rows[this.currRow];s.backSpace()},a.clearToEndOfRow=function(){var s=this.rows[this.currRow];s.clearToEndOfRow()},a.insertChar=function(s){var f=this.rows[this.currRow];f.insertChar(s)},a.setPen=function(s){var f=this.rows[this.currRow];f.setPenStyles(s)},a.moveCursor=function(s){var f=this.rows[this.currRow];f.moveCursor(s)},a.setCursor=function(s){this.logger.log(E.INFO,"setCursor: "+s);var f=this.rows[this.currRow];f.setCursor(s)},a.setPAC=function(s){this.logger.log(E.INFO,"pacData = "+JSON.stringify(s));var f=s.row-1;if(this.nrRollUpRows&&f<this.nrRollUpRows-1&&(f=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==f){for(var v=0;v<w;v++)this.rows[v].clear();var S=this.currRow+1-this.nrRollUpRows,x=this.lastOutputScreen;if(x){var P=x.rows[S].cueStartTime,B=this.logger.time;if(P&&B!==null&&P<B)for(var k=0;k<this.nrRollUpRows;k++)this.rows[f-this.nrRollUpRows+k+1].copy(x.rows[S+k])}}this.currRow=f;var U=this.rows[this.currRow];if(s.indent!==null){var W=s.indent,H=Math.max(W-1,0);U.setCursor(s.indent),s.color=U.chars[H].penState.foreground}var z={foreground:s.color,underline:s.underline,italics:s.italics,background:"black",flash:!1};this.setPen(z)},a.setBkgData=function(s){this.logger.log(E.INFO,"bkgData = "+JSON.stringify(s)),this.backSpace(),this.setPen(s),this.insertChar(32)},a.setRollUpRows=function(s){this.nrRollUpRows=s},a.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 s=this.currRow+1-this.nrRollUpRows,f=this.rows.splice(s,1)[0];f.clear(),this.rows.splice(this.currRow,0,f),this.logger.log(E.INFO,"Rolling up")},a.getDisplayText=function(s){s=s||!1;for(var f=[],v="",S=-1,x=0;x<w;x++){var P=this.rows[x].getTextString();P&&(S=x+1,s?f.push("Row "+S+": '"+P+"'"):f.push(P.trim()))}return f.length>0&&(s?v="["+f.join(" | ")+"]":v=f.join(`
|
|
21
|
-
`)),v},a.getTextAndFormat=function(){return this.rows},t}(),g=function(){function t(u,s,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=u,this.outputFilter=s,this.mode=null,this.verbose=0,this.displayedMemory=new h(f),this.nonDisplayedMemory=new h(f),this.lastOutputScreen=new h(f),this.currRollUpRow=this.displayedMemory.rows[w-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=f}var a=t.prototype;return a.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[w-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},a.getHandler=function(){return this.outputFilter},a.setHandler=function(s){this.outputFilter=s},a.setPAC=function(s){this.writeScreen.setPAC(s)},a.setBkgData=function(s){this.writeScreen.setBkgData(s)},a.setMode=function(s){s!==this.mode&&(this.mode=s,this.logger.log(E.INFO,"MODE="+s),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=s)},a.insertChars=function(s){for(var f=0;f<s.length;f++)this.writeScreen.insertChar(s[f]);var v=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(E.INFO,v+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(E.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},a.ccRCL=function(){this.logger.log(E.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},a.ccBS=function(){this.logger.log(E.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},a.ccAOF=function(){},a.ccAON=function(){},a.ccDER=function(){this.logger.log(E.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},a.ccRU=function(s){this.logger.log(E.INFO,"RU("+s+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(s)},a.ccFON=function(){this.logger.log(E.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},a.ccRDC=function(){this.logger.log(E.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},a.ccTR=function(){this.logger.log(E.INFO,"TR"),this.setMode("MODE_TEXT")},a.ccRTD=function(){this.logger.log(E.INFO,"RTD"),this.setMode("MODE_TEXT")},a.ccEDM=function(){this.logger.log(E.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},a.ccCR=function(){this.logger.log(E.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},a.ccENM=function(){this.logger.log(E.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},a.ccEOC=function(){if(this.logger.log(E.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var s=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=s,this.writeScreen=this.nonDisplayedMemory,this.logger.log(E.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},a.ccTO=function(s){this.logger.log(E.INFO,"TO("+s+") - Tab Offset"),this.writeScreen.moveCursor(s)},a.ccMIDROW=function(s){var f={flash:!1};if(f.underline=s%2===1,f.italics=s>=46,f.italics)f.foreground="white";else{var v=Math.floor(s/2)-16,S=["white","green","blue","cyan","red","yellow","magenta"];f.foreground=S[v]}this.logger.log(E.INFO,"MIDROW: "+JSON.stringify(f)),this.writeScreen.setPen(f)},a.outputDataUpdate=function(s){s===void 0&&(s=!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),s&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:f),this.lastOutputScreen.copy(this.displayedMemory))},a.cueSplitAtTime=function(s){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,s,this.displayedMemory),this.cueStartTime=s))},t}(),i=function(){function t(u,s,f){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var v=new m;this.channels=[null,new g(u,s,v),new g(u+1,f,v)],this.cmdHistory=c(),this.logger=v}var a=t.prototype;return a.getHandler=function(s){return this.channels[s].getHandler()},a.setHandler=function(s,f){this.channels[s].setHandler(f)},a.addData=function(s,f){var v,S,x,P=!1;this.logger.time=s;for(var B=0;B<f.length;B+=2)if(S=f[B]&127,x=f[B+1]&127,!(S===0&&x===0)){if(this.logger.log(E.DATA,"["+p([f[B],f[B+1]])+"] -> ("+p([S,x])+")"),v=this.parseCmd(S,x),v||(v=this.parseMidrow(S,x)),v||(v=this.parsePAC(S,x)),v||(v=this.parseBackgroundAttributes(S,x)),!v&&(P=this.parseChars(S,x),P)){var k=this.currentChannel;if(k&&k>0){var U=this.channels[k];U.insertChars(P)}else this.logger.log(E.WARNING,"No channel found yet. TEXT-MODE?")}!v&&!P&&this.logger.log(E.WARNING,"Couldn't parse cleaned data "+p([S,x])+" orig: "+p([f[B],f[B+1]]))}},a.parseCmd=function(s,f){var v=this.cmdHistory,S=(s===20||s===28||s===21||s===29)&&f>=32&&f<=47,x=(s===23||s===31)&&f>=33&&f<=35;if(!(S||x))return!1;if(l(s,f,v))return r(null,null,v),this.logger.log(E.DEBUG,"Repeated command ("+p([s,f])+") is dropped"),!0;var P=s===20||s===21||s===23?1:2,B=this.channels[P];return s===20||s===21||s===28||s===29?f===32?B.ccRCL():f===33?B.ccBS():f===34?B.ccAOF():f===35?B.ccAON():f===36?B.ccDER():f===37?B.ccRU(2):f===38?B.ccRU(3):f===39?B.ccRU(4):f===40?B.ccFON():f===41?B.ccRDC():f===42?B.ccTR():f===43?B.ccRTD():f===44?B.ccEDM():f===45?B.ccCR():f===46?B.ccENM():f===47&&B.ccEOC():B.ccTO(f-32),r(s,f,v),this.currentChannel=P,!0},a.parseMidrow=function(s,f){var v=0;if((s===17||s===25)&&f>=32&&f<=47){if(s===17?v=1:v=2,v!==this.currentChannel)return this.logger.log(E.ERROR,"Mismatch channel in midrow parsing"),!1;var S=this.channels[v];return S?(S.ccMIDROW(f),this.logger.log(E.DEBUG,"MIDROW ("+p([s,f])+")"),!0):!1}return!1},a.parsePAC=function(s,f){var v,S=this.cmdHistory,x=(s>=17&&s<=23||s>=25&&s<=31)&&f>=64&&f<=127,P=(s===16||s===24)&&f>=64&&f<=95;if(!(x||P))return!1;if(l(s,f,S))return r(null,null,S),!0;var B=s<=23?1:2;f>=64&&f<=95?v=B===1?O[s]:y[s]:v=B===1?_[s]:T[s];var k=this.channels[B];return k?(k.setPAC(this.interpretPAC(v,f)),r(s,f,S),this.currentChannel=B,!0):!1},a.interpretPAC=function(s,f){var v,S={color:null,italics:!1,indent:null,underline:!1,row:s};return f>95?v=f-96:v=f-64,S.underline=(v&1)===1,v<=13?S.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(v/2)]:v<=15?(S.italics=!0,S.color="white"):S.indent=Math.floor((v-16)/2)*4,S},a.parseChars=function(s,f){var v,S=null,x=null;if(s>=25?(v=2,x=s-8):(v=1,x=s),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 '"+D(P)+"' in channel "+v),S=[P]}else s>=32&&s<=127&&(S=f===0?[s]:[s,f]);if(S){var B=p(S);this.logger.log(E.DEBUG,"Char codes = "+B.join(",")),r(s,f,this.cmdHistory)}return S},a.parseBackgroundAttributes=function(s,f){var v=(s===16||s===24)&&f>=32&&f<=47,S=(s===23||s===31)&&f>=45&&f<=47;if(!(v||S))return!1;var x,P={};s===16||s===24?(x=Math.floor((f-32)/2),P.background=A[x],f%2===1&&(P.background=P.background+"_semi")):f===45?P.background="transparent":(P.foreground="black",f===47&&(P.underline=!0));var B=s<=23?1:2,k=this.channels[B];return k.setBkgData(P),r(s,f,this.cmdHistory),!0},a.reset=function(){for(var s=0;s<Object.keys(this.channels).length;s++){var f=this.channels[s];f&&f.reset()}this.cmdHistory=c()},a.cueSplitAtTime=function(s){for(var f=0;f<this.channels.length;f++){var v=this.channels[f];v&&v.cueSplitAtTime(s)}},t}();function r(t,a,u){u.a=t,u.b=a}function l(t,a,u){return u.a===t&&u.b===a}function c(){return{a:null,b:null}}b.default=i},"./src/utils/codecs.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"isCodecType",function(){return L}),n.d(b,"isCodecSupportedInMp4",function(){return D});var I={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function L(w,R){var O=I[R];return!!O&&O[w.slice(0,4)]===!0}function D(w,R){return MediaSource.isTypeSupported((R||"video")+'/mp4;codecs="'+w+'"')}},"./src/utils/cues.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/utils/vttparser.ts"),L=n("./src/utils/webvtt-parser.ts"),D=n("./src/utils/texttrack-utils.ts"),w=/\s/,R={newCue:function(_,y,T,A){for(var E=[],m,p,d,e,o,h=self.VTTCue||self.TextTrackCue,g=0;g<A.rows.length;g++)if(m=A.rows[g],d=!0,e=0,o="",!m.isEmpty()){for(var i=0;i<m.chars.length;i++)w.test(m.chars[i].uchar)&&d?e++:(o+=m.chars[i].uchar,d=!1);m.cueStartTime=y,y===T&&(T+=1e-4),e>=16?e--:e++;var r=Object(I.fixLineBreaks)(o.trim()),l=Object(L.generateCueId)(y,T,r);(!_||!_.cues||!_.cues.getCueById(l))&&(p=new h(y,T,r),p.id=l,p.line=g+1,p.align="left",p.position=10+Math.min(80,Math.floor(e*8/32)*10),E.push(p))}return _&&E.length&&(E.sort(function(c,t){return c.line==="auto"||t.line==="auto"?0:c.line>8&&t.line>8?t.line-c.line:c.line-t.line}),E.forEach(function(c){return Object(D.addCueToTrack)(_,c)})),E}};b.default=R},"./src/utils/discontinuities.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"findFirstFragWithCC",function(){return w}),n.d(b,"shouldAlignOnDiscontinuities",function(){return R}),n.d(b,"findDiscontinuousReferenceFrag",function(){return O}),n.d(b,"adjustSlidingStart",function(){return y}),n.d(b,"alignStream",function(){return T}),n.d(b,"alignPDT",function(){return E}),n.d(b,"alignFragmentByPDTDelta",function(){return m}),n.d(b,"alignMediaPlaylistByPDT",function(){return p});var I=n("./src/polyfills/number.ts"),L=n("./src/utils/logger.ts"),D=n("./src/controller/level-helper.ts");function w(d,e){for(var o=null,h=0,g=d.length;h<g;h++){var i=d[h];if(i&&i.cc===e){o=i;break}}return o}function R(d,e,o){return!!(e.details&&(o.endCC>o.startCC||d&&d.cc<o.startCC))}function O(d,e){var o=d.fragments,h=e.fragments;if(!h.length||!o.length){L.logger.log("No fragments to align");return}var g=w(o,h[0].cc);if(!g||g&&!g.startPTS){L.logger.log("No frag in previous level to align on");return}return g}function _(d,e){if(d){var o=d.start+e;d.start=d.startPTS=o,d.endPTS=o+d.duration}}function y(d,e){for(var o=e.fragments,h=0,g=o.length;h<g;h++)_(o[h],d);e.fragmentHint&&_(e.fragmentHint,d),e.alignedSliding=!0}function T(d,e,o){!e||(A(d,o,e),!o.alignedSliding&&e.details&&E(o,e.details),!o.alignedSliding&&e.details&&!o.skippedSegments&&Object(D.adjustSliding)(e.details,o))}function A(d,e,o){if(R(d,o,e)){var h=O(o.details,e);h&&Object(I.isFiniteNumber)(h.start)&&(L.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),y(h.start,e))}}function E(d,e){if(!(!e.fragments.length||!d.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,h=d.fragments[0].programDateTime,g=(h-o)/1e3+e.fragments[0].start;g&&Object(I.isFiniteNumber)(g)&&(L.logger.log("Adjusting PTS using programDateTime delta "+(h-o)+"ms, sliding:"+g.toFixed(3)+" "+d.url+" "),y(g,d))}}function m(d,e){var o=d.programDateTime;if(!!o){var h=(o-e)/1e3;d.start=d.startPTS=h,d.endPTS=h+d.duration}}function p(d,e){if(!(!e.fragments.length||!d.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,h=e.fragments[0].start,g=o-h*1e3;d.fragments.forEach(function(i){m(i,g)}),d.fragmentHint&&m(d.fragmentHint,g),d.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/utils/ewma.ts"),L=function(){function D(R,O,_){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=_,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new I.default(R),this.fast_=new I.default(O)}var w=D.prototype;return w.update=function(O,_){var y=this.slow_,T=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new I.default(O,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new I.default(_,T.getEstimate(),T.getTotalWeight()))},w.sample=function(O,_){O=Math.max(O,this.minDelayMs_);var y=8*_,T=O/1e3,A=y/T;this.fast_.sample(T,A),this.slow_.sample(T,A)},w.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},w.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},w.destroy=function(){},D}();b.default=L},"./src/utils/ewma.ts":function(j,b,n){"use strict";n.r(b);var I=function(){function L(w,R,O){R===void 0&&(R=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=w,this.alpha_=w?Math.exp(Math.log(.5)/w):0,this.estimate_=R,this.totalWeight_=O}var D=L.prototype;return D.sample=function(R,O){var _=Math.pow(this.alpha_,R);this.estimate_=O*(1-_)+_*this.estimate_,this.totalWeight_+=R},D.getTotalWeight=function(){return this.totalWeight_},D.getEstimate=function(){if(this.alpha_){var R=1-Math.pow(this.alpha_,this.totalWeight_);if(R)return this.estimate_/R}return this.estimate_},L}();b.default=I},"./src/utils/fetch-loader.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"fetchSupported",function(){return m});var I=n("./src/polyfills/number.ts"),L=n("./src/loader/load-stats.ts"),D=n("./src/demux/chunk-cache.ts");function w(h,g){h.prototype=Object.create(g.prototype),h.prototype.constructor=h,T(h,g)}function R(h){var g=typeof Map=="function"?new Map:void 0;return R=function(r){if(r===null||!y(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof g!="undefined"){if(g.has(r))return g.get(r);g.set(r,l)}function l(){return O(r,arguments,A(this).constructor)}return l.prototype=Object.create(r.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),T(l,r)},R(h)}function O(h,g,i){return _()?O=Reflect.construct.bind():O=function(l,c,t){var a=[null];a.push.apply(a,c);var u=Function.bind.apply(l,a),s=new u;return t&&T(s,t.prototype),s},O.apply(null,arguments)}function _(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function y(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function T(h,g){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,l){return r.__proto__=l,r},T(h,g)}function A(h){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},A(h)}function E(){return E=Object.assign?Object.assign.bind():function(h){for(var g=1;g<arguments.length;g++){var i=arguments[g];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(h[r]=i[r])}return h},E.apply(this,arguments)}function m(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function h(i){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=i.fetchSetup||e,this.controller=new self.AbortController,this.stats=new L.LoadStats}var g=h.prototype;return g.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},g.abortInternal=function(){var r=this.response;(!r||!r.ok)&&(this.stats.aborted=!0,this.controller.abort())},g.abort=function(){var r;this.abortInternal(),(r=this.callbacks)!==null&&r!==void 0&&r.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},g.load=function(r,l,c){var t=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var u=d(r,this.controller.signal),s=c.onProgress,f=r.responseType==="arraybuffer",v=f?"byteLength":"length";this.context=r,this.config=l,this.callbacks=c,this.request=this.fetchSetup(r,u),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){t.abortInternal(),c.onTimeout(a,r,t.response)},l.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 o(P||"fetch, bad network response",x,S)}return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(S.headers.get("Content-Length")||"0"),s&&Object(I.isFiniteNumber)(l.highWaterMark)?t.loadProgressively(S,a,r,l.highWaterMark,s):f?S.arrayBuffer():S.text()}).then(function(S){var x=t.response;self.clearTimeout(t.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first),a.loaded=a.total=S[v];var P={url:x.url,data:S};s&&!Object(I.isFiniteNumber)(l.highWaterMark)&&s(a,r,S,x),c.onSuccess(P,a,r,x)}).catch(function(S){if(self.clearTimeout(t.requestTimeout),!a.aborted){var x=S&&S.code||0,P=S?S.message:null;c.onError({code:x,text:P},r,S?S.details:null)}})},g.getCacheAge=function(){var r=null;if(this.response){var l=this.response.headers.get("age");r=l?parseFloat(l):null}return r},g.loadProgressively=function(r,l,c,t,a){t===void 0&&(t=0);var u=new D.default,s=r.body.getReader(),f=function v(){return s.read().then(function(S){if(S.done)return u.dataLength&&a(l,c,u.flush(),r),Promise.resolve(new ArrayBuffer(0));var x=S.value,P=x.length;return l.loaded+=P,P<t||u.dataLength?(u.push(x),u.dataLength>=t&&a(l,c,u.flush(),r)):a(l,c,x,r),v()}).catch(function(){return Promise.reject()})};return f()},h}();function d(h,g){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:g,headers:new self.Headers(E({},h.headers))};return h.rangeEnd&&i.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),i}function e(h,g){return new self.Request(h.url,g)}var o=function(h){w(g,h);function g(i,r,l){var c;return c=h.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=r,c.details=l,c}return g}(R(Error));b.default=p},"./src/utils/imsc1-ttml-parser.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"IMSC1_CODEC",function(){return y}),n.d(b,"parseIMSC1",function(){return m});var I=n("./src/utils/mp4-tools.ts"),L=n("./src/utils/vttparser.ts"),D=n("./src/utils/vttcue.ts"),w=n("./src/demux/id3.ts"),R=n("./src/utils/timescale-conversion.ts"),O=n("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign?Object.assign.bind():function(t){for(var a=1;a<arguments.length;a++){var u=arguments[a];for(var s in u)Object.prototype.hasOwnProperty.call(u,s)&&(t[s]=u[s])}return t},_.apply(this,arguments)}var y="stpp.ttml.im1t",T=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,A=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,E={left:"start",center:"center",right:"end",start:"start",end:"end"};function m(t,a,u,s,f){var v=Object(I.findBox)(new Uint8Array(t),["mdat"]);if(v.length===0){f(new Error("Could not parse IMSC1 mdat"));return}var S=v.map(function(P){return Object(w.utf8ArrayToStr)(P)}),x=Object(R.toTimescaleFromScale)(a,1,u);try{S.forEach(function(P){return s(p(P,x))})}catch(P){f(P)}}function p(t,a){var u=new DOMParser,s=u.parseFromString(t,"text/xml"),f=s.getElementsByTagName("tt")[0];if(!f)throw new Error("Invalid ttml");var v={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},S=Object.keys(v).reduce(function(U,W){return U[W]=f.getAttribute("ttp:"+W)||v[W],U},{}),x=f.getAttribute("xml:space")!=="preserve",P=e(d(f,"styling","style")),B=e(d(f,"layout","region")),k=d(f,"body","[begin]");return[].map.call(k,function(U){var W=o(U,x);if(!W||!U.hasAttribute("begin"))return null;var H=r(U.getAttribute("begin"),S),z=r(U.getAttribute("dur"),S),Y=r(U.getAttribute("end"),S);if(H===null)throw i(U);if(Y===null){if(z===null)throw i(U);Y=H+z}var J=new D.default(H-a,Y-a,W);J.id=Object(O.generateCueId)(J.startTime,J.endTime,J.text);var te=B[U.getAttribute("region")],X=P[U.getAttribute("style")];J.position=10,J.size=80;var q=h(te,X,P),ne=q.textAlign;if(ne){var ae=E[ne];ae&&(J.lineAlign=ae),J.align=ne}return _(J,q),J}).filter(function(U){return U!==null})}function d(t,a,u){var s=t.getElementsByTagName(a)[0];return s?[].slice.call(s.querySelectorAll(u)):[]}function e(t){return t.reduce(function(a,u){var s=u.getAttribute("xml:id");return s&&(a[s]=u),a},{})}function o(t,a){return[].slice.call(t.childNodes).reduce(function(u,s,f){var v;return s.nodeName==="br"&&f?u+`
|
|
22
|
-
`:(v=s.childNodes)!==null&&v!==void 0&&v.length?o(s,a):a?u+s.textContent.trim().replace(/\s+/g," "):u+s.textContent},"")}function h(t,a,u){var s="http://www.w3.org/ns/ttml#styling",f=null,v=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],S=t!=null&&t.hasAttribute("style")?t.getAttribute("style"):null;return S&&u.hasOwnProperty(S)&&(f=u[S]),v.reduce(function(x,P){var B=g(a,s,P)||g(t,s,P)||g(f,s,P);return B&&(x[P]=B),x},{})}function g(t,a,u){return t&&t.hasAttributeNS(a,u)?t.getAttributeNS(a,u):null}function i(t){return new Error("Could not parse ttml timestamp "+t)}function r(t,a){if(!t)return null;var u=Object(L.parseTimeStamp)(t);return u===null&&(T.test(t)?u=l(t,a):A.test(t)&&(u=c(t,a))),u}function l(t,a){var u=T.exec(t),s=(u[4]|0)+(u[5]|0)/a.subFrameRate;return(u[1]|0)*3600+(u[2]|0)*60+(u[3]|0)+s/a.frameRate}function c(t,a){var u=A.exec(t),s=Number(u[1]),f=u[2];switch(f){case"h":return s*3600;case"m":return s*60;case"ms":return s*1e3;case"f":return s/a.frameRate;case"t":return s/a.tickRate}return s}},"./src/utils/logger.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"enableLogs",function(){return O}),n.d(b,"logger",function(){return _});var I=function(){},L={trace:I,debug:I,log:I,warn:I,info:I,error:I},D=L;function w(y){var T=self.console[y];return T?T.bind(self.console,"["+y+"] >"):I}function R(y){for(var T=arguments.length,A=new Array(T>1?T-1:0),E=1;E<T;E++)A[E-1]=arguments[E];A.forEach(function(m){D[m]=y[m]?y[m].bind(y):w(m)})}function O(y){if(self.console&&y===!0||typeof y=="object"){R(y,"debug","log","info","warn","error");try{D.log()}catch{D=L}}else D=L}var _=D},"./src/utils/mediakeys-helper.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"KeySystems",function(){return I}),n.d(b,"requestMediaKeySystemAccess",function(){return L});var I;(function(D){D.WIDEVINE="com.widevine.alpha",D.PLAYREADY="com.microsoft.playready"})(I||(I={}));var L=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"getMediaSource",function(){return I});function I(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"RemuxerTrackIdConfig",function(){return O}),n.d(b,"bin2str",function(){return _}),n.d(b,"readUint16",function(){return y}),n.d(b,"readUint32",function(){return T}),n.d(b,"readSint32",function(){return A}),n.d(b,"writeUint32",function(){return E}),n.d(b,"findBox",function(){return m}),n.d(b,"parseSegmentIndex",function(){return p}),n.d(b,"parseInitSegment",function(){return d}),n.d(b,"getStartDTS",function(){return e}),n.d(b,"getDuration",function(){return o}),n.d(b,"computeRawDurationFromSamples",function(){return h}),n.d(b,"offsetStartDTS",function(){return g}),n.d(b,"segmentValidRange",function(){return i}),n.d(b,"appendUint8Array",function(){return r}),n.d(b,"parseSamples",function(){return l}),n.d(b,"parseSEIMessageFromNALu",function(){return a}),n.d(b,"parseEmsg",function(){return s});var I=n("./src/utils/typed-array.ts"),L=n("./src/loader/fragment.ts"),D=n("./src/demux/id3.ts"),w=Math.pow(2,32)-1,R=[].push,O={video:1,audio:2,id3:3,text:4};function _(f){return String.fromCharCode.apply(null,f)}function y(f,v){var S=f[v]<<8|f[v+1];return S<0?65536+S:S}function T(f,v){var S=A(f,v);return S<0?4294967296+S:S}function A(f,v){return f[v]<<24|f[v+1]<<16|f[v+2]<<8|f[v+3]}function E(f,v,S){f[v]=S>>24,f[v+1]=S>>16&255,f[v+2]=S>>8&255,f[v+3]=S&255}function m(f,v){var S=[];if(!v.length)return S;for(var x=f.byteLength,P=0;P<x;){var B=T(f,P),k=_(f.subarray(P+4,P+8)),U=B>1?P+B:x;if(k===v[0])if(v.length===1)S.push(f.subarray(P+8,U));else{var W=m(f.subarray(P+8,U),v.slice(1));W.length&&R.apply(S,W)}P=U}return S}function p(f){var v=[],S=f[0],x=8,P=T(f,x);x+=4;var B=0,k=0;S===0?x+=8:x+=16,x+=2;var U=f.length+k,W=y(f,x);x+=2;for(var H=0;H<W;H++){var z=x,Y=T(f,z);z+=4;var J=Y&2147483647,te=(Y&2147483648)>>>31;if(te===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var X=T(f,z);z+=4,v.push({referenceSize:J,subsegmentDuration:X,info:{duration:X/P,start:U,end:U+J-1}}),U+=J,z+=4,x=z}return{earliestPresentationTime:B,timescale:P,version:S,referencesCount:W,references:v}}function d(f){for(var v=[],S=m(f,["moov","trak"]),x=0;x<S.length;x++){var P=S[x],B=m(P,["tkhd"])[0];if(B){var k=B[0],U=k===0?12:20,W=T(B,U),H=m(P,["mdia","mdhd"])[0];if(H){k=H[0],U=k===0?12:20;var z=T(H,U),Y=m(P,["mdia","hdlr"])[0];if(Y){var J=_(Y.subarray(8,12)),te={soun:L.ElementaryStreamTypes.AUDIO,vide:L.ElementaryStreamTypes.VIDEO}[J];if(te){var X=m(P,["mdia","minf","stbl","stsd"])[0],q=void 0;X&&(q=_(X.subarray(12,16))),v[W]={timescale:z,type:te},v[te]={timescale:z,id:W,codec:q}}}}}}var ne=m(f,["moov","mvex","trex"]);return ne.forEach(function(ae){var re=T(ae,4),le=v[re];le&&(le.default={duration:T(ae,12),flags:T(ae,20)})}),v}function e(f,v){return m(v,["moof","traf"]).reduce(function(S,x){var P=m(x,["tfdt"])[0],B=P[0],k=m(x,["tfhd"]).reduce(function(U,W){var H=T(W,4),z=f[H];if(z){var Y=T(P,4);B===1&&(Y*=Math.pow(2,32),Y+=T(P,8));var J=z.timescale||9e4,te=Y/J;if(isFinite(te)&&(U===null||te<U))return te}return U},null);return k!==null&&isFinite(k)&&(S===null||k<S)?k:S},null)||0}function o(f,v){for(var S=0,x=0,P=0,B=m(f,["moof","traf"]),k=0;k<B.length;k++){var U=B[k],W=m(U,["tfhd"])[0],H=T(W,4),z=v[H];if(!!z){var Y=z.default,J=T(W,0)|(Y==null?void 0:Y.flags),te=Y==null?void 0:Y.duration;J&8&&(J&2?te=T(W,12):te=T(W,8));for(var X=z.timescale||9e4,q=m(U,["trun"]),ne=0;ne<q.length;ne++){if(S=h(q[ne]),!S&&te){var ae=T(q[ne],4);S=te*ae}z.type===L.ElementaryStreamTypes.VIDEO?x+=S/X:z.type===L.ElementaryStreamTypes.AUDIO&&(P+=S/X)}}}if(x===0&&P===0){for(var re=0,le=m(f,["sidx"]),fe=0;fe<le.length;fe++){var ie=p(le[fe]);ie!=null&&ie.references&&(re+=ie.references.reduce(function(ge,pe){return ge+pe.info.duration||0},0))}return re}return x||P}function h(f){var v=T(f,0),S=8;v&1&&(S+=4),v&4&&(S+=4);for(var x=0,P=T(f,4),B=0;B<P;B++){if(v&256){var k=T(f,S);x+=k,S+=4}v&512&&(S+=4),v&1024&&(S+=4),v&2048&&(S+=4)}return x}function g(f,v,S){m(v,["moof","traf"]).forEach(function(x){m(x,["tfhd"]).forEach(function(P){var B=T(P,4),k=f[B];if(!!k){var U=k.timescale||9e4;m(x,["tfdt"]).forEach(function(W){var H=W[0],z=T(W,4);if(H===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/(w+1)),J=Math.floor(z%(w+1));E(W,4,Y),E(W,8,J)}})}})})}function i(f){var v={valid:null,remainder:null},S=m(f,["moof"]);if(S){if(S.length<2)return v.remainder=f,v}else return v;var x=S[S.length-1];return v.valid=Object(I.sliceUint8)(f,0,x.byteOffset-8),v.remainder=Object(I.sliceUint8)(f,x.byteOffset-8),v}function r(f,v){var S=new Uint8Array(f.length+v.length);return S.set(f),S.set(v,f.length),S}function l(f,v){var S=[],x=v.samples,P=v.timescale,B=v.id,k=!1,U=m(x,["moof"]);return U.map(function(W){var H=W.byteOffset-8,z=m(W,["traf"]);z.map(function(Y){var J=m(Y,["tfdt"]).map(function(te){var X=te[0],q=T(te,4);return X===1&&(q*=Math.pow(2,32),q+=T(te,8)),q/P})[0];return J!==void 0&&(f=J),m(Y,["tfhd"]).map(function(te){var X=T(te,4),q=T(te,0)&16777215,ne=(q&1)!==0,ae=(q&2)!==0,re=(q&8)!==0,le=0,fe=(q&16)!==0,ie=0,ge=(q&32)!==0,pe=8;X===B&&(ne&&(pe+=8),ae&&(pe+=4),re&&(le=T(te,pe),pe+=4),fe&&(ie=T(te,pe),pe+=4),ge&&(pe+=4),v.type==="video"&&(k=c(v.codec)),m(Y,["trun"]).map(function(De){var Me=De[0],Oe=T(De,0)&16777215,je=(Oe&1)!==0,Pe=0,Be=(Oe&4)!==0,Ee=(Oe&256)!==0,we=0,Ue=(Oe&512)!==0,Ye=0,Ne=(Oe&1024)!==0,Je=(Oe&2048)!==0,Ge=0,ot=T(De,4),Fe=8;je&&(Pe=T(De,Fe),Fe+=4),Be&&(Fe+=4);for(var We=Pe+H,Ze=0;Ze<ot;Ze++){if(Ee?(we=T(De,Fe),Fe+=4):we=le,Ue?(Ye=T(De,Fe),Fe+=4):Ye=ie,Ne&&(Fe+=4),Je&&(Me===0?Ge=T(De,Fe):Ge=A(De,Fe),Fe+=4),v.type===L.ElementaryStreamTypes.VIDEO)for(var ke=0;ke<Ye;){var Re=T(x,We);We+=4;var lt=x[We]&31;if(t(k,lt)){var qe=x.subarray(We,We+Re);a(qe,f+Ge/P,S)}We+=Re,ke+=Re+4}f+=we/P}}))})})}),S}function c(f){if(!f)return!1;var v=f.indexOf("."),S=v<0?f:f.substring(0,v);return S==="hvc1"||S==="hev1"||S==="dvh1"||S==="dvhe"}function t(f,v){return f?v===39||v===40:v===6}function a(f,v,S){var x=u(f),P=0;P++;for(var B=0,k=0,U=!1,W=0;P<x.length;){B=0;do{if(P>=x.length)break;W=x[P++],B+=W}while(W===255);k=0;do{if(P>=x.length)break;W=x[P++],k+=W}while(W===255);var H=x.length-P;if(!U&&B===4&&P<x.length){U=!0;var z=x[P++];if(z===181){var Y=y(x,P);if(P+=2,Y===49){var J=T(x,P);if(P+=4,J===1195456820){var te=x[P++];if(te===3){var X=x[P++],q=31&X,ne=64&X,ae=ne?2+q*3:0,re=new Uint8Array(ae);if(ne){re[0]=X;for(var le=1;le<ae;le++)re[le]=x[P++]}S.push({type:te,payloadType:B,pts:v,bytes:re})}}}}}else if(B===5&&k<H){if(U=!0,k>16){for(var fe=[],ie=0;ie<16;ie++){var ge=x[P++].toString(16);fe.push(ge.length==1?"0"+ge:ge),(ie===3||ie===5||ie===7||ie===9)&&fe.push("-")}for(var pe=k-16,De=new Uint8Array(pe),Me=0;Me<pe;Me++)De[Me]=x[P++];S.push({payloadType:B,pts:v,uuid:fe.join(""),userData:Object(D.utf8ArrayToStr)(De),userDataBytes:De})}}else if(k<H)P+=k;else if(k>H)break}}function u(f){for(var v=f.byteLength,S=[],x=1;x<v-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=v-S.length,B=new Uint8Array(P),k=0;for(x=0;x<P;k++,x++)k===S[0]&&(k++,S.shift()),B[x]=f[k];return B}function s(f){var v=f[0],S="",x="",P=0,B=0,k=0,U=0,W=0,H=0;if(v===0){for(;_(f.subarray(H,H+1))!=="\0";)S+=_(f.subarray(H,H+1)),H+=1;for(S+=_(f.subarray(H,H+1)),H+=1;_(f.subarray(H,H+1))!=="\0";)x+=_(f.subarray(H,H+1)),H+=1;x+=_(f.subarray(H,H+1)),H+=1,P=T(f,12),B=T(f,16),U=T(f,20),W=T(f,24),H=28}else if(v===1){H+=4,P=T(f,H),H+=4;var z=T(f,H);H+=4;var Y=T(f,H);for(H+=4,k=Math.pow(2,32)*z+Y,Number.isSafeInteger(k)||(k=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,H),H+=4,W=T(f,H),H+=4;_(f.subarray(H,H+1))!=="\0";)S+=_(f.subarray(H,H+1)),H+=1;for(S+=_(f.subarray(H,H+1)),H+=1;_(f.subarray(H,H+1))!=="\0";)x+=_(f.subarray(H,H+1)),H+=1;x+=_(f.subarray(H,H+1)),H+=1}var J=f.subarray(H,f.byteLength);return{schemeIdUri:S,value:x,timeScale:P,presentationTime:k,presentationTimeDelta:B,eventDuration:U,id:W,payload:J}}},"./src/utils/output-filter.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"default",function(){return I});var I=function(){function L(w,R){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=w,this.trackName=R}var D=L.prototype;return D.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},D.newCue=function(R,O,_){(this.startTime===null||this.startTime>R)&&(this.startTime=R),this.endTime=O,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},D.reset=function(){this.cueRanges=[],this.startTime=null},L}()},"./src/utils/texttrack-utils.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"sendAddTrackEvent",function(){return L}),n.d(b,"addCueToTrack",function(){return D}),n.d(b,"clearCurrentCues",function(){return w}),n.d(b,"removeCuesInRange",function(){return R}),n.d(b,"getCuesInRange",function(){return _});var I=n("./src/utils/logger.ts");function L(y,T){var A;try{A=new Event("addtrack")}catch{A=document.createEvent("Event"),A.initEvent("addtrack",!1,!1)}A.track=y,T.dispatchEvent(A)}function D(y,T){var A=y.mode;if(A==="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){I.logger.debug("[texttrack-utils]: "+m);var E=new self.TextTrackCue(T.startTime,T.endTime,T.text);E.id=T.id,y.addCue(E)}A==="disabled"&&(y.mode=A)}function w(y){var T=y.mode;if(T==="disabled"&&(y.mode="hidden"),y.cues)for(var A=y.cues.length;A--;)y.removeCue(y.cues[A]);T==="disabled"&&(y.mode=T)}function R(y,T,A,E){var m=y.mode;if(m==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var p=_(y.cues,T,A),d=0;d<p.length;d++)(!E||E(p[d]))&&y.removeCue(p[d]);m==="disabled"&&(y.mode=m)}function O(y,T){if(T<y[0].startTime)return 0;var A=y.length-1;if(T>y[A].endTime)return-1;for(var E=0,m=A;E<=m;){var p=Math.floor((m+E)/2);if(T<y[p].startTime)m=p-1;else if(T>y[p].startTime&&E<A)E=p+1;else return p}return y[E].startTime-T<T-y[m].startTime?E:m}function _(y,T,A){var E=[],m=O(y,T);if(m>-1)for(var p=m,d=y.length;p<d;p++){var e=y[p];if(e.startTime>=T&&e.endTime<=A)E.push(e);else if(e.startTime>A)return E}return E}},"./src/utils/time-ranges.ts":function(j,b,n){"use strict";n.r(b);var I={toString:function(D){for(var w="",R=D.length,O=0;O<R;O++)w+="["+D.start(O).toFixed(3)+","+D.end(O).toFixed(3)+"]";return w}};b.default=I},"./src/utils/timescale-conversion.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"toTimescaleFromBase",function(){return L}),n.d(b,"toTimescaleFromScale",function(){return D}),n.d(b,"toMsFromMpegTsClock",function(){return w}),n.d(b,"toMpegTsClockFromTimescale",function(){return R});var I=9e4;function L(O,_,y,T){y===void 0&&(y=1),T===void 0&&(T=!1);var A=O*_*y;return T?Math.round(A):A}function D(O,_,y,T){return y===void 0&&(y=1),T===void 0&&(T=!1),L(O,_,1/y,T)}function w(O,_){return _===void 0&&(_=!1),L(O,1e3,1/I,_)}function R(O,_){return _===void 0&&(_=1),L(O,I,1/_)}},"./src/utils/typed-array.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"sliceUint8",function(){return I});function I(L,D,w){return Uint8Array.prototype.slice?L.slice(D,w):new Uint8Array(Array.prototype.slice.call(L,D,w))}},"./src/utils/vttcue.ts":function(j,b,n){"use strict";n.r(b),b.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var I=["","lr","rl"],L=["start","middle","end","left","right"];function D(y,T){if(typeof T!="string"||!Array.isArray(y))return!1;var A=T.toLowerCase();return~y.indexOf(A)?A:!1}function w(y){return D(I,y)}function R(y){return D(L,y)}function O(y){for(var T=arguments.length,A=new Array(T>1?T-1:0),E=1;E<T;E++)A[E-1]=arguments[E];for(var m=1;m<arguments.length;m++){var p=arguments[m];for(var d in p)y[d]=p[d]}return y}function _(y,T,A){var E=this,m={enumerable:!0};E.hasBeenReset=!1;var p="",d=!1,e=y,o=T,h=A,g=null,i="",r=!0,l="auto",c="start",t=50,a="middle",u=50,s="middle";Object.defineProperty(E,"id",O({},m,{get:function(){return p},set:function(v){p=""+v}})),Object.defineProperty(E,"pauseOnExit",O({},m,{get:function(){return d},set:function(v){d=!!v}})),Object.defineProperty(E,"startTime",O({},m,{get:function(){return e},set:function(v){if(typeof v!="number")throw new TypeError("Start time must be set to a number.");e=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"endTime",O({},m,{get:function(){return o},set:function(v){if(typeof v!="number")throw new TypeError("End time must be set to a number.");o=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"text",O({},m,{get:function(){return h},set:function(v){h=""+v,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",O({},m,{get:function(){return g},set:function(v){g=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",O({},m,{get:function(){return i},set:function(v){var S=w(v);if(S===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",O({},m,{get:function(){return r},set:function(v){r=!!v,this.hasBeenReset=!0}})),Object.defineProperty(E,"line",O({},m,{get:function(){return l},set:function(v){if(typeof v!="number"&&v!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");l=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"lineAlign",O({},m,{get:function(){return c},set:function(v){var S=R(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");c=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"position",O({},m,{get:function(){return t},set:function(v){if(v<0||v>100)throw new Error("Position must be between 0 and 100.");t=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"positionAlign",O({},m,{get:function(){return a},set:function(v){var S=R(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");a=S,this.hasBeenReset=!0}})),Object.defineProperty(E,"size",O({},m,{get:function(){return u},set:function(v){if(v<0||v>100)throw new Error("Size must be between 0 and 100.");u=v,this.hasBeenReset=!0}})),Object.defineProperty(E,"align",O({},m,{get:function(){return s},set:function(v){var S=R(v);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");s=S,this.hasBeenReset=!0}})),E.displayState=void 0}return _.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(j,b,n){"use strict";n.r(b),n.d(b,"parseTimeStamp",function(){return D}),n.d(b,"fixLineBreaks",function(){return T}),n.d(b,"VTTParser",function(){return A});var I=n("./src/utils/vttcue.ts"),L=function(){function E(){}var m=E.prototype;return m.decode=function(d,e){if(!d)return"";if(typeof d!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(d))},E}();function D(E){function m(d,e,o,h){return(d|0)*3600+(e|0)*60+(o|0)+parseFloat(h||0)}var p=E.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?m(p[2],p[3],0,p[4]):m(p[1],p[2],p[3],p[4]):null}var w=function(){function E(){this.values=Object.create(null)}var m=E.prototype;return m.set=function(d,e){!this.get(d)&&e!==""&&(this.values[d]=e)},m.get=function(d,e,o){return o?this.has(d)?this.values[d]:e[o]:this.has(d)?this.values[d]:e},m.has=function(d){return d in this.values},m.alt=function(d,e,o){for(var h=0;h<o.length;++h)if(e===o[h]){this.set(d,e);break}},m.integer=function(d,e){/^-?\d+$/.test(e)&&this.set(d,parseInt(e,10))},m.percent=function(d,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var o=parseFloat(e);if(o>=0&&o<=100)return this.set(d,o),!0}return!1},E}();function R(E,m,p,d){var e=d?E.split(d):[E];for(var o in e)if(typeof e[o]=="string"){var h=e[o].split(p);if(h.length===2){var g=h[0],i=h[1];m(g,i)}}}var O=new I.default(0,0,""),_=O.align==="middle"?"middle":"center";function y(E,m,p){var d=E;function e(){var g=D(E);if(g===null)throw new Error("Malformed timestamp: "+d);return E=E.replace(/^[^\sa-zA-Z-]+/,""),g}function o(g,i){var r=new w;R(g,function(t,a){var u;switch(t){case"region":for(var s=p.length-1;s>=0;s--)if(p[s].id===a){r.set(t,p[s].region);break}break;case"vertical":r.alt(t,a,["rl","lr"]);break;case"line":u=a.split(","),r.integer(t,u[0]),r.percent(t,u[0])&&r.set("snapToLines",!1),r.alt(t,u[0],["auto"]),u.length===2&&r.alt("lineAlign",u[1],["start",_,"end"]);break;case"position":u=a.split(","),r.percent(t,u[0]),u.length===2&&r.alt("positionAlign",u[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,a);break;case"align":r.alt(t,a,["start",_,"end","left","right"]);break}},/:/,/\s/),i.region=r.get("region",null),i.vertical=r.get("vertical","");var l=r.get("line","auto");l==="auto"&&O.line===-1&&(l=-1),i.line=l,i.lineAlign=r.get("lineAlign","start"),i.snapToLines=r.get("snapToLines",!0),i.size=r.get("size",100),i.align=r.get("align",_);var c=r.get("position","auto");c==="auto"&&O.position===50&&(c=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=c}function h(){E=E.replace(/^\s+/,"")}if(h(),m.startTime=e(),h(),E.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+d);E=E.slice(3),h(),m.endTime=e(),h(),o(E,m)}function T(E){return E.replace(/<br(?: \/)?>/gi,`
|
|
23
|
-
`)}var A=function(){function E(){this.state="INITIAL",this.buffer="",this.decoder=new L,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var m=E.prototype;return m.parse=function(d){var e=this;d&&(e.buffer+=e.decoder.decode(d,{stream:!0}));function o(){var c=e.buffer,t=0;for(c=T(c);t<c.length&&c[t]!=="\r"&&c[t]!==`
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
7
|
+
`))this.processLine(this.buffer.substring(0,C)),this.buffer=this.buffer.substring(C+1)},yr.prototype.processLine=function(N){var C=N.indexOf(":"),w=wn(N,C),G=w[0],j=w.length===2?Nr(w[1]):void 0;if(G[0]!=="#")this.currentUri.uri=G,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(G){case An:if(!isFinite(j)||j<0)return;this.manifest.targetDuration=j,this.setHoldBack();break;case Dn:Ur(this.manifest,w),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case bn:Ur(this.manifest,w),this.setHoldBack();break;case Ln:j===0?this.currentUri.duration=.01:j>0&&(this.currentUri.duration=j);break;case Pn:var J=j,z=new Date(J);this.manifest.dateTimeString||(this.manifest.dateTimeString=J,this.manifest.dateTimeObject=z),this.currentUri.dateTimeString=J,this.currentUri.dateTimeObject=z;break;case Rn:Ur(this.manifest,w);break;case In:var Z=kn(w[1]),ne=g(Z);a()(this.manifest.sessionData,ne)}},yr.prototype.setHoldBack=function(){var N=this.manifest,C=N.serverControl,w=N.targetDuration,G=N.partTargetDuration;if(C){var j="holdBack",J="partHoldBack",z=w&&3*w,Z=G&&2*G;w&&!C.hasOwnProperty(j)&&(C[j]=z),z&&C[j]<z&&(C[j]=z),G&&!C.hasOwnProperty(J)&&(C[J]=3*G),G&&C[J]<Z&&(C[J]=Z)}};var Ur=function(N,C){var w,G=Si(C[0].replace("#EXT-X-",""));Mn(C[1])?(w={},w=a()(Cn(C[1]),w)):w=Nr(C[1]),N[G]=w},Si=function(N){return N.toLowerCase().replace(/-(\w)/g,function(C){return C[1].toUpperCase()})},Nr=function(N){if(N.toLowerCase()==="yes"||N.toLowerCase()==="no")return N.toLowerCase()==="yes";var C=N.indexOf(":")!==-1?N:parseFloat(N);return isNaN(C)?N:C},On=function(N){var C={},w=N.split("=");return w.length>1&&(C[Si(w[0])]=Nr(w[1])),C},Cn=function(N){for(var C=N.split(","),w={},G=0;C.length>G;G++){var j=C[G],J=On(j);w=a()(J,w)}return w},Mn=function(N){return N.indexOf("=")>-1},wn=function(N,C){return C===-1?[N]:[N.substring(0,C),N.substring(C+1)]},kn=function(N){var C={};if(N){var w=N.search(",");return[N.slice(0,w),N.slice(w+1)].forEach(function(G,j){for(var J=G.replace(/['"]+/g,"").split("="),z=0;z<J.length;z++)J[z]==="DATA-ID"&&(C["DATA-ID"]=J[1-z]),J[z]==="VALUE"&&(C.VALUE=J[1-z])}),{data:C}}},Fn=yr,Un={safeCall:function(N,C,w,G){var j=G;if(N&&typeof N[C]=="function")try{j=N[C].apply(N,w)}catch(J){f.info("safeCall error",J)}return j},safeIncrement:l,getComputedStyle:function(N,C){var w;if(N&&C&&M()&&typeof M().getComputedStyle=="function")return Mt&&Mt.has(N)&&(w=Mt.get(N)),w||(w=M().getComputedStyle(N,null),Mt&&Mt.set(N,w)),w.getPropertyValue(C)},secondsToMs:function(N){return Math.floor(1e3*N)},assign:a(),headersStringToObject:u,extractHostnameAndDomain:n,extractHostname:s,manifestParser:Fn,generateShortID:U,generateUUID:P,now:p.now},Nn={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 Bn(N,C){return function(w){if(Array.isArray(w))return w}(N)||function(w,G){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var J,z,Z=[],ne=!0,te=!1;try{for(j=j.call(w);!(ne=(J=j.next()).done)&&(Z.push(J.value),!G||Z.length!==G);ne=!0);}catch(oe){te=!0,z=oe}finally{try{ne||j.return==null||j.return()}finally{if(te)throw z}}return Z}}(N,C)||function(w,G){if(w){if(typeof w=="string")return xi(w,G);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?xi(w,G):void 0}}(N,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
8
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function xi(N,C){(C==null||C>N.length)&&(C=N.length);for(var w=0,G=new Array(C);w<C;w++)G[w]=N[w];return G}var mt={},$t=function N(C){var w=arguments;typeof C=="string"?N.hasOwnProperty(C)?M().setTimeout(function(){w=Array.prototype.splice.call(w,1),N[C].apply(null,w)},0):f.warn("`"+C+"` is an unknown task"):typeof C=="function"?M().setTimeout(function(){C(N)},0):f.warn("`"+C+"` is invalid.")},Kn={loaded:p.now(),NAME:"mux-embed",VERSION:"4.17.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(N,C){return function(w,G,j){var J=_i(A(G),3),z=J[0],Z=J[1],ne=J[2],te=w.log,oe=w.utils.getComputedStyle,Te=w.utils.secondsToMs;if(!z)return te.error("No element was found with the `"+Z+"` query selector.");if(ne!=="video"&&ne!=="audio")return te.error("The element of `"+Z+"` was not a media element.");z.mux&&(z.mux.destroy(),delete z.mux,te.warn("Already monitoring this video element, replacing existing event listeners")),(j=a()({automaticErrorTracking:!0},j)).data=a()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:w.VERSION},j.data),j.getPlayheadTime=function(){return Te(z.currentTime)},j.getStateData=function(){var Ee,ve,_e=this.hlsjs&&this.hlsjs.url,Ce=this.dashjs&&Fr(this.dashjs.getSource==="function")&&this.dashjs.getSource(),ze={player_is_paused:z.paused,player_playhead_time:Te(z.currentTime),player_width:parseInt(oe(z,"width")),player_height:parseInt(oe(z,"height")),player_autoplay_on:z.autoplay,player_preload_on:z.preload,player_language_code:z.lang,player_is_fullscreen:Qt()&&!!(Qt().fullscreenElement||Qt().webkitFullscreenElement||Qt().mozFullScreenElement||Qt().msFullscreenElement),video_poster_url:z.poster,video_source_url:_e||Ce||z.currentSrc,video_source_duration:Te(z.duration),video_source_height:z.videoHeight,video_source_width:z.videoWidth,view_dropped_frame_count:(Ee=z)===null||Ee===void 0||(ve=Ee.getVideoPlaybackQuality)===null||ve===void 0?void 0:ve.call(Ee).droppedVideoFrames},Qe=j.getPlayheadTime();if(z.getStartDate&&Qe>0){var ut=z.getStartDate();if(ut&&typeof ut.getTime=="function"&&ut.getTime()){var Ie=ut.getTime();if(ze.player_program_time=Ie+Qe,z.seekable.length>0){var $e=Ie+z.seekable.end(z.seekable.length-1);ze.player_live_edge_program_time=$e}}}return ze},z.mux=z.mux||{},z.mux.deleted=!1,z.mux.emit=function(Ee,ve){w.emit(Z,Ee,ve)};var ge=function(){te.error("The monitor for this video element has already been destroyed.")};z.mux.destroy=function(){Object.keys(z.mux.listeners).forEach(function(Ee){z.removeEventListener(Ee,z.mux.listeners[Ee],!1)}),delete z.mux.listeners,z.mux.destroy=ge,z.mux.swapElement=ge,z.mux.emit=ge,z.mux.addHLSJS=ge,z.mux.addDashJS=ge,z.mux.removeHLSJS=ge,z.mux.removeDashJS=ge,z.mux.deleted=!0,w.emit(Z,"destroy")},z.mux.swapElement=function(Ee){var ve=_i(A(Ee),3),_e=ve[0],Ce=ve[1],ze=ve[2];return _e?ze!=="video"&&ze!=="audio"?w.log.error("The element of `"+Ce+"` was not a media element."):(_e.muxId=z.muxId,delete z.muxId,_e.mux=_e.mux||{},_e.mux.listeners=a()({},z.mux.listeners),delete z.mux.listeners,Object.keys(_e.mux.listeners).forEach(function(Qe){z.removeEventListener(Qe,_e.mux.listeners[Qe],!1),_e.addEventListener(Qe,_e.mux.listeners[Qe],!1)}),_e.mux.swapElement=z.mux.swapElement,_e.mux.destroy=z.mux.destroy,delete z.mux,void(z=_e)):w.log.error("No element was found with the `"+Ce+"` query selector.")},z.mux.addHLSJS=function(Ee){w.addHLSJS(Z,Ee)},z.mux.addDashJS=function(Ee){w.addDashJS(Z,Ee)},z.mux.removeHLSJS=function(){w.removeHLSJS(Z)},z.mux.removeDashJS=function(){w.removeDashJS(Z)},w.init(Z,j),w.emit(Z,"playerready"),z.paused||(w.emit(Z,"play"),z.readyState>2&&w.emit(Z,"playing")),z.mux.listeners={},Sn.forEach(function(Ee){(Ee!=="error"||j.automaticErrorTracking)&&(z.mux.listeners[Ee]=function(){var ve={};if(Ee==="error"){if(!z.error||z.error.code===1)return;ve.player_error_code=z.error.code,ve.player_error_message=xn[z.error.code]||z.error.message}w.emit(Z,Ee,ve)},z.addEventListener(Ee,z.mux.listeners[Ee],!1))})}($t,N,C)},destroyMonitor:function(N){var C=Bn(A(N),1)[0];C&&C.mux&&typeof C.mux.destroy=="function"?C.mux.destroy():f.error("A video element monitor for `"+N+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(N,C){var w=b(N);mt[w]?mt[w].addHLSJS(C):f.error("A monitor for `"+w+"` has not been initialized.")},addDashJS:function(N,C){var w=b(N);mt[w]?mt[w].addDashJS(C):f.error("A monitor for `"+w+"` has not been initialized.")},removeHLSJS:function(N){var C=b(N);mt[C]?mt[C].removeHLSJS():f.error("A monitor for `"+C+"` has not been initialized.")},removeDashJS:function(N){var C=b(N);mt[C]?mt[C].removeDashJS():f.error("A monitor for `"+C+"` has not been initialized.")},init:function(N,C){_()&&C&&C.respectDoNotTrack&&f.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var w=b(N);mt[w]=new _n($t,w,C)},emit:function(N,C,w){var G=b(N);mt[G]?(mt[G].emit(C,w),C==="destroy"&&delete mt[G]):f.error("A monitor for `"+G+"` has not been initialized.")},checkDoNotTrack:_,log:f,utils:Un,events:Nn,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign($t,Kn),M()!==void 0&&typeof M().addEventListener=="function"&&M().addEventListener("pagehide",function(N){N.persisted||($t.WINDOW_UNLOADING=!0)},!1);var Wn=$t},655:function(B,T,O){var D,M;function P(U){return P=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(b){return typeof b}:function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},P(U);}(function(U){var b=!1;if((M=typeof(D=U)=="function"?D.call(T,O,T,B):D)===void 0||(B.exports=M),b=!0,P(T)==="object"&&(B.exports=U(),b=!0),!b){var A=window.Cookies,S=window.Cookies=U();S.noConflict=function(){return window.Cookies=A,S}}})(function(){var U=function(){for(var b=0,A={};b<arguments.length;b++){var S=arguments[b];for(var E in S)A[E]=S[E]}return A};return function b(A){function S(E,x,f){var _;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(f=U({path:"/"},S.defaults,f)).expires=="number"){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*f.expires),f.expires=p}try{_=JSON.stringify(x),/^[\{\[]/.test(_)&&(x=_)}catch{}return x=A.write?A.write(x,E):encodeURIComponent(String(x)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),E=(E=(E=encodeURIComponent(String(E))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[E,"=",x,f.expires?"; expires="+f.expires.toUTCString():"",f.path?"; path="+f.path:"",f.domain?"; domain="+f.domain:"",f.secure?"; secure":""].join("")}E||(_={});for(var v=document.cookie?document.cookie.split("; "):[],a=/(%[0-9A-Z]{2})+/g,s=0;s<v.length;s++){var n=v[s].split("="),d=n.slice(1).join("=");d.charAt(0)==='"'&&(d=d.slice(1,-1));try{var l=n[0].replace(a,decodeURIComponent);if(d=A.read?A.read(d,l):A(d,l)||d.replace(a,decodeURIComponent),this.json)try{d=JSON.parse(d)}catch{}if(E===l){_=d;break}E||(_[l]=d)}catch{}}return _}}return S.set=S,S.get=function(E){return S.call(S,E)},S.getJSON=function(){return S.apply({json:!0},[].slice.call(arguments))},S.defaults={},S.remove=function(E,x){S(E,"",U(x,{expires:-1}))},S.withConverter=b,S}(function(){})})},153:function(B,T,O){var D,M=O.g!==void 0?O.g:typeof window!="undefined"?window:{},P=O(558);typeof document!="undefined"?D=document:(D=M["__GLOBAL_DOCUMENT_CACHE@4"])||(D=M["__GLOBAL_DOCUMENT_CACHE@4"]=P),B.exports=D},48:function(B,T,O){var D;D=typeof window!="undefined"?window:O.g!==void 0?O.g:typeof self!="undefined"?self:{},B.exports=D},678:function(B){var T=9007199254740991,O="[object Arguments]",D="[object Function]",M="[object GeneratorFunction]",P=/^(?:0|[1-9]\d*)$/;function U(e,r,t){switch(t.length){case 0:return e.call(r);case 1:return e.call(r,t[0]);case 2:return e.call(r,t[0],t[1]);case 3:return e.call(r,t[0],t[1],t[2])}return e.apply(r,t)}var b,A,S=Object.prototype,E=S.hasOwnProperty,x=S.toString,f=S.propertyIsEnumerable,_=(b=Object.keys,A=Object,function(e){return b(A(e))}),p=Math.max,v=!f.call({valueOf:1},"valueOf");function a(e,r){var t=i(e)||function(L){return function(R){return function(I){return!!I&&typeof I=="object"}(R)&&u(R)}(L)&&E.call(L,"callee")&&(!f.call(L,"callee")||x.call(L)==O)}(e)?function(L,R){for(var I=-1,k=Array(L);++I<L;)k[I]=R(I);return k}(e.length,String):[],o=t.length,y=!!o;for(var h in e)!r&&!E.call(e,h)||y&&(h=="length"||n(h,o))||t.push(h);return t}function s(e,r,t){var o=e[r];E.call(e,r)&&l(o,t)&&(t!==void 0||r in e)||(e[r]=t)}function n(e,r){return!!(r=r==null?T:r)&&(typeof e=="number"||P.test(e))&&e>-1&&e%1==0&&e<r}function d(e){var r=e&&e.constructor;return e===(typeof r=="function"&&r.prototype||S)}function l(e,r){return e===r||e!=e&&r!=r}var i=Array.isArray;function u(e){return e!=null&&function(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=T}(e.length)&&!function(r){var t=g(r)?x.call(r):"";return t==D||t==M}(e)}function g(e){var r=typeof e;return!!e&&(r=="object"||r=="function")}var c,m=(c=function(e,r){if(v||d(r)||u(r))(function(o,y,h,L){h||(h={});for(var R=-1,I=y.length;++R<I;){var k=y[R],F=L?L(h[k],o[k],k,h,o):void 0;s(h,k,F===void 0?o[k]:F)}})(r,function(o){return u(o)?a(o):function(y){if(!d(y))return _(y);var h=[];for(var L in Object(y))E.call(y,L)&&L!="constructor"&&h.push(L);return h}(o)}(r),e);else for(var t in r)E.call(r,t)&&s(e,t,r[t])},function(e,r){return r=p(r===void 0?e.length-1:r,0),function(){for(var t=arguments,o=-1,y=p(t.length-r,0),h=Array(y);++o<y;)h[o]=t[r+o];o=-1;for(var L=Array(r+1);++o<r;)L[o]=t[o];return L[r]=h,U(e,this,L)}}(function(e,r){var t=-1,o=r.length,y=o>1?r[o-1]:void 0,h=o>2?r[2]:void 0;for(y=c.length>3&&typeof y=="function"?(o--,y):void 0,h&&function(R,I,k){if(!g(k))return!1;var F=typeof I;return!!(F=="number"?u(k)&&n(I,k.length):F=="string"&&I in k)&&l(k[I],R)}(r[0],r[1],h)&&(y=o<3?void 0:y,o=1),e=Object(e);++t<o;){var L=r[t];L&&c(e,L,t,y)}return e}));B.exports=m},640:function(B,T,O){var D,M;(function(P,U){"use strict";D=function(){var b=function(){},A="undefined",S=typeof window!==A&&typeof window.navigator!==A&&/Trident\/|MSIE /.test(window.navigator.userAgent),E=["trace","debug","info","warn","error"];function x(i,u){var g=i[u];if(typeof g.bind=="function")return g.bind(i);try{return Function.prototype.bind.call(g,i)}catch{return function(){return Function.prototype.apply.apply(g,[i,arguments])}}}function f(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function _(i){return i==="debug"&&(i="log"),typeof console!==A&&(i==="trace"&&S?f:console[i]!==void 0?x(console,i):console.log!==void 0?x(console,"log"):b)}function p(i,u){for(var g=0;g<E.length;g++){var c=E[g];this[c]=g<i?b:this.methodFactory(c,i,u)}this.log=this.debug}function v(i,u,g){return function(){typeof console!==A&&(p.call(this,u,g),this[i].apply(this,arguments))}}function a(i,u,g){return _(i)||v.apply(this,arguments)}function s(i,u,g){var c,m=this;u=u==null?"WARN":u;var e="loglevel";function r(h){var L=(E[h]||"silent").toUpperCase();if(typeof window!==A&&e){try{return void(window.localStorage[e]=L)}catch{}try{window.document.cookie=encodeURIComponent(e)+"="+L+";"}catch{}}}function t(){var h;if(typeof window!==A&&e){try{h=window.localStorage[e]}catch{}if(typeof h===A)try{var L=window.document.cookie,R=L.indexOf(encodeURIComponent(e)+"=");R!==-1&&(h=/^([^;]+)/.exec(L.slice(R))[1])}catch{}return m.levels[h]===void 0&&(h=void 0),h}}function o(){if(typeof window!==A&&e){try{return void window.localStorage.removeItem(e)}catch{}try{window.document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof i=="string"?e+=":"+i:typeof i=="symbol"&&(e=void 0),m.name=i,m.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},m.methodFactory=g||a,m.getLevel=function(){return c},m.setLevel=function(h,L){if(typeof h=="string"&&m.levels[h.toUpperCase()]!==void 0&&(h=m.levels[h.toUpperCase()]),!(typeof h=="number"&&h>=0&&h<=m.levels.SILENT))throw"log.setLevel() called with invalid level: "+h;if(c=h,L!==!1&&r(h),p.call(m,h,i),typeof console===A&&h<m.levels.SILENT)return"No console available for logging"},m.setDefaultLevel=function(h){u=h,t()||m.setLevel(h,!1)},m.resetLevel=function(){m.setLevel(u,!1),o()},m.enableAll=function(h){m.setLevel(m.levels.TRACE,h)},m.disableAll=function(h){m.setLevel(m.levels.SILENT,h)};var y=t();y==null&&(y=u),m.setLevel(y,!1)}var n=new s,d={};n.getLogger=function(i){if(typeof i!="symbol"&&typeof i!="string"||i==="")throw new TypeError("You must supply a name when creating a logger.");var u=d[i];return u||(u=d[i]=new s(i,n.getLevel(),n.methodFactory)),u};var l=typeof window!==A?window.log:void 0;return n.noConflict=function(){return typeof window!==A&&window.log===n&&(window.log=l),n},n.getLoggers=function(){return d},n.default=n,n},(M=typeof D=="function"?D.call(T,O,T,B):D)===void 0||(B.exports=M)})()},375:function(B,T){"use strict";var O=Object.prototype.hasOwnProperty;function D(P){try{return decodeURIComponent(P.replace(/\+/g," "))}catch{return null}}function M(P){try{return encodeURIComponent(P)}catch{return null}}T.stringify=function(P,U){U=U||"";var b,A,S=[];for(A in typeof U!="string"&&(U="?"),P)if(O.call(P,A)){if((b=P[A])||b!=null&&!isNaN(b)||(b=""),A=M(A),b=M(b),A===null||b===null)continue;S.push(A+"="+b)}return S.length?U+S.join("&"):""},T.parse=function(P){for(var U,b=/([^=?#&]+)=?([^&]*)/g,A={};U=b.exec(P);){var S=D(U[1]),E=D(U[2]);S===null||E===null||S in A||(A[S]=E)}return A}},558:function(){}},ie={};function Q(B){var T=ie[B];if(T!==void 0)return T.exports;var O=ie[B]={exports:{}};return V[B].call(O.exports,O,O.exports,Q),O.exports}return Q.n=function(B){var T=B&&B.__esModule?function(){return B.default}:function(){return B};return Q.d(T,{a:T}),T},Q.d=function(B,T){for(var O in T)Q.o(T,O)&&!Q.o(B,O)&&Object.defineProperty(B,O,{enumerable:!0,get:T[O]})},Q.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),Q.o=function(B,T){return Object.prototype.hasOwnProperty.call(B,T)},Q(80)}()},typeof _r=="object"&&typeof Vr=="object"?Vr.exports=X():typeof _r=="object"?_r.mux=X():$.mux=X()})()});var Tr=Ai((tr,Yr)=>{typeof window!="undefined"&&function(X,V){typeof tr=="object"&&typeof Yr=="object"?Yr.exports=V():typeof define=="function"&&define.amd?define([],V):typeof tr=="object"?tr.Hls=V():X.Hls=V()}(tr,()=>(()=>{var $={"./src/config.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{enableStreamingMode:()=>r,hlsDefaultConfig:()=>c,mergeConfig:()=>e});var O=T("./src/controller/abr-controller.ts"),D=T("./src/controller/audio-stream-controller.ts"),M=T("./src/controller/audio-track-controller.ts"),P=T("./src/controller/subtitle-stream-controller.ts"),U=T("./src/controller/subtitle-track-controller.ts"),b=T("./src/controller/buffer-controller.ts"),A=T("./src/controller/timeline-controller.ts"),S=T("./src/controller/cap-level-controller.ts"),E=T("./src/controller/fps-controller.ts"),x=T("./src/controller/eme-controller.ts"),f=T("./src/controller/cmcd-controller.ts"),_=T("./src/utils/xhr-loader.ts"),p=T("./src/utils/fetch-loader.ts"),v=T("./src/utils/cues.ts"),a=T("./src/utils/mediakeys-helper.ts"),s=T("./src/utils/logger.ts");function n(){return n=Object.assign?Object.assign.bind():function(t){for(var o=1;o<arguments.length;o++){var y=arguments[o];for(var h in y)Object.prototype.hasOwnProperty.call(y,h)&&(t[h]=y[h])}return t},n.apply(this,arguments)}function d(t,o){var y=Object.keys(t);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(t);o&&(h=h.filter(function(L){return Object.getOwnPropertyDescriptor(t,L).enumerable})),y.push.apply(y,h)}return y}function l(t){for(var o=1;o<arguments.length;o++){var y=arguments[o]!=null?arguments[o]:{};o%2?d(Object(y),!0).forEach(function(h){i(t,h,y[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(y)):d(Object(y)).forEach(function(h){Object.defineProperty(t,h,Object.getOwnPropertyDescriptor(y,h))})}return t}function i(t,o,y){return o=u(o),o in t?Object.defineProperty(t,o,{value:y,enumerable:!0,configurable:!0,writable:!0}):t[o]=y,t}function u(t){var o=g(t,"string");return typeof o=="symbol"?o:String(o)}function g(t,o){if(typeof t!="object"||t===null)return t;var y=t[Symbol.toPrimitive];if(y!==void 0){var h=y.call(t,o||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(t)}var c=l(l({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:_.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:O.default,bufferController:b.default,capLevelController:S.default,fpsController:E.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,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:a.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},m()),{},{subtitleStreamController:P.SubtitleStreamController,subtitleTrackController:U.default,timelineController:A.TimelineController,audioStreamController:D.default,audioTrackController:M.default,emeController:x.default,cmcdController:f.default});function m(){return{cueHandler:v.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 e(t,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(o.liveMaxLatencyDurationCount!==void 0&&(o.liveSyncDurationCount===void 0||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(o.liveMaxLatencyDuration!==void 0&&(o.liveSyncDuration===void 0||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return n({},t,o)}function r(t){var o=t.loader;if(o!==p.default&&o!==_.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1;else{var y=(0,p.fetchSupported)();y&&(t.loader=p.default,t.progressive=!0,t.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>_});var O=T("./src/polyfills/number.ts"),D=T("./src/utils/ewma-bandwidth-estimator.ts"),M=T("./src/events.ts"),P=T("./src/errors.ts"),U=T("./src/types/loader.ts"),b=T("./src/utils/logger.ts");function A(p,v){for(var a=0;a<v.length;a++){var s=v[a];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(p,E(s.key),s)}}function S(p,v,a){return v&&A(p.prototype,v),a&&A(p,a),Object.defineProperty(p,"prototype",{writable:!1}),p}function E(p){var v=x(p,"string");return typeof v=="symbol"?v:String(v)}function x(p,v){if(typeof p!="object"||p===null)return p;var a=p[Symbol.toPrimitive];if(a!==void 0){var s=a.call(p,v||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(v==="string"?String:Number)(p)}var f=function(){function p(a){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=a;var s=a.config;this.bwEstimator=new D.default(s.abrEwmaSlowVoD,s.abrEwmaFastVoD,s.abrEwmaDefaultEstimate),this.registerListeners()}var v=p.prototype;return v.registerListeners=function(){var s=this.hls;s.on(M.Events.FRAG_LOADING,this.onFragLoading,this),s.on(M.Events.FRAG_LOADED,this.onFragLoaded,this),s.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.on(M.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){var s=this.hls;s.off(M.Events.FRAG_LOADING,this.onFragLoading,this),s.off(M.Events.FRAG_LOADED,this.onFragLoaded,this),s.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.off(M.Events.ERROR,this.onError,this)},v.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},v.onFragLoading=function(s,n){var d=n.frag;if(d.type===U.PlaylistLevelType.MAIN&&!this.timer){var l;this.fragCurrent=d,this.partCurrent=(l=n.part)!=null?l:null,this.timer=self.setInterval(this.onCheck,100)}},v.onLevelLoaded=function(s,n){var d=this.hls.config;n.details.live?this.bwEstimator.update(d.abrEwmaSlowLive,d.abrEwmaFastLive):this.bwEstimator.update(d.abrEwmaSlowVoD,d.abrEwmaFastVoD)},v._abandonRulesCheck=function(){var s=this.fragCurrent,n=this.partCurrent,d=this.hls,l=d.autoLevelEnabled,i=d.media;if(!(!s||!i)){var u=n?n.stats:s.stats,g=n?n.duration:s.duration;if(u.aborted||u.loaded&&u.loaded===u.total||s.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!l||i.paused||!i.playbackRate||!i.readyState)){var c=d.mainForwardBufferInfo;if(c!==null){var m=performance.now()-u.loading.start,e=Math.abs(i.playbackRate);if(!(m<=500*g/e)){var r=u.loaded&&u.loading.first,t=this.bwEstimator.getEstimate(),o=d.levels,y=d.minAutoLevel,h=o[s.level],L=u.total||Math.max(u.loaded,Math.round(g*h.maxBitrate/8)),R=r?u.loaded*1e3/m:0,I=R?(L-u.loaded)/R:L*8/t,k=c.len/e;if(!(I<=k)){var F=Number.POSITIVE_INFINITY,W;for(W=s.level-1;W>y;W--){var K=o[W].maxBitrate;if(F=R?g*K/(8*.8*R):g*K/t,F<k)break}F>=I||(b.logger.warn("Fragment "+s.sn+(n?" part "+n.index:"")+" of level "+s.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+W+`
|
|
9
|
+
Current BW estimate: `+((0,O.isFiniteNumber)(t)?(t/1024).toFixed(3):"Unknown")+` Kb/s
|
|
10
|
+
Estimated load time for current fragment: `+I.toFixed(3)+` s
|
|
11
|
+
Estimated load time for the next fragment: `+F.toFixed(3)+` s
|
|
12
|
+
Time to underbuffer: `+k.toFixed(3)+" s"),d.nextLoadLevel=W,r&&this.bwEstimator.sample(m,u.loaded),this.clearTimer(),(s.loader||s.keyLoader)&&(this.fragCurrent=this.partCurrent=null,s.abortRequests()),d.trigger(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:n,stats:u}))}}}}}},v.onFragLoaded=function(s,n){var d=n.frag,l=n.part;if(d.type===U.PlaylistLevelType.MAIN&&(0,O.isFiniteNumber)(d.sn)){var i=l?l.stats:d.stats,u=l?l.duration:d.duration;if(this.clearTimer(),this.lastLoadedFragLevel=d.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var g=this.hls.levels[d.level],c=(g.loaded?g.loaded.bytes:0)+i.loaded,m=(g.loaded?g.loaded.duration:0)+u;g.loaded={bytes:c,duration:m},g.realBitrate=Math.round(8*c/m)}if(d.bitrateTest){var e={stats:i,frag:d,part:l,id:d.type};this.onFragBuffered(M.Events.FRAG_BUFFERED,e)}}},v.onFragBuffered=function(s,n){var d=n.frag,l=n.part,i=l?l.stats:d.stats;if(!i.aborted&&!(d.type!==U.PlaylistLevelType.MAIN||d.sn==="initSegment")){var u=i.parsing.end-i.loading.start;this.bwEstimator.sample(u,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),d.bitrateTest?this.bitrateTestDelay=u/1e3:this.bitrateTestDelay=0}},v.onError=function(s,n){var d;if(((d=n.frag)===null||d===void 0?void 0:d.type)===U.PlaylistLevelType.MAIN){if(n.type===P.ErrorTypes.KEY_SYSTEM_ERROR){this.clearTimer();return}switch(n.details){case P.ErrorDetails.FRAG_LOAD_ERROR:case P.ErrorDetails.FRAG_LOAD_TIMEOUT:case P.ErrorDetails.KEY_LOAD_ERROR:case P.ErrorDetails.KEY_LOAD_TIMEOUT:this.clearTimer();break;default:break}}},v.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},v.getNextABRAutoLevel=function(){var s=this.fragCurrent,n=this.partCurrent,d=this.hls,l=d.maxAutoLevel,i=d.config,u=d.minAutoLevel,g=d.media,c=n?n.duration:s?s.duration:0,m=g&&g.playbackRate!==0?Math.abs(g.playbackRate):1,e=this.bwEstimator?this.bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,r=d.mainForwardBufferInfo,t=(r?r.len:0)/m,o=this.findBestLevel(e,u,l,t,i.abrBandWidthFactor,i.abrBandWidthUpFactor);if(o>=0)return o;b.logger.trace((t?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var y=c?Math.min(c,i.maxStarvationDelay):i.maxStarvationDelay,h=i.abrBandWidthFactor,L=i.abrBandWidthUpFactor;if(!t){var R=this.bitrateTestDelay;if(R){var I=c?Math.min(c,i.maxLoadingDelay):i.maxLoadingDelay;y=I-R,b.logger.trace("bitrate test took "+Math.round(1e3*R)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*y)+" ms"),h=L=1}}return o=this.findBestLevel(e,u,l,t+y,h,L),Math.max(o,0)},v.findBestLevel=function(s,n,d,l,i,u){for(var g,c=this.fragCurrent,m=this.partCurrent,e=this.lastLoadedFragLevel,r=this.hls.levels,t=r[e],o=!!(t!=null&&(g=t.details)!==null&&g!==void 0&&g.live),y=t==null?void 0:t.codecSet,h=m?m.duration:c?c.duration:0,L=d;L>=n;L--){var R=r[L];if(!(!R||y&&R.codecSet!==y)){var I=R.details,k=(m?I==null?void 0:I.partTarget:I==null?void 0:I.averagetargetduration)||h,F=void 0;L<=e?F=i*s:F=u*s;var W=r[L].maxBitrate,K=W*k/F;if(b.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+L+"/"+Math.round(F)+"/"+W+"/"+k+"/"+l+"/"+K),F>W&&(K===0||!(0,O.isFiniteNumber)(K)||o&&!this.bitrateTestDelay||K<l))return L}}return-1},S(p,[{key:"nextAutoLevel",get:function(){var s=this._nextAutoLevel,n=this.bwEstimator;if(s!==-1&&!n.canEstimate())return s;var d=this.getNextABRAutoLevel();return s!==-1&&this.hls.levels[d].loadError?s:(s!==-1&&(d=Math.min(s,d)),d)},set:function(s){this._nextAutoLevel=s}}]),p}();let _=f},"./src/controller/audio-stream-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>i});var O=T("./src/polyfills/number.ts"),D=T("./src/controller/base-stream-controller.ts"),M=T("./src/events.ts"),P=T("./src/utils/buffer-helper.ts"),U=T("./src/controller/fragment-tracker.ts"),b=T("./src/types/level.ts"),A=T("./src/types/loader.ts"),S=T("./src/loader/fragment.ts"),E=T("./src/demux/chunk-cache.ts"),x=T("./src/demux/transmuxer-interface.ts"),f=T("./src/types/transmuxer.ts"),_=T("./src/controller/fragment-finders.ts"),p=T("./src/utils/discontinuities.ts"),v=T("./src/errors.ts");function a(){return a=Object.assign?Object.assign.bind():function(u){for(var g=1;g<arguments.length;g++){var c=arguments[g];for(var m in c)Object.prototype.hasOwnProperty.call(c,m)&&(u[m]=c[m])}return u},a.apply(this,arguments)}function s(u,g){u.prototype=Object.create(g.prototype),u.prototype.constructor=u,n(u,g)}function n(u,g){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,e){return m.__proto__=e,m},n(u,g)}var d=100,l=function(u){s(g,u);function g(m,e,r){var t;return t=u.call(this,m,e,r,"[audio-stream-controller]")||this,t.videoBuffer=null,t.videoTrackCC=-1,t.waitingVideoCC=-1,t.audioSwitch=!1,t.trackId=-1,t.waitingData=null,t.mainDetails=null,t.bufferFlushed=!1,t.cachedTrackLoadedData=null,t._registerListeners(),t}var c=g.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._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.LEVEL_LOADED,this.onLevelLoaded,this),e.on(M.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(M.Events.ERROR,this.onError,this),e.on(M.Events.BUFFER_RESET,this.onBufferReset,this),e.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._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.LEVEL_LOADED,this.onLevelLoaded,this),e.off(M.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(M.Events.ERROR,this.onError,this),e.off(M.Events.BUFFER_RESET,this.onBufferReset,this),e.off(M.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(e,r){var t=r.frag,o=r.id,y=r.initPTS;if(o==="main"){var h=t.cc;this.initPTS[t.cc]=y,this.log("InitPTS for cc: "+h+" found from main: "+y),this.videoTrackCC=h,this.state===D.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(e){if(!this.levels){this.startPosition=e,this.state=D.State.STOPPED;return}var r=this.lastCurrentTime;this.stopLoad(),this.setInterval(d),this.fragLoadError=0,r>0&&e===-1?(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),e=r,this.state=D.State.IDLE):(this.loadedmetadata=!1,this.state=D.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},c.doTick=function(){switch(this.state){case D.State.IDLE:this.doTickIdle();break;case D.State.WAITING_TRACK:{var e,r=this.levels,t=this.trackId,o=r==null||(e=r[t])===null||e===void 0?void 0:e.details;if(o){if(this.waitForCdnTuneIn(o))break;this.state=D.State.WAITING_INIT_PTS}break}case D.State.FRAG_LOADING_WAITING_RETRY:{var y,h=performance.now(),L=this.retryDate;(!L||h>=L||(y=this.media)!==null&&y!==void 0&&y.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=D.State.IDLE);break}case D.State.WAITING_INIT_PTS:{var R=this.waitingData;if(R){var I=R.frag,k=R.part,F=R.cache,W=R.complete;if(this.initPTS[I.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=D.State.FRAG_LOADING;var K=F.flush(),H={frag:I,part:k,payload:K,networkDetails:null};this._handleFragmentLoadProgress(H),W&&u.prototype._handleFragmentLoadComplete.call(this,H)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+I.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var Y=this.getLoadPosition(),q=P.BufferHelper.bufferInfo(this.mediaBuffer,Y,this.config.maxBufferHole),ee=(0,_.fragmentWithinToleranceTest)(q.end,this.config.maxFragLookUpTolerance,I);ee<0&&(this.log("Waiting fragment cc ("+I.cc+") @ "+I.start+" cancelled because another fragment at "+q.end+" is needed"),this.clearWaitingFragment())}}else this.state=D.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=D.State.IDLE)},c.resetLoadingState=function(){this.clearWaitingFragment(),u.prototype.resetLoadingState.call(this)},c.onTickEnd=function(){var e=this.media;!e||!e.readyState||(this.lastCurrentTime=e.currentTime)},c.doTickIdle=function(){var e=this.hls,r=this.levels,t=this.media,o=this.trackId,y=e.config;if(!(!r||!r[o])&&!(!t&&(this.startFragRequested||!y.startFragPrefetch))){var h=r[o],L=h.details;if(!L||L.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(L)){this.state=D.State.WAITING_TRACK;return}var R=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&R&&(this.bufferFlushed=!1,this.afterBufferFlushed(R,S.ElementaryStreamTypes.AUDIO,A.PlaylistLevelType.AUDIO));var I=this.getFwdBufferInfo(R,A.PlaylistLevelType.AUDIO);if(I!==null){var k=this.audioSwitch;if(!k&&this._streamEnded(I,L)){e.trigger(M.Events.BUFFER_EOS,{type:"audio"}),this.state=D.State.ENDED;return}var F=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,A.PlaylistLevelType.MAIN),W=I.len,K=this.getMaxBufferLength(F==null?void 0:F.len);if(!(W>=K&&!k)){var H=L.fragments,Y=H[0].start,q=I.end;if(k&&t){var ee=this.getLoadPosition();q=ee,L.PTSKnown&&ee<Y&&(I.end>Y||I.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),t.currentTime=Y+.05)}if(!(F&&q>F.end+L.targetduration)&&!((!F||!F.len)&&I.len)){var ae=this.getNextFragment(q,L);if(!ae){this.bufferFlushed=!0;return}this.loadFragment(ae,L,q)}}}}},c.getMaxBufferLength=function(e){var r=u.prototype.getMaxBufferLength.call(this);return e?Math.max(r,e):r},c.onMediaDetaching=function(){this.videoBuffer=null,u.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(e,r){var t=r.audioTracks;this.resetTransmuxer(),this.levels=t.map(function(o){return new b.Level(o)})},c.onAudioTrackSwitching=function(e,r){var t=!!r.url;this.trackId=r.id;var o=this.fragCurrent;o&&o.abortRequests(),this.fragCurrent=null,this.clearWaitingFragment(),t?this.setInterval(d):this.resetTransmuxer(),t?(this.audioSwitch=!0,this.state=D.State.IDLE):this.state=D.State.STOPPED,this.tick()},c.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},c.onLevelLoaded=function(e,r){this.mainDetails=r.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(M.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},c.onAudioTrackLoaded=function(e,r){var t;if(this.mainDetails==null){this.cachedTrackLoadedData=r;return}var o=this.levels,y=r.details,h=r.id;if(!o){this.warn("Audio tracks were reset while loading level "+h);return}this.log("Track "+h+" loaded ["+y.startSN+","+y.endSN+"],duration:"+y.totalduration);var L=o[h],R=0;if(y.live||(t=L.details)!==null&&t!==void 0&&t.live){var I=this.mainDetails;if(y.fragments[0]||(y.deltaUpdateFailed=!0),y.deltaUpdateFailed||!I)return;!L.details&&y.hasProgramDateTime&&I.hasProgramDateTime?((0,p.alignMediaPlaylistByPDT)(y,I),R=y.fragments[0].start):R=this.alignPlaylists(y,L.details)}L.details=y,this.levelLastLoaded=h,!this.startFragRequested&&(this.mainDetails||!y.live)&&this.setStartPosition(L.details,R),this.state===D.State.WAITING_TRACK&&!this.waitForCdnTuneIn(y)&&(this.state=D.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(e){var r,t=e.frag,o=e.part,y=e.payload,h=this.config,L=this.trackId,R=this.levels;if(!R){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+t.sn+" of level "+t.level+" will not be buffered");return}var I=R[L];console.assert(I,"Audio track is defined on fragment load progress");var k=I.details;console.assert(k,"Audio track details are defined on fragment load progress");var F=h.defaultAudioCodec||I.audioCodec||"mp4a.40.2",W=this.transmuxer;W||(W=this.transmuxer=new x.default(this.hls,A.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var K=this.initPTS[t.cc],H=(r=t.initSegment)===null||r===void 0?void 0:r.data;if(K!==void 0){var Y=!1,q=o?o.index:-1,ee=q!==-1,ae=new f.ChunkMetadata(t.level,t.sn,t.stats.chunkCount,y.byteLength,q,ee);W.push(y,H,F,"",t,o,k.totalduration,Y,ae,K)}else{this.log("Unknown video PTS for cc "+t.cc+", waiting for video PTS before demuxing audio frag "+t.sn+" of ["+k.startSN+" ,"+k.endSN+"],track "+L);var re=this.waitingData=this.waitingData||{frag:t,part:o,cache:new E.default,complete:!1},se=re.cache;se.push(new Uint8Array(y)),this.waitingVideoCC=this.videoTrackCC,this.state=D.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(e){if(this.waitingData){this.waitingData.complete=!0;return}u.prototype._handleFragmentLoadComplete.call(this,e)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(e,r){var t=r.tracks.audio;t&&(this.mediaBuffer=t.buffer||null),r.tracks.video&&(this.videoBuffer=r.tracks.video.buffer||null)},c.onFragBuffered=function(e,r){var t=r.frag,o=r.part;if(t.type!==A.PlaylistLevelType.AUDIO){if(!this.loadedmetadata&&t.type===A.PlaylistLevelType.MAIN){var y;(y=this.videoBuffer||this.media)!==null&&y!==void 0&&y.buffered.length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(t)){this.warn("Fragment "+t.sn+(o?" p: "+o.index:"")+" of level "+t.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}t.sn!=="initSegment"&&(this.fragPrevious=t,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(t,o)},c.onError=function(e,r){if(r.type===v.ErrorTypes.KEY_SYSTEM_ERROR){this.onFragmentOrKeyLoadError(A.PlaylistLevelType.AUDIO,r);return}switch(r.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.FRAG_PARSING_ERROR:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.AUDIO,r);break;case v.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case v.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==D.State.ERROR&&this.state!==D.State.STOPPED&&(this.state=r.fatal?D.State.ERROR:D.State.IDLE,this.warn(r.details+" while loading frag, switching to "+this.state+" state"));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if(r.parent==="audio"&&(this.state===D.State.PARSING||this.state===D.State.PARSED)){var t=!0,o=this.getFwdBufferInfo(this.mediaBuffer,A.PlaylistLevelType.AUDIO);o&&o.len>.5&&(t=!this.reduceMaxBufferLength(o.len)),t&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,u.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},c.onBufferFlushed=function(e,r){var t=r.type;t===S.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0,this.state===D.State.ENDED&&(this.state=D.State.IDLE))},c._handleTransmuxComplete=function(e){var r,t="audio",o=this.hls,y=e.remuxResult,h=e.chunkMeta,L=this.getCurrentContext(h);if(!L){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 R=L.frag,I=L.part,k=L.level.details,F=y.audio,W=y.text,K=y.id3,H=y.initSegment;if(!(this.fragContextChanged(R)||!k)){if(this.state=D.State.PARSING,this.audioSwitch&&F&&this.completeAudioSwitch(),H!=null&&H.tracks&&(this._bufferInitSegment(H.tracks,R,h),o.trigger(M.Events.FRAG_PARSING_INIT_SEGMENT,{frag:R,id:t,tracks:H.tracks})),F){var Y=F.startPTS,q=F.endPTS,ee=F.startDTS,ae=F.endDTS;I&&(I.elementaryStreams[S.ElementaryStreamTypes.AUDIO]={startPTS:Y,endPTS:q,startDTS:ee,endDTS:ae}),R.setElementaryStreamInfo(S.ElementaryStreamTypes.AUDIO,Y,q,ee,ae),this.bufferFragmentData(F,R,I,h)}if(K!=null&&(r=K.samples)!==null&&r!==void 0&&r.length){var re=a({id:t,frag:R,details:k},K);o.trigger(M.Events.FRAG_PARSING_METADATA,re)}if(W){var se=a({id:t,frag:R,details:k},W);o.trigger(M.Events.FRAG_PARSING_USERDATA,se)}}},c._bufferInitSegment=function(e,r,t){if(this.state===D.State.PARSING){e.video&&delete e.video;var o=e.audio;if(!!o){o.levelCodec=o.codec,o.id="audio",this.log("Init audio buffer, container:"+o.container+", codecs[parsed]=["+o.codec+"]"),this.hls.trigger(M.Events.BUFFER_CODECS,e);var y=o.initSegment;if(y!=null&&y.byteLength){var h={type:"audio",frag:r,part:null,chunkMeta:t,parent:r.type,data:y};this.hls.trigger(M.Events.BUFFER_APPENDING,h)}this.tick()}}},c.loadFragment=function(e,r,t){var o=this.fragmentTracker.getState(e);this.fragCurrent=e,(this.audioSwitch||o===U.FragmentState.NOT_LOADED||o===U.FragmentState.PARTIAL)&&(e.sn==="initSegment"?this._loadInitSegment(e,r):r.live&&!(0,O.isFiniteNumber)(this.initPTS[e.cc])?(this.log("Waiting for video PTS in continuity counter "+e.cc+" of live stream before loading audio fragment "+e.sn+" of level "+this.trackId),this.state=D.State.WAITING_INIT_PTS):(this.startFragRequested=!0,u.prototype.loadFragment.call(this,e,r,t)))},c.completeAudioSwitch=function(){var e=this.hls,r=this.media,t=this.trackId;r&&(this.log("Switching audio track : flushing all audio"),u.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,e.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:t})},g}(D.default);let i=l},"./src/controller/audio-track-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>_});var O=T("./src/events.ts"),D=T("./src/errors.ts"),M=T("./src/controller/base-playlist-controller.ts"),P=T("./src/types/loader.ts");function U(p,v){for(var a=0;a<v.length;a++){var s=v[a];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(p,A(s.key),s)}}function b(p,v,a){return v&&U(p.prototype,v),a&&U(p,a),Object.defineProperty(p,"prototype",{writable:!1}),p}function A(p){var v=S(p,"string");return typeof v=="symbol"?v:String(v)}function S(p,v){if(typeof p!="object"||p===null)return p;var a=p[Symbol.toPrimitive];if(a!==void 0){var s=a.call(p,v||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(v==="string"?String:Number)(p)}function E(p,v){p.prototype=Object.create(v.prototype),p.prototype.constructor=p,x(p,v)}function x(p,v){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,n){return s.__proto__=n,s},x(p,v)}var f=function(p){E(v,p);function v(s){var n;return n=p.call(this,s,"[audio-track-controller]")||this,n.tracks=[],n.groupId=null,n.tracksInGroup=[],n.trackId=-1,n.trackName="",n.selectDefaultTrack=!0,n.registerListeners(),n}var a=v.prototype;return a.registerListeners=function(){var n=this.hls;n.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.on(O.Events.LEVEL_LOADING,this.onLevelLoading,this),n.on(O.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),n.on(O.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(O.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var n=this.hls;n.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.off(O.Events.LEVEL_LOADING,this.onLevelLoading,this),n.off(O.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),n.off(O.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(O.Events.ERROR,this.onError,this)},a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,p.prototype.destroy.call(this)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},a.onManifestParsed=function(n,d){this.tracks=d.audioTracks||[]},a.onAudioTrackLoaded=function(n,d){var l=d.id,i=d.details,u=this.tracksInGroup[l];if(!u){this.warn("Invalid audio track id "+l);return}var g=u.details;u.details=d.details,this.log("audioTrack "+l+" loaded ["+i.startSN+"-"+i.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,d,g))},a.onLevelLoading=function(n,d){this.switchLevel(d.level)},a.onLevelSwitching=function(n,d){this.switchLevel(d.level)},a.switchLevel=function(n){var d=this.hls.levels[n];if(!!(d!=null&&d.audioGroupIds)){var l=d.audioGroupIds[d.urlId];if(this.groupId!==l){this.groupId=l;var i=this.tracks.filter(function(g){return!l||g.groupId===l});this.selectDefaultTrack&&!i.some(function(g){return g.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=i;var u={audioTracks:i};this.log("Updating audio tracks, "+i.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(O.Events.AUDIO_TRACKS_UPDATED,u),this.selectInitialTrack()}}},a.onError=function(n,d){p.prototype.onError.call(this,n,d),!(d.fatal||!d.context)&&d.context.type===P.PlaylistContextType.AUDIO_TRACK&&d.context.id===this.trackId&&d.context.groupId===this.groupId&&this.retryLoadingOrFail(d)},a.setAudioTrack=function(n){var d=this.tracksInGroup;if(n<0||n>=d.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=d[this.trackId];this.log("Now switching to audio-track index "+n);var i=d[n],u=i.id,g=i.groupId,c=g===void 0?"":g,m=i.name,e=i.type,r=i.url;if(this.trackId=n,this.trackName=m,this.selectDefaultTrack=!1,this.hls.trigger(O.Events.AUDIO_TRACK_SWITCHING,{id:u,groupId:c,name:m,type:e,url:r}),!(i.details&&!i.details.live)){var t=this.switchParams(i.url,l==null?void 0:l.details);this.loadPlaylist(t)}},a.selectInitialTrack=function(){var n=this.tracksInGroup;console.assert(n.length,"Initial audio track should be selected when tracks are known");var d=this.trackName,l=this.findTrackId(d)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(O.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},a.findTrackId=function(n){for(var d=this.tracksInGroup,l=0;l<d.length;l++){var i=d[l];if((!this.selectDefaultTrack||i.default)&&(!n||n===i.name))return i.id}return-1},a.loadPlaylist=function(n){p.prototype.loadPlaylist.call(this);var d=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(d)){var l=d.id,i=d.groupId,u=d.url;if(n)try{u=n.addDirectives(u)}catch(g){this.warn("Could not construct new URL with HLS Delivery Directives: "+g)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(O.Events.AUDIO_TRACK_LOADING,{url:u,id:l,groupId:i,deliveryDirectives:n||null})}},b(v,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(n){this.selectDefaultTrack=!1,this.setAudioTrack(n)}}]),v}(M.default);let _=f},"./src/controller/base-playlist-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>U});var O=T("./src/types/level.ts"),D=T("./src/controller/level-helper.ts"),M=T("./src/utils/logger.ts"),P=T("./src/errors.ts"),U=function(){function b(S,E){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=M.logger.log.bind(M.logger,E+":"),this.warn=M.logger.warn.bind(M.logger,E+":"),this.hls=S}var A=b.prototype;return A.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},A.onError=function(E,x){x.fatal&&(x.type===P.ErrorTypes.NETWORK_ERROR||x.type===P.ErrorTypes.KEY_SYSTEM_ERROR)&&this.stopLoad()},A.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},A.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.requestScheduled=-1,this.loadPlaylist()},A.stopLoad=function(){this.canLoad=!1,this.clearTimer()},A.switchParams=function(E,x){var f=x==null?void 0:x.renditionReports;if(f)for(var _=0;_<f.length;_++){var p=f[_],v=void 0;try{v=new self.URL(p.URI,x.url).href}catch(d){M.logger.warn("Could not construct new URL for Rendition Report: "+d),v=p.URI||""}if(v===E.slice(-v.length)){var a=parseInt(p["LAST-MSN"])||(x==null?void 0:x.lastPartSn),s=parseInt(p["LAST-PART"])||(x==null?void 0:x.lastPartIndex);if(this.hls.config.lowLatencyMode){var n=Math.min(x.age-x.partTarget,x.targetduration);s>=0&&n>x.partTarget&&(s+=1)}return new O.HlsUrlParameters(a,s>=0?s:void 0,O.HlsSkip.No)}}},A.loadPlaylist=function(E){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},A.shouldLoadTrack=function(E){return this.canLoad&&E&&!!E.url&&(!E.details||E.details.live)},A.playlistLoaded=function(E,x,f){var _=this,p=x.details,v=x.stats,a=self.performance.now(),s=v.loading.first?Math.max(0,a-v.loading.first):0;if(p.advancedDateTime=Date.now()-s,p.live||f!=null&&f.live){if(p.reloaded(f),f&&this.log("live playlist "+E+" "+(p.advanced?"REFRESHED "+p.lastPartSn+"-"+p.lastPartIndex:"MISSED")),f&&p.fragments.length>0&&(0,D.mergeDetails)(f,p),!this.canLoad||!p.live)return;var n,d=void 0,l=void 0;if(p.canBlockReload&&p.endSN&&p.advanced){var i=this.hls.config.lowLatencyMode,u=p.lastPartSn,g=p.endSN,c=p.lastPartIndex,m=c!==-1,e=u===g,r=i?0:c;m?(d=e?g+1:u,l=e?r:c+1):d=g+1;var t=p.age,o=t+p.ageHeader,y=Math.min(o-p.partTarget,p.targetduration*1.5);if(y>0){if(f&&y>f.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+f.tuneInGoal+" to: "+y+" with playlist age: "+p.age),y=0;else{var h=Math.floor(y/p.targetduration);if(d+=h,l!==void 0){var L=Math.round(y%p.targetduration/p.partTarget);l+=L}this.log("CDN Tune-in age: "+p.ageHeader+"s last advanced "+t.toFixed(2)+"s goal: "+y+" skip sn "+h+" to part "+l)}p.tuneInGoal=y}if(n=this.getDeliveryDirectives(p,x.deliveryDirectives,d,l),i||!e){this.loadPlaylist(n);return}}else n=this.getDeliveryDirectives(p,x.deliveryDirectives,d,l);var R=this.hls.mainForwardBufferInfo,I=R?R.end-R.len:0,k=(p.edge-I)*1e3,F=(0,D.computeReloadInterval)(p,k);p.updated?a>this.requestScheduled+F&&(this.requestScheduled=v.loading.start):this.requestScheduled=-1,d!==void 0&&p.canBlockReload?this.requestScheduled=v.loading.first+F-(p.partTarget*1e3||1e3):this.requestScheduled=(this.requestScheduled===-1?a:this.requestScheduled)+F;var W=this.requestScheduled-a;W=Math.max(0,W),this.log("reload live playlist "+E+" in "+Math.round(W)+" ms"),this.timer=self.setTimeout(function(){return _.loadPlaylist(n)},W)}else this.clearTimer()},A.getDeliveryDirectives=function(E,x,f,_){var p=(0,O.getSkipValue)(E,f);return x!=null&&x.skip&&E.deltaUpdateFailed&&(f=x.msn,_=x.part,p=O.HlsSkip.No),new O.HlsUrlParameters(f,_,p)},A.retryLoadingOrFail=function(E){var x=this,f=this.hls.config,_=this.retryCount<f.levelLoadingMaxRetry;if(_){var p;if(this.requestScheduled=-1,this.retryCount++,E.details.indexOf("LoadTimeOut")>-1&&(p=E.context)!==null&&p!==void 0&&p.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+E.details+'"'),this.loadPlaylist();else{var v=Math.min(Math.pow(2,this.retryCount)*f.levelLoadingRetryDelay,f.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return x.loadPlaylist()},v),this.warn("retry playlist loading #"+this.retryCount+" in "+v+' ms after "'+E.details+'"')}}else this.warn('cannot recover from error "'+E.details+'"'),this.clearTimer(),E.fatal=!0;return _},b}()},"./src/controller/base-stream-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{State:()=>m,default:()=>e});var O=T("./src/polyfills/number.ts"),D=T("./src/task-loop.ts"),M=T("./src/controller/fragment-tracker.ts"),P=T("./src/utils/buffer-helper.ts"),U=T("./src/utils/logger.ts"),b=T("./src/events.ts"),A=T("./src/errors.ts"),S=T("./src/types/transmuxer.ts"),E=T("./src/utils/mp4-tools.ts"),x=T("./src/utils/discontinuities.ts"),f=T("./src/controller/fragment-finders.ts"),_=T("./src/controller/level-helper.ts"),p=T("./src/loader/fragment-loader.ts"),v=T("./src/crypt/decrypter.ts"),a=T("./src/utils/time-ranges.ts"),s=T("./src/types/loader.ts");function n(r,t){for(var o=0;o<t.length;o++){var y=t[o];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(r,l(y.key),y)}}function d(r,t,o){return t&&n(r.prototype,t),o&&n(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r}function l(r){var t=i(r,"string");return typeof t=="symbol"?t:String(t)}function i(r,t){if(typeof r!="object"||r===null)return r;var o=r[Symbol.toPrimitive];if(o!==void 0){var y=o.call(r,t||"default");if(typeof y!="object")return y;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function u(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function g(r,t){r.prototype=Object.create(t.prototype),r.prototype.constructor=r,c(r,t)}function c(r,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(y,h){return y.__proto__=h,y},c(r,t)}var m={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"},e=function(r){g(t,r);function t(y,h,L,R){var I;return I=r.call(this)||this,I.hls=void 0,I.fragPrevious=null,I.fragCurrent=null,I.fragmentTracker=void 0,I.transmuxer=null,I._state=m.STOPPED,I.media=null,I.mediaBuffer=null,I.config=void 0,I.bitrateTest=!1,I.lastCurrentTime=0,I.nextLoadPosition=0,I.startPosition=0,I.loadedmetadata=!1,I.fragLoadError=0,I.retryDate=0,I.levels=null,I.fragmentLoader=void 0,I.keyLoader=void 0,I.levelLastLoaded=null,I.startFragRequested=!1,I.decrypter=void 0,I.initPTS=[],I.onvseeking=null,I.onvended=null,I.logPrefix="",I.log=void 0,I.warn=void 0,I.logPrefix=R,I.log=U.logger.log.bind(U.logger,R+":"),I.warn=U.logger.warn.bind(U.logger,R+":"),I.hls=y,I.fragmentLoader=new p.default(y.config),I.keyLoader=L,I.fragmentTracker=h,I.config=y.config,I.decrypter=new v.default(y.config),y.on(b.Events.LEVEL_SWITCHING,I.onLevelSwitching,u(I)),I}var o=t.prototype;return o.doTick=function(){this.onTickEnd()},o.onTickEnd=function(){},o.startLoad=function(h){},o.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var h=this.fragCurrent;h&&(h.abortRequests(),this.fragmentTracker.removeFragment(h)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=m.STOPPED},o._streamEnded=function(h,L){if(L.live||h.nextStart||!h.end||!this.media)return!1;var R=L.partList;if(R!=null&&R.length){var I=R[R.length-1],k=P.BufferHelper.isBuffered(this.media,I.start+I.duration/2);return k}var F=L.fragments[L.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(F)},o.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var h;return(h=this.levels[this.levelLastLoaded])===null||h===void 0?void 0:h.details}},o.onMediaAttached=function(h,L){var R=this.media=this.mediaBuffer=L.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),R.addEventListener("seeking",this.onvseeking),R.addEventListener("ended",this.onvended);var I=this.config;this.levels&&I.autoStartLoad&&this.state===m.STOPPED&&this.startLoad(I.startPosition)},o.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.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},o.onMediaSeeking=function(){var h=this.config,L=this.fragCurrent,R=this.media,I=this.mediaBuffer,k=this.state,F=R?R.currentTime:0,W=P.BufferHelper.bufferInfo(I||R,F,h.maxBufferHole);if(this.log("media seeking to "+((0,O.isFiniteNumber)(F)?F.toFixed(3):F)+", state: "+k),this.state===m.ENDED)this.resetLoadingState();else if(L){var K=h.maxFragLookUpTolerance,H=L.start-K,Y=L.start+L.duration+K;if(!W.len||Y<W.start||H>W.end){var q=F>Y;(F<H||q)&&(q&&L.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),L.abortRequests()),this.resetLoadingState())}}R&&(this.lastCurrentTime=F),!this.loadedmetadata&&!W.len&&(this.nextLoadPosition=this.startPosition=F),this.tickImmediate()},o.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},o.onLevelSwitching=function(h,L){this.fragLoadError=0},o.onHandlerDestroying=function(){this.stopLoad(),r.prototype.onHandlerDestroying.call(this)},o.onHandlerDestroyed=function(){this.state=m.STOPPED,this.hls.off(b.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,r.prototype.onHandlerDestroyed.call(this)},o.loadFragment=function(h,L,R){this._loadFragForPlayback(h,L,R)},o._loadFragForPlayback=function(h,L,R){var I=this,k=function(W){if(I.fragContextChanged(h)){I.warn("Fragment "+h.sn+(W.part?" p: "+W.part.index:"")+" of level "+h.level+" was dropped during download."),I.fragmentTracker.removeFragment(h);return}h.stats.chunkCount++,I._handleFragmentLoadProgress(W)};this._doFragLoad(h,L,R,k).then(function(F){if(!!F){I.fragLoadError=0;var W=I.state;if(I.fragContextChanged(h)){(W===m.FRAG_LOADING||!I.fragCurrent&&W===m.PARSING)&&(I.fragmentTracker.removeFragment(h),I.state=m.IDLE);return}"payload"in F&&(I.log("Loaded fragment "+h.sn+" of level "+h.level),I.hls.trigger(b.Events.FRAG_LOADED,F)),I._handleFragmentLoadComplete(F)}}).catch(function(F){I.state===m.STOPPED||I.state===m.ERROR||(I.warn(F),I.resetFragmentLoading(h))})},o.flushMainBuffer=function(h,L,R){if(R===void 0&&(R=null),!!(h-L)){var I={startOffset:h,endOffset:L,type:R};this.fragLoadError=0,this.hls.trigger(b.Events.BUFFER_FLUSHING,I)}},o._loadInitSegment=function(h,L){var R=this;this._doFragLoad(h,L).then(function(I){if(!I||R.fragContextChanged(h)||!R.levels)throw new Error("init load aborted");return I}).then(function(I){var k=R.hls,F=I.payload,W=h.decryptdata;if(F&&F.byteLength>0&&W&&W.key&&W.iv&&W.method==="AES-128"){var K=self.performance.now();return R.decrypter.decrypt(new Uint8Array(F),W.key.buffer,W.iv.buffer).then(function(H){var Y=self.performance.now();return k.trigger(b.Events.FRAG_DECRYPTED,{frag:h,payload:H,stats:{tstart:K,tdecrypt:Y}}),I.payload=H,I})}return I}).then(function(I){var k=R.fragCurrent,F=R.hls,W=R.levels;if(!W)throw new Error("init load aborted, missing levels");var K=W[h.level].details;console.assert(K,"Level details are defined when init segment is loaded");var H=h.stats;R.state=m.IDLE,R.fragLoadError=0,h.data=new Uint8Array(I.payload),H.parsing.start=H.buffering.start=self.performance.now(),H.parsing.end=H.buffering.end=self.performance.now(),I.frag===k&&F.trigger(b.Events.FRAG_BUFFERED,{stats:H,frag:k,part:null,id:h.type}),R.tick()}).catch(function(I){R.state===m.STOPPED||R.state===m.ERROR||(R.warn(I),R.resetFragmentLoading(h))})},o.fragContextChanged=function(h){var L=this.fragCurrent;return!h||!L||h.level!==L.level||h.sn!==L.sn||h.urlId!==L.urlId},o.fragBufferedComplete=function(h,L){var R,I,k=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+h.type+" sn: "+h.sn+(L?" part: "+L.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+h.level+" "+(k?a.default.toString(P.BufferHelper.getBuffered(k)):"(detached)")),this.state=m.IDLE,k&&(!this.loadedmetadata&&h.type==s.PlaylistLevelType.MAIN&&k.buffered.length&&((R=this.fragCurrent)===null||R===void 0?void 0:R.sn)===((I=this.fragPrevious)===null||I===void 0?void 0:I.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},o.seekToStartPos=function(){},o._handleFragmentLoadComplete=function(h){var L=this.transmuxer;if(!!L){var R=h.frag,I=h.part,k=h.partsLoaded,F=!k||k.length===0||k.some(function(K){return!K}),W=new S.ChunkMetadata(R.level,R.sn,R.stats.chunkCount+1,0,I?I.index:-1,!F);L.flush(W)}},o._handleFragmentLoadProgress=function(h){},o._doFragLoad=function(h,L,R,I){var k,F=this;if(R===void 0&&(R=null),!this.levels)throw new Error("frag load aborted, missing levels");var W=null;if(h.encrypted&&!((k=h.decryptdata)!==null&&k!==void 0&&k.key)?(this.log("Loading key for "+h.sn+" of ["+L.startSN+"-"+L.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+h.level),this.state=m.KEY_LOADING,this.fragCurrent=h,W=this.keyLoader.load(h).then(function(ee){if(!F.fragContextChanged(ee.frag))return F.hls.trigger(b.Events.KEY_LOADED,ee),ee}),this.hls.trigger(b.Events.KEY_LOADING,{frag:h}),this.throwIfFragContextChanged("KEY_LOADING")):!h.encrypted&&L.encryptedFragments.length&&this.keyLoader.loadClear(h,L.encryptedFragments),R=Math.max(h.start,R||0),this.config.lowLatencyMode&&L){var K=L.partList;if(K&&I){R>h.end&&L.fragmentHint&&(h=L.fragmentHint);var H=this.getNextPart(K,h,R);if(H>-1){var Y=K[H];return this.log("Loading part sn: "+h.sn+" p: "+Y.index+" cc: "+h.cc+" of playlist ["+L.startSN+"-"+L.endSN+"] parts [0-"+H+"-"+(K.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+h.level+", target: "+parseFloat(R.toFixed(3))),this.nextLoadPosition=Y.start+Y.duration,this.state=m.FRAG_LOADING,this.hls.trigger(b.Events.FRAG_LOADING,{frag:h,part:K[H],targetBufferTime:R}),this.throwIfFragContextChanged("FRAG_LOADING parts"),W?W.then(function(ee){return!ee||F.fragContextChanged(ee.frag)?null:F.doFragPartsLoad(h,K,H,I)}).catch(function(ee){return F.handleFragLoadError(ee)}):this.doFragPartsLoad(h,K,H,I).catch(function(ee){return F.handleFragLoadError(ee)})}else if(!h.url||this.loadedEndOfParts(K,R))return Promise.resolve(null)}}this.log("Loading fragment "+h.sn+" cc: "+h.cc+" "+(L?"of ["+L.startSN+"-"+L.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+h.level+", target: "+parseFloat(R.toFixed(3))),(0,O.isFiniteNumber)(h.sn)&&!this.bitrateTest&&(this.nextLoadPosition=h.start+h.duration),this.state=m.FRAG_LOADING,this.hls.trigger(b.Events.FRAG_LOADING,{frag:h,targetBufferTime:R}),this.throwIfFragContextChanged("FRAG_LOADING");var q=this.config.progressive;return q&&W?W.then(function(ee){return!ee||F.fragContextChanged(ee==null?void 0:ee.frag)?null:F.fragmentLoader.load(h,I)}).catch(function(ee){return F.handleFragLoadError(ee)}):Promise.all([this.fragmentLoader.load(h,q?I:void 0),W]).then(function(ee){var ae=ee[0];return!q&&ae&&I&&I(ae),ae}).catch(function(ee){return F.handleFragLoadError(ee)})},o.throwIfFragContextChanged=function(h){if(this.fragCurrent===null)throw new Error("frag load aborted, context changed in "+h)},o.doFragPartsLoad=function(h,L,R,I){var k=this;return new Promise(function(F,W){var K=[],H=function Y(q){var ee=L[q];k.fragmentLoader.loadPart(h,ee,I).then(function(ae){K[ee.index]=ae;var re=ae.part;k.hls.trigger(b.Events.FRAG_LOADED,ae);var se=L[q+1];if(se&&se.fragment===h)Y(q+1);else return F({frag:h,part:re,partsLoaded:K})}).catch(W)};H(R)})},o.handleFragLoadError=function(h){if("data"in h){var L=h.data;h.data&&L.details===A.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(L.frag,L.part):this.hls.trigger(b.Events.ERROR,L)}else this.hls.trigger(b.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.INTERNAL_EXCEPTION,err:h,fatal:!0});return null},o._handleTransmuxerFlush=function(h){var L=this.getCurrentContext(h);if(!L||this.state!==m.PARSING){!this.fragCurrent&&this.state!==m.STOPPED&&this.state!==m.ERROR&&(this.state=m.IDLE);return}var R=L.frag,I=L.part,k=L.level,F=self.performance.now();R.stats.parsing.end=F,I&&(I.stats.parsing.end=F),this.updateLevelTiming(R,I,k,h.partial)},o.getCurrentContext=function(h){var L=this.levels,R=h.level,I=h.sn,k=h.part;if(!L||!L[R])return this.warn("Levels object was unset while buffering fragment "+I+" of level "+R+". The current chunk will not be buffered."),null;var F=L[R],W=k>-1?(0,_.getPartWith)(F,I,k):null,K=W?W.fragment:(0,_.getFragmentWithSN)(F,I,this.fragCurrent);return K?{frag:K,part:W,level:F}:null},o.bufferFragmentData=function(h,L,R,I){if(!(!h||this.state!==m.PARSING)){var k=h.data1,F=h.data2,W=k;if(k&&F&&(W=(0,E.appendUint8Array)(k,F)),!(!W||!W.length)){var K={type:h.type,frag:L,part:R,chunkMeta:I,parent:L.type,data:W};this.hls.trigger(b.Events.BUFFER_APPENDING,K),h.dropped&&h.independent&&!R&&this.flushBufferGap(L)}}},o.flushBufferGap=function(h){var L=this.media;if(!!L){if(!P.BufferHelper.isBuffered(L,L.currentTime)){this.flushMainBuffer(0,h.start);return}var R=L.currentTime,I=P.BufferHelper.bufferInfo(L,R,0),k=h.duration,F=Math.min(this.config.maxFragLookUpTolerance*2,k*.25),W=Math.max(Math.min(h.start-F,I.end-F),R+F);h.start-W>F&&this.flushMainBuffer(W,h.start)}},o.getFwdBufferInfo=function(h,L){var R=this.config,I=this.getLoadPosition();if(!(0,O.isFiniteNumber)(I))return null;var k=P.BufferHelper.bufferInfo(h,I,R.maxBufferHole);if(k.len===0&&k.nextStart!==void 0){var F=this.fragmentTracker.getBufferedFrag(I,L);if(F&&k.nextStart<F.end)return P.BufferHelper.bufferInfo(h,I,Math.max(k.nextStart,R.maxBufferHole))}return k},o.getMaxBufferLength=function(h){var L=this.config,R;return h?R=Math.max(8*L.maxBufferSize/h,L.maxBufferLength):R=L.maxBufferLength,Math.min(R,L.maxMaxBufferLength)},o.reduceMaxBufferLength=function(h){var L=this.config,R=h||L.maxBufferLength;return L.maxMaxBufferLength>=R?(L.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+L.maxMaxBufferLength+"s"),!0):!1},o.getNextFragment=function(h,L){var R=L.fragments,I=R.length;if(!I)return null;var k=this.config,F=R[0].start,W;if(L.live){var K=k.initialLiveManifestSize;if(I<K)return this.warn("Not enough fragments to start playback (have: "+I+", need: "+K+")"),null;!L.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(W=this.getInitialLiveFragment(L,R),this.startPosition=W?this.hls.liveSyncPosition||W.start:h)}else h<=F&&(W=R[0]);if(!W){var H=k.lowLatencyMode?L.partEnd:L.fragmentEnd;W=this.getFragmentAtPosition(h,H,L)}return this.mapToInitFragWhenRequired(W)},o.mapToInitFragWhenRequired=function(h){return h!=null&&h.initSegment&&!(h!=null&&h.initSegment.data)&&!this.bitrateTest?h.initSegment:h},o.getNextPart=function(h,L,R){for(var I=-1,k=!1,F=!0,W=0,K=h.length;W<K;W++){var H=h[W];if(F=F&&!H.independent,I>-1&&R<H.start)break;var Y=H.loaded;Y?I=-1:(k||H.independent||F)&&H.fragment===L&&(I=W),k=Y}return I},o.loadedEndOfParts=function(h,L){var R=h[h.length-1];return R&&L>R.start&&R.loaded},o.getInitialLiveFragment=function(h,L){var R=this.fragPrevious,I=null;if(R){if(h.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+R.programDateTime),I=(0,f.findFragmentByPDT)(L,R.endProgramDateTime,this.config.maxFragLookUpTolerance)),!I){var k=R.sn+1;if(k>=h.startSN&&k<=h.endSN){var F=L[k-h.startSN];R.cc===F.cc&&(I=F,this.log("Live playlist, switching playlist, load frag with next SN: "+I.sn))}I||(I=(0,f.findFragWithCC)(L,R.cc),I&&this.log("Live playlist, switching playlist, load frag with same CC: "+I.sn))}}else{var W=this.hls.liveSyncPosition;W!==null&&(I=this.getFragmentAtPosition(W,this.bitrateTest?h.fragmentEnd:h.edge,h))}return I},o.getFragmentAtPosition=function(h,L,R){var I=this.config,k=this.fragPrevious,F=R.fragments,W=R.endSN,K=R.fragmentHint,H=I.maxFragLookUpTolerance,Y=!!(I.lowLatencyMode&&R.partList&&K);Y&&K&&!this.bitrateTest&&(F=F.concat(K),W=K.sn);var q;if(h<L){var ee=h>L-H?0:H;q=(0,f.findFragmentByPTS)(k,F,h,ee)}else q=F[F.length-1];if(q){var ae=q.sn-R.startSN;if(this.fragmentTracker.getState(q)===M.FragmentState.OK&&(k=q),k&&q.sn===k.sn&&!Y){var re=k&&q.level===k.level;if(re){var se=F[ae+1];q.sn<W&&this.fragmentTracker.getState(se)!==M.FragmentState.OK?(this.log("SN "+q.sn+" just loaded, load next one: "+se.sn),q=se):q=null}}}return q},o.synchronizeToLiveEdge=function(h){var L=this.config,R=this.media;if(!!R){var I=this.hls.liveSyncPosition,k=R.currentTime,F=h.fragments[0].start,W=h.edge,K=k>=F-L.maxFragLookUpTolerance&&k<=W;if(I!==null&&R.duration>I&&(k<I||!K)){var H=L.liveMaxLatencyDuration!==void 0?L.liveMaxLatencyDuration:L.liveMaxLatencyDurationCount*h.targetduration;(!K&&R.readyState<4||k<W-H)&&(this.loadedmetadata||(this.nextLoadPosition=I),R.readyState&&(this.warn("Playback: "+k.toFixed(3)+" is located too far from the end of live sliding playlist: "+W+", reset currentTime to : "+I.toFixed(3)),R.currentTime=I))}}},o.alignPlaylists=function(h,L){var R=this.levels,I=this.levelLastLoaded,k=this.fragPrevious,F=I!==null?R[I]:null,W=h.fragments.length;if(!W)return this.warn("No fragments in live playlist"),0;var K=h.fragments[0].start,H=!L,Y=h.alignedSliding&&(0,O.isFiniteNumber)(K);if(H||!Y&&!K){(0,x.alignStream)(k,F,h);var q=h.fragments[0].start;return this.log("Live playlist sliding: "+q.toFixed(2)+" start-sn: "+(L?L.startSN:"na")+"->"+h.startSN+" prev-sn: "+(k?k.sn:"na")+" fragments: "+W),q}return K},o.waitForCdnTuneIn=function(h){var L=3;return h.live&&h.canBlockReload&&h.partTarget&&h.tuneInGoal>Math.max(h.partHoldBack,h.partTarget*L)},o.setStartPosition=function(h,L){var R=this.startPosition;if(R<L&&(R=-1),R===-1||this.lastCurrentTime===-1){var I=h.startTimeOffset;(0,O.isFiniteNumber)(I)?(R=L+I,I<0&&(R+=h.totalduration),R=Math.min(Math.max(L,R),L+h.totalduration),this.log("Start time offset "+I+" found in playlist, adjust startPosition to "+R),this.startPosition=R):h.live?R=this.hls.liveSyncPosition||L:this.startPosition=R=0,this.lastCurrentTime=R}this.nextLoadPosition=R},o.getLoadPosition=function(){var h=this.media,L=0;return this.loadedmetadata&&h?L=h.currentTime:this.nextLoadPosition&&(L=this.nextLoadPosition),L},o.handleFragLoadAborted=function(h,L){this.transmuxer&&h.sn!=="initSegment"&&h.stats.aborted&&(this.warn("Fragment "+h.sn+(L?" part"+L.index:"")+" of level "+h.level+" was aborted"),this.resetFragmentLoading(h))},o.resetFragmentLoading=function(h){(!this.fragCurrent||!this.fragContextChanged(h)&&this.state!==m.FRAG_LOADING_WAITING_RETRY)&&(this.state=m.IDLE)},o.onFragmentOrKeyLoadError=function(h,L){if(L.fatal){this.stopLoad(),this.state=m.ERROR;return}var R=this.config;if(L.chunkMeta){var I=this.getCurrentContext(L.chunkMeta);I&&(L.frag=I.frag,L.levelRetry=!0,this.fragLoadError=R.fragLoadingMaxRetry)}var k=L.frag;if(!(!k||k.type!==h)){var F=this.fragCurrent;if(console.assert(F&&k.sn===F.sn&&k.level===F.level&&k.urlId===F.urlId,"Frag load error must match current frag to retry"),this.fragLoadError+1<=R.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var W=Math.min(Math.pow(2,this.fragLoadError)*R.fragLoadingRetryDelay,R.fragLoadingMaxRetryTimeout);this.warn("Fragment "+k.sn+" of "+h+" "+k.level+" failed to load, retrying in "+W+"ms"),this.retryDate=self.performance.now()+W,this.fragLoadError++,this.state=m.FRAG_LOADING_WAITING_RETRY}else L.levelRetry?(h===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=m.IDLE):(U.logger.error(L.details+" reaches max retry, redispatch as fatal ..."),L.fatal=!0,this.hls.stopLoad(),this.state=m.ERROR)}},o.afterBufferFlushed=function(h,L,R){if(!!h){var I=P.BufferHelper.getBuffered(h);this.fragmentTracker.detectEvictedFragments(L,I,R),this.state===m.ENDED&&this.resetLoadingState()}},o.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=m.IDLE},o.resetStartWhenNotLoaded=function(h){if(!this.loadedmetadata){this.startFragRequested=!1;var L=this.levels?this.levels[h].details:null;L!=null&&L.live?(this.startPosition=-1,this.setStartPosition(L,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},o.updateLevelTiming=function(h,L,R,I){var k=this,F=R.details;console.assert(!!F,"level.details must be defined");var W=Object.keys(h.elementaryStreams).reduce(function(K,H){var Y=h.elementaryStreams[H];if(Y){var q=Y.endPTS-Y.startPTS;if(q<=0)return k.warn("Could not parse fragment "+h.sn+" "+H+" duration reliably ("+q+")"),K||!1;var ee=I?0:(0,_.updateFragPTSDTS)(F,h,Y.startPTS,Y.endPTS,Y.startDTS,Y.endDTS);return k.hls.trigger(b.Events.LEVEL_PTS_UPDATED,{details:F,level:R,drift:ee,type:H,frag:h,start:Y.startPTS,end:Y.endPTS}),!0}return K},!1);W||(this.warn("Found no media in fragment "+h.sn+" of level "+R.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=m.PARSED,this.hls.trigger(b.Events.FRAG_PARSED,{frag:h,part:L})},o.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},d(t,[{key:"state",get:function(){return this._state},set:function(h){var L=this._state;L!==h&&(this._state=h,this.log(L+"->"+h))}}]),t}(D.default)},"./src/controller/buffer-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>f});var O=T("./src/polyfills/number.ts"),D=T("./src/events.ts"),M=T("./src/utils/logger.ts"),P=T("./src/errors.ts"),U=T("./src/utils/buffer-helper.ts"),b=T("./src/utils/mediasource-helper.ts"),A=T("./src/loader/fragment.ts"),S=T("./src/controller/buffer-operation-queue.ts"),E=(0,b.getMediaSource)(),x=/([ha]vc.)(?:\.[^.,]+)+/,f=function(){function _(v){var a=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var s=a.hls,n=a.media,d=a.mediaSource;M.logger.log("[buffer-controller]: Media source opened"),n&&(a.updateMediaElementDuration(),s.trigger(D.Events.MEDIA_ATTACHED,{media:n})),d&&d.removeEventListener("sourceopen",a._onMediaSourceOpen),a.checkPendingTracks()},this._onMediaSourceClose=function(){M.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){M.logger.log("[buffer-controller]: Media source ended")},this.hls=v,this._initSourceBuffer(),this.registerListeners()}var p=_.prototype;return p.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},p.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},p.registerListeners=function(){var a=this.hls;a.on(D.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(D.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(D.Events.BUFFER_RESET,this.onBufferReset,this),a.on(D.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.on(D.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.on(D.Events.BUFFER_EOS,this.onBufferEos,this),a.on(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.on(D.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.on(D.Events.FRAG_PARSED,this.onFragParsed,this),a.on(D.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var a=this.hls;a.off(D.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(D.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(D.Events.BUFFER_RESET,this.onBufferReset,this),a.off(D.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.off(D.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.off(D.Events.BUFFER_EOS,this.onBufferEos,this),a.off(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.off(D.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.off(D.Events.FRAG_PARSED,this.onFragParsed,this),a.off(D.Events.FRAG_CHANGED,this.onFragChanged,this)},p._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new S.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},p.onManifestParsed=function(a,s){var n=2;(s.audio&&!s.video||!s.altAudio)&&(n=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=n,this.details=null,M.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(a,s){var n=this.media=s.media;if(n&&E){var d=this.mediaSource=new E;d.addEventListener("sourceopen",this._onMediaSourceOpen),d.addEventListener("sourceended",this._onMediaSourceEnded),d.addEventListener("sourceclose",this._onMediaSourceClose),n.src=self.URL.createObjectURL(d),this._objectUrl=n.src}},p.onMediaDetaching=function(){var a=this.media,s=this.mediaSource,n=this._objectUrl;if(s){if(M.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(d){M.logger.warn("[buffer-controller]: onMediaDetaching: "+d.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),a&&(n&&self.URL.revokeObjectURL(n),a.src===n?(a.removeAttribute("src"),a.load()):M.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(D.Events.MEDIA_DETACHED,void 0)},p.onBufferReset=function(){var a=this;this.getSourceBufferTypes().forEach(function(s){var n=a.sourceBuffer[s];try{n&&(a.removeBufferListeners(s),a.mediaSource&&a.mediaSource.removeSourceBuffer(n),a.sourceBuffer[s]=void 0)}catch(d){M.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",d)}}),this._initSourceBuffer()},p.onBufferCodecs=function(a,s){var n=this,d=this.getSourceBufferTypes().length;Object.keys(s).forEach(function(l){if(d){var i=n.tracks[l];if(i&&typeof i.buffer.changeType=="function"){var u=s[l],g=u.id,c=u.codec,m=u.levelCodec,e=u.container,r=u.metadata,t=(i.levelCodec||i.codec).replace(x,"$1"),o=(m||c).replace(x,"$1");if(t!==o){var y=e+";codecs="+(m||c);n.appendChangeType(l,y),M.logger.log("[buffer-controller]: switching codec "+t+" to "+o),n.tracks[l]={buffer:i.buffer,codec:c,container:e,levelCodec:m,metadata:r,id:g}}}}else n.pendingTracks[l]=s[l]}),!d&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(a,s){var n=this,d=this.operationQueue,l={execute:function(){var u=n.sourceBuffer[a];u&&(M.logger.log("[buffer-controller]: changing "+a+" sourceBuffer type to "+s),u.changeType(s)),d.shiftAndExecuteNext(a)},onStart:function(){},onComplete:function(){},onError:function(u){M.logger.warn("[buffer-controller]: Failed to change "+a+" SourceBuffer type",u)}};d.append(l,a)},p.onBufferAppending=function(a,s){var n=this,d=this.hls,l=this.operationQueue,i=this.tracks,u=s.data,g=s.type,c=s.frag,m=s.part,e=s.chunkMeta,r=e.buffering[g],t=self.performance.now();r.start=t;var o=c.stats.buffering,y=m?m.stats.buffering:null;o.start===0&&(o.start=t),y&&y.start===0&&(y.start=t);var h=i.audio,L=!1;g==="audio"&&(h==null?void 0:h.container)==="audio/mpeg"&&(L=!this.lastMpegAudioChunk||e.id===1||this.lastMpegAudioChunk.sn!==e.sn,this.lastMpegAudioChunk=e);var R=c.start,I={execute:function(){if(r.executeStart=self.performance.now(),L){var F=n.sourceBuffer[g];if(F){var W=R-F.timestampOffset;Math.abs(W)>=.1&&(M.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+R+" (delta: "+W+") sn: "+c.sn+")"),F.timestampOffset=R)}}n.appendExecutor(u,g)},onStart:function(){},onComplete:function(){var F=self.performance.now();r.executeEnd=r.end=F,o.first===0&&(o.first=F),y&&y.first===0&&(y.first=F);var W=n.sourceBuffer,K={};for(var H in W)K[H]=U.BufferHelper.getBuffered(W[H]);n.appendError=0,n.hls.trigger(D.Events.BUFFER_APPENDED,{type:g,frag:c,part:m,chunkMeta:e,parent:c.type,timeRanges:K})},onError:function(F){M.logger.error("[buffer-controller]: Error encountered while trying to append to the "+g+" SourceBuffer",F);var W={type:P.ErrorTypes.MEDIA_ERROR,parent:c.type,details:P.ErrorDetails.BUFFER_APPEND_ERROR,err:F,fatal:!1};F.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=P.ErrorDetails.BUFFER_FULL_ERROR:(n.appendError++,W.details=P.ErrorDetails.BUFFER_APPEND_ERROR,n.appendError>d.config.appendErrorMaxRetry&&(M.logger.error("[buffer-controller]: Failed "+d.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0,d.stopLoad())),d.trigger(D.Events.ERROR,W)}};l.append(I,g)},p.onBufferFlushing=function(a,s){var n=this,d=this.operationQueue,l=function(u){return{execute:n.removeExecutor.bind(n,u,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){n.hls.trigger(D.Events.BUFFER_FLUSHED,{type:u})},onError:function(c){M.logger.warn("[buffer-controller]: Failed to remove from "+u+" SourceBuffer",c)}}};s.type?d.append(l(s.type),s.type):this.getSourceBufferTypes().forEach(function(i){d.append(l(i),i)})},p.onFragParsed=function(a,s){var n=this,d=s.frag,l=s.part,i=[],u=l?l.elementaryStreams:d.elementaryStreams;u[A.ElementaryStreamTypes.AUDIOVIDEO]?i.push("audiovideo"):(u[A.ElementaryStreamTypes.AUDIO]&&i.push("audio"),u[A.ElementaryStreamTypes.VIDEO]&&i.push("video"));var g=function(){var m=self.performance.now();d.stats.buffering.end=m,l&&(l.stats.buffering.end=m);var e=l?l.stats:d.stats;n.hls.trigger(D.Events.FRAG_BUFFERED,{frag:d,part:l,stats:e,id:d.type})};i.length===0&&M.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+d.type+" level: "+d.level+" sn: "+d.sn),this.blockBuffers(g,i)},p.onFragChanged=function(a,s){this.flushBackBuffer()},p.onBufferEos=function(a,s){var n=this,d=this.getSourceBufferTypes().reduce(function(l,i){var u=n.sourceBuffer[i];return u&&(!s.type||s.type===i)&&(u.ending=!0,u.ended||(u.ended=!0,M.logger.log("[buffer-controller]: "+i+" sourceBuffer now EOS"))),l&&!!(!u||u.ended)},!0);d&&(M.logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){n.getSourceBufferTypes().forEach(function(i){var u=n.sourceBuffer[i];u&&(u.ending=!1)});var l=n.mediaSource;if(!l||l.readyState!=="open"){l&&M.logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+l.readyState);return}M.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),l.endOfStream()}))},p.onLevelUpdated=function(a,s){var n=s.details;!n.fragments.length||(this.details=n,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var a=this.hls,s=this.details,n=this.media,d=this.sourceBuffer;if(!(!n||s===null)){var l=this.getSourceBufferTypes();if(!!l.length){var i=s.live&&a.config.liveBackBufferLength!==null?a.config.liveBackBufferLength:a.config.backBufferLength;if(!(!(0,O.isFiniteNumber)(i)||i<0)){var u=n.currentTime,g=s.levelTargetDuration,c=Math.max(i,g),m=Math.floor(u/g)*g-c;l.forEach(function(e){var r=d[e];if(r){var t=U.BufferHelper.getBuffered(r);if(t.length>0&&m>t.start(0)){if(a.trigger(D.Events.BACK_BUFFER_REACHED,{bufferEnd:m}),s.live)a.trigger(D.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:m});else if(r.ended&&t.end(t.length-1)-u<g*2){M.logger.info("[buffer-controller]: Cannot flush "+e+" back buffer while SourceBuffer is in ended state");return}a.trigger(D.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:m,type:e})}}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var a=this.details,s=this.hls,n=this.media,d=this.mediaSource,l=a.fragments[0].start+a.totalduration,i=n.duration,u=(0,O.isFiniteNumber)(d.duration)?d.duration:0;a.live&&s.config.liveDurationInfinity?(M.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),d.duration=1/0,this.updateSeekableRange(a)):(l>u&&l>i||!(0,O.isFiniteNumber)(i))&&(M.logger.log("[buffer-controller]: Updating Media Source duration to "+l.toFixed(3)),d.duration=l)}},p.updateSeekableRange=function(a){var s=this.mediaSource,n=a.fragments,d=n.length;if(d&&a.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var l=Math.max(0,n[0].start),i=Math.max(l,l+a.totalduration);s.setLiveSeekableRange(l,i)}},p.checkPendingTracks=function(){var a=this.bufferCodecEventsExpected,s=this.operationQueue,n=this.pendingTracks,d=Object.keys(n).length;if(d&&!a||d===2){this.createSourceBuffers(n),this.pendingTracks={};var l=this.getSourceBufferTypes();if(l.length===0){this.hls.trigger(D.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}l.forEach(function(i){s.executeNext(i)})}},p.createSourceBuffers=function(a){var s=this.sourceBuffer,n=this.mediaSource;if(!n)throw Error("createSourceBuffers called when mediaSource was null");var d=0;for(var l in a)if(!s[l]){var i=a[l];if(!i)throw Error("source buffer exists for track "+l+", however track does not");var u=i.levelCodec||i.codec,g=i.container+";codecs="+u;M.logger.log("[buffer-controller]: creating sourceBuffer("+g+")");try{var c=s[l]=n.addSourceBuffer(g),m=l;this.addBufferListener(m,"updatestart",this._onSBUpdateStart),this.addBufferListener(m,"updateend",this._onSBUpdateEnd),this.addBufferListener(m,"error",this._onSBUpdateError),this.tracks[l]={buffer:c,codec:u,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id},d++}catch(e){M.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(D.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:g})}}d&&this.hls.trigger(D.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(a){var s=this.operationQueue,n=s.current(a);n.onStart()},p._onSBUpdateEnd=function(a){var s=this.operationQueue,n=s.current(a);n.onComplete(),s.shiftAndExecuteNext(a)},p._onSBUpdateError=function(a,s){M.logger.error("[buffer-controller]: "+a+" SourceBuffer error",s),this.hls.trigger(D.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var n=this.operationQueue.current(a);n&&n.onError(s)},p.removeExecutor=function(a,s,n){var d=this.media,l=this.mediaSource,i=this.operationQueue,u=this.sourceBuffer,g=u[a];if(!d||!l||!g){M.logger.warn("[buffer-controller]: Attempting to remove from the "+a+" SourceBuffer, but it does not exist"),i.shiftAndExecuteNext(a);return}var c=(0,O.isFiniteNumber)(d.duration)?d.duration:1/0,m=(0,O.isFiniteNumber)(l.duration)?l.duration:1/0,e=Math.max(0,s),r=Math.min(n,c,m);r>e&&!g.ending?(g.ended=!1,M.logger.log("[buffer-controller]: Removing ["+e+","+r+"] from the "+a+" SourceBuffer"),console.assert(!g.updating,a+" sourceBuffer must not be updating"),g.remove(e,r)):i.shiftAndExecuteNext(a)},p.appendExecutor=function(a,s){var n=this.operationQueue,d=this.sourceBuffer,l=d[s];if(!l){M.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),n.shiftAndExecuteNext(s);return}l.ended=!1,console.assert(!l.updating,s+" sourceBuffer must not be updating"),l.appendBuffer(a)},p.blockBuffers=function(a,s){var n=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){M.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(a);return}var d=this.operationQueue,l=s.map(function(i){return d.appendBlocker(i)});Promise.all(l).then(function(){a(),s.forEach(function(i){var u=n.sourceBuffer[i];(!u||!u.updating)&&d.shiftAndExecuteNext(i)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(a,s,n){var d=this.sourceBuffer[a];if(!!d){var l=n.bind(this,a);this.listeners[a].push({event:s,listener:l}),d.addEventListener(s,l)}},p.removeBufferListeners=function(a){var s=this.sourceBuffer[a];!s||this.listeners[a].forEach(function(n){s.removeEventListener(n.event,n.listener)})},_}()},"./src/controller/buffer-operation-queue.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>D});var O=T("./src/utils/logger.ts"),D=function(){function M(U){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=U}var P=M.prototype;return P.append=function(b,A){var S=this.queues[A];S.push(b),S.length===1&&this.buffers[A]&&this.executeNext(A)},P.insertAbort=function(b,A){var S=this.queues[A];S.unshift(b),this.executeNext(A)},P.appendBlocker=function(b){var A,S=new Promise(function(x){A=x}),E={execute:A,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(E,b),S},P.executeNext=function(b){var A=this.buffers,S=this.queues,E=A[b],x=S[b];if(x.length){var f=x[0];try{f.execute()}catch(_){O.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),f.onError(_),(!E||!E.updating)&&(x.shift(),this.executeNext(b))}}},P.shiftAndExecuteNext=function(b){this.queues[b].shift(),this.executeNext(b)},P.current=function(b){return this.queues[b][0]},M}()},"./src/controller/cap-level-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>A});var O=T("./src/events.ts");function D(S,E){for(var x=0;x<E.length;x++){var f=E[x];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(S,P(f.key),f)}}function M(S,E,x){return E&&D(S.prototype,E),x&&D(S,x),Object.defineProperty(S,"prototype",{writable:!1}),S}function P(S){var E=U(S,"string");return typeof E=="symbol"?E:String(E)}function U(S,E){if(typeof S!="object"||S===null)return S;var x=S[Symbol.toPrimitive];if(x!==void 0){var f=x.call(S,E||"default");if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(S)}var b=function(){function S(x){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=x,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var E=S.prototype;return E.setStreamController=function(f){this.streamController=f},E.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},E.registerListeners=function(){var f=this.hls;f.on(O.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),f.on(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),f.on(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.on(O.Events.BUFFER_CODECS,this.onBufferCodecs,this),f.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},E.unregisterListener=function(){var f=this.hls;f.off(O.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),f.off(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),f.off(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.off(O.Events.BUFFER_CODECS,this.onBufferCodecs,this),f.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},E.onFpsDropLevelCapping=function(f,_){S.isLevelAllowed(_.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(_.droppedLevel)},E.onMediaAttaching=function(f,_){this.media=_.media instanceof HTMLVideoElement?_.media:null,this.clientRect=null},E.onManifestParsed=function(f,_){var p=this.hls;this.restrictedLevels=[],this.firstLevel=_.firstLevel,p.config.capLevelToPlayerSize&&_.video&&this.startCapping()},E.onBufferCodecs=function(f,_){var p=this.hls;p.config.capLevelToPlayerSize&&_.video&&this.startCapping()},E.onMediaDetaching=function(){this.stopCapping()},E.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var f=this.hls.levels;if(f.length){var _=this.hls;_.autoLevelCapping=this.getMaxLevel(f.length-1),_.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=_.autoLevelCapping}}},E.getMaxLevel=function(f){var _=this,p=this.hls.levels;if(!p.length)return-1;var v=p.filter(function(a,s){return S.isLevelAllowed(s,_.restrictedLevels)&&s<=f});return this.clientRect=null,S.getMaxLevelByMediaSize(v,this.mediaWidth,this.mediaHeight)},E.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())},E.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},E.getDimensions=function(){if(this.clientRect)return this.clientRect;var f=this.media,_={width:0,height:0};if(f){var p=f.getBoundingClientRect();_.width=p.width,_.height=p.height,!_.width&&!_.height&&(_.width=p.right-p.left||f.width||0,_.height=p.bottom-p.top||f.height||0)}return this.clientRect=_,_},S.isLevelAllowed=function(f,_){return _===void 0&&(_=[]),_.indexOf(f)===-1},S.getMaxLevelByMediaSize=function(f,_,p){if(!f||!f.length)return-1;for(var v=function(l,i){return i?l.width!==i.width||l.height!==i.height:!0},a=f.length-1,s=0;s<f.length;s+=1){var n=f[s];if((n.width>=_||n.height>=p)&&v(n,f[s+1])){a=s;break}}return a},M(S,[{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 f=1;if(!this.hls.config.ignoreDevicePixelRatio)try{f=self.devicePixelRatio}catch{}return f}}]),S}();let A=b},"./src/controller/cmcd-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>p});var O=T("./src/events.ts"),D=T("./src/types/cmcd.ts"),M=T("./src/utils/buffer-helper.ts"),P=T("./src/utils/logger.ts");function U(v,a){for(var s=0;s<a.length;s++){var n=a[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(v,A(n.key),n)}}function b(v,a,s){return a&&U(v.prototype,a),s&&U(v,s),Object.defineProperty(v,"prototype",{writable:!1}),v}function A(v){var a=S(v,"string");return typeof a=="symbol"?a:String(a)}function S(v,a){if(typeof v!="object"||v===null)return v;var s=v[Symbol.toPrimitive];if(s!==void 0){var n=s.call(v,a||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(v)}function E(v,a){var s=typeof Symbol!="undefined"&&v[Symbol.iterator]||v["@@iterator"];if(s)return(s=s.call(v)).next.bind(s);if(Array.isArray(v)||(s=x(v))||a&&v&&typeof v.length=="number"){s&&(v=s);var n=0;return function(){return n>=v.length?{done:!0}:{done:!1,value:v[n++]}}}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 x(v,a){if(!!v){if(typeof v=="string")return f(v,a);var s=Object.prototype.toString.call(v).slice(8,-1);if(s==="Object"&&v.constructor&&(s=v.constructor.name),s==="Map"||s==="Set")return Array.from(v);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return f(v,a)}}function f(v,a){(a==null||a>v.length)&&(a=v.length);for(var s=0,n=new Array(a);s<a;s++)n[s]=v[s];return n}function _(){return _=Object.assign?Object.assign.bind():function(v){for(var a=1;a<arguments.length;a++){var s=arguments[a];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(v[n]=s[n])}return v},_.apply(this,arguments)}var p=function(){function v(s){var n=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(){n.initialized&&(n.starved=!0),n.buffering=!0},this.onPlaying=function(){n.initialized||(n.initialized=!0),n.buffering=!1},this.applyPlaylistData=function(i){try{n.apply(i,{ot:D.CMCDObjectType.MANIFEST,su:!n.initialized})}catch(u){P.logger.warn("Could not generate manifest CMCD data.",u)}},this.applyFragmentData=function(i){try{var u=i.frag,g=n.hls.levels[u.level],c=n.getObjectType(u),m={d:u.duration*1e3,ot:c};(c===D.CMCDObjectType.VIDEO||c===D.CMCDObjectType.AUDIO||c==D.CMCDObjectType.MUXED)&&(m.br=g.bitrate/1e3,m.tb=n.getTopBandwidth(c)/1e3,m.bl=n.getBufferLength(c)),n.apply(i,m)}catch(e){P.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=s;var d=this.config=s.config,l=d.cmcd;l!=null&&(d.pLoader=this.createPlaylistLoader(),d.fLoader=this.createFragmentLoader(),this.sid=l.sessionId||v.uuid(),this.cid=l.contentId,this.useHeaders=l.useHeaders===!0,this.registerListeners())}var a=v.prototype;return a.registerListeners=function(){var n=this.hls;n.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(O.Events.MEDIA_DETACHED,this.onMediaDetached,this),n.on(O.Events.BUFFER_CREATED,this.onBufferCreated,this)},a.unregisterListeners=function(){var n=this.hls;n.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(O.Events.MEDIA_DETACHED,this.onMediaDetached,this),n.off(O.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},a.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},a.onMediaAttached=function(n,d){this.media=d.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},a.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},a.onBufferCreated=function(n,d){var l,i;this.audioBuffer=(l=d.tracks.audio)===null||l===void 0?void 0:l.buffer,this.videoBuffer=(i=d.tracks.video)===null||i===void 0?void 0:i.buffer},a.createData=function(){var n;return{v:D.CMCDVersion,sf:D.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(n=this.media)===null||n===void 0?void 0:n.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},a.apply=function(n,d){d===void 0&&(d={}),_(d,this.createData());var l=d.ot===D.CMCDObjectType.INIT||d.ot===D.CMCDObjectType.VIDEO||d.ot===D.CMCDObjectType.MUXED;if(this.starved&&l&&(d.bs=!0,d.su=!0,this.starved=!1),d.su==null&&(d.su=this.buffering),this.useHeaders){var i=v.toHeaders(d);if(!Object.keys(i).length)return;n.headers||(n.headers={}),_(n.headers,i)}else{var u=v.toQuery(d);if(!u)return;n.url=v.appendQueryToUri(n.url,u)}},a.getObjectType=function(n){var d=n.type;if(d==="subtitle")return D.CMCDObjectType.TIMED_TEXT;if(n.sn==="initSegment")return D.CMCDObjectType.INIT;if(d==="audio")return D.CMCDObjectType.AUDIO;if(d==="main")return this.hls.audioTracks.length?D.CMCDObjectType.VIDEO:D.CMCDObjectType.MUXED},a.getTopBandwidth=function(n){var d=0,l,i=this.hls;if(n===D.CMCDObjectType.AUDIO)l=i.audioTracks;else{var u=i.maxAutoLevel,g=u>-1?u+1:i.levels.length;l=i.levels.slice(0,g)}for(var c=E(l),m;!(m=c()).done;){var e=m.value;e.bitrate>d&&(d=e.bitrate)}return d>0?d:NaN},a.getBufferLength=function(n){var d=this.hls.media,l=n===D.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!l||!d)return NaN;var i=M.BufferHelper.bufferInfo(l,d.currentTime,this.config.maxBufferHole);return i.len*1e3},a.createPlaylistLoader=function(){var n=this.config.pLoader,d=this.applyPlaylistData,l=n||this.config.loader;return function(){function i(g){this.loader=void 0,this.loader=new l(g)}var u=i.prototype;return u.destroy=function(){this.loader.destroy()},u.abort=function(){this.loader.abort()},u.load=function(c,m,e){d(c),this.loader.load(c,m,e)},b(i,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),i}()},a.createFragmentLoader=function(){var n=this.config.fLoader,d=this.applyFragmentData,l=n||this.config.loader;return function(){function i(g){this.loader=void 0,this.loader=new l(g)}var u=i.prototype;return u.destroy=function(){this.loader.destroy()},u.abort=function(){this.loader.abort()},u.load=function(c,m,e){d(c),this.loader.load(c,m,e)},b(i,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),i}()},v.uuid=function(){var n=URL.createObjectURL(new Blob),d=n.toString();return URL.revokeObjectURL(n),d.slice(d.lastIndexOf("/")+1)},v.serialize=function(n){for(var d=[],l=function(I){return!Number.isNaN(I)&&I!=null&&I!==""&&I!==!1},i=function(I){return Math.round(I)},u=function(I){return i(I/100)*100},g=function(I){return encodeURIComponent(I)},c={br:i,d:i,bl:u,dl:u,mtp:u,nor:g,rtp:u,tb:i},m=Object.keys(n||{}).sort(),e=E(m),r;!(r=e()).done;){var t=r.value,o=n[t];if(!!l(o)&&!(t==="v"&&o===1)&&!(t=="pr"&&o===1)){var y=c[t];y&&(o=y(o));var h=typeof o,L=void 0;t==="ot"||t==="sf"||t==="st"?L=t+"="+o:h==="boolean"?L=t:h==="number"?L=t+"="+o:L=t+"="+JSON.stringify(o),d.push(L)}}return d.join(",")},v.toHeaders=function(n){for(var d=Object.keys(n),l={},i=["Object","Request","Session","Status"],u=[{},{},{},{}],g={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},c=0,m=d;c<m.length;c++){var e=m[c],r=g[e]!=null?g[e]:1;u[r][e]=n[e]}for(var t=0;t<u.length;t++){var o=v.serialize(u[t]);o&&(l["CMCD-"+i[t]]=o)}return l},v.toQuery=function(n){return"CMCD="+encodeURIComponent(v.serialize(n))},v.appendQueryToUri=function(n,d){if(!d)return n;var l=n.includes("?")?"&":"?";return""+n+l+d},v}()},"./src/controller/eme-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>c});var O=T("./src/events.ts"),D=T("./src/errors.ts"),M=T("./src/utils/logger.ts"),P=T("./src/utils/mediakeys-helper.ts"),U=T("./src/utils/keysystem-util.ts"),b=T("./src/utils/numeric-encoding-utils.ts"),A=T("./src/loader/level-key.ts"),S=T("./src/utils/hex.ts"),E=T("./src/utils/mp4-tools.ts"),x=T("./node_modules/eventemitter3/index.js"),f=T.n(x);function _(m,e){m.prototype=Object.create(e.prototype),m.prototype.constructor=m,n(m,e)}function p(m){var e=typeof Map=="function"?new Map:void 0;return p=function(t){if(t===null||!s(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(t))return e.get(t);e.set(t,o)}function o(){return v(t,arguments,d(this).constructor)}return o.prototype=Object.create(t.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),n(o,t)},p(m)}function v(m,e,r){return a()?v=Reflect.construct.bind():v=function(o,y,h){var L=[null];L.push.apply(L,y);var R=Function.bind.apply(o,L),I=new R;return h&&n(I,h.prototype),I},v.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 s(m){return Function.toString.call(m).indexOf("[native code]")!==-1}function n(m,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,o){return t.__proto__=o,t},n(m,e)}function d(m){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},d(m)}var l=3,i="[eme]",u=function(){function m(r){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=m.CDMCleanupPromise?[m.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=M.logger.debug.bind(M.logger,i),this.log=M.logger.log.bind(M.logger,i),this.warn=M.logger.warn.bind(M.logger,i),this.error=M.logger.error.bind(M.logger,i),this.hls=r,this.config=r.config,this.registerListeners()}var e=m.prototype;return e.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null},e.registerListeners=function(){this.hls.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(O.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},e.unregisterListeners=function(){this.hls.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(O.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},e.getLicenseServerUrl=function(t){var o=this.config,y=o.drmSystems,h=o.widevineLicenseUrl,L=y[t];if(L)return L.licenseUrl;if(t===P.KeySystems.WIDEVINE&&h)return h;throw new Error('no license server URL configured for key-system "'+t+'"')},e.getServerCertificateUrl=function(t){var o=this.config.drmSystems,y=o[t];if(y)return y.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+t+'"]')},e.attemptKeySystemAccess=function(t){var o=this,y=this.hls.levels,h=function(k,F,W){return!!k&&W.indexOf(k)===F},L=y.map(function(I){return I.audioCodec}).filter(h),R=y.map(function(I){return I.videoCodec}).filter(h);return L.length+R.length===0&&R.push("avc1.42e01e"),new Promise(function(I,k){var F=function W(K){var H=K.shift();o.getMediaKeysPromise(H,L,R).then(function(Y){return I({keySystem:H,mediaKeys:Y})}).catch(function(Y){K.length?W(K):Y instanceof g?k(Y):k(new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:Y,fatal:!0},Y.message))})};F(t)})},e.requestMediaKeySystemAccess=function(t,o){var y=this.config.requestMediaKeySystemAccessFunc;if(typeof y!="function"){var h="Configured requestMediaKeySystemAccess is not a function "+y;return P.requestMediaKeySystemAccess===null&&self.location.protocol==="http:"&&(h="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(h))}return y(t,o)},e.getMediaKeysPromise=function(t,o,y){var h=this,L=(0,P.getSupportedMediaKeySystemConfigurations)(t,o,y,this.config.drmSystemOptions),R=this.keySystemAccessPromises[t],I=R==null?void 0:R.keySystemAccess;if(!I){this.log('Requesting encrypted media "'+t+'" key-system access with config: '+JSON.stringify(L)),I=this.requestMediaKeySystemAccess(t,L);var k=this.keySystemAccessPromises[t]={keySystemAccess:I};return I.catch(function(F){h.log('Failed to obtain access to key-system "'+t+'": '+F)}),I.then(function(F){h.log('Access for key-system "'+F.keySystem+'" obtained');var W=h.fetchServerCertificate(t);return h.log('Create media-keys for "'+t+'"'),k.mediaKeys=F.createMediaKeys().then(function(K){return h.log('Media-keys created for "'+t+'"'),W.then(function(H){return H?h.setMediaKeysServerCertificate(K,t,H):K})}),k.mediaKeys.catch(function(K){h.error('Failed to create media-keys for "'+t+'"}: '+K)}),k.mediaKeys})}return I.then(function(){return R.mediaKeys})},e.createMediaKeySessionContext=function(t){var o=t.decryptdata,y=t.keySystem,h=t.mediaKeys;console.assert(!!h,"mediaKeys is defined"),this.log('Creating key-system session "'+y+'" keyId: '+S.default.hexDump(o.keyId||[]));var L=h.createSession(),R={decryptdata:o,keySystem:y,mediaKeys:h,mediaKeysSession:L,keyStatus:"status-pending"};return this.mediaKeySessions.push(R),R},e.renewKeySession=function(t){var o=t.decryptdata;if(o.pssh){var y=this.createMediaKeySessionContext(t),h=this.getKeyIdString(o),L="cenc";this.keyIdToKeySessionPromise[h]=this.generateRequestWithPreferredKeySession(y,L,o.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)},e.getKeyIdString=function(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(t.keyId===null)throw new Error("keyId is null");return S.default.hexDump(t.keyId)},e.updateKeySession=function(t,o){var y,h=t.mediaKeysSession;return this.log('Updating key-session "'+h.sessionId+'" for keyID '+S.default.hexDump(((y=t.decryptdata)===null||y===void 0?void 0:y.keyId)||[])+`
|
|
14
|
+
} (data length: `+(o&&o.byteLength)+")"),h.update(o)},e.selectKeySystemFormat=function(t){var o=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+t.sn+" "+t.type+": "+t.level+") key formats "+o.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(o)),this.keyFormatPromise},e.getKeyFormatPromise=function(t){var o=this;return new Promise(function(y,h){var L=(0,P.getKeySystemsForConfig)(o.config),R=t.map(P.keySystemFormatToKeySystemDomain).filter(function(I){return!!I&&L.indexOf(I)!==-1});return o.getKeySystemSelectionPromise(R).then(function(I){var k=I.keySystem,F=(0,P.keySystemDomainToKeySystemFormat)(k);F?y(F):h(new Error('Unable to find format for key-system "'+k+'"'))}).catch(h)})},e.loadKey=function(t){var o=this,y=t.keyInfo.decryptdata,h=this.getKeyIdString(y),L="(keyId: "+h+' format: "'+y.keyFormat+'" method: '+y.method+" uri: "+y.uri+")";this.log("Starting session for key "+L);var R=this.keyIdToKeySessionPromise[h];return R||(R=this.keyIdToKeySessionPromise[h]=this.getKeySystemForKeyPromise(y).then(function(I){var k=I.keySystem,F=I.mediaKeys;return o.throwIfDestroyed(),o.log("Handle encrypted media sn: "+t.frag.sn+" "+t.frag.type+": "+t.frag.level+" using key "+L),o.attemptSetMediaKeys(k,F).then(function(){o.throwIfDestroyed();var W=o.createMediaKeySessionContext({keySystem:k,mediaKeys:F,decryptdata:y}),K="cenc";return o.generateRequestWithPreferredKeySession(W,K,y.pssh,"playlist-key")})}),R.catch(function(I){return o.handleError(I)})),R},e.throwIfDestroyed=function(t){if(t===void 0&&(t="Invalid state"),!this.hls)throw new Error("invalid state")},e.handleError=function(t){!this.hls||(this.error(t.message),t instanceof g?this.hls.trigger(O.Events.ERROR,t.data):this.hls.trigger(O.Events.ERROR,{type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))},e.getKeySystemForKeyPromise=function(t){var o=this.getKeyIdString(t),y=this.keyIdToKeySessionPromise[o];if(!y){var h=(0,P.keySystemFormatToKeySystemDomain)(t.keyFormat),L=h?[h]:(0,P.getKeySystemsForConfig)(this.config);return this.attemptKeySystemAccess(L)}return y},e.getKeySystemSelectionPromise=function(t){if(t.length||(t=(0,P.getKeySystemsForConfig)(this.config)),t.length===0)throw new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(t)},e._onMediaEncrypted=function(t){var o=this,y=t.initDataType,h=t.initData;if(this.debug('"'+t.type+'" event: init data type: "'+y+'"'),h!==null){var L,R;if(y==="sinf"&&this.config.drmSystems[P.KeySystems.FAIRPLAY]){var I=(0,E.bin2str)(new Uint8Array(h));try{var k=(0,b.base64Decode)(JSON.parse(I).sinf),F=(0,E.parseSinf)(new Uint8Array(k));if(!F)return;L=F.subarray(8,24),R=P.KeySystems.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{var W=(0,E.parsePssh)(h);if(W===null)return;W.version===0&&W.systemId===P.KeySystemIds.WIDEVINE&&W.data&&(L=W.data.subarray(8,24)),R=(0,P.keySystemIdToKeySystemDomain)(W.systemId)}if(!(!R||!L)){for(var K=S.default.hexDump(L),H=this.keyIdToKeySessionPromise,Y=this.mediaKeySessions,q=H[K],ee=function(le){var de=Y[le],ue=de.decryptdata;if(ue.pssh||!ue.keyId)return"continue";var fe=S.default.hexDump(ue.keyId);if(K===fe||ue.uri.replace(/-/g,"").indexOf(K)!==-1)return q=H[fe],delete H[fe],ue.pssh=new Uint8Array(h),ue.keyId=L,q=H[K]=q.then(function(){return o.generateRequestWithPreferredKeySession(de,y,h,"encrypted-event-key-match")}),"break"},ae=0;ae<Y.length;ae++){var re=ee(ae);if(re!=="continue"&&re==="break")break}q||(q=H[K]=this.getKeySystemSelectionPromise([R]).then(function(se){var le,de=se.keySystem,ue=se.mediaKeys;o.throwIfDestroyed();var fe=new A.LevelKey("ISO-23001-7",K,(le=(0,P.keySystemDomainToKeySystemFormat)(de))!=null?le:"");return fe.pssh=new Uint8Array(h),fe.keyId=L,o.attemptSetMediaKeys(de,ue).then(function(){o.throwIfDestroyed();var ce=o.createMediaKeySessionContext({decryptdata:fe,keySystem:de,mediaKeys:ue});return o.generateRequestWithPreferredKeySession(ce,y,h,"encrypted-event-no-match")})})),q.catch(function(se){return o.handleError(se)})}}},e._onWaitingForKey=function(t){this.log('"'+t.type+'" event')},e.attemptSetMediaKeys=function(t,o){var y=this,h=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+t+'"');var L=Promise.all(h).then(function(){if(!y.media)throw new Error("Attempted to set mediaKeys without media element attached");return y.media.setMediaKeys(o)});return this.setMediaKeysQueue.push(L),L.then(function(){y.log('Media-keys set for "'+t+'"'),h.push(L),y.setMediaKeysQueue=y.setMediaKeysQueue.filter(function(R){return h.indexOf(R)===-1})})},e.generateRequestWithPreferredKeySession=function(t,o,y,h){var L,R,I=this,k=(L=this.config.drmSystems)===null||L===void 0||(R=L[t.keySystem])===null||R===void 0?void 0:R.generateRequest;if(k)try{var F=k.call(this.hls,o,y,t);if(!F)throw new Error("Invalid response from configured generateRequest filter");o=F.initDataType,y=t.decryptdata.pssh=F.initData?new Uint8Array(F.initData):null}catch(q){var W;if(this.warn(q.message),(W=this.hls)!==null&&W!==void 0&&W.config.debug)throw q}if(y===null)return this.log('Skipping key-session request for "'+h+'" (no initData)'),Promise.resolve(t);var K=this.getKeyIdString(t.decryptdata);this.log('Generating key-session request for "'+h+'": '+K+" (init data type: "+o+" length: "+(y?y.byteLength:null)+")");var H=new(f());t.mediaKeysSession.onmessage=function(q){var ee=t.mediaKeysSession;if(!ee){H.emit("error",new Error("invalid state"));return}var ae=q.messageType,re=q.message;I.log('"'+ae+'" message event for session "'+ee.sessionId+'" message size: '+re.byteLength),ae==="license-request"||ae==="license-renewal"?I.renewLicense(t,re).catch(function(se){I.handleError(se),H.emit("error",se)}):ae==="license-release"?t.keySystem===P.KeySystems.FAIRPLAY&&(I.updateKeySession(t,(0,U.strToUtf8array)("acknowledged")),I.removeSession(t)):I.warn('unhandled media key message type "'+ae+'"')},t.mediaKeysSession.onkeystatuseschange=function(q){var ee=t.mediaKeysSession;if(!ee){H.emit("error",new Error("invalid state"));return}I.onKeyStatusChange(t);var ae=t.keyStatus;H.emit("keyStatus",ae),ae==="expired"&&(I.warn(t.keySystem+" expired for key "+K),I.renewKeySession(t))};var Y=new Promise(function(q,ee){H.on("error",ee),H.on("keyStatus",function(ae){ae.startsWith("usable")?q():ae==="output-restricted"?ee(new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):ae==="internal-error"?ee(new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+ae+'"')):ae==="expired"?ee(new Error("key expired while generating request")):I.warn('unhandled key status change "'+ae+'"')})});return t.mediaKeysSession.generateRequest(o,y).then(function(){var q;I.log('Request generated for key-session "'+((q=t.mediaKeysSession)===null||q===void 0?void 0:q.sessionId)+'" keyId: '+K)}).catch(function(q){throw new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_NO_SESSION,error:q,fatal:!1},"Error generating key-session request: "+q)}).then(function(){return Y}).catch(function(q){throw H.removeAllListeners(),I.removeSession(t),q}).then(function(){return H.removeAllListeners(),t})},e.onKeyStatusChange=function(t){var o=this;t.mediaKeysSession.keyStatuses.forEach(function(y,h){o.log('key status change "'+y+'" for keyStatuses keyId: '+S.default.hexDump("buffer"in h?new Uint8Array(h.buffer,h.byteOffset,h.byteLength):new Uint8Array(h))+" session keyId: "+S.default.hexDump(new Uint8Array(t.decryptdata.keyId||[]))+" uri: "+t.decryptdata.uri),t.keyStatus=y})},e.fetchServerCertificate=function(t){var o=this;return new Promise(function(y,h){var L=o.getServerCertificateUrl(t);if(!L)return y();o.log('Fetching serverCertificate for "'+t+'"');var R=new XMLHttpRequest;R.open("GET",L,!0),R.responseType="arraybuffer",R.onreadystatechange=function(){R.readyState===XMLHttpRequest.DONE&&(R.status===200?y(R.response):h(new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:R},'"'+t+'" certificate request XHR failed ('+L+"). Status: "+R.status+" ("+R.statusText+")")))},R.send()})},e.setMediaKeysServerCertificate=function(t,o,y){var h=this;return new Promise(function(L,R){t.setServerCertificate(y).then(function(I){h.log("setServerCertificate "+(I?"success":"not supported by CDM")+" ("+(y==null?void 0:y.byteLength)+') on "'+o+'"'),L(t)}).catch(function(I){R(new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:I,fatal:!0},I.message))})})},e.renewLicense=function(t,o){var y=this;return this.requestLicense(t,new Uint8Array(o)).then(function(h){return y.updateKeySession(t,new Uint8Array(h)).catch(function(L){throw new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:L,fatal:!0},L.message)})})},e.setupLicenseXHR=function(t,o,y,h){var L=this,R=this.config.licenseXhrSetup;return R?Promise.resolve().then(function(){if(!y.decryptdata)throw new Error("Key removed");return R.call(L.hls,t,o,y,h)}).catch(function(I){if(!y.decryptdata)throw I;return t.open("POST",o,!0),R.call(L.hls,t,o,y,h)}).then(function(I){t.readyState||t.open("POST",o,!0);var k=I||h;return{xhr:t,licenseChallenge:k}}):(t.open("POST",o,!0),Promise.resolve({xhr:t,licenseChallenge:h}))},e.requestLicense=function(t,o){var y=this;return new Promise(function(h,L){var R=y.getLicenseServerUrl(t.keySystem);y.log("Sending license request to URL: "+R);var I=new XMLHttpRequest;I.responseType="arraybuffer",I.onreadystatechange=function(){if(!y.hls||!t.mediaKeysSession)return L(new Error("invalid state"));if(I.readyState===4)if(I.status===200){y._requestLicenseFailureCount=0;var k=I.response;y.log("License received "+(k instanceof ArrayBuffer?k.byteLength:k));var F=y.config.licenseResponseCallback;if(F)try{k=F.call(y.hls,I,R,t)}catch(K){y.error(K)}h(k)}else if(y._requestLicenseFailureCount++,y._requestLicenseFailureCount>l||I.status>=400&&I.status<500)L(new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:I},"License Request XHR failed ("+R+"). Status: "+I.status+" ("+I.statusText+")"));else{var W=l-y._requestLicenseFailureCount+1;y.warn("Retrying license request, "+W+" attempts left"),y.requestLicense(t,o).then(h,L)}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=I,y.setupLicenseXHR(I,R,t,o).then(function(k){var F=k.xhr,W=k.licenseChallenge;F.send(W)})})},e.onMediaAttached=function(t,o){if(!!this.config.emeEnabled){var y=o.media;this.media=y,y.addEventListener("encrypted",this.onMediaEncrypted),y.addEventListener("waitingforkey",this.onWaitingForKey)}},e.onMediaDetached=function(){var t=this,o=this.media,y=this.mediaKeySessions;o&&(o.removeEventListener("encrypted",this.onMediaEncrypted),o.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},A.LevelKey.clearKeyUriToKeyIdMap();var h=y.length;m.CDMCleanupPromise=Promise.all(y.map(function(L){return t.removeSession(L)}).concat(o==null?void 0:o.setMediaKeys(null).catch(function(L){t.log("Could not clear media keys: "+L+". media.src: "+(o==null?void 0:o.src))}))).then(function(){h&&(t.log("finished closing key sessions and clearing media keys"),y.length=0)}).catch(function(L){t.log("Could not close sessions and clear media keys: "+L+". media.src: "+(o==null?void 0:o.src))})},e.onManifestLoaded=function(t,o){var y=o.sessionKeys;if(!(!y||!this.config.emeEnabled)&&!this.keyFormatPromise){var h=y.reduce(function(L,R){return L.indexOf(R.keyFormat)===-1&&L.push(R.keyFormat),L},[]);this.log("Selecting key-system from session-keys "+h.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(h)}},e.removeSession=function(t){var o=this,y=t.mediaKeysSession,h=t.licenseXhr;if(y){this.log("Remove licenses and keys and close session "+y.sessionId),y.onmessage=null,y.onkeystatuseschange=null,h&&h.readyState!==XMLHttpRequest.DONE&&h.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;var L=this.mediaKeySessions.indexOf(t);return L>-1&&this.mediaKeySessions.splice(L,1),y.remove().catch(function(R){o.log("Could not remove session: "+R)}).then(function(){return y.close()}).catch(function(R){o.log("Could not close session: "+R)})}},m}();u.CDMCleanupPromise=void 0;var g=function(m){_(e,m);function e(r,t){var o;return o=m.call(this,t)||this,o.data=void 0,o.data=r,r.err=r.error,o}return e}(p(Error));let c=u},"./src/controller/fps-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>P});var O=T("./src/events.ts"),D=T("./src/utils/logger.ts"),M=function(){function U(A){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=A,this.registerListeners()}var b=U.prototype;return b.setStreamController=function(S){this.streamController=S},b.registerListeners=function(){this.hls.on(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},b.unregisterListeners=function(){this.hls.off(O.Events.MEDIA_ATTACHING,this.onMediaAttaching)},b.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},b.onMediaAttaching=function(S,E){var x=this.hls.config;if(x.capLevelOnFPSDrop){var f=E.media instanceof self.HTMLVideoElement?E.media:null;this.media=f,f&&typeof f.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),x.fpsDroppedMonitoringPeriod)}},b.checkFPS=function(S,E,x){var f=performance.now();if(E){if(this.lastTime){var _=f-this.lastTime,p=x-this.lastDroppedFrames,v=E-this.lastDecodedFrames,a=1e3*p/_,s=this.hls;if(s.trigger(O.Events.FPS_DROP,{currentDropped:p,currentDecoded:v,totalDroppedFrames:x}),a>0&&p>s.config.fpsDroppedMonitoringThreshold*v){var n=s.currentLevel;D.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+n),n>0&&(s.autoLevelCapping===-1||s.autoLevelCapping>=n)&&(n=n-1,s.trigger(O.Events.FPS_DROP_LEVEL_CAPPING,{level:n,droppedLevel:s.currentLevel}),s.autoLevelCapping=n,this.streamController.nextLevelSwitch())}}this.lastTime=f,this.lastDroppedFrames=x,this.lastDecodedFrames=E}},b.checkFPSInterval=function(){var S=this.media;if(S)if(this.isVideoPlaybackQualityAvailable){var E=S.getVideoPlaybackQuality();this.checkFPS(S,E.totalVideoFrames,E.droppedVideoFrames)}else this.checkFPS(S,S.webkitDecodedFrameCount,S.webkitDroppedFrameCount)},U}();let P=M},"./src/controller/fragment-finders.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{findFragWithCC:()=>A,findFragmentByPDT:()=>M,findFragmentByPTS:()=>P,fragmentWithinToleranceTest:()=>U,pdtWithinToleranceTest:()=>b});var O=T("./src/polyfills/number.ts"),D=T("./src/utils/binary-search.ts");function M(S,E,x){if(E===null||!Array.isArray(S)||!S.length||!(0,O.isFiniteNumber)(E))return null;var f=S[0].programDateTime;if(E<(f||0))return null;var _=S[S.length-1].endProgramDateTime;if(E>=(_||0))return null;x=x||0;for(var p=0;p<S.length;++p){var v=S[p];if(b(E,x,v))return v}return null}function P(S,E,x,f){x===void 0&&(x=0),f===void 0&&(f=0);var _=null;if(S?_=E[S.sn-E[0].sn+1]||null:x===0&&E[0].start===0&&(_=E[0]),_&&U(x,f,_)===0)return _;var p=D.default.search(E,U.bind(null,x,f));return p&&(p!==S||!_)?p:_}function U(S,E,x){if(S===void 0&&(S=0),E===void 0&&(E=0),x.start<=S&&x.start+x.duration>S)return 0;var f=Math.min(E,x.duration+(x.deltaPTS?x.deltaPTS:0));return x.start+x.duration-f<=S?1:x.start-f>S&&x.start?-1:0}function b(S,E,x){var f=Math.min(E,x.duration+(x.deltaPTS?x.deltaPTS:0))*1e3,_=x.endProgramDateTime||0;return _-f>S}function A(S,E){return D.default.search(S,function(x){return x.cc<E?1:x.cc>E?-1:0})}},"./src/controller/fragment-tracker.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{FragmentState:()=>M,FragmentTracker:()=>P});var O=T("./src/events.ts"),D=T("./src/types/loader.ts"),M;(function(A){A.NOT_LOADED="NOT_LOADED",A.APPENDING="APPENDING",A.PARTIAL="PARTIAL",A.OK="OK"})(M||(M={}));var P=function(){function A(E){this.activeFragment=null,this.activeParts=null,this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=E,this._registerListeners()}var S=A.prototype;return S._registerListeners=function(){var x=this.hls;x.on(O.Events.BUFFER_APPENDED,this.onBufferAppended,this),x.on(O.Events.FRAG_BUFFERED,this.onFragBuffered,this),x.on(O.Events.FRAG_LOADED,this.onFragLoaded,this)},S._unregisterListeners=function(){var x=this.hls;x.off(O.Events.BUFFER_APPENDED,this.onBufferAppended,this),x.off(O.Events.FRAG_BUFFERED,this.onFragBuffered,this),x.off(O.Events.FRAG_LOADED,this.onFragLoaded,this)},S.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.activeFragment=this.activeParts=null},S.getAppendedFrag=function(x,f){if(f===D.PlaylistLevelType.MAIN){var _=this.activeFragment,p=this.activeParts;if(!_)return null;if(p)for(var v=p.length;v--;){var a=p[v],s=a?a.end:_.appendedPTS;if(a.start<=x&&s!==void 0&&x<=s)return v>9&&(this.activeParts=p.slice(v-9)),a}else if(_.start<=x&&_.appendedPTS!==void 0&&x<=_.appendedPTS)return _}return this.getBufferedFrag(x,f)},S.getBufferedFrag=function(x,f){for(var _=this.fragments,p=Object.keys(_),v=p.length;v--;){var a=_[p[v]];if((a==null?void 0:a.body.type)===f&&a.buffered){var s=a.body;if(s.start<=x&&x<=s.end)return s}}return null},S.detectEvictedFragments=function(x,f,_){var p=this;this.timeRanges&&(this.timeRanges[x]=f),Object.keys(this.fragments).forEach(function(v){var a=p.fragments[v];if(!!a){if(!a.buffered&&!a.loaded){a.body.type===_&&p.removeFragment(a.body);return}var s=a.range[x];!s||s.time.some(function(n){var d=!p.isTimeBuffered(n.startPTS,n.endPTS,f);return d&&p.removeFragment(a.body),d})}})},S.detectPartialFragments=function(x){var f=this,_=this.timeRanges,p=x.frag,v=x.part;if(!(!_||p.sn==="initSegment")){var a=b(p),s=this.fragments[a];!s||(Object.keys(_).forEach(function(n){var d=p.elementaryStreams[n];if(!!d){var l=_[n],i=v!==null||d.partial===!0;s.range[n]=f.getBufferedTimes(p,v,i,l)}}),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,s.body.endList&&(this.endListFragments[s.body.type]=s)):this.removeFragment(s.body))}},S.fragBuffered=function(x){var f=b(x),_=this.fragments[f];_&&(_.loaded=null,_.buffered=!0)},S.getBufferedTimes=function(x,f,_,p){for(var v={time:[],partial:_},a=f?f.start:x.start,s=f?f.end:x.end,n=x.minEndPTS||s,d=x.maxStartPTS||a,l=0;l<p.length;l++){var i=p.start(l)-this.bufferPadding,u=p.end(l)+this.bufferPadding;if(d>=i&&n<=u){v.time.push({startPTS:Math.max(a,p.start(l)),endPTS:Math.min(s,p.end(l))});break}else if(a<u&&s>i)v.partial=!0,v.time.push({startPTS:Math.max(a,p.start(l)),endPTS:Math.min(s,p.end(l))});else if(s<=i)break}return v},S.getPartialFragment=function(x){var f=null,_,p,v,a=0,s=this.bufferPadding,n=this.fragments;return Object.keys(n).forEach(function(d){var l=n[d];!l||U(l)&&(p=l.body.start-s,v=l.body.end+s,x>=p&&x<=v&&(_=Math.min(x-p,v-x),a<=_&&(f=l.body,a=_)))}),f},S.isEndListAppended=function(x){var f=this.endListFragments[x];return f!==void 0&&(f.buffered||U(f))},S.getState=function(x){var f=b(x),_=this.fragments[f];return _?_.buffered?U(_)?M.PARTIAL:M.OK:M.APPENDING:M.NOT_LOADED},S.isTimeBuffered=function(x,f,_){for(var p,v,a=0;a<_.length;a++){if(p=_.start(a)-this.bufferPadding,v=_.end(a)+this.bufferPadding,x>=p&&f<=v)return!0;if(f<=p)return!1}return!1},S.onFragLoaded=function(x,f){var _=f.frag,p=f.part;if(!(_.sn==="initSegment"||_.bitrateTest||p)){var v=b(_);this.fragments[v]={body:_,loaded:f,buffered:!1,range:Object.create(null)}}},S.onBufferAppended=function(x,f){var _=this,p=f.frag,v=f.part,a=f.timeRanges;if(p.type===D.PlaylistLevelType.MAIN)if(this.activeFragment!==p&&(this.activeFragment=p,p.appendedPTS=void 0),v){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(v)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach(function(n){var d=a[n];if(_.detectEvictedFragments(n,d),!v&&p.type===D.PlaylistLevelType.MAIN){var l=p.elementaryStreams[n];if(!l)return;for(var i=0;i<d.length;i++){var u=d.end(i);u<=l.endPTS&&u>l.startPTS?p.appendedPTS=Math.max(u,p.appendedPTS||0):p.appendedPTS=l.endPTS}}})},S.onFragBuffered=function(x,f){this.detectPartialFragments(f)},S.hasFragment=function(x){var f=b(x);return!!this.fragments[f]},S.removeFragmentsInRange=function(x,f,_){var p=this;Object.keys(this.fragments).forEach(function(v){var a=p.fragments[v];if(!!a&&a.buffered){var s=a.body;s.type===_&&s.start<f&&s.end>x&&p.removeFragment(s)}})},S.removeFragment=function(x){var f=b(x);x.stats.loaded=0,x.clearElementaryStreamInfo(),x.appendedPTS=void 0,delete this.fragments[f],x.endList&&delete this.endListFragments[x.type]},S.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activeFragment=null,this.activeParts=null},A}();function U(A){var S,E;return A.buffered&&(((S=A.range.video)===null||S===void 0?void 0:S.partial)||((E=A.range.audio)===null||E===void 0?void 0:E.partial))}function b(A){return A.type+"_"+A.level+"_"+A.urlId+"_"+A.sn}},"./src/controller/gap-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{MAX_START_GAP_JUMP:()=>b,SKIP_BUFFER_HOLE_STEP_SECONDS:()=>A,SKIP_BUFFER_RANGE_START:()=>S,STALL_MINIMUM_DURATION_MS:()=>U,default:()=>E});var O=T("./src/utils/buffer-helper.ts"),D=T("./src/errors.ts"),M=T("./src/events.ts"),P=T("./src/utils/logger.ts"),U=250,b=2,A=.1,S=.05,E=function(){function x(_,p,v,a){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=_,this.media=p,this.fragmentTracker=v,this.hls=a}var f=x.prototype;return f.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},f.poll=function(p,v){var a=this.config,s=this.media,n=this.stalled;if(s!==null){var d=s.currentTime,l=s.seeking,i=this.seeking&&!l,u=!this.seeking&&l;if(this.seeking=l,d!==p){if(this.moved=!0,n!==null){if(this.stallReported){var g=self.performance.now()-n;P.logger.warn("playback not stuck anymore @"+d+", after "+Math.round(g)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((u||i)&&(this.stalled=null),!(s.paused&&!l||s.ended||s.playbackRate===0||!O.BufferHelper.getBuffered(s).length)){var c=O.BufferHelper.bufferInfo(s,d,0),m=c.len>0,e=c.nextStart||0;if(!(!m&&!e)){if(l){var r=c.len>b,t=!e||v&&v.start<=d||e-d>b&&!this.fragmentTracker.getPartialFragment(d);if(r||t)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var o,y=Math.max(e,c.start||0)-d,h=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,L=h==null||(o=h.details)===null||o===void 0?void 0:o.live,R=L?h.details.targetduration*2:b;if(y>0&&y<=R){this._trySkipBufferHole(null);return}}var I=self.performance.now();if(n===null){this.stalled=I;return}var k=I-n;if(!(!l&&k>=U&&(this._reportStall(c),!this.media))){var F=O.BufferHelper.bufferInfo(s,d,a.maxBufferHole);this._tryFixBufferStall(F,k)}}}}},f._tryFixBufferStall=function(p,v){var a=this.config,s=this.fragmentTracker,n=this.media;if(n!==null){var d=n.currentTime,l=s.getPartialFragment(d);if(l){var i=this._trySkipBufferHole(l);if(i||!this.media)return}p.len>a.maxBufferHole&&v>a.highBufferWatchdogPeriod*1e3&&(P.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},f._reportStall=function(p){var v=this.hls,a=this.media,s=this.stallReported;!s&&a&&(this.stallReported=!0,P.logger.warn("Playback stalling at @"+a.currentTime+" due to low buffer ("+JSON.stringify(p)+")"),v.trigger(M.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p.len}))},f._trySkipBufferHole=function(p){var v=this.config,a=this.hls,s=this.media;if(s===null)return 0;for(var n=s.currentTime,d=0,l=O.BufferHelper.getBuffered(s),i=0;i<l.length;i++){var u=l.start(i);if(n+v.maxBufferHole>=d&&n<u){var g=Math.max(u+S,s.currentTime+A);return P.logger.warn("skipping hole, adjusting currentTime from "+n+" to "+g),this.moved=!0,this.stalled=null,s.currentTime=g,p&&a.trigger(M.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+n+" to "+g,frag:p}),g}d=l.end(i)}return 0},f._tryNudgeBuffer=function(){var p=this.config,v=this.hls,a=this.media,s=this.nudgeRetry;if(a!==null){var n=a.currentTime;if(this.nudgeRetry++,s<p.nudgeMaxRetry){var d=n+(s+1)*p.nudgeOffset;P.logger.warn("Nudging 'currentTime' from "+n+" to "+d),a.currentTime=d,v.trigger(M.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else P.logger.error("Playhead still not moving while enough data buffered @"+n+" after "+p.nudgeMaxRetry+" nudges"),v.trigger(M.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},x}()},"./src/controller/id3-track-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>p});var O=T("./src/polyfills/number.ts"),D=T("./src/events.ts"),M=T("./src/utils/texttrack-utils.ts"),P=T("./src/demux/id3.ts"),U=T("./src/loader/date-range.ts"),b=T("./src/types/demuxer.ts"),A=.25;function S(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var E=function(){var v=S();try{new v(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function x(v,a){return v.getTime()/1e3-a}function f(v){return Uint8Array.from(v.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var _=function(){function v(s){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=s,this._registerListeners()}var a=v.prototype;return a.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},a._registerListeners=function(){var n=this.hls;n.on(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(D.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),n.on(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),n.on(D.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},a._unregisterListeners=function(){var n=this.hls;n.off(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(D.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),n.off(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),n.off(D.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},a.onMediaAttached=function(n,d){this.media=d.media},a.onMediaDetaching=function(){!this.id3Track||((0,M.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},a.onManifestLoading=function(){this.dateRangeCuesAppended={}},a.createTrack=function(n){var d=this.getID3Track(n.textTracks);return d.mode="hidden",d},a.getID3Track=function(n){if(!!this.media){for(var d=0;d<n.length;d++){var l=n[d];if(l.kind==="metadata"&&l.label==="id3")return(0,M.sendAddTrackEvent)(l,this.media),l}return this.media.addTextTrack("metadata","id3")}},a.onFragParsingMetadata=function(n,d){if(!!this.media){var l=this.hls.config,i=l.enableEmsgMetadataCues,u=l.enableID3MetadataCues;if(!(!i&&!u)){var g=d.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var c=S(),m=0;m<g.length;m++){var e=g[m].type;if(!(e===b.MetadataSchema.emsg&&!i||!u)){var r=P.getID3Frames(g[m].data);if(r){var t=g[m].pts,o=t+g[m].duration;o>E&&(o=E);var y=o-t;y<=0&&(o=t+A);for(var h=0;h<r.length;h++){var L=r[h];if(!P.isTimeStampFrame(L)){this.updateId3CueEnds(t);var R=new c(t,o,"");R.value=L,e&&(R.type=e),this.id3Track.addCue(R)}}}}}}}},a.updateId3CueEnds=function(n){var d,l=(d=this.id3Track)===null||d===void 0?void 0:d.cues;if(l)for(var i=l.length;i--;){var u=l[i];u.startTime<n&&u.endTime===E&&(u.endTime=n)}},a.onBufferFlushing=function(n,d){var l=d.startOffset,i=d.endOffset,u=d.type,g=this.id3Track,c=this.hls;if(!!c){var m=c.config,e=m.enableEmsgMetadataCues,r=m.enableID3MetadataCues;if(g&&(e||r)){var t;u==="audio"?t=function(y){return y.type===b.MetadataSchema.audioId3&&r}:u==="video"?t=function(y){return y.type===b.MetadataSchema.emsg&&e}:t=function(y){return y.type===b.MetadataSchema.audioId3&&r||y.type===b.MetadataSchema.emsg&&e},(0,M.removeCuesInRange)(g,l,i,t)}}},a.onLevelUpdated=function(n,d){var l=this,i=d.details;if(!(!this.media||!i.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var u=this.dateRangeCuesAppended,g=this.id3Track,c=i.dateRanges,m=Object.keys(c);if(g)for(var e=Object.keys(u).filter(function(I){return!m.includes(I)}),r=function(k){var F=e[k];Object.keys(u[F].cues).forEach(function(W){g.removeCue(u[F].cues[W])}),delete u[F]},t=e.length;t--;)r(t);var o=i.fragments[i.fragments.length-1];if(!(m.length===0||!(0,O.isFiniteNumber)(o==null?void 0:o.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var y=o.programDateTime/1e3-o.start,h=S(),L=function(k){var F=m[k],W=c[F],K=u[F],H=(K==null?void 0:K.cues)||{},Y=(K==null?void 0:K.durationKnown)||!1,q=x(W.startDate,y),ee=E,ae=W.endDate;if(ae)ee=x(ae,y),Y=!0;else if(W.endOnNext&&!Y){var re=m.reduce(function(ce,be){var Pe=c[be];return Pe.class===W.class&&Pe.id!==be&&Pe.startDate>W.startDate&&ce.push(Pe),ce},[]).sort(function(ce,be){return ce.startDate.getTime()-be.startDate.getTime()})[0];re&&(ee=x(re.startDate,y),Y=!0)}for(var se=Object.keys(W.attr),le=0;le<se.length;le++){var de=se[le];if(!(de===U.DateRangeAttribute.ID||de===U.DateRangeAttribute.CLASS||de===U.DateRangeAttribute.START_DATE||de===U.DateRangeAttribute.DURATION||de===U.DateRangeAttribute.END_DATE||de===U.DateRangeAttribute.END_ON_NEXT)){var ue=H[de];if(ue)Y&&!K.durationKnown&&(ue.endTime=ee);else{var fe=W.attr[de];ue=new h(q,ee,""),(de===U.DateRangeAttribute.SCTE35_OUT||de===U.DateRangeAttribute.SCTE35_IN)&&(fe=f(fe)),ue.value={key:de,data:fe},ue.type=b.MetadataSchema.dateRange,l.id3Track.addCue(ue),H[de]=ue}}}u[F]={cues:H,dateRange:W,durationKnown:Y}},R=0;R<m.length;R++)L(R)}}},v}();let p=_},"./src/controller/latency-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>S});var O=T("./src/errors.ts"),D=T("./src/events.ts"),M=T("./src/utils/logger.ts");function P(E,x){for(var f=0;f<x.length;f++){var _=x[f];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(E,b(_.key),_)}}function U(E,x,f){return x&&P(E.prototype,x),f&&P(E,f),Object.defineProperty(E,"prototype",{writable:!1}),E}function b(E){var x=A(E,"string");return typeof x=="symbol"?x:String(x)}function A(E,x){if(typeof E!="object"||E===null)return E;var f=E[Symbol.toPrimitive];if(f!==void 0){var _=f.call(E,x||"default");if(typeof _!="object")return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return(x==="string"?String:Number)(E)}var S=function(){function E(f){var _=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 _.timeupdate()},this.hls=f,this.config=f.config,this.registerListeners()}var x=E.prototype;return x.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},x.registerListeners=function(){this.hls.on(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(D.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(D.Events.ERROR,this.onError,this)},x.unregisterListeners=function(){this.hls.off(D.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(D.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(D.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(D.Events.ERROR,this.onError)},x.onMediaAttached=function(_,p){this.media=p.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},x.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},x.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},x.onLevelUpdated=function(_,p){var v=p.details;this.levelDetails=v,v.advanced&&this.timeupdate(),!v.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},x.onError=function(_,p){p.details===O.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,M.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},x.timeupdate=function(){var _=this.media,p=this.levelDetails;if(!(!_||!p)){this.currentTime=_.currentTime;var v=this.computeLatency();if(v!==null){this._latency=v;var a=this.config,s=a.lowLatencyMode,n=a.maxLiveSyncPlaybackRate;if(!(!s||n===1)){var d=this.targetLatency;if(d!==null){var l=v-d,i=Math.min(this.maxLatency,d+p.targetduration),u=l<i;if(p.live&&u&&l>.05&&this.forwardBufferLength>1){var g=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*l-this.edgeStalled))*20)/20;_.playbackRate=Math.min(g,Math.max(1,c))}else _.playbackRate!==1&&_.playbackRate!==0&&(_.playbackRate=1)}}}}},x.estimateLiveEdge=function(){var _=this.levelDetails;return _===null?null:_.edge+_.age},x.computeLatency=function(){var _=this.estimateLiveEdge();return _===null?null:_-this.currentTime},U(E,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var _=this.config,p=this.levelDetails;return _.liveMaxLatencyDuration!==void 0?_.liveMaxLatencyDuration:p?_.liveMaxLatencyDurationCount*p.targetduration:0}},{key:"targetLatency",get:function(){var _=this.levelDetails;if(_===null)return null;var p=_.holdBack,v=_.partHoldBack,a=_.targetduration,s=this.config,n=s.liveSyncDuration,d=s.liveSyncDurationCount,l=s.lowLatencyMode,i=this.hls.userConfig,u=l&&v||p;(i.liveSyncDuration||i.liveSyncDurationCount||u===0)&&(u=n!==void 0?n:d*a);var g=a,c=1;return u+Math.min(this.stallCount*c,g)}},{key:"liveSyncPosition",get:function(){var _=this.estimateLiveEdge(),p=this.targetLatency,v=this.levelDetails;if(_===null||p===null||v===null)return null;var a=v.edge,s=_-p-this.edgeStalled,n=a-v.totalduration,d=a-(this.config.lowLatencyMode&&v.partTarget||v.targetduration);return Math.min(Math.max(n,s),d)}},{key:"drift",get:function(){var _=this.levelDetails;return _===null?1:_.drift}},{key:"edgeStalled",get:function(){var _=this.levelDetails;if(_===null)return 0;var p=(this.config.lowLatencyMode&&_.partTarget||_.targetduration)*3;return Math.max(_.age-p,0)}},{key:"forwardBufferLength",get:function(){var _=this.media,p=this.levelDetails;if(!_||!p)return 0;var v=_.buffered.length;return(v?_.buffered.end(v-1):p.edge)-this.currentTime}}]),E}()},"./src/controller/level-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>s});var O=T("./src/types/level.ts"),D=T("./src/events.ts"),M=T("./src/errors.ts"),P=T("./src/utils/codecs.ts"),U=T("./src/controller/level-helper.ts"),b=T("./src/controller/base-playlist-controller.ts"),A=T("./src/types/loader.ts");function S(){return S=Object.assign?Object.assign.bind():function(n){for(var d=1;d<arguments.length;d++){var l=arguments[d];for(var i in l)Object.prototype.hasOwnProperty.call(l,i)&&(n[i]=l[i])}return n},S.apply(this,arguments)}function E(n,d){for(var l=0;l<d.length;l++){var i=d[l];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,f(i.key),i)}}function x(n,d,l){return d&&E(n.prototype,d),l&&E(n,l),Object.defineProperty(n,"prototype",{writable:!1}),n}function f(n){var d=_(n,"string");return typeof d=="symbol"?d:String(d)}function _(n,d){if(typeof n!="object"||n===null)return n;var l=n[Symbol.toPrimitive];if(l!==void 0){var i=l.call(n,d||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(n)}function p(n,d){n.prototype=Object.create(d.prototype),n.prototype.constructor=n,v(n,d)}function v(n,d){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,u){return i.__proto__=u,i},v(n,d)}var a=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),s=function(n){p(d,n);function d(i){var u;return u=n.call(this,i,"[level-controller]")||this,u._levels=[],u._firstLevel=-1,u._startLevel=void 0,u.currentLevelIndex=-1,u.manualLevelIndex=-1,u.onParsedComplete=void 0,u._registerListeners(),u}var l=d.prototype;return l._registerListeners=function(){var u=this.hls;u.on(D.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(D.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),u.on(D.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(D.Events.ERROR,this.onError,this)},l._unregisterListeners=function(){var u=this.hls;u.off(D.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(D.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),u.off(D.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(D.Events.ERROR,this.onError,this)},l.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,n.prototype.destroy.call(this)},l.startLoad=function(){var u=this._levels;u.forEach(function(g){g.loadError=0}),n.prototype.startLoad.call(this)},l.onManifestLoaded=function(u,g){var c=[],m=[],e=[],r,t={},o,y=!1,h=!1,L=!1;if(g.levels.forEach(function(F){var W=F.attrs;y=y||!!(F.width&&F.height),h=h||!!F.videoCodec,L=L||!!F.audioCodec,a&&F.audioCodec&&F.audioCodec.indexOf("mp4a.40.34")!==-1&&(F.audioCodec=void 0);var K=F.bitrate+"-"+F.attrs.RESOLUTION+"-"+F.attrs.CODECS;o=t[K],o?o.url.push(F.url):(o=new O.Level(F),t[K]=o,c.push(o)),W&&(W.AUDIO&&(0,U.addGroupId)(o,"audio",W.AUDIO),W.SUBTITLES&&(0,U.addGroupId)(o,"text",W.SUBTITLES))}),(y||h)&&L&&(c=c.filter(function(F){var W=F.videoCodec,K=F.width,H=F.height;return!!W||!!(K&&H)})),c=c.filter(function(F){var W=F.audioCodec,K=F.videoCodec;return(!W||(0,P.isCodecSupportedInMp4)(W,"audio"))&&(!K||(0,P.isCodecSupportedInMp4)(K,"video"))}),g.audioTracks&&(m=g.audioTracks.filter(function(F){return!F.audioCodec||(0,P.isCodecSupportedInMp4)(F.audioCodec,"audio")}),(0,U.assignTrackIdsByGroup)(m)),g.subtitles&&(e=g.subtitles,(0,U.assignTrackIdsByGroup)(e)),c.length>0){r=c[0].bitrate,c.sort(function(F,W){return F.attrs["HDCP-LEVEL"]!==W.attrs["HDCP-LEVEL"]?(F.attrs["HDCP-LEVEL"]||"")>(W.attrs["HDCP-LEVEL"]||"")?1:-1:F.bitrate!==W.bitrate?F.bitrate-W.bitrate:F.attrs.SCORE!==W.attrs.SCORE?F.attrs.decimalFloatingPoint("SCORE")-W.attrs.decimalFloatingPoint("SCORE"):y&&F.height!==W.height?F.height-W.height:0}),this._levels=c;for(var R=0;R<c.length;R++)if(c[R].bitrate===r){this._firstLevel=R,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+r);break}var I=L&&!h,k={levels:c,audioTracks:m,subtitleTracks:e,sessionData:g.sessionData,sessionKeys:g.sessionKeys,firstLevel:this._firstLevel,stats:g.stats,audio:L,video:h,altAudio:!I&&m.some(function(F){return!!F.url})};this.hls.trigger(D.Events.MANIFEST_PARSED,k),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(D.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:g.url,reason:"no level with compatible codecs found in manifest"})},l.onError=function(u,g){var c,m;if(n.prototype.onError.call(this,u,g),!g.fatal){var e=g.context,r=this._levels[this.currentLevelIndex];if(e&&(e.type===A.PlaylistContextType.AUDIO_TRACK&&r.audioGroupIds&&e.groupId===r.audioGroupIds[r.urlId]||e.type===A.PlaylistContextType.SUBTITLE_TRACK&&r.textGroupIds&&e.groupId===r.textGroupIds[r.urlId])){this.redundantFailover(this.currentLevelIndex);return}var t=!1,o=!0,y;switch(g.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:if(g.frag){var h=g.frag.type===A.PlaylistLevelType.MAIN?g.frag.level:this.currentLevelIndex,L=this._levels[h];L?(L.fragmentError++,L.fragmentError>this.hls.config.fragLoadingMaxRetry&&(y=h)):y=h}break;case M.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var R=r.attrs["HDCP-LEVEL"];R&&(this.hls.maxHdcpLevel=O.HdcpLevels[O.HdcpLevels.indexOf(R)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'))}case M.ErrorDetails.FRAG_PARSING_ERROR:case M.ErrorDetails.KEY_SYSTEM_NO_SESSION:y=((c=g.frag)===null||c===void 0?void 0:c.type)===A.PlaylistLevelType.MAIN?g.frag.level:this.currentLevelIndex,g.levelRetry=!1;break;case M.ErrorDetails.LEVEL_LOAD_ERROR:case M.ErrorDetails.LEVEL_LOAD_TIMEOUT:e&&(e.deliveryDirectives&&(o=!1),y=e.level),t=!0;break;case M.ErrorDetails.REMUX_ALLOC_ERROR:y=(m=g.level)!=null?m:this.currentLevelIndex,t=!0;break}y!==void 0&&this.recoverLevel(g,y,t,o)}},l.recoverLevel=function(u,g,c,m){var e=u.details,r=this._levels[g];if(r.loadError++,c){var t=this.retryLoadingOrFail(u);if(t)u.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(m){var o=r.url.length;if(o>1&&r.loadError<o)u.levelRetry=!0,this.redundantFailover(g);else if(this.manualLevelIndex===-1){for(var y=-1,h=this._levels,L=h.length;L--;){var R=(L+this.currentLevelIndex)%h.length;if(R!==this.currentLevelIndex&&h[R].loadError===0){y=R;break}}y>-1&&this.currentLevelIndex!==y?(this.warn(e+": switch to "+y),u.levelRetry=!0,this.hls.nextAutoLevel=y):u.levelRetry===!1&&(u.fatal=!0)}}},l.redundantFailover=function(u){var g=this._levels[u],c=g.url.length;if(c>1){var m=(g.urlId+1)%c;this.warn("Switching to redundant URL-id "+m),this._levels.forEach(function(e){e.urlId=m}),this.level=u}},l.onFragLoaded=function(u,g){var c=g.frag;if(c!==void 0&&c.type===A.PlaylistLevelType.MAIN){var m=this._levels[c.level];m!==void 0&&(m.fragmentError=0,m.loadError=0)}},l.onLevelLoaded=function(u,g){var c,m=g.level,e=g.details,r=this._levels[m];if(!r){var t;this.warn("Invalid level index "+m),(t=g.deliveryDirectives)!==null&&t!==void 0&&t.skip&&(e.deltaUpdateFailed=!0);return}m===this.currentLevelIndex?(r.fragmentError===0&&(r.loadError=0,this.retryCount=0),this.playlistLoaded(m,g,r.details)):(c=g.deliveryDirectives)!==null&&c!==void 0&&c.skip&&(e.deltaUpdateFailed=!0)},l.onAudioTrackSwitched=function(u,g){var c=this.hls.levels[this.currentLevelIndex];if(!!c&&c.audioGroupIds){for(var m=-1,e=this.hls.audioTracks[g.id].groupId,r=0;r<c.audioGroupIds.length;r++)if(c.audioGroupIds[r]===e){m=r;break}m!==c.urlId&&(c.urlId=m,this.startLoad())}},l.loadPlaylist=function(u){n.prototype.loadPlaylist.call(this);var g=this.currentLevelIndex,c=this._levels[g];if(this.canLoad&&c&&c.url.length>0){var m=c.urlId,e=c.url[m];if(u)try{e=u.addDirectives(e)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Attempt loading level index "+g+(u?" at sn "+u.msn+" part "+u.part:"")+" with URL-id "+m+" "+e),this.clearTimer(),this.hls.trigger(D.Events.LEVEL_LOADING,{url:e,level:g,id:m,deliveryDirectives:u||null})}},l.removeLevel=function(u,g){var c=function(r,t){return t!==g},m=this._levels.filter(function(e,r){return r!==u?!0:e.url.length>1&&g!==void 0?(e.url=e.url.filter(c),e.audioGroupIds&&(e.audioGroupIds=e.audioGroupIds.filter(c)),e.textGroupIds&&(e.textGroupIds=e.textGroupIds.filter(c)),e.urlId=0,!0):!1}).map(function(e,r){var t=e.details;return t!=null&&t.fragments&&t.fragments.forEach(function(o){o.level=r}),e});this._levels=m,this.hls.trigger(D.Events.LEVELS_UPDATED,{levels:m})},x(d,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(u){var g,c=this._levels;if(c.length!==0&&!(this.currentLevelIndex===u&&(g=c[u])!==null&&g!==void 0&&g.details)){if(u<0||u>=c.length){var m=u<0;if(this.hls.trigger(D.Events.ERROR,{type:M.ErrorTypes.OTHER_ERROR,details:M.ErrorDetails.LEVEL_SWITCH_ERROR,level:u,fatal:m,reason:"invalid level idx"}),m)return;u=Math.min(u,c.length-1)}this.clearTimer();var e=this.currentLevelIndex,r=c[e],t=c[u];this.log("switching to level "+u+" from "+e),this.currentLevelIndex=u;var o=S({},t,{level:u,maxBitrate:t.maxBitrate,uri:t.uri,urlId:t.urlId});delete o._urlId,this.hls.trigger(D.Events.LEVEL_SWITCHING,o);var y=t.details;if(!y||y.live){var h=this.switchParams(t.uri,r==null?void 0:r.details);this.loadPlaylist(h)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(u){this.manualLevelIndex=u,this._startLevel===void 0&&(this._startLevel=u),u!==-1&&(this.level=u)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(u){this._firstLevel=u}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var u=this.hls.config.startLevel;return u!==void 0?u:this._firstLevel}else return this._startLevel},set:function(u){this._startLevel=u}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(u){this.level=u,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=u)}}]),d}(b.default)},"./src/controller/level-helper.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{addGroupId:()=>U,addSliding:()=>a,adjustSliding:()=>v,assignTrackIdsByGroup:()=>b,computeReloadInterval:()=>s,getFragmentWithSN:()=>n,getPartWith:()=>d,mapFragmentIntersection:()=>p,mapPartIntersection:()=>_,mergeDetails:()=>x,updateFragPTSDTS:()=>E,updatePTS:()=>A});var O=T("./src/polyfills/number.ts"),D=T("./src/utils/logger.ts"),M=T("./src/loader/date-range.ts");function P(){return P=Object.assign?Object.assign.bind():function(l){for(var i=1;i<arguments.length;i++){var u=arguments[i];for(var g in u)Object.prototype.hasOwnProperty.call(u,g)&&(l[g]=u[g])}return l},P.apply(this,arguments)}function U(l,i,u){switch(i){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(u);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(u);break}}function b(l){var i={};l.forEach(function(u){var g=u.groupId||"";u.id=i[g]=i[g]||0,i[g]++})}function A(l,i,u){var g=l[i],c=l[u];S(g,c)}function S(l,i){var u=i.startPTS;if((0,O.isFiniteNumber)(u)){var g=0,c;i.sn>l.sn?(g=u-l.start,c=l):(g=l.start-u,c=i),c.duration!==g&&(c.duration=g)}else if(i.sn>l.sn){var m=l.cc===i.cc;m&&l.minEndPTS?i.start=l.start+(l.minEndPTS-l.start):i.start=l.start+l.duration}else i.start=Math.max(l.start-i.duration,0)}function E(l,i,u,g,c,m){var e=g-u;e<=0&&(D.logger.warn("Fragment should have a positive duration",i),g=u+i.duration,m=c+i.duration);var r=u,t=g,o=i.startPTS,y=i.endPTS;if((0,O.isFiniteNumber)(o)){var h=Math.abs(o-u);(0,O.isFiniteNumber)(i.deltaPTS)?i.deltaPTS=Math.max(h,i.deltaPTS):i.deltaPTS=h,r=Math.max(u,o),u=Math.min(u,o),c=Math.min(c,i.startDTS),t=Math.min(g,y),g=Math.max(g,y),m=Math.max(m,i.endDTS)}i.duration=g-u;var L=u-i.start;i.start=i.startPTS=u,i.maxStartPTS=r,i.startDTS=c,i.endPTS=g,i.minEndPTS=t,i.endDTS=m;var R=i.sn;if(!l||R<l.startSN||R>l.endSN)return 0;var I,k=R-l.startSN,F=l.fragments;for(F[k]=i,I=k;I>0;I--)S(F[I],F[I-1]);for(I=k;I<F.length-1;I++)S(F[I],F[I+1]);return l.fragmentHint&&S(F[F.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,L}function x(l,i){for(var u=null,g=l.fragments,c=g.length-1;c>=0;c--){var m=g[c].initSegment;if(m){u=m;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var e=0,r;if(p(l,i,function(I,k){I.relurl&&(e=I.cc-k.cc),(0,O.isFiniteNumber)(I.startPTS)&&(0,O.isFiniteNumber)(I.endPTS)&&(k.start=k.startPTS=I.startPTS,k.startDTS=I.startDTS,k.appendedPTS=I.appendedPTS,k.maxStartPTS=I.maxStartPTS,k.endPTS=I.endPTS,k.endDTS=I.endDTS,k.minEndPTS=I.minEndPTS,k.duration=I.endPTS-I.startPTS,k.duration&&(r=k),i.PTSKnown=i.alignedSliding=!0),k.elementaryStreams=I.elementaryStreams,k.loader=I.loader,k.stats=I.stats,k.urlId=I.urlId,I.initSegment&&(k.initSegment=I.initSegment,u=I.initSegment)}),u){var t=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;t.forEach(function(I){var k;(!I.initSegment||I.initSegment.relurl===((k=u)===null||k===void 0?void 0:k.relurl))&&(I.initSegment=u)})}if(i.skippedSegments)if(i.deltaUpdateFailed=i.fragments.some(function(I){return!I}),i.deltaUpdateFailed){D.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var o=i.skippedSegments;o--;)i.fragments.shift();i.startSN=i.fragments[0].sn,i.startCC=i.fragments[0].cc}else i.canSkipDateRanges&&(i.dateRanges=f(l.dateRanges,i.dateRanges,i.recentlyRemovedDateranges));var y=i.fragments;if(e){D.logger.warn("discontinuity sliding from playlist, take drift into account");for(var h=0;h<y.length;h++)y[h].cc+=e}i.skippedSegments&&(i.startCC=i.fragments[0].cc),_(l.partList,i.partList,function(I,k){k.elementaryStreams=I.elementaryStreams,k.stats=I.stats}),r?E(i,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):v(l,i),y.length&&(i.totalduration=i.edge-y[0].start),i.driftStartTime=l.driftStartTime,i.driftStart=l.driftStart;var L=i.advancedDateTime;if(i.advanced&&L){var R=i.edge;i.driftStart||(i.driftStartTime=L,i.driftStart=R),i.driftEndTime=L,i.driftEnd=R}else i.driftEndTime=l.driftEndTime,i.driftEnd=l.driftEnd,i.advancedDateTime=l.advancedDateTime}function f(l,i,u){var g=P({},l);return u&&u.forEach(function(c){delete g[c]}),Object.keys(i).forEach(function(c){var m=new M.DateRange(i[c].attr,g[c]);m.isValid?g[c]=m:D.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(i[c].attr)+'"')}),g}function _(l,i,u){if(l&&i)for(var g=0,c=0,m=l.length;c<=m;c++){var e=l[c],r=i[c+g];e&&r&&e.index===r.index&&e.fragment.sn===r.fragment.sn?u(e,r):g--}}function p(l,i,u){for(var g=i.skippedSegments,c=Math.max(l.startSN,i.startSN)-i.startSN,m=(l.fragmentHint?1:0)+(g?i.endSN:Math.min(l.endSN,i.endSN))-i.startSN,e=i.startSN-l.startSN,r=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,t=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,o=c;o<=m;o++){var y=t[e+o],h=r[o];g&&!h&&o<g&&(h=i.fragments[o]=y),y&&h&&u(y,h)}}function v(l,i){var u=i.startSN+i.skippedSegments-l.startSN,g=l.fragments;u<0||u>=g.length||a(i,g[u].start)}function a(l,i){if(i){for(var u=l.fragments,g=l.skippedSegments;g<u.length;g++)u[g].start+=i;l.fragmentHint&&(l.fragmentHint.start+=i)}}function s(l,i){i===void 0&&(i=1/0);var u=1e3*l.targetduration;if(l.updated){var g=l.fragments,c=4;if(g.length&&u*c>i){var m=g[g.length-1].duration*1e3;m<u&&(u=m)}}else u/=2;return Math.round(u)}function n(l,i,u){if(!l||!l.details)return null;var g=l.details,c=g.fragments[i-g.startSN];return c||(c=g.fragmentHint,c&&c.sn===i)?c:i<g.startSN&&u&&u.sn===i?u:null}function d(l,i,u){if(!l||!l.details)return null;var g=l.details.partList;if(g)for(var c=g.length;c--;){var m=g[c];if(m.index===u&&m.fragment.sn===i)return m}return null}},"./src/controller/stream-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>i});var O=T("./src/polyfills/number.ts"),D=T("./src/controller/base-stream-controller.ts"),M=T("./src/is-supported.ts"),P=T("./src/events.ts"),U=T("./src/utils/buffer-helper.ts"),b=T("./src/controller/fragment-tracker.ts"),A=T("./src/types/loader.ts"),S=T("./src/loader/fragment.ts"),E=T("./src/demux/transmuxer-interface.ts"),x=T("./src/types/transmuxer.ts"),f=T("./src/controller/gap-controller.ts"),_=T("./src/errors.ts");function p(u,g){for(var c=0;c<g.length;c++){var m=g[c];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,a(m.key),m)}}function v(u,g,c){return g&&p(u.prototype,g),c&&p(u,c),Object.defineProperty(u,"prototype",{writable:!1}),u}function a(u){var g=s(u,"string");return typeof g=="symbol"?g:String(g)}function s(u,g){if(typeof u!="object"||u===null)return u;var c=u[Symbol.toPrimitive];if(c!==void 0){var m=c.call(u,g||"default");if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(u)}function n(u,g){u.prototype=Object.create(g.prototype),u.prototype.constructor=u,d(u,g)}function d(u,g){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,e){return m.__proto__=e,m},d(u,g)}var l=100,i=function(u){n(g,u);function g(m,e,r){var t;return t=u.call(this,m,e,r,"[stream-controller]")||this,t.audioCodecSwap=!1,t.gapController=null,t.level=-1,t._forceStartLoad=!1,t.altAudio=!1,t.audioOnly=!1,t.fragPlaying=null,t.onvplaying=null,t.onvseeked=null,t.fragLastKbps=0,t.couldBacktrack=!1,t.backtrackFragment=null,t.audioCodecSwitch=!1,t.videoBuffer=null,t._registerListeners(),t}var c=g.prototype;return c._registerListeners=function(){var e=this.hls;e.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(P.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(P.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(P.Events.ERROR,this.onError,this),e.on(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(P.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(P.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(P.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var e=this.hls;e.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(P.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(P.Events.ERROR,this.onError,this),e.off(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(P.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(P.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(P.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},c.startLoad=function(e){if(this.levels){var r=this.lastCurrentTime,t=this.hls;if(this.stopLoad(),this.setInterval(l),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var o=t.startLevel;o===-1&&(t.config.testBandwidth&&this.levels.length>1?(o=0,this.bitrateTest=!0):o=t.nextAutoLevel),this.level=t.nextLoadLevel=o,this.loadedmetadata=!1}r>0&&e===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),e=r),this.state=D.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=D.State.STOPPED},c.stopLoad=function(){this._forceStartLoad=!1,u.prototype.stopLoad.call(this)},c.doTick=function(){switch(this.state){case D.State.IDLE:this.doTickIdle();break;case D.State.WAITING_LEVEL:{var e,r=this.levels,t=this.level,o=r==null||(e=r[t])===null||e===void 0?void 0:e.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=D.State.IDLE;break}break}case D.State.FRAG_LOADING_WAITING_RETRY:{var y,h=self.performance.now(),L=this.retryDate;(!L||h>=L||(y=this.media)!==null&&y!==void 0&&y.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=D.State.IDLE)}break;default:break}this.onTickEnd()},c.onTickEnd=function(){u.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},c.doTickIdle=function(){var e=this.hls,r=this.levelLastLoaded,t=this.levels,o=this.media,y=e.config,h=e.nextLoadLevel;if(!(r===null||!o&&(this.startFragRequested||!y.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!t||!t[h])){var L=t[h],R=this.getMainFwdBufferInfo();if(R!==null){var I=this.getLevelDetails();if(I&&this._streamEnded(R,I)){var k={};this.altAudio&&(k.type="video"),this.hls.trigger(P.Events.BUFFER_EOS,k),this.state=D.State.ENDED;return}this.level=e.nextLoadLevel=h;var F=L.details;if(!F||this.state===D.State.WAITING_LEVEL||F.live&&this.levelLastLoaded!==h){this.level=h,this.state=D.State.WAITING_LEVEL;return}var W=R.len,K=this.getMaxBufferLength(L.maxBitrate);if(!(W>=K)){this.backtrackFragment&&this.backtrackFragment.start>R.end&&(this.backtrackFragment=null);var H=this.backtrackFragment?this.backtrackFragment.start:R.end,Y=this.getNextFragment(H,F);if(this.couldBacktrack&&!this.fragPrevious&&Y&&Y.sn!=="initSegment"&&this.fragmentTracker.getState(Y)!==b.FragmentState.OK){var q,ee=((q=this.backtrackFragment)!=null?q:Y).sn,ae=ee-F.startSN,re=F.fragments[ae-1];re&&Y.cc===re.cc&&(Y=re,this.fragmentTracker.removeFragment(re))}else this.backtrackFragment&&R.len&&(this.backtrackFragment=null);if(Y&&this.fragmentTracker.getState(Y)===b.FragmentState.OK&&this.nextLoadPosition>H){var se=this.audioOnly&&!this.altAudio?S.ElementaryStreamTypes.AUDIO:S.ElementaryStreamTypes.VIDEO,le=(se===S.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;le&&this.afterBufferFlushed(le,se,A.PlaylistLevelType.MAIN),Y=this.getNextFragment(this.nextLoadPosition,F)}!Y||(Y.initSegment&&!Y.initSegment.data&&!this.bitrateTest&&(Y=Y.initSegment),this.loadFragment(Y,F,H))}}}},c.loadFragment=function(e,r,t){var o,y=this.fragmentTracker.getState(e);this.fragCurrent=e,y===b.FragmentState.NOT_LOADED?e.sn==="initSegment"?this._loadInitSegment(e,r):this.bitrateTest?(this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e,r)):(this.startFragRequested=!0,u.prototype.loadFragment.call(this,e,r,t)):y===b.FragmentState.APPENDING?this.reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e):((o=this.media)===null||o===void 0?void 0:o.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},c.getAppendedFrag=function(e){var r=this.fragmentTracker.getAppendedFrag(e,A.PlaylistLevelType.MAIN);return r&&"fragment"in r?r.fragment:r},c.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,A.PlaylistLevelType.MAIN)},c.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},c.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},c.nextLevelSwitch=function(){var e=this.levels,r=this.media;if(r!=null&&r.readyState){var t,o=this.getAppendedFrag(r.currentTime);if(o&&o.start>1&&this.flushMainBuffer(0,o.start-1),!r.paused&&e){var y=this.hls.nextLoadLevel,h=e[y],L=this.fragLastKbps;L&&this.fragCurrent?t=this.fragCurrent.duration*h.maxBitrate/(1e3*L)+1:t=0}else t=0;var R=this.getBufferedFrag(r.currentTime+t);if(R){var I=this.followingBufferedFrag(R);if(I){this.abortCurrentFrag();var k=I.maxStartPTS?I.maxStartPTS:I.start,F=I.duration,W=Math.max(R.end,k+Math.min(Math.max(F-this.config.maxFragLookUpTolerance,F*.5),F*.75));this.flushMainBuffer(W,Number.POSITIVE_INFINITY)}}}},c.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&e.abortRequests(),this.state){case D.State.KEY_LOADING:case D.State.FRAG_LOADING:case D.State.FRAG_LOADING_WAITING_RETRY:case D.State.PARSING:case D.State.PARSED:this.state=D.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},c.flushMainBuffer=function(e,r){u.prototype.flushMainBuffer.call(this,e,r,this.altAudio?"video":null)},c.onMediaAttached=function(e,r){u.prototype.onMediaAttached.call(this,e,r);var t=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),t.addEventListener("playing",this.onvplaying),t.addEventListener("seeked",this.onvseeked),this.gapController=new f.default(this.config,t,this.fragmentTracker,this.hls)},c.onMediaDetaching=function(){var e=this.media;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),u.prototype.onMediaDetaching.call(this)},c.onMediaPlaying=function(){this.tick()},c.onMediaSeeked=function(){var e=this.media,r=e?e.currentTime:null;(0,O.isFiniteNumber)(r)&&this.log("Media seeked to "+r.toFixed(3)),this.tick()},c.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(P.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},c.onManifestParsed=function(e,r){var t=!1,o=!1,y;r.levels.forEach(function(h){y=h.audioCodec,y&&(y.indexOf("mp4a.40.2")!==-1&&(t=!0),y.indexOf("mp4a.40.5")!==-1&&(o=!0))}),this.audioCodecSwitch=t&&o&&!(0,M.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},c.onLevelLoading=function(e,r){var t=this.levels;if(!(!t||this.state!==D.State.IDLE)){var o=t[r.level];(!o.details||o.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(o.details))&&(this.state=D.State.WAITING_LEVEL)}},c.onLevelLoaded=function(e,r){var t,o=this.levels,y=r.level,h=r.details,L=h.totalduration;if(!o){this.warn("Levels were reset while loading level "+y);return}this.log("Level "+y+" loaded ["+h.startSN+","+h.endSN+"], cc ["+h.startCC+", "+h.endCC+"] duration:"+L);var R=this.fragCurrent;R&&(this.state===D.State.FRAG_LOADING||this.state===D.State.FRAG_LOADING_WAITING_RETRY)&&R.level!==r.level&&R.loader&&(this.state=D.State.IDLE,this.backtrackFragment=null,R.abortRequests());var I=o[y],k=0;if(h.live||(t=I.details)!==null&&t!==void 0&&t.live){if(h.fragments[0]||(h.deltaUpdateFailed=!0),h.deltaUpdateFailed)return;k=this.alignPlaylists(h,I.details)}if(I.details=h,this.levelLastLoaded=y,this.hls.trigger(P.Events.LEVEL_UPDATED,{details:h,level:y}),this.state===D.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(h))return;this.state=D.State.IDLE}this.startFragRequested?h.live&&this.synchronizeToLiveEdge(h):this.setStartPosition(h,k),this.tick()},c._handleFragmentLoadProgress=function(e){var r,t=e.frag,o=e.part,y=e.payload,h=this.levels;if(!h){this.warn("Levels were reset while fragment load was in progress. Fragment "+t.sn+" of level "+t.level+" will not be buffered");return}var L=h[t.level],R=L.details;if(!R){this.warn("Dropping fragment "+t.sn+" of level "+t.level+" after level details were reset");return}var I=L.videoCodec,k=R.PTSKnown||!R.live,F=(r=t.initSegment)===null||r===void 0?void 0:r.data,W=this._getAudioCodec(L),K=this.transmuxer=this.transmuxer||new E.default(this.hls,A.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),H=o?o.index:-1,Y=H!==-1,q=new x.ChunkMetadata(t.level,t.sn,t.stats.chunkCount,y.byteLength,H,Y),ee=this.initPTS[t.cc];K.push(y,F,W,I,t,o,R.totalduration,k,q,ee)},c.onAudioTrackSwitching=function(e,r){var t=this.altAudio,o=!!r.url,y=r.id;if(!o){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&&(this.log("Switching to main audio track, cancel main fragment load"),h.abortRequests()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var L=this.hls;t&&L.trigger(P.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),L.trigger(P.Events.AUDIO_TRACK_SWITCHED,{id:y})}},c.onAudioTrackSwitched=function(e,r){var t=r.id,o=!!this.hls.audioTracks[t].url;if(o){var y=this.videoBuffer;y&&this.mediaBuffer!==y&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=y)}this.altAudio=o,this.tick()},c.onBufferCreated=function(e,r){var t=r.tracks,o,y,h=!1;for(var L in t){var R=t[L];if(R.id==="main"){if(y=L,o=R,L==="video"){var I=t[L];I&&(this.videoBuffer=I.buffer)}}else h=!0}h&&o?(this.log("Alternate track found, use "+y+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},c.onFragBuffered=function(e,r){var t=r.frag,o=r.part;if(!(t&&t.type!==A.PlaylistLevelType.MAIN)){if(this.fragContextChanged(t)){this.warn("Fragment "+t.sn+(o?" p: "+o.index:"")+" of level "+t.level+" finished buffering, but was aborted. state: "+this.state),this.state===D.State.PARSED&&(this.state=D.State.IDLE);return}var y=o?o.stats:t.stats;this.fragLastKbps=Math.round(8*y.total/(y.buffering.end-y.loading.first)),t.sn!=="initSegment"&&(this.fragPrevious=t),this.fragBufferedComplete(t,o)}},c.onError=function(e,r){if(r.type===_.ErrorTypes.KEY_SYSTEM_ERROR){this.onFragmentOrKeyLoadError(A.PlaylistLevelType.MAIN,r);return}switch(r.details){case _.ErrorDetails.FRAG_LOAD_ERROR:case _.ErrorDetails.FRAG_LOAD_TIMEOUT:case _.ErrorDetails.FRAG_PARSING_ERROR:case _.ErrorDetails.KEY_LOAD_ERROR:case _.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.MAIN,r);break;case _.ErrorDetails.LEVEL_LOAD_ERROR:case _.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==D.State.ERROR&&(r.fatal?(this.warn(""+r.details),this.state=D.State.ERROR):!r.levelRetry&&this.state===D.State.WAITING_LEVEL&&(this.state=D.State.IDLE));break;case _.ErrorDetails.BUFFER_FULL_ERROR:if(r.parent==="main"&&(this.state===D.State.PARSING||this.state===D.State.PARSED)){var t=!0,o=this.getFwdBufferInfo(this.media,A.PlaylistLevelType.MAIN);o&&o.len>.5&&(t=!this.reduceMaxBufferLength(o.len)),t&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},c.checkBuffer=function(){var e=this.media,r=this.gapController;if(!(!e||!r||!e.readyState)){if(this.loadedmetadata||!U.BufferHelper.getBuffered(e).length){var t=this.state!==D.State.IDLE?this.fragCurrent:null;r.poll(this.lastCurrentTime,t)}this.lastCurrentTime=e.currentTime}},c.onFragLoadEmergencyAborted=function(){this.state=D.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},c.onBufferFlushed=function(e,r){var t=r.type;if(t!==S.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var o=(t===S.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(o,t,A.PlaylistLevelType.MAIN)}},c.onLevelsUpdated=function(e,r){this.levels=r.levels},c.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},c.seekToStartPos=function(){var e=this.media;if(!!e){var r=e.currentTime,t=this.startPosition;if(t>=0&&r<t){if(e.seeking){this.log("could not seek to "+t+", already seeking at "+r);return}var o=U.BufferHelper.getBuffered(e),y=o.length?o.start(0):0,h=y-t;h>0&&(h<this.config.maxBufferHole||h<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+h+" to match buffer start"),t+=h,this.startPosition=t),this.log("seek to target start position "+t+" from current time "+r),e.currentTime=t}}},c._getAudioCodec=function(e){var r=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r.indexOf("mp4a.40.5")!==-1?r="mp4a.40.2":r="mp4a.40.5"),r},c._loadBitrateTestFrag=function(e,r){var t=this;e.bitrateTest=!0,this._doFragLoad(e,r).then(function(o){var y=t.hls;if(!(!o||y.nextLoadLevel||t.fragContextChanged(e))){t.fragLoadError=0,t.state=D.State.IDLE,t.startFragRequested=!1,t.bitrateTest=!1;var h=e.stats;h.parsing.start=h.parsing.end=h.buffering.start=h.buffering.end=self.performance.now(),y.trigger(P.Events.FRAG_LOADED,o),e.bitrateTest=!1}})},c._handleTransmuxComplete=function(e){var r,t="main",o=this.hls,y=e.remuxResult,h=e.chunkMeta,L=this.getCurrentContext(h);if(!L){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 R=L.frag,I=L.part,k=L.level,F=y.video,W=y.text,K=y.id3,H=y.initSegment,Y=k.details,q=this.altAudio?void 0:y.audio;if(!this.fragContextChanged(R)){if(this.state=D.State.PARSING,H){H.tracks&&(this._bufferInitSegment(k,H.tracks,R,h),o.trigger(P.Events.FRAG_PARSING_INIT_SEGMENT,{frag:R,id:t,tracks:H.tracks}));var ee=H.initPTS,ae=H.timescale;(0,O.isFiniteNumber)(ee)&&(this.initPTS[R.cc]=ee,o.trigger(P.Events.INIT_PTS_FOUND,{frag:R,id:t,initPTS:ee,timescale:ae}))}if(F&&y.independent!==!1){if(Y){var re=F.startPTS,se=F.endPTS,le=F.startDTS,de=F.endDTS;if(I)I.elementaryStreams[F.type]={startPTS:re,endPTS:se,startDTS:le,endDTS:de};else if(F.firstKeyFrame&&F.independent&&h.id===1&&(this.couldBacktrack=!0),F.dropped&&F.independent){var ue=this.getMainFwdBufferInfo(),fe=(ue?ue.end:this.getLoadPosition())+this.config.maxBufferHole,ce=F.firstKeyFramePTS?F.firstKeyFramePTS:re;if(fe<ce-this.config.maxBufferHole){this.backtrack(R);return}R.setElementaryStreamInfo(F.type,R.start,se,R.start,de,!0)}R.setElementaryStreamInfo(F.type,re,se,le,de),this.backtrackFragment&&(this.backtrackFragment=R),this.bufferFragmentData(F,R,I,h)}}else if(y.independent===!1){this.backtrack(R);return}if(q){var be=q.startPTS,Pe=q.endPTS,we=q.startDTS,pe=q.endDTS;I&&(I.elementaryStreams[S.ElementaryStreamTypes.AUDIO]={startPTS:be,endPTS:Pe,startDTS:we,endDTS:pe}),R.setElementaryStreamInfo(S.ElementaryStreamTypes.AUDIO,be,Pe,we,pe),this.bufferFragmentData(q,R,I,h)}if(Y&&K!==null&&K!==void 0&&(r=K.samples)!==null&&r!==void 0&&r.length){var Me={id:t,frag:R,details:Y,samples:K.samples};o.trigger(P.Events.FRAG_PARSING_METADATA,Me)}if(Y&&W){var Re={id:t,frag:R,details:Y,samples:W.samples};o.trigger(P.Events.FRAG_PARSING_USERDATA,Re)}}},c._bufferInitSegment=function(e,r,t,o){var y=this;if(this.state===D.State.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var h=r.audio,L=r.video,R=r.audiovideo;if(h){var I=e.audioCodec,k=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(I&&(I.indexOf("mp4a.40.5")!==-1?I="mp4a.40.2":I="mp4a.40.5"),h.metadata.channelCount!==1&&k.indexOf("firefox")===-1&&(I="mp4a.40.5")),k.indexOf("android")!==-1&&h.container!=="audio/mpeg"&&(I="mp4a.40.2",this.log("Android: force audio codec to "+I)),e.audioCodec&&e.audioCodec!==I&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+I+'"'),h.levelCodec=I,h.id="main",this.log("Init audio buffer, container:"+h.container+", codecs[selected/level/parsed]=["+(I||"")+"/"+(e.audioCodec||"")+"/"+h.codec+"]")}L&&(L.levelCodec=e.videoCodec,L.id="main",this.log("Init video buffer, container:"+L.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+L.codec+"]")),R&&this.log("Init audiovideo buffer, container:"+R.container+", codecs[level/parsed]=["+(e.attrs.CODECS||"")+"/"+R.codec+"]"),this.hls.trigger(P.Events.BUFFER_CODECS,r),Object.keys(r).forEach(function(F){var W=r[F],K=W.initSegment;K!=null&&K.byteLength&&y.hls.trigger(P.Events.BUFFER_APPENDING,{type:F,data:K,frag:t,part:null,chunkMeta:o,parent:t.type})}),this.tick()}},c.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,A.PlaylistLevelType.MAIN)},c.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=D.State.IDLE},c.checkFragmentChanged=function(){var e=this.media,r=null;if(e&&e.readyState>1&&e.seeking===!1){var t=e.currentTime;if(U.BufferHelper.isBuffered(e,t)?r=this.getAppendedFrag(t):U.BufferHelper.isBuffered(e,t+.1)&&(r=this.getAppendedFrag(t+.1)),r){this.backtrackFragment=null;var o=this.fragPlaying,y=r.level;(!o||r.sn!==o.sn||o.level!==y||r.urlId!==o.urlId)&&(this.fragPlaying=r,this.hls.trigger(P.Events.FRAG_CHANGED,{frag:r}),(!o||o.level!==y)&&this.hls.trigger(P.Events.LEVEL_SWITCHED,{level:y}))}}},v(g,[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var r=e.currentTime,t=this.currentFrag;if(t&&(0,O.isFiniteNumber)(r)&&(0,O.isFiniteNumber)(t.programDateTime)){var o=t.programDateTime+(r-t.start)*1e3;return new Date(o)}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),g}(D.default)},"./src/controller/subtitle-stream-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{SubtitleStreamController:()=>n});var O=T("./src/events.ts"),D=T("./src/utils/buffer-helper.ts"),M=T("./src/controller/fragment-finders.ts"),P=T("./src/utils/discontinuities.ts"),U=T("./src/controller/level-helper.ts"),b=T("./src/controller/fragment-tracker.ts"),A=T("./src/controller/base-stream-controller.ts"),S=T("./src/types/loader.ts"),E=T("./src/types/level.ts");function x(l,i){for(var u=0;u<i.length;u++){var g=i[u];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(l,_(g.key),g)}}function f(l,i,u){return i&&x(l.prototype,i),u&&x(l,u),Object.defineProperty(l,"prototype",{writable:!1}),l}function _(l){var i=p(l,"string");return typeof i=="symbol"?i:String(i)}function p(l,i){if(typeof l!="object"||l===null)return l;var u=l[Symbol.toPrimitive];if(u!==void 0){var g=u.call(l,i||"default");if(typeof g!="object")return g;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(l)}function v(l,i){l.prototype=Object.create(i.prototype),l.prototype.constructor=l,a(l,i)}function a(l,i){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,c){return g.__proto__=c,g},a(l,i)}var s=500,n=function(l){v(i,l);function i(g,c,m){var e;return e=l.call(this,g,c,m,"[subtitle-stream-controller]")||this,e.levels=[],e.currentTrackId=-1,e.tracksBuffered=[],e.mainDetails=null,e._registerListeners(),e}var u=i.prototype;return u.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},u._registerListeners=function(){var c=this.hls;c.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(O.Events.ERROR,this.onError,this),c.on(O.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),c.on(O.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),c.on(O.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),c.on(O.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),c.on(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),c.on(O.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u._unregisterListeners=function(){var c=this.hls;c.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(O.Events.ERROR,this.onError,this),c.off(O.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),c.off(O.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),c.off(O.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),c.off(O.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),c.off(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),c.off(O.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u.startLoad=function(c){this.stopLoad(),this.state=A.State.IDLE,this.setInterval(s),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()},u.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},u.onLevelLoaded=function(c,m){this.mainDetails=m.details},u.onSubtitleFragProcessed=function(c,m){var e=m.frag,r=m.success;if(this.fragPrevious=e,this.state=A.State.IDLE,!!r){var t=this.tracksBuffered[this.currentTrackId];if(!!t){for(var o,y=e.start,h=0;h<t.length;h++)if(y>=t[h].start&&y<=t[h].end){o=t[h];break}var L=e.start+e.duration;o?o.end=L:(o={start:y,end:L},t.push(o)),this.fragmentTracker.fragBuffered(e)}}},u.onBufferFlushing=function(c,m){var e=m.startOffset,r=m.endOffset;if(e===0&&r!==Number.POSITIVE_INFINITY){var t=this.currentTrackId,o=this.levels;if(!o.length||!o[t]||!o[t].details)return;var y=o[t].details,h=y.targetduration,L=r-h;if(L<=0)return;m.endOffsetSubtitles=Math.max(0,L),this.tracksBuffered.forEach(function(R){for(var I=0;I<R.length;){if(R[I].end<=L){R.shift();continue}else if(R[I].start<L)R[I].start=L;else break;I++}}),this.fragmentTracker.removeFragmentsInRange(e,L,S.PlaylistLevelType.SUBTITLE)}},u.onFragBuffered=function(c,m){if(!this.loadedmetadata&&m.frag.type===S.PlaylistLevelType.MAIN){var e;(e=this.media)!==null&&e!==void 0&&e.buffered.length&&(this.loadedmetadata=!0)}},u.onError=function(c,m){var e=m.frag;!e||e.type!==S.PlaylistLevelType.SUBTITLE||(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state=A.State.IDLE)},u.onSubtitleTracksUpdated=function(c,m){var e=this,r=m.subtitleTracks;this.tracksBuffered=[],this.levels=r.map(function(t){return new E.Level(t)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(t){e.tracksBuffered[t.id]=[]}),this.mediaBuffer=null},u.onSubtitleTrackSwitch=function(c,m){if(this.currentTrackId=m.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var e=this.levels[this.currentTrackId];e!=null&&e.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,e&&this.setInterval(s)},u.onSubtitleTrackLoaded=function(c,m){var e,r=m.details,t=m.id,o=this.currentTrackId,y=this.levels;if(!!y.length){var h=y[o];if(!(t>=y.length||t!==o||!h)){this.mediaBuffer=this.mediaBufferTimeRanges;var L=0;if(r.live||(e=h.details)!==null&&e!==void 0&&e.live){var R=this.mainDetails;if(r.deltaUpdateFailed||!R)return;var I=R.fragments[0];h.details?(L=this.alignPlaylists(r,h.details),L===0&&I&&(L=I.start,(0,U.addSliding)(r,L))):r.hasProgramDateTime&&R.hasProgramDateTime?((0,P.alignMediaPlaylistByPDT)(r,R),L=r.fragments[0].start):I&&(L=I.start,(0,U.addSliding)(r,L))}if(h.details=r,this.levelLastLoaded=t,!this.startFragRequested&&(this.mainDetails||!r.live)&&this.setStartPosition(h.details,L),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===A.State.IDLE){var k=(0,M.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0);k||(this.warn("Subtitle playlist not aligned with playback"),h.details=void 0)}}}},u._handleFragmentLoadComplete=function(c){var m=this,e=c.frag,r=c.payload,t=e.decryptdata,o=this.hls;if(!this.fragContextChanged(e)&&r&&r.byteLength>0&&t&&t.key&&t.iv&&t.method==="AES-128"){var y=performance.now();this.decrypter.decrypt(new Uint8Array(r),t.key.buffer,t.iv.buffer).then(function(h){var L=performance.now();o.trigger(O.Events.FRAG_DECRYPTED,{frag:e,payload:h,stats:{tstart:y,tdecrypt:L}})}).catch(function(h){m.warn(h.name+": "+h.message),m.state=A.State.IDLE})}},u.doTick=function(){if(!this.media){this.state=A.State.IDLE;return}if(this.state===A.State.IDLE){var c=this.currentTrackId,m=this.levels;if(!m.length||!m[c]||!m[c].details)return;var e=m[c].details,r=e.targetduration,t=this.config,o=this.getLoadPosition(),y=D.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o-r,t.maxBufferHole),h=y.end,L=y.len,R=this.getFwdBufferInfo(this.media,S.PlaylistLevelType.MAIN),I=this.getMaxBufferLength(R==null?void 0:R.len)+r;if(L>I)return;console.assert(e,"Subtitle track details are defined on idle subtitle stream controller tick");var k=e.fragments,F=k.length,W=e.edge,K=null,H=this.fragPrevious;if(h<W){var Y=t.maxFragLookUpTolerance;K=(0,M.findFragmentByPTS)(H,k,Math.max(k[0].start,h),Y),!K&&H&&H.start<k[0].start&&(K=k[0])}else K=k[F-1];if(!K)return;K=this.mapToInitFragWhenRequired(K),this.fragmentTracker.getState(K)===b.FragmentState.NOT_LOADED&&this.loadFragment(K,e,h)}},u.getMaxBufferLength=function(c){var m=l.prototype.getMaxBufferLength.call(this);return c?Math.max(m,c):m},u.loadFragment=function(c,m,e){this.fragCurrent=c,c.sn==="initSegment"?this._loadInitSegment(c,m):(this.startFragRequested=!0,l.prototype.loadFragment.call(this,c,m,e))},f(i,[{key:"mediaBufferTimeRanges",get:function(){return new d(this.tracksBuffered[this.currentTrackId]||[])}}]),i}(A.default),d=function(i){this.buffered=void 0;var u=function(c,m,e){if(m=m>>>0,m>e-1)throw new DOMException("Failed to execute '"+c+"' on 'TimeRanges': The index provided ("+m+") is greater than the maximum bound ("+e+")");return i[m][c]};this.buffered={get length(){return i.length},end:function(c){return u("end",c,i.length)},start:function(c){return u("start",c,i.length)}}}},"./src/controller/subtitle-track-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>p});var O=T("./src/events.ts"),D=T("./src/utils/texttrack-utils.ts"),M=T("./src/controller/base-playlist-controller.ts"),P=T("./src/types/loader.ts");function U(v,a){for(var s=0;s<a.length;s++){var n=a[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(v,A(n.key),n)}}function b(v,a,s){return a&&U(v.prototype,a),s&&U(v,s),Object.defineProperty(v,"prototype",{writable:!1}),v}function A(v){var a=S(v,"string");return typeof a=="symbol"?a:String(a)}function S(v,a){if(typeof v!="object"||v===null)return v;var s=v[Symbol.toPrimitive];if(s!==void 0){var n=s.call(v,a||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(v)}function E(v,a){v.prototype=Object.create(a.prototype),v.prototype.constructor=v,x(v,a)}function x(v,a){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,d){return n.__proto__=d,n},x(v,a)}var f=function(v){E(a,v);function a(n){var d;return d=v.call(this,n,"[subtitle-track-controller]")||this,d.media=null,d.tracks=[],d.groupId=null,d.tracksInGroup=[],d.trackId=-1,d.selectDefaultTrack=!0,d.queuedDefaultTrack=-1,d.trackChangeListener=function(){return d.onTextTracksChanged()},d.asyncPollTrackChange=function(){return d.pollTrackChange(0)},d.useTextTrackPolling=!1,d.subtitlePollingInterval=-1,d._subtitleDisplay=!0,d.registerListeners(),d}var s=a.prototype;return s.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,v.prototype.destroy.call(this)},s.registerListeners=function(){var d=this.hls;d.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.on(O.Events.LEVEL_LOADING,this.onLevelLoading,this),d.on(O.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.on(O.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),d.on(O.Events.ERROR,this.onError,this)},s.unregisterListeners=function(){var d=this.hls;d.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.off(O.Events.LEVEL_LOADING,this.onLevelLoading,this),d.off(O.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.off(O.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),d.off(O.Events.ERROR,this.onError,this)},s.onMediaAttached=function(d,l){this.media=l.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))},s.pollTrackChange=function(d){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,d)},s.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 d=_(this.media.textTracks);d.forEach(function(l){(0,D.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null}},s.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},s.onManifestParsed=function(d,l){this.tracks=l.subtitleTracks},s.onSubtitleTrackLoaded=function(d,l){var i=l.id,u=l.details,g=this.trackId,c=this.tracksInGroup[g];if(!c){this.warn("Invalid subtitle track id "+i);return}var m=c.details;c.details=l.details,this.log("subtitle track "+i+" loaded ["+u.startSN+"-"+u.endSN+"]"),i===this.trackId&&(this.retryCount=0,this.playlistLoaded(i,l,m))},s.onLevelLoading=function(d,l){this.switchLevel(l.level)},s.onLevelSwitching=function(d,l){this.switchLevel(l.level)},s.switchLevel=function(d){var l=this.hls.levels[d];if(!!(l!=null&&l.textGroupIds)){var i=l.textGroupIds[l.urlId];if(this.groupId!==i){var u=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,g=this.tracks.filter(function(e){return!i||e.groupId===i});this.tracksInGroup=g;var c=this.findTrackId(u==null?void 0:u.name)||this.findTrackId();this.groupId=i;var m={subtitleTracks:g};this.log("Updating subtitle tracks, "+g.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(O.Events.SUBTITLE_TRACKS_UPDATED,m),c!==-1&&this.setSubtitleTrack(c,u)}}},s.findTrackId=function(d){for(var l=this.tracksInGroup,i=0;i<l.length;i++){var u=l[i];if((!this.selectDefaultTrack||u.default)&&(!d||d===u.name))return u.id}return-1},s.onError=function(d,l){v.prototype.onError.call(this,d,l),!(l.fatal||!l.context)&&l.context.type===P.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},s.loadPlaylist=function(d){v.prototype.loadPlaylist.call(this);var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var i=l.id,u=l.groupId,g=l.url;if(d)try{g=d.addDirectives(g)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(O.Events.SUBTITLE_TRACK_LOADING,{url:g,id:i,groupId:u,deliveryDirectives:d||null})}},s.toggleTrackModes=function(d){var l=this,i=this.media,u=this.trackId;if(!!i){var g=_(i.textTracks),c=g.filter(function(r){return r.groupId===l.groupId});if(d===-1)[].slice.call(g).forEach(function(r){r.mode="disabled"});else{var m=c[u];m&&(m.mode="disabled")}var e=c[d];e&&(e.mode=this.subtitleDisplay?"showing":"hidden")}},s.setSubtitleTrack=function(d,l){var i,u=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=d;return}if(this.trackId!==d&&this.toggleTrackModes(d),!(this.trackId===d&&(d===-1||(i=u[d])!==null&&i!==void 0&&i.details)||d<-1||d>=u.length)){this.clearTimer();var g=u[d];if(this.log("Switching to subtitle track "+d),this.trackId=d,g){var c=g.id,m=g.groupId,e=m===void 0?"":m,r=g.name,t=g.type,o=g.url;this.hls.trigger(O.Events.SUBTITLE_TRACK_SWITCH,{id:c,groupId:e,name:r,type:t,url:o});var y=this.switchParams(g.url,l==null?void 0:l.details);this.loadPlaylist(y)}else this.hls.trigger(O.Events.SUBTITLE_TRACK_SWITCH,{id:d})}},s.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var d=-1,l=_(this.media.textTracks),i=0;i<l.length;i++)if(l[i].mode==="hidden")d=i;else if(l[i].mode==="showing"){d=i;break}this.subtitleTrack!==d&&(this.subtitleTrack=d)}},b(a,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(d){this._subtitleDisplay=d,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(d){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(d,l)}}]),a}(M.default);function _(v){for(var a=[],s=0;s<v.length;s++){var n=v[s];n.kind==="subtitles"&&n.label&&a.push(v[s])}return a}let p=f},"./src/controller/timeline-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{TimelineController:()=>f});var O=T("./src/polyfills/number.ts"),D=T("./src/events.ts"),M=T("./src/utils/cea-608-parser.ts"),P=T("./src/utils/output-filter.ts"),U=T("./src/utils/webvtt-parser.ts"),b=T("./src/utils/texttrack-utils.ts"),A=T("./src/utils/imsc1-ttml-parser.ts"),S=T("./src/utils/mp4-tools.ts"),E=T("./src/types/loader.ts"),x=T("./src/utils/logger.ts"),f=function(){function a(n){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=v(),this.captionsProperties=void 0,this.hls=n,this.config=n.config,this.Cues=n.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 d=new P.default(this,"textTrack1"),l=new P.default(this,"textTrack2"),i=new P.default(this,"textTrack3"),u=new P.default(this,"textTrack4");this.cea608Parser1=new M.default(1,d,l),this.cea608Parser2=new M.default(3,i,u)}n.on(D.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),n.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(D.Events.MANIFEST_LOADED,this.onManifestLoaded,this),n.on(D.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.on(D.Events.FRAG_LOADING,this.onFragLoading,this),n.on(D.Events.FRAG_LOADED,this.onFragLoaded,this),n.on(D.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),n.on(D.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),n.on(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(D.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),n.on(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=a.prototype;return s.destroy=function(){var d=this.hls;d.off(D.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),d.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(D.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.off(D.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),d.off(D.Events.FRAG_LOADING,this.onFragLoading,this),d.off(D.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(D.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),d.off(D.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),d.off(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(D.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),d.off(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(d,l,i,u,g){for(var c=!1,m=g.length;m--;){var e=g[m],r=p(e[0],e[1],l,i);if(r>=0&&(e[0]=Math.min(e[0],l),e[1]=Math.max(e[1],i),c=!0,r/(i-l)>.5))return}if(c||g.push([l,i]),this.config.renderTextTracksNatively){var t=this.captionsTracks[d];this.Cues.newCue(t,l,i,u)}else{var o=this.Cues.newCue(null,l,i,u);this.hls.trigger(D.Events.CUES_PARSED,{type:"captions",cues:o,track:d})}},s.onInitPtsFound=function(d,l){var i=this,u=l.frag,g=l.id,c=l.initPTS,m=l.timescale,e=this.unparsedVttFrags;g==="main"&&(this.initPTS[u.cc]=c,this.timescale[u.cc]=m),e.length&&(this.unparsedVttFrags=[],e.forEach(function(r){i.onFragLoaded(D.Events.FRAG_LOADED,r)}))},s.getExistingTrack=function(d){var l=this.media;if(l)for(var i=0;i<l.textTracks.length;i++){var u=l.textTracks[i];if(u[d])return u}return null},s.createCaptionsTrack=function(d){this.config.renderTextTracksNatively?this.createNativeTrack(d):this.createNonNativeTrack(d)},s.createNativeTrack=function(d){if(!this.captionsTracks[d]){var l=this.captionsProperties,i=this.captionsTracks,u=this.media,g=l[d],c=g.label,m=g.languageCode,e=this.getExistingTrack(d);if(e)i[d]=e,(0,b.clearCurrentCues)(i[d]),(0,b.sendAddTrackEvent)(i[d],u);else{var r=this.createTextTrack("captions",c,m);r&&(r[d]=!0,i[d]=r)}}},s.createNonNativeTrack=function(d){if(!this.nonNativeCaptionsTracks[d]){var l=this.captionsProperties[d];if(!!l){var i=l.label,u={_id:d,label:i,kind:"captions",default:l.media?!!l.media.default:!1,closedCaptions:l.media};this.nonNativeCaptionsTracks[d]=u,this.hls.trigger(D.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[u]})}}},s.createTextTrack=function(d,l,i){var u=this.media;if(!!u)return u.addTextTrack(d,l,i)},s.onMediaAttaching=function(d,l){this.media=l.media,this._cleanTracks()},s.onMediaDetaching=function(){var d=this.captionsTracks;Object.keys(d).forEach(function(l){(0,b.clearCurrentCues)(d[l]),delete d[l]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=v(),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 d=this.media;if(!!d){var l=d.textTracks;if(l)for(var i=0;i<l.length;i++)(0,b.clearCurrentCues)(l[i])}},s.onSubtitleTracksUpdated=function(d,l){var i=this;this.textTracks=[];var u=l.subtitleTracks||[],g=u.some(function(r){return r.textCodec===A.IMSC1_CODEC});if(this.config.enableWebVTT||g&&this.config.enableIMSC1){var c=this.tracks&&u&&this.tracks.length===u.length;if(this.tracks=u||[],this.config.renderTextTracksNatively){var m=this.media?this.media.textTracks:[];this.tracks.forEach(function(r,t){var o;if(t<m.length){for(var y=null,h=0;h<m.length;h++)if(_(m[h],r)){y=m[h];break}y&&(o=y)}if(o)(0,b.clearCurrentCues)(o);else{var L=i._captionsOrSubtitlesFromCharacteristics(r);o=i.createTextTrack(L,r.name,r.lang),o&&(o.mode="disabled")}o&&(o.groupId=r.groupId,i.textTracks.push(o))})}else if(!c&&this.tracks&&this.tracks.length){var e=this.tracks.map(function(r){return{label:r.name,kind:r.type.toLowerCase(),default:r.default,subtitleTrack:r}});this.hls.trigger(D.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}},s._captionsOrSubtitlesFromCharacteristics=function(d){var l;if((l=d.attrs)!==null&&l!==void 0&&l.CHARACTERISTICS){var i=/transcribes-spoken-dialog/gi.test(d.attrs.CHARACTERISTICS),u=/describes-music-and-sound/gi.test(d.attrs.CHARACTERISTICS);if(i&&u)return"captions"}return"subtitles"},s.onManifestLoaded=function(d,l){var i=this;this.config.enableCEA708Captions&&l.captions&&l.captions.forEach(function(u){var g=/(?:CC|SERVICE)([1-4])/.exec(u.instreamId);if(!!g){var c="textTrack"+g[1],m=i.captionsProperties[c];!m||(m.label=u.name,u.lang&&(m.languageCode=u.lang),m.media=u)}})},s.closedCaptionsForLevel=function(d){var l=this.hls.levels[d.level];return l==null?void 0:l.attrs["CLOSED-CAPTIONS"]},s.onFragLoading=function(d,l){var i=this.cea608Parser1,u=this.cea608Parser2,g=this.lastSn,c=this.lastPartIndex;if(!(!this.enabled||!(i&&u))&&l.frag.type===E.PlaylistLevelType.MAIN){var m,e,r=l.frag.sn,t=(m=l==null||(e=l.part)===null||e===void 0?void 0:e.index)!=null?m:-1;r===g+1||r===g&&t===c+1||(i.reset(),u.reset()),this.lastSn=r,this.lastPartIndex=t}},s.onFragLoaded=function(d,l){var i=l.frag,u=l.payload,g=this.initPTS,c=this.unparsedVttFrags;if(i.type===E.PlaylistLevelType.SUBTITLE)if(u.byteLength){if(!(0,O.isFiniteNumber)(g[i.cc])){c.push(l),g.length&&this.hls.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Missing initial subtitle PTS")});return}var m=i.decryptdata,e="stats"in l;if(m==null||!m.encrypted||e){var r=this.tracks[i.level],t=this.vttCCs;t[i.cc]||(t[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),r&&r.textCodec===A.IMSC1_CODEC?this._parseIMSC1(i,u):this._parseVTTs(i,u,t)}}else this.hls.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(d,l){var i=this,u=this.hls;(0,A.parseIMSC1)(l,this.initPTS[d.cc],this.timescale[d.cc],function(g){i._appendCues(g,d.level),u.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(g){x.logger.log("Failed to parse IMSC1: "+g),u.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:g})})},s._parseVTTs=function(d,l,i){var u,g=this,c=this.hls,m=(u=d.initSegment)!==null&&u!==void 0&&u.data?(0,S.appendUint8Array)(d.initSegment.data,new Uint8Array(l)):l;(0,U.parseWebVTT)(m,this.initPTS[d.cc],this.timescale[d.cc],i,d.cc,d.start,function(e){g._appendCues(e,d.level),c.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(e){g._fallbackToIMSC1(d,l),x.logger.log("Failed to parse VTT cue: "+e),c.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:e})})},s._fallbackToIMSC1=function(d,l){var i=this,u=this.tracks[d.level];u.textCodec||(0,A.parseIMSC1)(l,this.initPTS[d.cc],this.timescale[d.cc],function(){u.textCodec=A.IMSC1_CODEC,i._parseIMSC1(d,l)},function(){u.textCodec="wvtt"})},s._appendCues=function(d,l){var i=this.hls;if(this.config.renderTextTracksNatively){var u=this.textTracks[l];if(!u||u.mode==="disabled")return;d.forEach(function(m){return(0,b.addCueToTrack)(u,m)})}else{var g=this.tracks[l];if(!g)return;var c=g.default?"default":"subtitles"+l;i.trigger(D.Events.CUES_PARSED,{type:"subtitles",cues:d,track:c})}},s.onFragDecrypted=function(d,l){var i=l.frag;if(i.type===E.PlaylistLevelType.SUBTITLE){if(!(0,O.isFiniteNumber)(this.initPTS[i.cc])){this.unparsedVttFrags.push(l);return}this.onFragLoaded(D.Events.FRAG_LOADED,l)}},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(d,l){var i=this.cea608Parser1,u=this.cea608Parser2;if(!(!this.enabled||!(i&&u))){var g=l.frag,c=l.samples;if(!(g.type===E.PlaylistLevelType.MAIN&&this.closedCaptionsForLevel(g)==="NONE"))for(var m=0;m<c.length;m++){var e=c[m].bytes;if(e){var r=this.extractCea608Data(e);i.addData(c[m].pts,r[0]),u.addData(c[m].pts,r[1])}}}},s.onBufferFlushing=function(d,l){var i=l.startOffset,u=l.endOffset,g=l.endOffsetSubtitles,c=l.type,m=this.media;if(!(!m||m.currentTime<u)){if(!c||c==="video"){var e=this.captionsTracks;Object.keys(e).forEach(function(t){return(0,b.removeCuesInRange)(e[t],i,u)})}if(this.config.renderTextTracksNatively&&i===0&&g!==void 0){var r=this.textTracks;Object.keys(r).forEach(function(t){return(0,b.removeCuesInRange)(r[t],i,g)})}}},s.extractCea608Data=function(d){for(var l=[[],[]],i=d[0]&31,u=2,g=0;g<i;g++){var c=d[u++],m=127&d[u++],e=127&d[u++];if(!(m===0&&e===0)){var r=(4&c)!==0;if(r){var t=3&c;(t===0||t===1)&&(l[t].push(m),l[t].push(e))}}}return l},a}();function _(a,s){return a&&a.label===s.name&&!(a.textTrack1||a.textTrack2)}function p(a,s,n,d){return Math.min(s,d)-Math.max(a,n)}function v(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>O});var O=function(){function D(P,U){this.subtle=void 0,this.aesIV=void 0,this.subtle=P,this.aesIV=U}var M=D.prototype;return M.decrypt=function(U,b){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},b,U)},D}()},"./src/crypt/aes-decryptor.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>M,removePadding:()=>D});var O=T("./src/utils/typed-array.ts");function D(P){var U=P.byteLength,b=U&&new DataView(P.buffer).getUint8(U-1);return b?(0,O.sliceUint8)(P,0,U-b):P}var M=function(){function P(){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 U=P.prototype;return U.uint8ArrayToUint32Array_=function(A){for(var S=new DataView(A),E=new Uint32Array(4),x=0;x<4;x++)E[x]=S.getUint32(x*4);return E},U.initTable=function(){var A=this.sBox,S=this.invSBox,E=this.subMix,x=E[0],f=E[1],_=E[2],p=E[3],v=this.invSubMix,a=v[0],s=v[1],n=v[2],d=v[3],l=new Uint32Array(256),i=0,u=0,g=0;for(g=0;g<256;g++)g<128?l[g]=g<<1:l[g]=g<<1^283;for(g=0;g<256;g++){var c=u^u<<1^u<<2^u<<3^u<<4;c=c>>>8^c&255^99,A[i]=c,S[c]=i;var m=l[i],e=l[m],r=l[e],t=l[c]*257^c*16843008;x[i]=t<<24|t>>>8,f[i]=t<<16|t>>>16,_[i]=t<<8|t>>>24,p[i]=t,t=r*16843009^e*65537^m*257^i*16843008,a[c]=t<<24|t>>>8,s[c]=t<<16|t>>>16,n[c]=t<<8|t>>>24,d[c]=t,i?(i=m^l[l[l[r^m]]],u^=l[l[u]]):i=u=1}},U.expandKey=function(A){for(var S=this.uint8ArrayToUint32Array_(A),E=!0,x=0;x<S.length&&E;)E=S[x]===this.key[x],x++;if(!E){this.key=S;var f=this.keySize=S.length;if(f!==4&&f!==6&&f!==8)throw new Error("Invalid aes key size="+f);var _=this.ksRows=(f+6+1)*4,p,v,a=this.keySchedule=new Uint32Array(_),s=this.invKeySchedule=new Uint32Array(_),n=this.sBox,d=this.rcon,l=this.invSubMix,i=l[0],u=l[1],g=l[2],c=l[3],m,e;for(p=0;p<_;p++){if(p<f){m=a[p]=S[p];continue}e=m,p%f===0?(e=e<<8|e>>>24,e=n[e>>>24]<<24|n[e>>>16&255]<<16|n[e>>>8&255]<<8|n[e&255],e^=d[p/f|0]<<24):f>6&&p%f===4&&(e=n[e>>>24]<<24|n[e>>>16&255]<<16|n[e>>>8&255]<<8|n[e&255]),a[p]=m=(a[p-f]^e)>>>0}for(v=0;v<_;v++)p=_-v,v&3?e=a[p]:e=a[p-4],v<4||p<=4?s[v]=e:s[v]=i[n[e>>>24]]^u[n[e>>>16&255]]^g[n[e>>>8&255]]^c[n[e&255]],s[v]=s[v]>>>0}},U.networkToHostOrderSwap=function(A){return A<<24|(A&65280)<<8|(A&16711680)>>8|A>>>24},U.decrypt=function(A,S,E){for(var x=this.keySize+6,f=this.invKeySchedule,_=this.invSBox,p=this.invSubMix,v=p[0],a=p[1],s=p[2],n=p[3],d=this.uint8ArrayToUint32Array_(E),l=d[0],i=d[1],u=d[2],g=d[3],c=new Int32Array(A),m=new Int32Array(c.length),e,r,t,o,y,h,L,R,I,k,F,W,K,H,Y=this.networkToHostOrderSwap;S<c.length;){for(I=Y(c[S]),k=Y(c[S+1]),F=Y(c[S+2]),W=Y(c[S+3]),y=I^f[0],h=W^f[1],L=F^f[2],R=k^f[3],K=4,H=1;H<x;H++)e=v[y>>>24]^a[h>>16&255]^s[L>>8&255]^n[R&255]^f[K],r=v[h>>>24]^a[L>>16&255]^s[R>>8&255]^n[y&255]^f[K+1],t=v[L>>>24]^a[R>>16&255]^s[y>>8&255]^n[h&255]^f[K+2],o=v[R>>>24]^a[y>>16&255]^s[h>>8&255]^n[L&255]^f[K+3],y=e,h=r,L=t,R=o,K=K+4;e=_[y>>>24]<<24^_[h>>16&255]<<16^_[L>>8&255]<<8^_[R&255]^f[K],r=_[h>>>24]<<24^_[L>>16&255]<<16^_[R>>8&255]<<8^_[y&255]^f[K+1],t=_[L>>>24]<<24^_[R>>16&255]<<16^_[y>>8&255]<<8^_[h&255]^f[K+2],o=_[R>>>24]<<24^_[y>>16&255]<<16^_[h>>8&255]<<8^_[L&255]^f[K+3],m[S]=Y(e^l),m[S+1]=Y(o^i),m[S+2]=Y(t^u),m[S+3]=Y(r^g),l=I,i=k,u=F,g=W,S=S+4}return m.buffer},P}()},"./src/crypt/decrypter.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>S});var O=T("./src/crypt/aes-crypto.ts"),D=T("./src/crypt/fast-aes-key.ts"),M=T("./src/crypt/aes-decryptor.ts"),P=T("./src/utils/logger.ts"),U=T("./src/utils/mp4-tools.ts"),b=T("./src/utils/typed-array.ts"),A=16,S=function(){function E(f,_){var p=_===void 0?{}:_,v=p.removePKCS7Padding,a=v===void 0?!0:v;if(this.logEnabled=!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.useSoftware=void 0,this.useSoftware=f.enableSoftwareAES,this.removePKCS7Padding=a,a)try{var s=self.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var x=E.prototype;return x.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},x.isSync=function(){return this.useSoftware},x.flush=function(){var _=this.currentResult,p=this.remainderData;if(!_||p)return P.logger.error("[softwareDecrypt] "+(p?"overflow bytes: "+p.byteLength:"no result")),this.reset(),null;var v=new Uint8Array(_);return this.reset(),this.removePKCS7Padding?(0,M.removePadding)(v):v},x.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},x.decrypt=function(_,p,v){var a=this;return this.useSoftware?new Promise(function(s,n){a.softwareDecrypt(new Uint8Array(_),p,v);var d=a.flush();d?s(d.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(_),p,v)},x.softwareDecrypt=function(_,p,v){var a=this.currentIV,s=this.currentResult,n=this.remainderData;this.logOnce("JS AES decrypt"),n&&(_=(0,U.appendUint8Array)(n,_),this.remainderData=null);var d=this.getValidChunk(_);if(!d.length)return null;a&&(v=a);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new M.default),l.expandKey(p);var i=s;return this.currentResult=l.decrypt(d.buffer,0,v),this.currentIV=(0,b.sliceUint8)(d,-16).buffer,i||null},x.webCryptoDecrypt=function(_,p,v){var a=this,s=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new D.default(s,p)),this.fastAesKey.expandKey().then(function(n){if(!s)return Promise.reject(new Error("web crypto not initialized"));a.logOnce("WebCrypto AES decrypt");var d=new O.default(s,new Uint8Array(v));return d.decrypt(_.buffer,n)}).catch(function(n){return P.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+n.name+": "+n.message),a.onWebCryptoError(_,p,v)})},x.onWebCryptoError=function(_,p,v){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(_,p,v);var a=this.flush();if(a)return a.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},x.getValidChunk=function(_){var p=_,v=_.length-_.length%A;return v!==_.length&&(p=(0,b.sliceUint8)(_,0,v),this.remainderData=(0,b.sliceUint8)(_,v)),p},x.logOnce=function(_){!this.logEnabled||(P.logger.log("[decrypter]: "+_),this.logEnabled=!1)},E}()},"./src/crypt/fast-aes-key.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>O});var O=function(){function D(P,U){this.subtle=void 0,this.key=void 0,this.subtle=P,this.key=U}var M=D.prototype;return M.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},D}()},"./src/demux/aacdemuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>S});var O=T("./src/demux/base-audio-demuxer.ts"),D=T("./src/demux/adts.ts"),M=T("./src/utils/logger.ts"),P=T("./src/demux/id3.ts");function U(E,x){E.prototype=Object.create(x.prototype),E.prototype.constructor=E,b(E,x)}function b(E,x){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(_,p){return _.__proto__=p,_},b(E,x)}var A=function(E){U(x,E);function x(_,p){var v;return v=E.call(this)||this,v.observer=void 0,v.config=void 0,v.observer=_,v.config=p,v}var f=x.prototype;return f.resetInitSegment=function(p,v,a,s){E.prototype.resetInitSegment.call(this,p,v,a,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:v,duration:s,inputTimeScale:9e4,dropped:0}},x.probe=function(p){if(!p)return!1;for(var v=P.getID3Data(p,0)||[],a=v.length,s=p.length;a<s;a++)if(D.probe(p,a))return M.logger.log("ADTS sync word found !"),!0;return!1},f.canParse=function(p,v){return D.canParse(p,v)},f.appendFrame=function(p,v,a){D.initTrackConfig(p,this.observer,v,a,p.manifestCodec);var s=D.appendFrame(p,v,a,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s},x}(O.default);let S=A},"./src/demux/adts.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{appendFrame:()=>a,canGetFrameLength:()=>S,canParse:()=>x,getAudioConfig:()=>P,getFrameDuration:()=>p,getFullFrameLength:()=>A,getHeaderLength:()=>b,initTrackConfig:()=>_,isHeader:()=>E,isHeaderPattern:()=>U,parseFrameHeader:()=>v,probe:()=>f});var O=T("./src/utils/logger.ts"),D=T("./src/errors.ts"),M=T("./src/events.ts");function P(s,n,d,l){var i,u,g,c,m=navigator.userAgent.toLowerCase(),e=l,r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];i=((n[d+2]&192)>>>6)+1;var t=(n[d+2]&60)>>>2;if(t>r.length-1){s.trigger(M.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+t});return}return g=(n[d+2]&1)<<2,g|=(n[d+3]&192)>>>6,O.logger.log("manifest codec:"+l+", ADTS type:"+i+", samplingIndex:"+t),/firefox/i.test(m)?t>=6?(i=5,c=new Array(4),u=t-3):(i=2,c=new Array(2),u=t):m.indexOf("android")!==-1?(i=2,c=new Array(2),u=t):(i=5,c=new Array(4),l&&(l.indexOf("mp4a.40.29")!==-1||l.indexOf("mp4a.40.5")!==-1)||!l&&t>=6?u=t-3:((l&&l.indexOf("mp4a.40.2")!==-1&&(t>=6&&g===1||/vivaldi/i.test(m))||!l&&g===1)&&(i=2,c=new Array(2)),u=t)),c[0]=i<<3,c[0]|=(t&14)>>1,c[1]|=(t&1)<<7,c[1]|=g<<3,i===5&&(c[1]|=(u&14)>>1,c[2]=(u&1)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:r[t],channelCount:g,codec:"mp4a.40."+i,manifestCodec:e}}function U(s,n){return s[n]===255&&(s[n+1]&246)===240}function b(s,n){return s[n+1]&1?7:9}function A(s,n){return(s[n+3]&3)<<11|s[n+4]<<3|(s[n+5]&224)>>>5}function S(s,n){return n+5<s.length}function E(s,n){return n+1<s.length&&U(s,n)}function x(s,n){return S(s,n)&&U(s,n)&&A(s,n)<=s.length-n}function f(s,n){if(E(s,n)){var d=b(s,n);if(n+d>=s.length)return!1;var l=A(s,n);if(l<=d)return!1;var i=n+l;return i===s.length||E(s,i)}return!1}function _(s,n,d,l,i){if(!s.samplerate){var u=P(n,d,l,i);if(!u)return;s.config=u.config,s.samplerate=u.samplerate,s.channelCount=u.channelCount,s.codec=u.codec,s.manifestCodec=u.manifestCodec,O.logger.log("parsed codec:"+s.codec+", rate:"+u.samplerate+", channels:"+u.channelCount)}}function p(s){return 9216e4/s}function v(s,n){var d=b(s,n);if(n+d<=s.length){var l=A(s,n)-d;if(l>0)return{headerLength:d,frameLength:l}}}function a(s,n,d,l,i){var u=p(s.samplerate),g=l+i*u,c=v(n,d),m;if(c){var e=c.frameLength,r=c.headerLength,t=r+e,o=Math.max(0,d+t-n.length);o?(m=new Uint8Array(t-r),m.set(n.subarray(d+r,n.length),0)):m=n.subarray(d+r,d+t);var y={unit:m,pts:g};return o||s.samples.push(y),{sample:y,length:t,missing:o}}var h=n.length-d;m=new Uint8Array(h),m.set(n.subarray(d,n.length),0);var L={unit:m,pts:g};return{sample:L,length:h,missing:-1}}},"./src/demux/base-audio-demuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>E,initPTSFn:()=>S});var O=T("./src/polyfills/number.ts"),D=T("./src/demux/id3.ts"),M=T("./src/types/demuxer.ts"),P=T("./src/demux/dummy-demuxed-track.ts"),U=T("./src/utils/mp4-tools.ts"),b=T("./src/utils/typed-array.ts"),A=function(){function x(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var f=x.prototype;return f.resetInitSegment=function(p,v,a,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},f.resetTimeStamp=function(p){this.initPTS=p,this.resetContiguity()},f.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},f.canParse=function(p,v){return!1},f.appendFrame=function(p,v,a){},f.demux=function(p,v){this.cachedData&&(p=(0,U.appendUint8Array)(this.cachedData,p),this.cachedData=null);var a=D.getID3Data(p,0),s=a?a.length:0,n,d=this._audioTrack,l=this._id3Track,i=a?D.getTimeStamp(a):void 0,u=p.length;for((this.basePTS===null||this.frameIndex===0&&(0,O.isFiniteNumber)(i))&&(this.basePTS=S(i,v,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),a&&a.length>0&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:a,type:M.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});s<u;){if(this.canParse(p,s)){var g=this.appendFrame(d,p,s);g?(this.frameIndex++,this.lastPTS=g.sample.pts,s+=g.length,n=s):s=u}else D.canParse(p,s)?(a=D.getID3Data(p,s),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:a,type:M.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),s+=a.length,n=s):s++;if(s===u&&n!==u){var c=(0,b.sliceUint8)(p,n);this.cachedData?this.cachedData=(0,U.appendUint8Array)(this.cachedData,c):this.cachedData=c}}return{audioTrack:d,videoTrack:(0,P.dummyTrack)(),id3Track:l,textTrack:(0,P.dummyTrack)()}},f.demuxSampleAes=function(p,v,a){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},f.flush=function(p){var v=this.cachedData;return v&&(this.cachedData=null,this.demux(v,0)),{audioTrack:this._audioTrack,videoTrack:(0,P.dummyTrack)(),id3Track:this._id3Track,textTrack:(0,P.dummyTrack)()}},f.destroy=function(){},x}(),S=function(f,_,p){return(0,O.isFiniteNumber)(f)?f*90:_*9e4+(p||0)};let E=A},"./src/demux/chunk-cache.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>O});var O=function(){function M(){this.chunks=[],this.dataLength=0}var P=M.prototype;return P.push=function(b){this.chunks.push(b),this.dataLength+=b.length},P.flush=function(){var b=this.chunks,A=this.dataLength,S;if(b.length)b.length===1?S=b[0]:S=D(b,A);else return new Uint8Array(0);return this.reset(),S},P.reset=function(){this.chunks.length=0,this.dataLength=0},M}();function D(M,P){for(var U=new Uint8Array(P),b=0,A=0;A<M.length;A++){var S=M[A];U.set(S,b),b+=S.length}return U}},"./src/demux/dummy-demuxed-track.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{dummyTrack:()=>O});function O(D,M){return D===void 0&&(D=""),M===void 0&&(M=9e4),{type:D,id:-1,pid:-1,inputTimeScale:M,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>M});var O=T("./src/utils/logger.ts"),D=function(){function P(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 U=P.prototype;return U.loadWord=function(){var A=this.data,S=this.bytesAvailable,E=A.byteLength-S,x=new Uint8Array(4),f=Math.min(4,S);if(f===0)throw new Error("no bytes available");x.set(A.subarray(E,E+f)),this.word=new DataView(x.buffer).getUint32(0),this.bitsAvailable=f*8,this.bytesAvailable-=f},U.skipBits=function(A){var S;A=Math.min(A,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>A?(this.word<<=A,this.bitsAvailable-=A):(A-=this.bitsAvailable,S=A>>3,A-=S<<3,this.bytesAvailable-=S,this.loadWord(),this.word<<=A,this.bitsAvailable-=A)},U.readBits=function(A){var S=Math.min(this.bitsAvailable,A),E=this.word>>>32-S;if(A>32&&O.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=S,this.bitsAvailable>0)this.word<<=S;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return S=A-S,S>0&&this.bitsAvailable?E<<S|this.readBits(S):E},U.skipLZ=function(){var A;for(A=0;A<this.bitsAvailable;++A)if((this.word&2147483648>>>A)!==0)return this.word<<=A,this.bitsAvailable-=A,A;return this.loadWord(),A+this.skipLZ()},U.skipUEG=function(){this.skipBits(1+this.skipLZ())},U.skipEG=function(){this.skipBits(1+this.skipLZ())},U.readUEG=function(){var A=this.skipLZ();return this.readBits(A+1)-1},U.readEG=function(){var A=this.readUEG();return 1&A?1+A>>>1:-1*(A>>>1)},U.readBoolean=function(){return this.readBits(1)===1},U.readUByte=function(){return this.readBits(8)},U.readUShort=function(){return this.readBits(16)},U.readUInt=function(){return this.readBits(32)},U.skipScalingList=function(A){for(var S=8,E=8,x,f=0;f<A;f++)E!==0&&(x=this.readEG(),E=(S+x+256)%256),S=E===0?S:E},U.readSPS=function(){var A=0,S=0,E=0,x=0,f,_,p,v=this.readUByte.bind(this),a=this.readBits.bind(this),s=this.readUEG.bind(this),n=this.readBoolean.bind(this),d=this.skipBits.bind(this),l=this.skipEG.bind(this),i=this.skipUEG.bind(this),u=this.skipScalingList.bind(this);v();var g=v();if(a(5),d(3),v(),i(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){var c=s();if(c===3&&d(1),i(),i(),d(1),n())for(_=c!==3?8:12,p=0;p<_;p++)n()&&(p<6?u(16):u(64))}i();var m=s();if(m===0)s();else if(m===1)for(d(1),l(),l(),f=s(),p=0;p<f;p++)l();i(),d(1);var e=s(),r=s(),t=a(1);t===0&&d(1),d(1),n()&&(A=s(),S=s(),E=s(),x=s());var o=[1,1];if(n()&&n()){var y=v();switch(y){case 1:o=[1,1];break;case 2:o=[12,11];break;case 3:o=[10,11];break;case 4:o=[16,11];break;case 5:o=[40,33];break;case 6:o=[24,11];break;case 7:o=[20,11];break;case 8:o=[32,11];break;case 9:o=[80,33];break;case 10:o=[18,11];break;case 11:o=[15,11];break;case 12:o=[64,33];break;case 13:o=[160,99];break;case 14:o=[4,3];break;case 15:o=[3,2];break;case 16:o=[2,1];break;case 255:{o=[v()<<8|v(),v()<<8|v()];break}}}return{width:Math.ceil((e+1)*16-A*2-S*2),height:(2-t)*(r+1)*16-(t?2:4)*(E+x),pixelRatio:o}},U.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},P}();let M=D},"./src/demux/id3.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{canParse:()=>U,decodeFrame:()=>x,getID3Data:()=>M,getID3Frames:()=>E,getTimeStamp:()=>b,isFooter:()=>D,isHeader:()=>O,isTimeStampFrame:()=>A,testables:()=>s,utf8ArrayToStr:()=>a});var O=function(i,u){return u+10<=i.length&&i[u]===73&&i[u+1]===68&&i[u+2]===51&&i[u+3]<255&&i[u+4]<255&&i[u+6]<128&&i[u+7]<128&&i[u+8]<128&&i[u+9]<128},D=function(i,u){return u+10<=i.length&&i[u]===51&&i[u+1]===68&&i[u+2]===73&&i[u+3]<255&&i[u+4]<255&&i[u+6]<128&&i[u+7]<128&&i[u+8]<128&&i[u+9]<128},M=function(i,u){for(var g=u,c=0;O(i,u);){c+=10;var m=P(i,u+6);c+=m,D(i,u+10)&&(c+=10),u+=c}if(c>0)return i.subarray(g,g+c)},P=function(i,u){var g=0;return g=(i[u]&127)<<21,g|=(i[u+1]&127)<<14,g|=(i[u+2]&127)<<7,g|=i[u+3]&127,g},U=function(i,u){return O(i,u)&&P(i,u+6)+10<=i.length-u},b=function(i){for(var u=E(i),g=0;g<u.length;g++){var c=u[g];if(A(c))return v(c)}},A=function(i){return i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp"},S=function(i){var u=String.fromCharCode(i[0],i[1],i[2],i[3]),g=P(i,4),c=10;return{type:u,size:g,data:i.subarray(c,c+g)}},E=function(i){for(var u=0,g=[];O(i,u);){var c=P(i,u+6);u+=10;for(var m=u+c;u+8<m;){var e=S(i.subarray(u)),r=x(e);r&&g.push(r),u+=e.size+10}D(i,u)&&(u+=10)}return g},x=function(i){return i.type==="PRIV"?f(i):i.type[0]==="W"?p(i):_(i)},f=function(i){if(!(i.size<2)){var u=a(i.data,!0),g=new Uint8Array(i.data.subarray(u.length+1));return{key:i.type,info:u,data:g.buffer}}},_=function(i){if(!(i.size<2)){if(i.type==="TXXX"){var u=1,g=a(i.data.subarray(u),!0);u+=g.length+1;var c=a(i.data.subarray(u));return{key:i.type,info:g,data:c}}var m=a(i.data.subarray(1));return{key:i.type,data:m}}},p=function(i){if(i.type==="WXXX"){if(i.size<2)return;var u=1,g=a(i.data.subarray(u),!0);u+=g.length+1;var c=a(i.data.subarray(u));return{key:i.type,info:g,data:c}}var m=a(i.data);return{key:i.type,data:m}},v=function(i){if(i.data.byteLength===8){var u=new Uint8Array(i.data),g=u[3]&1,c=(u[4]<<23)+(u[5]<<15)+(u[6]<<7)+u[7];return c/=45,g&&(c+=4772185884e-2),Math.round(c)}},a=function(i,u){u===void 0&&(u=!1);var g=d();if(g){var c=g.decode(i);if(u){var m=c.indexOf("\0");return m!==-1?c.substring(0,m):c}return c.replace(/\0/g,"")}for(var e=i.length,r,t,o,y="",h=0;h<e;){if(r=i[h++],r===0&&u)return y;if(r===0||r===3)continue;switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:y+=String.fromCharCode(r);break;case 12:case 13:t=i[h++],y+=String.fromCharCode((r&31)<<6|t&63);break;case 14:t=i[h++],o=i[h++],y+=String.fromCharCode((r&15)<<12|(t&63)<<6|(o&63)<<0);break;default:}}return y},s={decodeTextFrame:_},n;function d(){return!n&&typeof self.TextDecoder!="undefined"&&(n=new self.TextDecoder("utf-8")),n}},"./src/demux/mp3demuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>S});var O=T("./src/demux/base-audio-demuxer.ts"),D=T("./src/demux/id3.ts"),M=T("./src/utils/logger.ts"),P=T("./src/demux/mpegaudio.ts");function U(E,x){E.prototype=Object.create(x.prototype),E.prototype.constructor=E,b(E,x)}function b(E,x){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(_,p){return _.__proto__=p,_},b(E,x)}var A=function(E){U(x,E);function x(){return E.apply(this,arguments)||this}var f=x.prototype;return f.resetInitSegment=function(p,v,a,s){E.prototype.resetInitSegment.call(this,p,v,a,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:v,duration:s,inputTimeScale:9e4,dropped:0}},x.probe=function(p){if(!p)return!1;for(var v=D.getID3Data(p,0)||[],a=v.length,s=p.length;a<s;a++)if(P.probe(p,a))return M.logger.log("MPEG Audio sync word found !"),!0;return!1},f.canParse=function(p,v){return P.canParse(p,v)},f.appendFrame=function(p,v,a){if(this.basePTS!==null)return P.appendFrame(p,v,a,this.basePTS,this.frameIndex)},x}(O.default);let S=A},"./src/demux/mp4demuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>A});var O=T("./src/polyfills/number.ts"),D=T("./src/types/demuxer.ts"),M=T("./src/utils/mp4-tools.ts"),P=T("./src/demux/dummy-demuxed-track.ts"),U=/\/emsg[-/]ID3/i,b=function(){function S(x,f){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=f}var E=S.prototype;return E.resetTimeStamp=function(){},E.resetInitSegment=function(f,_,p,v){var a=this.videoTrack=(0,P.dummyTrack)("video",1),s=this.audioTrack=(0,P.dummyTrack)("audio",1),n=this.txtTrack=(0,P.dummyTrack)("text",1);if(this.id3Track=(0,P.dummyTrack)("id3",1),this.timeOffset=0,!(!f||!f.byteLength)){var d=(0,M.parseInitSegment)(f);if(d.video){var l=d.video,i=l.id,u=l.timescale,g=l.codec;a.id=i,a.timescale=n.timescale=u,a.codec=g}if(d.audio){var c=d.audio,m=c.id,e=c.timescale,r=c.codec;s.id=m,s.timescale=e,s.codec=r}n.id=M.RemuxerTrackIdConfig.text,a.sampleDuration=0,a.duration=s.duration=v}},E.resetContiguity=function(){},S.probe=function(f){return f=f.length>16384?f.subarray(0,16384):f,(0,M.findBox)(f,["moof"]).length>0},E.demux=function(f,_){this.timeOffset=_;var p=f,v=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(p=(0,M.appendUint8Array)(this.remainderData,f));var s=(0,M.segmentValidRange)(p);this.remainderData=s.remainder,v.samples=s.valid||new Uint8Array}else v.samples=p;var n=this.extractID3Track(v,_);return a.samples=(0,M.parseSamples)(_,v),{videoTrack:v,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}},E.flush=function(){var f=this.timeOffset,_=this.videoTrack,p=this.txtTrack;_.samples=this.remainderData||new Uint8Array,this.remainderData=null;var v=this.extractID3Track(_,this.timeOffset);return p.samples=(0,M.parseSamples)(f,_),{videoTrack:_,audioTrack:(0,P.dummyTrack)(),id3Track:v,textTrack:(0,P.dummyTrack)()}},E.extractID3Track=function(f,_){var p=this.id3Track;if(f.samples.length){var v=(0,M.findBox)(f.samples,["emsg"]);v&&v.forEach(function(a){var s=(0,M.parseEmsg)(a);if(U.test(s.schemeIdUri)){var n=(0,O.isFiniteNumber)(s.presentationTime)?s.presentationTime/s.timeScale:_+s.presentationTimeDelta/s.timeScale,d=s.eventDuration===4294967295?Number.POSITIVE_INFINITY:s.eventDuration/s.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);var l=s.payload;p.samples.push({data:l,len:l.byteLength,dts:n,pts:n,type:D.MetadataSchema.emsg,duration:d})}})}return p},E.demuxSampleAes=function(f,_,p){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},E.destroy=function(){},S}();let A=b},"./src/demux/mpegaudio.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{appendFrame:()=>b,canParse:()=>x,isHeader:()=>E,isHeaderPattern:()=>S,parseHeader:()=>A,probe:()=>f});var O=null,D=[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],M=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],P=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],U=[0,1,1,4];function b(_,p,v,a,s){if(!(v+24>p.length)){var n=A(p,v);if(n&&v+n.frameLength<=p.length){var d=n.samplesPerFrame*9e4/n.sampleRate,l=a+s*d,i={unit:p.subarray(v,v+n.frameLength),pts:l,dts:l};return _.config=[],_.channelCount=n.channelCount,_.samplerate=n.sampleRate,_.samples.push(i),{sample:i,length:n.frameLength,missing:0}}}}function A(_,p){var v=_[p+1]>>3&3,a=_[p+1]>>1&3,s=_[p+2]>>4&15,n=_[p+2]>>2&3;if(v!==1&&s!==0&&s!==15&&n!==3){var d=_[p+2]>>1&1,l=_[p+3]>>6,i=v===3?3-a:a===3?3:4,u=D[i*14+s-1]*1e3,g=v===3?0:v===2?1:2,c=M[g*3+n],m=l===3?1:2,e=P[v][a],r=U[a],t=e*8*r,o=Math.floor(e*u/c+d)*r;if(O===null){var y=navigator.userAgent||"",h=y.match(/Chrome\/(\d+)/i);O=h?parseInt(h[1]):0}var L=!!O&&O<=87;return L&&a===2&&u>=224e3&&l===0&&(_[p+3]=_[p+3]|128),{sampleRate:c,channelCount:m,frameLength:o,samplesPerFrame:t}}}function S(_,p){return _[p]===255&&(_[p+1]&224)===224&&(_[p+1]&6)!==0}function E(_,p){return p+1<_.length&&S(_,p)}function x(_,p){var v=4;return S(_,p)&&v<=_.length-p}function f(_,p){if(p+1<_.length&&S(_,p)){var v=4,a=A(_,p),s=v;a!=null&&a.frameLength&&(s=a.frameLength);var n=p+s;return n===_.length||E(_,n)}return!1}},"./src/demux/sample-aes.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>P});var O=T("./src/crypt/decrypter.ts"),D=T("./src/utils/mp4-tools.ts"),M=function(){function U(A,S,E){this.keyData=void 0,this.decrypter=void 0,this.keyData=E,this.decrypter=new O.default(S,{removePKCS7Padding:!1})}var b=U.prototype;return b.decryptBuffer=function(S){return this.decrypter.decrypt(S,this.keyData.key.buffer,this.keyData.iv.buffer)},b.decryptAacSample=function(S,E,x){var f=this,_=S[E].unit;if(!(_.length<=16)){var p=_.subarray(16,_.length-_.length%16),v=p.buffer.slice(p.byteOffset,p.byteOffset+p.length);this.decryptBuffer(v).then(function(a){var s=new Uint8Array(a);_.set(s,16),f.decrypter.isSync()||f.decryptAacSamples(S,E+1,x)})}},b.decryptAacSamples=function(S,E,x){for(;;E++){if(E>=S.length){x();return}if(!(S[E].unit.length<32)&&(this.decryptAacSample(S,E,x),!this.decrypter.isSync()))return}},b.getAvcEncryptedData=function(S){for(var E=Math.floor((S.length-48)/160)*16+16,x=new Int8Array(E),f=0,_=32;_<S.length-16;_+=160,f+=16)x.set(S.subarray(_,_+16),f);return x},b.getAvcDecryptedUnit=function(S,E){for(var x=new Uint8Array(E),f=0,_=32;_<S.length-16;_+=160,f+=16)S.set(x.subarray(f,f+16),_);return S},b.decryptAvcSample=function(S,E,x,f,_){var p=this,v=(0,D.discardEPB)(_.data),a=this.getAvcEncryptedData(v);this.decryptBuffer(a.buffer).then(function(s){_.data=p.getAvcDecryptedUnit(v,s),p.decrypter.isSync()||p.decryptAvcSamples(S,E,x+1,f)})},b.decryptAvcSamples=function(S,E,x,f){if(S instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;E++,x=0){if(E>=S.length){f();return}for(var _=S[E].units;!(x>=_.length);x++){var p=_[x];if(!(p.data.length<=48||p.type!==1&&p.type!==5)&&(this.decryptAvcSample(S,E,x,f,p),!this.decrypter.isSync()))return}}},U}();let P=M},"./src/demux/transmuxer-interface.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>x});var O=T("./src/demux/webworkify-webpack.js"),D=T("./src/events.ts"),M=T("./src/demux/transmuxer.ts"),P=T("./src/utils/logger.ts"),U=T("./src/errors.ts"),b=T("./src/utils/mediasource-helper.ts"),A=T("./node_modules/eventemitter3/index.js"),S=T.n(A),E=(0,b.getMediaSource)()||{isTypeSupported:function(){return!1}},x=function(){function f(p,v,a,s){var n=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var d=p.config;this.hls=p,this.id=v,this.useWorker=!!d.enableWorker,this.onTransmuxComplete=a,this.onFlush=s;var l=function(m,e){e=e||{},e.frag=n.frag,e.id=n.id,n.hls.trigger(m,e)};this.observer=new A.EventEmitter,this.observer.on(D.Events.FRAG_DECRYPTED,l),this.observer.on(D.Events.ERROR,l);var i={mp4:E.isTypeSupported("video/mp4"),mpeg:E.isTypeSupported("audio/mpeg"),mp3:E.isTypeSupported('audio/mp4; codecs="mp3"')},u=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"){P.logger.log("demuxing in webworker");var g;try{g=this.worker=(0,O.default)("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),g.addEventListener("message",this.onwmsg),g.onerror=function(c){n.useWorker=!1,P.logger.warn("Exception in webworker, fallback to inline"),n.hls.trigger(D.Events.ERROR,{type:U.ErrorTypes.OTHER_ERROR,details:U.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},g.postMessage({cmd:"init",typeSupported:i,vendor:u,id:v,config:JSON.stringify(d)})}catch(c){P.logger.warn("Error in worker:",c),P.logger.error("Error while initializing DemuxerWorker, fallback to inline"),g&&self.URL.revokeObjectURL(g.objectURL),this.transmuxer=new M.default(this.observer,i,d,u,v),this.worker=null}}else this.transmuxer=new M.default(this.observer,i,d,u,v)}var _=f.prototype;return _.destroy=function(){var v=this.worker;if(v)v.removeEventListener("message",this.onwmsg),v.terminate(),this.worker=null,this.onwmsg=void 0;else{var a=this.transmuxer;a&&(a.destroy(),this.transmuxer=null)}var s=this.observer;s&&s.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},_.push=function(v,a,s,n,d,l,i,u,g,c){var m,e,r=this;g.transmuxing.start=self.performance.now();var t=this.transmuxer,o=this.worker,y=l?l.start:d.start,h=d.decryptdata,L=this.frag,R=!(L&&d.cc===L.cc),I=!(L&&g.level===L.level),k=L?g.sn-L.sn:-1,F=this.part?g.part-this.part.index:-1,W=k===0&&g.id>1&&g.id===(L==null?void 0:L.stats.chunkCount),K=!I&&(k===1||k===0&&(F===1||W&&F<=0)),H=self.performance.now();(I||k||d.stats.parsing.start===0)&&(d.stats.parsing.start=H),l&&(F||!K)&&(l.stats.parsing.start=H);var Y=!(L&&((m=d.initSegment)===null||m===void 0?void 0:m.url)===((e=L.initSegment)===null||e===void 0?void 0:e.url)),q=new M.TransmuxState(R,K,u,I,y,Y);if(!K||R||Y){P.logger.log("[transmuxer-interface, "+d.type+"]: Starting new transmux session for sn: "+g.sn+" p: "+g.part+" level: "+g.level+" id: "+g.id+`
|
|
15
|
+
discontinuity: `+R+`
|
|
16
|
+
trackSwitch: `+I+`
|
|
17
|
+
contiguous: `+K+`
|
|
18
|
+
accurateTimeOffset: `+u+`
|
|
19
|
+
timeOffset: `+y+`
|
|
20
|
+
initSegmentChange: `+Y);var ee=new M.TransmuxConfig(s,n,a,i,c);this.configureTransmuxer(ee)}if(this.frag=d,this.part=l,o)o.postMessage({cmd:"demux",data:v,decryptdata:h,chunkMeta:g,state:q},v instanceof ArrayBuffer?[v]:[]);else if(t){var ae=t.push(v,h,g,q);(0,M.isPromise)(ae)?(t.async=!0,ae.then(function(re){r.handleTransmuxComplete(re)}).catch(function(re){r.transmuxerError(re,g,"transmuxer-interface push error")})):(t.async=!1,this.handleTransmuxComplete(ae))}},_.flush=function(v){var a=this;v.transmuxing.start=self.performance.now();var s=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:v});else if(s){var d=s.flush(v),l=(0,M.isPromise)(d);l||s.async?((0,M.isPromise)(d)||(d=Promise.resolve(d)),d.then(function(i){a.handleFlushResult(i,v)}).catch(function(i){a.transmuxerError(i,v,"transmuxer-interface flush error")})):this.handleFlushResult(d,v)}},_.transmuxerError=function(v,a,s){!this.hls||this.hls.trigger(D.Events.ERROR,{type:U.ErrorTypes.MEDIA_ERROR,details:U.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:a,fatal:!1,error:v,err:v,reason:s})},_.handleFlushResult=function(v,a){var s=this;v.forEach(function(n){s.handleTransmuxComplete(n)}),this.onFlush(a)},_.onWorkerMessage=function(v){var a=v.data,s=this.hls;switch(a.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(a.data);break}case"flush":{this.onFlush(a.data);break}case"workerLog":P.logger[a.data.logType]&&P.logger[a.data.logType](a.data.message);break;default:{a.data=a.data||{},a.data.frag=this.frag,a.data.id=this.id,s.trigger(a.event,a.data);break}}},_.configureTransmuxer=function(v){var a=this.worker,s=this.transmuxer;a?a.postMessage({cmd:"configure",config:v}):s&&s.configure(v)},_.handleTransmuxComplete=function(v){v.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(v)},f}()},"./src/demux/transmuxer-worker.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>A});var O=T("./src/demux/transmuxer.ts"),D=T("./src/events.ts"),M=T("./src/utils/logger.ts"),P=T("./node_modules/eventemitter3/index.js"),U=T.n(P),b=T("./src/errors.ts");function A(_){var p=new P.EventEmitter,v=function(n,d){_.postMessage({event:n,data:d})};p.on(D.Events.FRAG_DECRYPTED,v),p.on(D.Events.ERROR,v);var a=function(){var n=function(i){var u=function(c){v("workerLog",{logType:i,message:c})};M.logger[i]=u};for(var d in M.logger)n(d)};_.addEventListener("message",function(s){var n=s.data;switch(n.cmd){case"init":{var d=JSON.parse(n.config);_.transmuxer=new O.default(p,n.typeSupported,d,n.vendor,n.id),(0,M.enableLogs)(d.debug,n.id),a(),v("init",null);break}case"configure":{_.transmuxer.configure(n.config);break}case"demux":{var l=_.transmuxer.push(n.data,n.decryptdata,n.chunkMeta,n.state);(0,O.isPromise)(l)?(_.transmuxer.async=!0,l.then(function(c){S(_,c)}).catch(function(c){v(D.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:c,err:c,reason:"transmuxer-worker push error"})})):(_.transmuxer.async=!1,S(_,l));break}case"flush":{var i=n.chunkMeta,u=_.transmuxer.flush(i),g=(0,O.isPromise)(u);g||_.transmuxer.async?((0,O.isPromise)(u)||(u=Promise.resolve(u)),u.then(function(c){x(_,c,i)}).catch(function(c){v(D.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:c,err:c,reason:"transmuxer-worker flush error"})})):x(_,u,i);break}default:break}})}function S(_,p){if(f(p.remuxResult))return!1;var v=[],a=p.remuxResult,s=a.audio,n=a.video;return s&&E(v,s),n&&E(v,n),_.postMessage({event:"transmuxComplete",data:p},v),!0}function E(_,p){p.data1&&_.push(p.data1.buffer),p.data2&&_.push(p.data2.buffer)}function x(_,p,v){var a=p.reduce(function(s,n){return S(_,n)||s},!1);a||_.postMessage({event:"transmuxComplete",data:p[0]}),_.postMessage({event:"flush",data:v})}function f(_){return!_.audio&&!_.video&&!_.text&&!_.id3&&!_.initSegment}},"./src/demux/transmuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{TransmuxConfig:()=>n,TransmuxState:()=>d,default:()=>p,isPromise:()=>s});var O=T("./src/events.ts"),D=T("./src/errors.ts"),M=T("./src/crypt/decrypter.ts"),P=T("./src/demux/aacdemuxer.ts"),U=T("./src/demux/mp4demuxer.ts"),b=T("./src/demux/tsdemuxer.ts"),A=T("./src/demux/mp3demuxer.ts"),S=T("./src/remux/mp4-remuxer.ts"),E=T("./src/remux/passthrough-remuxer.ts"),x=T("./src/utils/logger.ts"),f;try{f=self.performance.now.bind(self.performance)}catch{x.logger.debug("Unable to use Performance API on this environment"),f=self.Date.now}var _=[{demux:U.default,remux:E.default},{demux:b.default,remux:S.default},{demux:P.default,remux:S.default},{demux:A.default,remux:S.default}],p=function(){function l(u,g,c,m,e){this.async=!1,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=u,this.typeSupported=g,this.config=c,this.vendor=m,this.id=e}var i=l.prototype;return i.configure=function(g){this.transmuxConfig=g,this.decrypter&&this.decrypter.reset()},i.push=function(g,c,m,e){var r=this,t=m.transmuxing;t.executeStart=f();var o=new Uint8Array(g),y=this.currentTransmuxState,h=this.transmuxConfig;e&&(this.currentTransmuxState=e);var L=e||y,R=L.contiguous,I=L.discontinuity,k=L.trackSwitch,F=L.accurateTimeOffset,W=L.timeOffset,K=L.initSegmentChange,H=h.audioCodec,Y=h.videoCodec,q=h.defaultInitPts,ee=h.duration,ae=h.initSegmentData,re=v(o,c);if(re&&re.method==="AES-128"){var se=this.getDecrypter();if(se.isSync()){var le=se.softwareDecrypt(o,re.key.buffer,re.iv.buffer);if(!le)return t.executeEnd=f(),a(m);o=new Uint8Array(le)}else return this.decryptionPromise=se.webCryptoDecrypt(o,re.key.buffer,re.iv.buffer).then(function(ce){var be=r.push(ce,null,m);return r.decryptionPromise=null,be}),this.decryptionPromise}var de=this.needsProbing(I,k);de&&this.configureTransmuxer(o),(I||k||K||de)&&this.resetInitSegment(ae,H,Y,ee,c),(I||K||de)&&this.resetInitialTimestamp(q),R||this.resetContiguity();var ue=this.transmux(o,re,W,F,m),fe=this.currentTransmuxState;return fe.contiguous=!0,fe.discontinuity=!1,fe.trackSwitch=!1,t.executeEnd=f(),ue},i.flush=function(g){var c=this,m=g.transmuxing;m.executeStart=f();var e=this.decrypter,r=this.currentTransmuxState,t=this.decryptionPromise;if(t)return t.then(function(){return c.flush(g)});var o=[],y=r.timeOffset;if(e){var h=e.flush();h&&o.push(this.push(h,null,g))}var L=this.demuxer,R=this.remuxer;if(!L||!R)return this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),m.executeEnd=f(),[a(g)];var I=L.flush(y);return s(I)?I.then(function(k){return c.flushRemux(o,k,g),o}):(this.flushRemux(o,I,g),o)},i.flushRemux=function(g,c,m){var e=c.audioTrack,r=c.videoTrack,t=c.id3Track,o=c.textTrack,y=this.currentTransmuxState,h=y.accurateTimeOffset,L=y.timeOffset;x.logger.log("[transmuxer.ts]: Flushed fragment "+m.sn+(m.part>-1?" p: "+m.part:"")+" of level "+m.level);var R=this.remuxer.remux(e,r,t,o,L,h,!0,this.id);g.push({remuxResult:R,chunkMeta:m}),m.transmuxing.executeEnd=f()},i.resetInitialTimestamp=function(g){var c=this.demuxer,m=this.remuxer;!c||!m||(c.resetTimeStamp(g),m.resetTimeStamp(g))},i.resetContiguity=function(){var g=this.demuxer,c=this.remuxer;!g||!c||(g.resetContiguity(),c.resetNextTimestamp())},i.resetInitSegment=function(g,c,m,e,r){var t=this.demuxer,o=this.remuxer;!t||!o||(t.resetInitSegment(g,c,m,e),o.resetInitSegment(g,c,m,r))},i.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},i.transmux=function(g,c,m,e,r){var t;return c&&c.method==="SAMPLE-AES"?t=this.transmuxSampleAes(g,c,m,e,r):t=this.transmuxUnencrypted(g,m,e,r),t},i.transmuxUnencrypted=function(g,c,m,e){var r=this.demuxer.demux(g,c,!1,!this.config.progressive),t=r.audioTrack,o=r.videoTrack,y=r.id3Track,h=r.textTrack,L=this.remuxer.remux(t,o,y,h,c,m,!1,this.id);return{remuxResult:L,chunkMeta:e}},i.transmuxSampleAes=function(g,c,m,e,r){var t=this;return this.demuxer.demuxSampleAes(g,c,m).then(function(o){var y=t.remuxer.remux(o.audioTrack,o.videoTrack,o.id3Track,o.textTrack,m,e,!1,t.id);return{remuxResult:y,chunkMeta:r}})},i.configureTransmuxer=function(g){for(var c=this.config,m=this.observer,e=this.typeSupported,r=this.vendor,t,o=0,y=_.length;o<y;o++)if(_[o].demux.probe(g)){t=_[o];break}t||(x.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),t={demux:U.default,remux:E.default});var h=this.demuxer,L=this.remuxer,R=t.remux,I=t.demux;(!L||!(L instanceof R))&&(this.remuxer=new R(m,c,e,r)),(!h||!(h instanceof I))&&(this.demuxer=new I(m,c,e),this.probe=I.probe)},i.needsProbing=function(g,c){return!this.demuxer||!this.remuxer||g||c},i.getDecrypter=function(){var g=this.decrypter;return g||(g=this.decrypter=new M.default(this.config)),g},l}();function v(l,i){var u=null;return l.byteLength>0&&i!=null&&i.key!=null&&i.iv!==null&&i.method!=null&&(u=i),u}var a=function(i){return{remuxResult:{},chunkMeta:i}};function s(l){return"then"in l&&l.then instanceof Function}var n=function(i,u,g,c,m){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=i,this.videoCodec=u,this.initSegmentData=g,this.duration=c,this.defaultInitPts=m},d=function(i,u,g,c,m,e){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=i,this.contiguous=u,this.accurateTimeOffset=g,this.trackSwitch=c,this.timeOffset=m,this.initSegmentChange=e}},"./src/demux/tsdemuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>d});var O=T("./src/demux/adts.ts"),D=T("./src/demux/mpegaudio.ts"),M=T("./src/demux/exp-golomb.ts"),P=T("./src/demux/sample-aes.ts"),U=T("./src/events.ts"),b=T("./src/utils/mp4-tools.ts"),A=T("./src/utils/logger.ts"),S=T("./src/errors.ts"),E=T("./src/types/demuxer.ts");function x(){return x=Object.assign?Object.assign.bind():function(l){for(var i=1;i<arguments.length;i++){var u=arguments[i];for(var g in u)Object.prototype.hasOwnProperty.call(u,g)&&(l[g]=u[g])}return l},x.apply(this,arguments)}var f=188,_=function(){function l(u,g,c){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=u,this.config=g,this.typeSupported=c}l.probe=function(g){var c=l.syncOffset(g);return c>0&&A.logger.warn("MPEG2-TS detected but first sync word found @ offset "+c),c!==-1},l.syncOffset=function(g){for(var c=Math.min(f*5,g.length-f*2)+1,m=0;m<c;){if(g[m]===71&&g[m+f]===71)return m;m++}return-1},l.createTrack=function(g,c){return{container:g==="video"||g==="audio"?"video/mp2t":void 0,type:g,id:b.RemuxerTrackIdConfig[g],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:g==="audio"?c:void 0}};var i=l.prototype;return i.resetInitSegment=function(g,c,m,e){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=l.createTrack("video"),this._audioTrack=l.createTrack("audio",e),this._id3Track=l.createTrack("id3"),this._txtTrack=l.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=c,this.videoCodec=m,this._duration=e},i.resetTimeStamp=function(){},i.resetContiguity=function(){var g=this._audioTrack,c=this._avcTrack,m=this._id3Track;g&&(g.pesData=null),c&&(c.pesData=null),m&&(m.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},i.demux=function(g,c,m,e){m===void 0&&(m=!1),e===void 0&&(e=!1),m||(this.sampleAes=null);var r,t=this._avcTrack,o=this._audioTrack,y=this._id3Track,h=this._txtTrack,L=t.pid,R=t.pesData,I=o.pid,k=y.pid,F=o.pesData,W=y.pesData,K=null,H=this.pmtParsed,Y=this._pmtId,q=g.length;if(this.remainderData&&(g=(0,b.appendUint8Array)(this.remainderData,g),q=g.length,this.remainderData=null),q<f&&!e)return this.remainderData=g,{audioTrack:o,videoTrack:t,id3Track:y,textTrack:h};var ee=Math.max(0,l.syncOffset(g));q-=(q-ee)%f,q<g.byteLength&&!e&&(this.remainderData=new Uint8Array(g.buffer,q,g.buffer.byteLength-q));for(var ae=0,re=ee;re<q;re+=f)if(g[re]===71){var se=!!(g[re+1]&64),le=((g[re+1]&31)<<8)+g[re+2],de=(g[re+3]&48)>>4,ue=void 0;if(de>1){if(ue=re+5+g[re+4],ue===re+f)continue}else ue=re+4;switch(le){case L:se&&(R&&(r=s(R))&&this.parseAVCPES(t,h,r,!1),R={data:[],size:0}),R&&(R.data.push(g.subarray(ue,re+f)),R.size+=re+f-ue);break;case I:if(se){if(F&&(r=s(F)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,r);break;case"mp3":this.parseMPEGPES(o,r);break}F={data:[],size:0}}F&&(F.data.push(g.subarray(ue,re+f)),F.size+=re+f-ue);break;case k:se&&(W&&(r=s(W))&&this.parseID3PES(y,r),W={data:[],size:0}),W&&(W.data.push(g.subarray(ue,re+f)),W.size+=re+f-ue);break;case 0:se&&(ue+=g[ue]+1),Y=this._pmtId=v(g,ue);break;case Y:{se&&(ue+=g[ue]+1);var fe=a(g,ue,this.typeSupported,m);L=fe.avc,L>0&&(t.pid=L),I=fe.audio,I>0&&(o.pid=I,o.segmentCodec=fe.segmentCodec),k=fe.id3,k>0&&(y.pid=k),K!==null&&!H&&(A.logger.log("unknown PID '"+K+"' in TS found"),K=null,re=ee-188),H=this.pmtParsed=!0;break}case 17:case 8191:break;default:K=le;break}}else ae++;ae>0&&this.observer.emit(U.Events.ERROR,U.Events.ERROR,{type:S.ErrorTypes.MEDIA_ERROR,details:S.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+ae+" TS packet/s that do not start with 0x47"}),t.pesData=R,o.pesData=F,y.pesData=W;var ce={audioTrack:o,videoTrack:t,id3Track:y,textTrack:h};return e&&this.extractRemainingSamples(ce),ce},i.flush=function(){var g=this.remainderData;this.remainderData=null;var c;return g?c=this.demux(g,-1,!1,!0):c={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(c),this.sampleAes?this.decrypt(c,this.sampleAes):c},i.extractRemainingSamples=function(g){var c=g.audioTrack,m=g.videoTrack,e=g.id3Track,r=g.textTrack,t=m.pesData,o=c.pesData,y=e.pesData,h;if(t&&(h=s(t))?(this.parseAVCPES(m,r,h,!0),m.pesData=null):m.pesData=t,o&&(h=s(o))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,h);break;case"mp3":this.parseMPEGPES(c,h);break}c.pesData=null}else o!=null&&o.size&&A.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=o;y&&(h=s(y))?(this.parseID3PES(e,h),e.pesData=null):e.pesData=y},i.demuxSampleAes=function(g,c,m){var e=this.demux(g,m,!0,!this.config.progressive),r=this.sampleAes=new P.default(this.observer,this.config,c);return this.decrypt(e,r)},i.decrypt=function(g,c){return new Promise(function(m){var e=g.audioTrack,r=g.videoTrack;e.samples&&e.segmentCodec==="aac"?c.decryptAacSamples(e.samples,0,function(){r.samples?c.decryptAvcSamples(r.samples,0,0,function(){m(g)}):m(g)}):r.samples&&c.decryptAvcSamples(r.samples,0,0,function(){m(g)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(g,c,m,e){var r=this,t=this.parseAVCNALu(g,m.data),o=!1,y=this.avcSample,h,L=!1;m.data=null,y&&t.length&&!g.audFound&&(n(y,g),y=this.avcSample=p(!1,m.pts,m.dts,"")),t.forEach(function(R){switch(R.type){case 1:{h=!0,y||(y=r.avcSample=p(!0,m.pts,m.dts,"")),o&&(y.debug+="NDR "),y.frame=!0;var I=R.data;if(L&&I.length>4){var k=new M.default(I).readSliceType();(k===2||k===4||k===7||k===9)&&(y.key=!0)}break}case 5:h=!0,y||(y=r.avcSample=p(!0,m.pts,m.dts,"")),o&&(y.debug+="IDR "),y.key=!0,y.frame=!0;break;case 6:{h=!0,o&&y&&(y.debug+="SEI "),(0,b.parseSEIMessageFromNALu)(R.data,1,m.pts,c.samples);break}case 7:if(h=!0,L=!0,o&&y&&(y.debug+="SPS "),!g.sps){var F=new M.default(R.data),W=F.readSPS();g.width=W.width,g.height=W.height,g.pixelRatio=W.pixelRatio,g.sps=[R.data],g.duration=r._duration;for(var K=R.data.subarray(1,4),H="avc1.",Y=0;Y<3;Y++){var q=K[Y].toString(16);q.length<2&&(q="0"+q),H+=q}g.codec=H}break;case 8:h=!0,o&&y&&(y.debug+="PPS "),g.pps||(g.pps=[R.data]);break;case 9:h=!1,g.audFound=!0,y&&n(y,g),y=r.avcSample=p(!1,m.pts,m.dts,o?"AUD ":"");break;case 12:h=!0;break;default:h=!1,y&&(y.debug+="unknown NAL "+R.type+" ");break}if(y&&h){var ee=y.units;ee.push(R)}}),e&&y&&(n(y,g),this.avcSample=null)},i.getLastNalUnit=function(g){var c,m=this.avcSample,e;if((!m||m.units.length===0)&&(m=g[g.length-1]),(c=m)!==null&&c!==void 0&&c.units){var r=m.units;e=r[r.length-1]}return e},i.parseAVCNALu=function(g,c){var m=c.byteLength,e=g.naluState||0,r=e,t=[],o=0,y,h,L,R=-1,I=0;for(e===-1&&(R=0,I=c[0]&31,e=0,o=1);o<m;){if(y=c[o++],!e){e=y?0:1;continue}if(e===1){e=y?0:2;continue}if(!y)e=3;else if(y===1){if(R>=0){var k={data:c.subarray(R,o-e-1),type:I};t.push(k)}else{var F=this.getLastNalUnit(g.samples);if(F&&(r&&o<=4-r&&F.state&&(F.data=F.data.subarray(0,F.data.byteLength-r)),h=o-e-1,h>0)){var W=new Uint8Array(F.data.byteLength+h);W.set(F.data,0),W.set(c.subarray(0,h),F.data.byteLength),F.data=W,F.state=0}}o<m?(L=c[o]&31,R=o,I=L,e=0):e=-1}else e=0}if(R>=0&&e>=0){var K={data:c.subarray(R,m),type:I,state:e};t.push(K)}if(t.length===0){var H=this.getLastNalUnit(g.samples);if(H){var Y=new Uint8Array(H.data.byteLength+c.byteLength);Y.set(H.data,0),Y.set(c,H.data.byteLength),H.data=Y}}return g.naluState=e,t},i.parseAACPES=function(g,c){var m=0,e=this.aacOverFlow,r=c.data;if(e){this.aacOverFlow=null;var t=e.missing,o=e.sample.unit.byteLength;if(t===-1){var y=new Uint8Array(o+r.byteLength);y.set(e.sample.unit,0),y.set(r,o),r=y}else{var h=o-t;e.sample.unit.set(r.subarray(0,t),h),g.samples.push(e.sample),m=e.missing}}var L,R;for(L=m,R=r.length;L<R-1&&!O.isHeader(r,L);L++);if(L!==m){var I,k;if(L<R-1?(I="AAC PES did not start with ADTS header,offset:"+L,k=!1):(I="no ADTS header found in AAC PES",k=!0),A.logger.warn("parsing error:"+I),this.observer.emit(U.Events.ERROR,U.Events.ERROR,{type:S.ErrorTypes.MEDIA_ERROR,details:S.ErrorDetails.FRAG_PARSING_ERROR,fatal:k,reason:I}),k)return}O.initTrackConfig(g,this.observer,r,L,this.audioCodec);var F;if(c.pts!==void 0)F=c.pts;else if(e){var W=O.getFrameDuration(g.samplerate);F=e.sample.pts+W}else{A.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var K=0,H;L<R;)if(H=O.appendFrame(g,r,L,F,K),L+=H.length,H.missing){this.aacOverFlow=H;break}else for(K++;L<R-1&&!O.isHeader(r,L);L++);},i.parseMPEGPES=function(g,c){var m=c.data,e=m.length,r=0,t=0,o=c.pts;if(o===void 0){A.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;t<e;)if(D.isHeader(m,t)){var y=D.appendFrame(g,m,t,o,r);if(y)t+=y.length,r++;else break}else t++},i.parseID3PES=function(g,c){if(c.pts===void 0){A.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var m=x({},c,{type:this._avcTrack?E.MetadataSchema.emsg:E.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});g.samples.push(m)},l}();function p(l,i,u,g){return{key:l,frame:!1,pts:i,dts:u,units:[],debug:g,length:0}}function v(l,i){return(l[i+10]&31)<<8|l[i+11]}function a(l,i,u,g){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},m=(l[i+1]&15)<<8|l[i+2],e=i+3+m-4,r=(l[i+10]&15)<<8|l[i+11];for(i+=12+r;i<e;){var t=(l[i+1]&31)<<8|l[i+2];switch(l[i]){case 207:if(!g){A.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=t);break;case 21:c.id3===-1&&(c.id3=t);break;case 219:if(!g){A.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=t);break;case 3:case 4:u.mpeg!==!0&&u.mp3!==!0?A.logger.log("MPEG audio found, not supported in this browser"):c.audio===-1&&(c.audio=t,c.segmentCodec="mp3");break;case 36:A.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((l[i+3]&15)<<8|l[i+4])+5}return c}function s(l){var i=0,u,g,c,m,e,r=l.data;if(!l||l.size===0)return null;for(;r[0].length<19&&r.length>1;){var t=new Uint8Array(r[0].length+r[1].length);t.set(r[0]),t.set(r[1],r[0].length),r[0]=t,r.splice(1,1)}u=r[0];var o=(u[0]<<16)+(u[1]<<8)+u[2];if(o===1){if(g=(u[4]<<8)+u[5],g&&g>l.size-6)return null;var y=u[7];y&192&&(m=(u[9]&14)*536870912+(u[10]&255)*4194304+(u[11]&254)*16384+(u[12]&255)*128+(u[13]&254)/2,y&64?(e=(u[14]&14)*536870912+(u[15]&255)*4194304+(u[16]&254)*16384+(u[17]&255)*128+(u[18]&254)/2,m-e>54e5&&(A.logger.warn(Math.round((m-e)/9e4)+"s delta between PTS and DTS, align them"),m=e)):e=m),c=u[8];var h=c+9;if(l.size<=h)return null;l.size-=h;for(var L=new Uint8Array(l.size),R=0,I=r.length;R<I;R++){u=r[R];var k=u.byteLength;if(h)if(h>k){h-=k;continue}else u=u.subarray(h),k-=h,h=0;L.set(u,i),i+=k}return g&&(g-=c+3),{data:L,pts:m,dts:e,len:g}}return null}function n(l,i){if(l.units.length&&l.frame){if(l.pts===void 0){var u=i.samples,g=u.length;if(g){var c=u[g-1];l.pts=c.pts,l.dts=c.dts}else{i.dropped++;return}}i.samples.push(l)}l.debug.length&&A.logger.log(l.pts+"/"+l.dts+":"+l.debug)}let d=_},"./src/demux/webworkify-webpack.js":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>f});var O=function(){var p=ENTRY_MODULE,v={},a=function n(d){var l=v[d];if(l!==void 0)return l.exports;var i=v[d]={exports:{}};return p[d].call(i.exports,i,i.exports,n),i.exports};a.m=p,function(){a.n=function(n){var d=n&&n.__esModule?function(){return n.default}:function(){return n};return a.d(d,{a:d}),d}}(),function(){a.d=function(n,d){for(var l in d)a.o(d,l)&&!a.o(n,l)&&Object.defineProperty(n,l,{enumerable:!0,get:d[l]})}}(),function(){a.o=function(n,d){return Object.prototype.hasOwnProperty.call(n,d)}}(),function(){a.r=function(n){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}}();var s=a(ENTRY_MODULE);return s.default||s},D=O.toString().split("ENTRY_MODULE"),M="[\\.|\\-|\\+|\\w|/|@]+",P="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+M+").*?\\)";function U(_){return(_+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function b(_){return!isNaN(1*_)}function A(_,p,v){var a={};a[v]=[];var s=p.toString().replace(/^"[^"]+"/,"function"),n=s.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||s.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!n)return a;for(var d=n[1],l=new RegExp("(\\\\n|\\W)"+U(d)+P,"g"),i;i=l.exec(s);)i[3]!=="dll-reference"&&a[v].push(i[3]);for(l=new RegExp("\\("+U(d)+'\\("(dll-reference\\s('+M+'))"\\)\\)'+P,"g");i=l.exec(s);)_[i[2]]||(a[v].push(i[1]),_[i[2]]=T(i[1]).m),a[i[2]]=a[i[2]]||[],a[i[2]].push(i[4]);for(var u=Object.keys(a),g=0;g<u.length;g++)for(var c=0;c<a[u[g]].length;c++)b(a[u[g]][c])&&(a[u[g]][c]=1*a[u[g]][c]);return a}function S(_){var p=Object.keys(_);return p.reduce(function(v,a){return v||_[a].length>0},!1)}function E(_,p){for(var v={main:[p]},a={main:[]},s={main:{}};S(v);)for(var n=Object.keys(v),d=0;d<n.length;d++){var l=n[d],i=v[l],u=i.pop();if(s[l]=s[l]||{},!(s[l][u]||!_[l][u])){s[l][u]=!0,a[l]=a[l]||[],a[l].push(u);for(var g=A(_,_[l][u],l),c=Object.keys(g),m=0;m<c.length;m++)v[c[m]]=v[c[m]]||[],v[c[m]]=v[c[m]].concat(g[c[m]])}}return a}function x(_,p,v,a){var s=_[a].map(function(n){return'"'+n+'": '+p[a][n].toString().replace(/^"[^"]+"/,"function")}).join(",");return D[0]+"{"+s+"}"+D[1]+'"'+v+'"'+D[2]}function f(_,p){p=p||{};var v={main:T.m},a=p.all?{main:Object.keys(v.main)}:E(v,_),s="";Object.keys(a).filter(function(u){return u!=="main"}).forEach(function(u){for(var g=0;a[u][g];)g++;a[u].push(g),v[u][g]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",s=s+("var "+u+" = ("+x(a,v,g,modules)+`)();
|
|
21
|
+
`)}),s=s+("new (("+x(a,v,_,"main")+")())(self);");var n=new window.Blob([s],{type:"text/javascript"}),d=window.URL||window.webkitURL||window.mozURL||window.msURL,l=d.createObjectURL(n),i=new window.Worker(l);return i.objectURL=l,i}},"./src/errors.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{ErrorDetails:()=>D,ErrorTypes:()=>O});var O;(function(M){M.NETWORK_ERROR="networkError",M.MEDIA_ERROR="mediaError",M.KEY_SYSTEM_ERROR="keySystemError",M.MUX_ERROR="muxError",M.OTHER_ERROR="otherError"})(O||(O={}));var D;(function(M){M.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",M.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",M.KEY_SYSTEM_NO_SESSION="keySystemNoSession",M.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",M.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",M.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",M.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",M.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",M.MANIFEST_LOAD_ERROR="manifestLoadError",M.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",M.MANIFEST_PARSING_ERROR="manifestParsingError",M.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",M.LEVEL_EMPTY_ERROR="levelEmptyError",M.LEVEL_LOAD_ERROR="levelLoadError",M.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",M.LEVEL_SWITCH_ERROR="levelSwitchError",M.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",M.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",M.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",M.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",M.FRAG_LOAD_ERROR="fragLoadError",M.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",M.FRAG_DECRYPT_ERROR="fragDecryptError",M.FRAG_PARSING_ERROR="fragParsingError",M.REMUX_ALLOC_ERROR="remuxAllocError",M.KEY_LOAD_ERROR="keyLoadError",M.KEY_LOAD_TIMEOUT="keyLoadTimeOut",M.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",M.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",M.BUFFER_APPEND_ERROR="bufferAppendError",M.BUFFER_APPENDING_ERROR="bufferAppendingError",M.BUFFER_STALLED_ERROR="bufferStalledError",M.BUFFER_FULL_ERROR="bufferFullError",M.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",M.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",M.INTERNAL_EXCEPTION="internalException",M.INTERNAL_ABORTED="aborted",M.UNKNOWN="unknown"})(D||(D={}))},"./src/events.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{Events:()=>O});var O;(function(D){D.MEDIA_ATTACHING="hlsMediaAttaching",D.MEDIA_ATTACHED="hlsMediaAttached",D.MEDIA_DETACHING="hlsMediaDetaching",D.MEDIA_DETACHED="hlsMediaDetached",D.BUFFER_RESET="hlsBufferReset",D.BUFFER_CODECS="hlsBufferCodecs",D.BUFFER_CREATED="hlsBufferCreated",D.BUFFER_APPENDING="hlsBufferAppending",D.BUFFER_APPENDED="hlsBufferAppended",D.BUFFER_EOS="hlsBufferEos",D.BUFFER_FLUSHING="hlsBufferFlushing",D.BUFFER_FLUSHED="hlsBufferFlushed",D.MANIFEST_LOADING="hlsManifestLoading",D.MANIFEST_LOADED="hlsManifestLoaded",D.MANIFEST_PARSED="hlsManifestParsed",D.LEVEL_SWITCHING="hlsLevelSwitching",D.LEVEL_SWITCHED="hlsLevelSwitched",D.LEVEL_LOADING="hlsLevelLoading",D.LEVEL_LOADED="hlsLevelLoaded",D.LEVEL_UPDATED="hlsLevelUpdated",D.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",D.LEVELS_UPDATED="hlsLevelsUpdated",D.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",D.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",D.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",D.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",D.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",D.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",D.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",D.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",D.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",D.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",D.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",D.CUES_PARSED="hlsCuesParsed",D.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",D.INIT_PTS_FOUND="hlsInitPtsFound",D.FRAG_LOADING="hlsFragLoading",D.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",D.FRAG_LOADED="hlsFragLoaded",D.FRAG_DECRYPTED="hlsFragDecrypted",D.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",D.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",D.FRAG_PARSING_METADATA="hlsFragParsingMetadata",D.FRAG_PARSED="hlsFragParsed",D.FRAG_BUFFERED="hlsFragBuffered",D.FRAG_CHANGED="hlsFragChanged",D.FPS_DROP="hlsFpsDrop",D.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",D.ERROR="hlsError",D.DESTROYING="hlsDestroying",D.KEY_LOADING="hlsKeyLoading",D.KEY_LOADED="hlsKeyLoaded",D.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",D.BACK_BUFFER_REACHED="hlsBackBufferReached"})(O||(O={}))},"./src/hls.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>g});var O=T("./node_modules/url-toolkit/src/url-toolkit.js"),D=T.n(O),M=T("./src/loader/playlist-loader.ts"),P=T("./src/controller/id3-track-controller.ts"),U=T("./src/controller/latency-controller.ts"),b=T("./src/controller/level-controller.ts"),A=T("./src/controller/fragment-tracker.ts"),S=T("./src/loader/key-loader.ts"),E=T("./src/controller/stream-controller.ts"),x=T("./src/is-supported.ts"),f=T("./src/utils/logger.ts"),_=T("./src/config.ts"),p=T("./node_modules/eventemitter3/index.js"),v=T.n(p),a=T("./src/events.ts"),s=T("./src/errors.ts"),n=T("./src/types/level.ts");function d(c,m){for(var e=0;e<m.length;e++){var r=m[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(c,i(r.key),r)}}function l(c,m,e){return m&&d(c.prototype,m),e&&d(c,e),Object.defineProperty(c,"prototype",{writable:!1}),c}function i(c){var m=u(c,"string");return typeof m=="symbol"?m:String(m)}function u(c,m){if(typeof c!="object"||c===null)return c;var e=c[Symbol.toPrimitive];if(e!==void 0){var r=e.call(c,m||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(c)}var g=function(){c.isSupported=function(){return(0,x.isSupported)()};function c(e){e===void 0&&(e={}),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._maxHdcpLevel=null,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 r=this.config=(0,_.mergeConfig)(c.DefaultConfig,e);this.userConfig=e,(0,f.enableLogs)(r.debug,"Hls instance"),this._autoLevelCapping=-1,r.progressive&&(0,_.enableStreamingMode)(r);var t=r.abrController,o=r.bufferController,y=r.capLevelController,h=r.fpsController,L=this.abrController=new t(this),R=this.bufferController=new o(this),I=this.capLevelController=new y(this),k=new h(this),F=new M.default(this),W=new P.default(this),K=this.levelController=new b.default(this),H=new A.FragmentTracker(this),Y=new S.default(this.config),q=this.streamController=new E.default(this,H,Y);I.setStreamController(q),k.setStreamController(q);var ee=[F,K,q];this.networkControllers=ee;var ae=[L,R,I,k,W,H];this.audioTrackController=this.createController(r.audioTrackController,ee);var re=r.audioStreamController;re&&ee.push(new re(this,H,Y)),this.subtitleTrackController=this.createController(r.subtitleTrackController,ee);var se=r.subtitleStreamController;se&&ee.push(new se(this,H,Y)),this.createController(r.timelineController,ae),Y.emeController=this.emeController=this.createController(r.emeController,ae),this.cmcdController=this.createController(r.cmcdController,ae),this.latencyController=this.createController(U.default,ae),this.coreComponents=ae}var m=c.prototype;return m.createController=function(r,t){if(r){var o=new r(this);return t&&t.push(o),o}return null},m.on=function(r,t,o){o===void 0&&(o=this),this._emitter.on(r,t,o)},m.once=function(r,t,o){o===void 0&&(o=this),this._emitter.once(r,t,o)},m.removeAllListeners=function(r){this._emitter.removeAllListeners(r)},m.off=function(r,t,o,y){o===void 0&&(o=this),this._emitter.off(r,t,o,y)},m.listeners=function(r){return this._emitter.listeners(r)},m.emit=function(r,t,o){return this._emitter.emit(r,t,o)},m.trigger=function(r,t){if(this.config.debug)return this.emit(r,r,t);try{return this.emit(r,r,t)}catch(o){f.logger.error("An internal error happened while handling event "+r+'. Error message: "'+o.message+'". Here is a stacktrace:',o),this.trigger(a.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:r,error:o})}return!1},m.listenerCount=function(r){return this._emitter.listenerCount(r)},m.destroy=function(){f.logger.log("destroy"),this.trigger(a.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(r){return r.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(r){return r.destroy()}),this.coreComponents.length=0},m.attachMedia=function(r){f.logger.log("attachMedia"),this._media=r,this.trigger(a.Events.MEDIA_ATTACHING,{media:r})},m.detachMedia=function(){f.logger.log("detachMedia"),this.trigger(a.Events.MEDIA_DETACHING,void 0),this._media=null},m.loadSource=function(r){this.stopLoad();var t=this.media,o=this.url,y=this.url=O.buildAbsoluteURL(self.location.href,r,{alwaysNormalize:!0});f.logger.log("loadSource:"+y),t&&o&&o!==y&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(t)),this.trigger(a.Events.MANIFEST_LOADING,{url:r})},m.startLoad=function(r){r===void 0&&(r=-1),f.logger.log("startLoad("+r+")"),this.networkControllers.forEach(function(t){t.startLoad(r)})},m.stopLoad=function(){f.logger.log("stopLoad"),this.networkControllers.forEach(function(r){r.stopLoad()})},m.swapAudioCodec=function(){f.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},m.recoverMediaError=function(){f.logger.log("recoverMediaError");var r=this._media;this.detachMedia(),r&&this.attachMedia(r)},m.removeLevel=function(r,t){t===void 0&&(t=0),this.levelController.removeLevel(r,t)},l(c,[{key:"levels",get:function(){var r=this.levelController.levels;return r||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(r){f.logger.log("set currentLevel:"+r),this.loadLevel=r,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(r){f.logger.log("set nextLevel:"+r),this.levelController.manualLevel=r,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(r){f.logger.log("set loadLevel:"+r),this.levelController.manualLevel=r}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(r){this.levelController.nextLoadLevel=r}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(r){f.logger.log("set firstLevel:"+r),this.levelController.firstLevel=r}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(r){f.logger.log("set startLevel:"+r),r!==-1&&(r=Math.max(r,this.minAutoLevel)),this.levelController.startLevel=r}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(r){var t=!!r;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(r){this._autoLevelCapping!==r&&(f.logger.log("set autoLevelCapping:"+r),this._autoLevelCapping=r)}},{key:"bandwidthEstimate",get:function(){var r=this.abrController.bwEstimator;return r?r.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(r){n.HdcpLevels.indexOf(r)>-1&&(this._maxHdcpLevel=r)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var r=this.levels,t=this.config.minAutoBitrate;if(!r)return 0;for(var o=r.length,y=0;y<o;y++)if(r[y].maxBitrate>=t)return y;return 0}},{key:"maxAutoLevel",get:function(){var r=this.levels,t=this.autoLevelCapping,o=this.maxHdcpLevel,y;if(t===-1&&r&&r.length?y=r.length-1:y=t,o)for(var h=y;h--;){var L=r[h].attrs["HDCP-LEVEL"];if(L&&L<=o)return h}return y}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(r){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,r)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var r=this.audioTrackController;return r?r.audioTracks:[]}},{key:"audioTrack",get:function(){var r=this.audioTrackController;return r?r.audioTrack:-1},set:function(r){var t=this.audioTrackController;t&&(t.audioTrack=r)}},{key:"subtitleTracks",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTrack:-1},set:function(r){var t=this.subtitleTrackController;t&&(t.subtitleTrack=r)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var r=this.subtitleTrackController;return r?r.subtitleDisplay:!1},set:function(r){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=r)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(r){this.config.lowLatencyMode=r}},{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.3.1"}},{key:"Events",get:function(){return a.Events}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return c.defaultConfig?c.defaultConfig:_.hlsDefaultConfig},set:function(r){c.defaultConfig=r}}]),c}();g.defaultConfig=void 0},"./src/is-supported.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{changeTypeSupported:()=>P,isSupported:()=>M});var O=T("./src/utils/mediasource-helper.ts");function D(){return self.SourceBuffer||self.WebKitSourceBuffer}function M(){var U=(0,O.getMediaSource)();if(!U)return!1;var b=D(),A=U&&typeof U.isTypeSupported=="function"&&U.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),S=!b||b.prototype&&typeof b.prototype.appendBuffer=="function"&&typeof b.prototype.remove=="function";return!!A&&!!S}function P(){var U,b=D();return typeof(b==null||(U=b.prototype)===null||U===void 0?void 0:U.changeType)=="function"}},"./src/loader/date-range.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{DateRange:()=>x,DateRangeAttribute:()=>E});var O=T("./src/polyfills/number.ts"),D=T("./src/utils/attr-list.ts"),M=T("./src/utils/logger.ts");function P(){return P=Object.assign?Object.assign.bind():function(f){for(var _=1;_<arguments.length;_++){var p=arguments[_];for(var v in p)Object.prototype.hasOwnProperty.call(p,v)&&(f[v]=p[v])}return f},P.apply(this,arguments)}function U(f,_){for(var p=0;p<_.length;p++){var v=_[p];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(f,A(v.key),v)}}function b(f,_,p){return _&&U(f.prototype,_),p&&U(f,p),Object.defineProperty(f,"prototype",{writable:!1}),f}function A(f){var _=S(f,"string");return typeof _=="symbol"?_:String(_)}function S(f,_){if(typeof f!="object"||f===null)return f;var p=f[Symbol.toPrimitive];if(p!==void 0){var v=p.call(f,_||"default");if(typeof v!="object")return v;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(f)}var E;(function(f){f.ID="ID",f.CLASS="CLASS",f.START_DATE="START-DATE",f.DURATION="DURATION",f.END_DATE="END-DATE",f.END_ON_NEXT="END-ON-NEXT",f.PLANNED_DURATION="PLANNED-DURATION",f.SCTE35_OUT="SCTE35-OUT",f.SCTE35_IN="SCTE35-IN"})(E||(E={}));var x=function(){function f(_,p){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,p){var v=p.attr;for(var a in v)if(Object.prototype.hasOwnProperty.call(_,a)&&_[a]!==v[a]){M.logger.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+_.ID+'"'),this._badValueForSameId=a;break}_=P(new D.AttrList({}),v,_)}if(this.attr=_,this._startDate=new Date(_[E.START_DATE]),E.END_DATE in this.attr){var s=new Date(this.attr[E.END_DATE]);(0,O.isFiniteNumber)(s.getTime())&&(this._endDate=s)}}return b(f,[{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 p=this.duration;return p!==null?new Date(this._startDate.getTime()+p*1e3):null}},{key:"duration",get:function(){if(E.DURATION in this.attr){var p=this.attr.decimalFloatingPoint(E.DURATION);if((0,O.isFiniteNumber)(p))return p}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return E.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(E.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(E.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,O.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),f}()},"./src/loader/fragment-loader.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{LoadError:()=>p,default:()=>f});var O=T("./src/polyfills/number.ts"),D=T("./src/errors.ts");function M(v,a){v.prototype=Object.create(a.prototype),v.prototype.constructor=v,S(v,a)}function P(v){var a=typeof Map=="function"?new Map:void 0;return P=function(n){if(n===null||!A(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a!="undefined"){if(a.has(n))return a.get(n);a.set(n,d)}function d(){return U(n,arguments,E(this).constructor)}return d.prototype=Object.create(n.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),S(d,n)},P(v)}function U(v,a,s){return b()?U=Reflect.construct.bind():U=function(d,l,i){var u=[null];u.push.apply(u,l);var g=Function.bind.apply(d,u),c=new g;return i&&S(c,i.prototype),c},U.apply(null,arguments)}function b(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function A(v){return Function.toString.call(v).indexOf("[native code]")!==-1}function S(v,a){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,d){return n.__proto__=d,n},S(v,a)}function E(v){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},E(v)}var x=Math.pow(2,17),f=function(){function v(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var a=v.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(n,d){var l=this,i=n.url;if(!i)return Promise.reject(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,networkDetails:null},"Fragment does not have a "+(i?"part list":"url")));this.abort();var u=this.config,g=u.fLoader,c=u.loader;return new Promise(function(m,e){l.loader&&l.loader.destroy();var r=l.loader=n.loader=g?new g(u):new c(u),t=_(n),o={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:n.sn==="initSegment"?1/0:x};n.stats=r.stats,r.load(t,o,{onSuccess:function(h,L,R,I){l.resetLoader(n,r);var k=h.data;R.resetIV&&n.decryptdata&&(n.decryptdata.iv=new Uint8Array(k.slice(0,16)),k=k.slice(16)),m({frag:n,part:null,payload:k,networkDetails:I})},onError:function(h,L,R){l.resetLoader(n,r),e(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,response:h,networkDetails:R}))},onAbort:function(h,L,R){l.resetLoader(n,r),e(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,networkDetails:R}))},onTimeout:function(h,L,R){l.resetLoader(n,r),e(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,networkDetails:R}))},onProgress:function(h,L,R,I){d&&d({frag:n,part:null,payload:R,networkDetails:I})}})})},a.loadPart=function(n,d,l){var i=this;this.abort();var u=this.config,g=u.fLoader,c=u.loader;return new Promise(function(m,e){i.loader&&i.loader.destroy();var r=i.loader=n.loader=g?new g(u):new c(u),t=_(n,d),o={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:x};d.stats=r.stats,r.load(t,o,{onSuccess:function(h,L,R,I){i.resetLoader(n,r),i.updateStatsFromPart(n,d);var k={frag:n,part:d,payload:h.data,networkDetails:I};l(k),m(k)},onError:function(h,L,R){i.resetLoader(n,r),e(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,part:d,response:h,networkDetails:R}))},onAbort:function(h,L,R){n.stats.aborted=d.stats.aborted,i.resetLoader(n,r),e(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,part:d,networkDetails:R}))},onTimeout:function(h,L,R){i.resetLoader(n,r),e(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,part:d,networkDetails:R}))}})})},a.updateStatsFromPart=function(n,d){var l=n.stats,i=d.stats,u=i.total;if(l.loaded+=i.loaded,u){var g=Math.round(n.duration/d.duration),c=Math.min(Math.round(l.loaded/u),g),m=g-c,e=m*Math.round(l.loaded/c);l.total=l.loaded+e}else l.total=Math.max(l.loaded,l.total);var r=l.loading,t=i.loading;r.start?r.first+=t.first-t.start:(r.start=t.start,r.first=t.first),r.end=t.end},a.resetLoader=function(n,d){n.loader=null,this.loader===d&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),d.destroy()},v}();function _(v,a){a===void 0&&(a=null);var s=a||v,n={frag:v,part:a,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},d=s.byteRangeStartOffset,l=s.byteRangeEndOffset;if((0,O.isFiniteNumber)(d)&&(0,O.isFiniteNumber)(l)){var i,u=d,g=l;if(v.sn==="initSegment"&&((i=v.decryptdata)===null||i===void 0?void 0:i.method)==="AES-128"){var c=l-d;c%16&&(g=l+(16-c%16)),d!==0&&(n.resetIV=!0,u=d-16)}n.rangeStart=u,n.rangeEnd=g}return n}var p=function(v){M(a,v);function a(s){for(var n,d=arguments.length,l=new Array(d>1?d-1:0),i=1;i<d;i++)l[i-1]=arguments[i];return n=v.call.apply(v,[this].concat(l))||this,n.data=void 0,n.data=s,n}return a}(P(Error))},"./src/loader/fragment.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{BaseSegment:()=>_,ElementaryStreamTypes:()=>f,Fragment:()=>p,Part:()=>v});var O=T("./src/polyfills/number.ts"),D=T("./node_modules/url-toolkit/src/url-toolkit.js"),M=T.n(D),P=T("./src/loader/load-stats.ts");function U(a,s){a.prototype=Object.create(s.prototype),a.prototype.constructor=a,b(a,s)}function b(a,s){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(d,l){return d.__proto__=l,d},b(a,s)}function A(a,s){for(var n=0;n<s.length;n++){var d=s[n];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,E(d.key),d)}}function S(a,s,n){return s&&A(a.prototype,s),n&&A(a,n),Object.defineProperty(a,"prototype",{writable:!1}),a}function E(a){var s=x(a,"string");return typeof s=="symbol"?s:String(s)}function x(a,s){if(typeof a!="object"||a===null)return a;var n=a[Symbol.toPrimitive];if(n!==void 0){var d=n.call(a,s||"default");if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(a)}var f;(function(a){a.AUDIO="audio",a.VIDEO="video",a.AUDIOVIDEO="audiovideo"})(f||(f={}));var _=function(){function a(n){var d;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(d={},d[f.AUDIO]=null,d[f.VIDEO]=null,d[f.AUDIOVIDEO]=null,d),this.baseurl=n}var s=a.prototype;return s.setByteRange=function(d,l){var i=d.split("@",2),u=[];i.length===1?u[0]=l?l.byteRangeEndOffset:0:u[0]=parseInt(i[1]),u[1]=parseInt(i[0])+u[0],this._byteRange=u},S(a,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=(0,D.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(d){this._url=d}}]),a}(),p=function(a){U(s,a);function s(d,l){var i;return i=a.call(this,l)||this,i._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.appendedPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new P.LoadStats,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.type=d,i}var n=s.prototype;return n.setKeyFormat=function(l){if(this.levelkeys){var i=this.levelkeys[l];i&&!this._decryptdata&&(this._decryptdata=i.getDecryptData(this.sn))}},n.abortRequests=function(){var l,i;(l=this.loader)===null||l===void 0||l.abort(),(i=this.keyLoader)===null||i===void 0||i.abort()},n.setElementaryStreamInfo=function(l,i,u,g,c,m){m===void 0&&(m=!1);var e=this.elementaryStreams,r=e[l];if(!r){e[l]={startPTS:i,endPTS:u,startDTS:g,endDTS:c,partial:m};return}r.startPTS=Math.min(r.startPTS,i),r.endPTS=Math.max(r.endPTS,u),r.startDTS=Math.min(r.startDTS,g),r.endDTS=Math.max(r.endDTS,c)},n.clearElementaryStreamInfo=function(){var l=this.elementaryStreams;l[f.AUDIO]=null,l[f.VIDEO]=null,l[f.AUDIOVIDEO]=null},S(s,[{key:"decryptdata",get:function(){var l=this.levelkeys;if(!l&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var i=this.levelkeys.identity;if(i)this._decryptdata=i.getDecryptData(this.sn);else{var u=Object.keys(this.levelkeys);if(u.length===1)return this._decryptdata=this.levelkeys[u[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!(0,O.isFiniteNumber)(this.programDateTime))return null;var l=(0,O.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+l*1e3}},{key:"encrypted",get:function(){var l;if((l=this._decryptdata)!==null&&l!==void 0&&l.encrypted)return!0;if(this.levelkeys){var i=Object.keys(this.levelkeys),u=i.length;if(u>1||u===1&&this.levelkeys[i[0]].encrypted)return!0}return!1}}]),s}(_),v=function(a){U(s,a);function s(n,d,l,i,u){var g;g=a.call(this,l)||this,g.fragOffset=0,g.duration=0,g.gap=!1,g.independent=!1,g.relurl=void 0,g.fragment=void 0,g.index=void 0,g.stats=new P.LoadStats,g.duration=n.decimalFloatingPoint("DURATION"),g.gap=n.bool("GAP"),g.independent=n.bool("INDEPENDENT"),g.relurl=n.enumeratedString("URI"),g.fragment=d,g.index=i;var c=n.enumeratedString("BYTERANGE");return c&&g.setByteRange(c,u),u&&(g.fragOffset=u.fragOffset+u.duration),g}return S(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 d=this.elementaryStreams;return!!(d.audio||d.video||d.audiovideo)}}]),s}(_)},"./src/loader/key-loader.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>M});var O=T("./src/errors.ts"),D=T("./src/loader/fragment-loader.ts"),M=function(){function P(b){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=b}var U=P.prototype;return U.abort=function(){for(var A in this.keyUriToKeyInfo){var S=this.keyUriToKeyInfo[A].loader;S&&S.abort()}},U.detach=function(){for(var A in this.keyUriToKeyInfo){var S=this.keyUriToKeyInfo[A];(S.mediaKeySessionContext||S.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[A]}},U.destroy=function(){this.detach();for(var A in this.keyUriToKeyInfo){var S=this.keyUriToKeyInfo[A].loader;S&&S.destroy()}this.keyUriToKeyInfo={}},U.createKeyLoadError=function(A,S,E,x){return S===void 0&&(S=O.ErrorDetails.KEY_LOAD_ERROR),new D.LoadError({type:O.ErrorTypes.NETWORK_ERROR,details:S,fatal:!1,frag:A,networkDetails:E})},U.loadClear=function(A,S){var E=this;if(this.emeController&&this.config.emeEnabled)for(var x=A.sn,f=A.cc,_=function(s){var n=S[s];if(f<=n.cc&&(x==="initSegment"||x<n.sn))return E.emeController.selectKeySystemFormat(n).then(function(d){n.setKeyFormat(d)}),"break"},p=0;p<S.length;p++){var v=_(p);if(v==="break")break}},U.load=function(A){var S=this;return!A.decryptdata&&A.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(A).then(function(E){return S.loadInternal(A,E)}):this.loadInternal(A)},U.loadInternal=function(A,S){var E,x;S&&A.setKeyFormat(S);var f=A.decryptdata;if(!f){var _=S?"Expected frag.decryptdata to be defined after setting format "+S:"Missing decryption data on fragment in onKeyLoading";return Promise.reject(this.createKeyLoadError(A,O.ErrorDetails.KEY_LOAD_ERROR,null,_))}var p=f.uri;if(!p)return Promise.reject(this.createKeyLoadError(A,O.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+p+'"'));var v=this.keyUriToKeyInfo[p];if((E=v)!==null&&E!==void 0&&E.decryptdata.key)return f.key=v.decryptdata.key,Promise.resolve({frag:A,keyInfo:v});if((x=v)!==null&&x!==void 0&&x.keyLoadPromise){var a;switch((a=v.mediaKeySessionContext)===null||a===void 0?void 0:a.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return v.keyLoadPromise}}switch(v=this.keyUriToKeyInfo[p]={decryptdata:f,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},f.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return f.keyFormat==="identity"?this.loadKeyHTTP(v,A):this.loadKeyEME(v,A);case"AES-128":return this.loadKeyHTTP(v,A);default:return Promise.reject(this.createKeyLoadError(A,O.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+f.method+'"'))}},U.loadKeyEME=function(A,S){var E={frag:S,keyInfo:A};if(this.emeController&&this.config.emeEnabled){var x=this.emeController.loadKey(E);if(x)return(A.keyLoadPromise=x.then(function(f){return A.mediaKeySessionContext=f,E})).catch(function(f){throw A.keyLoadPromise=null,f})}return Promise.resolve(E)},U.loadKeyHTTP=function(A,S){var E=this,x=this.config,f=x.loader,_=new f(x);return S.keyLoader=A.loader=_,A.keyLoadPromise=new Promise(function(p,v){var a={keyInfo:A,frag:S,responseType:"arraybuffer",url:A.decryptdata.uri},s={timeout:x.fragLoadingTimeOut,maxRetry:0,retryDelay:x.fragLoadingRetryDelay,maxRetryDelay:x.fragLoadingMaxRetryTimeout,highWaterMark:0},n={onSuccess:function(l,i,u,g){var c=u.frag,m=u.keyInfo,e=u.url;if(!c.decryptdata||m!==E.keyUriToKeyInfo[e])return v(E.createKeyLoadError(c,O.ErrorDetails.KEY_LOAD_ERROR,g,"after key load, decryptdata unset or changed"));m.decryptdata.key=c.decryptdata.key=new Uint8Array(l.data),c.keyLoader=null,m.loader=null,p({frag:c,keyInfo:m})},onError:function(l,i,u){E.resetLoader(i),v(E.createKeyLoadError(S,O.ErrorDetails.KEY_LOAD_ERROR,u))},onTimeout:function(l,i,u){E.resetLoader(i),v(E.createKeyLoadError(S,O.ErrorDetails.KEY_LOAD_TIMEOUT,u))},onAbort:function(l,i,u){E.resetLoader(i),v(E.createKeyLoadError(S,O.ErrorDetails.INTERNAL_ABORTED,u))}};_.load(a,s,n)})},U.resetLoader=function(A){var S=A.frag,E=A.keyInfo,x=A.url,f=E.loader;S.keyLoader===f&&(S.keyLoader=null,E.loader=null),delete this.keyUriToKeyInfo[x],f&&f.destroy()},P}()},"./src/loader/level-details.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{LevelDetails:()=>A});var O=T("./src/polyfills/number.ts");function D(S,E){for(var x=0;x<E.length;x++){var f=E[x];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(S,P(f.key),f)}}function M(S,E,x){return E&&D(S.prototype,E),x&&D(S,x),Object.defineProperty(S,"prototype",{writable:!1}),S}function P(S){var E=U(S,"string");return typeof E=="symbol"?E:String(E)}function U(S,E){if(typeof S!="object"||S===null)return S;var x=S[Symbol.toPrimitive];if(x!==void 0){var f=x.call(S,E||"default");if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(S)}var b=10,A=function(){function S(x){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.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.encryptedFragments=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=x}var E=S.prototype;return E.reloaded=function(f){if(!f){this.advanced=!0,this.updated=!0;return}var _=this.lastPartSn-f.lastPartSn,p=this.lastPartIndex-f.lastPartIndex;this.updated=this.endSN!==f.endSN||!!p||!!_,this.advanced=this.endSN>f.endSN||_>0||_===0&&p>0,this.updated||this.advanced?this.misses=Math.floor(f.misses*.6):this.misses=f.misses+1,this.availabilityDelay=f.availabilityDelay},M(S,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?(0,O.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||b}},{key:"drift",get:function(){var f=this.driftEndTime-this.driftStartTime;if(f>0){var _=this.driftEnd-this.driftStart;return _*1e3/f}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var f;return(f=this.partList)!==null&&f!==void 0&&f.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var f;return(f=this.fragments)!==null&&f!==void 0&&f.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 f;return(f=this.partList)!==null&&f!==void 0&&f.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var f;return(f=this.partList)!==null&&f!==void 0&&f.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),S}()},"./src/loader/level-key.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{LevelKey:()=>A});var O=T("./src/utils/keysystem-util.ts"),D=T("./src/utils/mediakeys-helper.ts"),M=T("./src/utils/mp4-tools.ts"),P=T("./src/utils/logger.ts"),U=T("./src/utils/numeric-encoding-utils.ts"),b={},A=function(){E.clearKeyUriToKeyIdMap=function(){b={}};function E(f,_,p,v,a){v===void 0&&(v=[1]),a===void 0&&(a=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=f,this.uri=_,this.keyFormat=p,this.keyFormatVersions=v,this.iv=a,this.encrypted=f?f!=="NONE":!1,this.isCommonEncryption=this.encrypted&&f!=="AES-128"}var x=E.prototype;return x.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;switch(this.keyFormat){case"identity":return this.method==="SAMPLE-AES";case D.KeySystemFormats.FAIRPLAY:case D.KeySystemFormats.WIDEVINE:case D.KeySystemFormats.PLAYREADY:case D.KeySystemFormats.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},x.getDecryptData=function(_){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof _!="number"&&(this.method==="AES-128"&&!this.iv&&P.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),_=0);var p=S(_),v=new E(this.method,this.uri,"identity",this.keyFormatVersions,p);return v}var a=(0,O.convertDataUriToArrayBytes)(this.uri);if(a)switch(this.keyFormat){case D.KeySystemFormats.WIDEVINE:this.pssh=a,a.length>=22&&(this.keyId=a.subarray(a.length-22,a.length-6));break;case D.KeySystemFormats.PLAYREADY:{var s=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,M.mp4pssh)(s,null,a);var n=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2),d=String.fromCharCode.apply(null,Array.from(n)),l=d.substring(d.indexOf("<"),d.length),i=new DOMParser,u=i.parseFromString(l,"text/xml"),g=u.getElementsByTagName("KID")[0];if(g){var c=g.childNodes[0]?g.childNodes[0].nodeValue:g.getAttribute("VALUE");if(c){var m=(0,U.base64Decode)(c).subarray(0,16);(0,O.changeEndianness)(m),this.keyId=m}}break}default:{var e=a.subarray(0,16);if(e.length!==16){var r=new Uint8Array(16);r.set(e,16-e.length),e=r}this.keyId=e;break}}if(!this.keyId||this.keyId.byteLength!==16){var t=b[this.uri];if(!t){var o=Object.keys(b).length%Number.MAX_SAFE_INTEGER;t=new Uint8Array(16);var y=new DataView(t.buffer,12,4);y.setUint32(0,o),b[this.uri]=t}this.keyId=t}return this},E}();function S(E){for(var x=new Uint8Array(16),f=12;f<16;f++)x[f]=E>>8*(15-f)&255;return x}},"./src/loader/load-stats.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{LoadStats:()=>O});var O=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":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>s});var O=T("./src/polyfills/number.ts"),D=T("./node_modules/url-toolkit/src/url-toolkit.js"),M=T.n(D),P=T("./src/loader/date-range.ts"),U=T("./src/loader/fragment.ts"),b=T("./src/loader/level-details.ts"),A=T("./src/loader/level-key.ts"),S=T("./src/utils/attr-list.ts"),E=T("./src/utils/logger.ts"),x=T("./src/utils/codecs.ts");function f(){return f=Object.assign?Object.assign.bind():function(c){for(var m=1;m<arguments.length;m++){var e=arguments[m];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(c[r]=e[r])}return c},f.apply(this,arguments)}var _=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+|#EXT-X-SESSION-KEY:([^\n\r]*)[\r\n]+/g,p=/#EXT-X-MEDIA:(.*)/g,v=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),a=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("|")),s=function(){function c(){}return c.findGroup=function(e,r){for(var t=0;t<e.length;t++){var o=e[t];if(o.id===r)return o}},c.convertAVC1ToAVCOTI=function(e){var r=e.split(".");if(r.length>2){var t=r.shift()+".";return t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).slice(-4),t}return e},c.resolve=function(e,r){return(0,D.buildAbsoluteURL)(r,e,{alwaysNormalize:!0})},c.parseMasterPlaylist=function(e,r){var t=[],o=[],y={},h=[],L=!1;_.lastIndex=0;for(var R;(R=_.exec(e))!=null;)if(R[1]){var I,k=new S.AttrList(R[1]),F={attrs:k,bitrate:k.decimalInteger("AVERAGE-BANDWIDTH")||k.decimalInteger("BANDWIDTH"),name:k.NAME,url:c.resolve(R[2],r)},W=k.decimalResolution("RESOLUTION");W&&(F.width=W.width,F.height=W.height),d((k.CODECS||"").split(/[ ,]+/).filter(function(ee){return ee}),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=c.convertAVC1ToAVCOTI(F.videoCodec)),(I=F.unknownCodecs)!==null&&I!==void 0&&I.length||o.push(F),t.push(F)}else if(R[3]){var K=new S.AttrList(R[3]);K["DATA-ID"]&&(L=!0,y[K["DATA-ID"]]=K)}else if(R[4]){var H=R[4],Y=n(H,r);Y.encrypted&&Y.isSupported()?h.push(Y):E.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+H+'"')}var q=o.length>0&&o.length<t.length;return{levels:q?o:t,sessionData:L?y:null,sessionKeys:h.length?h:null}},c.parseMasterPlaylistMedia=function(e,r,t,o){o===void 0&&(o=[]);var y,h=[],L=0;for(p.lastIndex=0;(y=p.exec(e))!==null;){var R=new S.AttrList(y[1]);if(R.TYPE===t){var I={attrs:R,bitrate:0,id:L++,groupId:R["GROUP-ID"],instreamId:R["INSTREAM-ID"],name:R.NAME||R.LANGUAGE||"",type:t,default:R.bool("DEFAULT"),autoselect:R.bool("AUTOSELECT"),forced:R.bool("FORCED"),lang:R.LANGUAGE,url:R.URI?c.resolve(R.URI,r):""};if(o.length){var k=c.findGroup(o,I.groupId)||o[0];l(I,k,"audioCodec"),l(I,k,"textCodec")}h.push(I)}}return h},c.parseLevelPlaylist=function(e,r,t,o,y){var h=new b.LevelDetails(r),L=h.fragments,R=null,I=0,k=0,F=0,W=0,K=null,H=new U.Fragment(o,r),Y,q,ee,ae=-1,re=!1;for(v.lastIndex=0,h.m3u8=e;(Y=v.exec(e))!==null;){re&&(re=!1,H=new U.Fragment(o,r),H.start=F,H.sn=I,H.cc=W,H.level=t,R&&(H.initSegment=R,H.rawProgramDateTime=R.rawProgramDateTime,R.rawProgramDateTime=null));var se=Y[1];if(se){H.duration=parseFloat(se);var le=(" "+Y[2]).slice(1);H.title=le||null,H.tagList.push(le?["INF",se,le]:["INF",se])}else if(Y[3]){if((0,O.isFiniteNumber)(H.duration)){if(H.start=F,ee){H.levelkeys=ee;var de=h.encryptedFragments;H.levelkeys&&Object.keys(H.levelkeys).some(function(nt){return H.levelkeys[nt].isCommonEncryption})&&(!de.length||de[de.length-1].levelkeys!==ee)&&de.push(H)}H.sn=I,H.level=t,H.cc=W,H.urlId=y,L.push(H),H.relurl=(" "+Y[3]).slice(1),u(H,K),K=H,F+=H.duration,I++,k=0,re=!0}}else if(Y[4]){var ue=(" "+Y[4]).slice(1);K?H.setByteRange(ue,K):H.setByteRange(ue)}else if(Y[5])H.rawProgramDateTime=(" "+Y[5]).slice(1),H.tagList.push(["PROGRAM-DATE-TIME",H.rawProgramDateTime]),ae===-1&&(ae=L.length);else{if(Y=Y[0].match(a),!Y){E.logger.warn("No matches on slow regex match for level playlist!");continue}for(q=1;q<Y.length&&typeof Y[q]=="undefined";q++);var fe=(" "+Y[q]).slice(1),ce=(" "+Y[q+1]).slice(1),be=Y[q+2]?(" "+Y[q+2]).slice(1):"";switch(fe){case"PLAYLIST-TYPE":h.type=ce.toUpperCase();break;case"MEDIA-SEQUENCE":I=h.startSN=parseInt(ce);break;case"SKIP":{var Pe=new S.AttrList(ce),we=Pe.decimalInteger("SKIPPED-SEGMENTS");if((0,O.isFiniteNumber)(we)){h.skippedSegments=we;for(var pe=we;pe--;)L.unshift(null);I+=we}var Me=Pe.enumeratedString("RECENTLY-REMOVED-DATERANGES");Me&&(h.recentlyRemovedDateranges=Me.split(" "));break}case"TARGETDURATION":h.targetduration=parseFloat(ce);break;case"VERSION":h.version=parseInt(ce);break;case"EXTM3U":break;case"ENDLIST":h.live=!1;break;case"#":(ce||be)&&H.tagList.push(be?[ce,be]:[ce]);break;case"DISCONTINUITY":W++,H.tagList.push(["DIS"]);break;case"GAP":H.tagList.push([fe]);break;case"BITRATE":H.tagList.push([fe,ce]);break;case"DATERANGE":{var Re=new S.AttrList(ce),ke=new P.DateRange(Re,h.dateRanges[Re.ID]);ke.isValid||h.skippedSegments?h.dateRanges[ke.id]=ke:E.logger.warn('Ignoring invalid DATERANGE tag: "'+ce+'"'),H.tagList.push(["EXT-X-DATERANGE",ce]);break}case"DISCONTINUITY-SEQUENCE":W=parseInt(ce);break;case"KEY":{var Le=n(ce,r);if(Le.isSupported()){if(Le.method==="NONE"){ee=void 0;break}ee||(ee={}),ee[Le.keyFormat]&&(ee=f({},ee)),ee[Le.keyFormat]=Le}else E.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+ce+'"');break}case"START":{var Ue=new S.AttrList(ce),He=Ue.decimalFloatingPoint("TIME-OFFSET");(0,O.isFiniteNumber)(He)&&(h.startTimeOffset=He);break}case"MAP":{var Be=new S.AttrList(ce);if(H.duration){var Je=new U.Fragment(o,r);g(Je,Be,t,ee),R=Je,H.initSegment=R,R.rawProgramDateTime&&!H.rawProgramDateTime&&(H.rawProgramDateTime=R.rawProgramDateTime)}else g(H,Be,t,ee),R=H,re=!0;break}case"SERVER-CONTROL":{var qe=new S.AttrList(ce);h.canBlockReload=qe.bool("CAN-BLOCK-RELOAD"),h.canSkipUntil=qe.optionalFloat("CAN-SKIP-UNTIL",0),h.canSkipDateRanges=h.canSkipUntil>0&&qe.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=qe.optionalFloat("PART-HOLD-BACK",0),h.holdBack=qe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var st=new S.AttrList(ce);h.partTarget=st.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ze=h.partList;Ze||(Ze=h.partList=[]);var ot=k>0?Ze[Ze.length-1]:void 0,lt=k++,tt=new U.Part(new S.AttrList(ce),H,r,lt,ot);Ze.push(tt),H.duration+=tt.duration;break}case"PRELOAD-HINT":{var je=new S.AttrList(ce);h.preloadHint=je;break}case"RENDITION-REPORT":{var Ve=new S.AttrList(ce);h.renditionReports=h.renditionReports||[],h.renditionReports.push(Ve);break}default:E.logger.warn("line parsed but not handled: "+Y);break}}}K&&!K.relurl?(L.pop(),F-=K.duration,h.partList&&(h.fragmentHint=K)):h.partList&&(u(H,K),H.cc=W,h.fragmentHint=H);var rt=L.length,gt=L[0],Ne=L[rt-1];if(F+=h.skippedSegments*h.targetduration,F>0&&rt&&Ne){h.averagetargetduration=F/rt;var it=Ne.sn;h.endSN=it!=="initSegment"?it:0,h.live||(Ne.endList=!0),gt&&(h.startCC=gt.cc)}else h.endSN=0,h.startCC=0;return h.fragmentHint&&(F+=h.fragmentHint.duration),h.totalduration=F,h.endCC=W,ae>0&&i(L,ae),h},c}();function n(c,m){var e,r,t=new S.AttrList(c),o=(e=t.enumeratedString("METHOD"))!=null?e:"",y=t.URI,h=t.hexadecimalInteger("IV"),L=t.enumeratedString("KEYFORMATVERSIONS"),R=(r=t.enumeratedString("KEYFORMAT"))!=null?r:"identity";y&&t.IV&&!h&&E.logger.error("Invalid IV: "+t.IV);var I=y?s.resolve(y,m):"",k=(L||"1").split("/").map(Number).filter(Number.isFinite);return new A.LevelKey(o,I,R,k,h)}function d(c,m){["video","audio","text"].forEach(function(e){var r=c.filter(function(o){return(0,x.isCodecType)(o,e)});if(r.length){var t=r.filter(function(o){return o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0});m[e+"Codec"]=t.length>0?t[0]:r[0],c=c.filter(function(o){return r.indexOf(o)===-1})}}),m.unknownCodecs=c}function l(c,m,e){var r=m[e];r&&(c[e]=r)}function i(c,m){for(var e=c[m],r=m;r--;){var t=c[r];if(!t)return;t.programDateTime=e.programDateTime-t.duration*1e3,e=t}}function u(c,m){c.rawProgramDateTime?c.programDateTime=Date.parse(c.rawProgramDateTime):m!=null&&m.programDateTime&&(c.programDateTime=m.endProgramDateTime),(0,O.isFiniteNumber)(c.programDateTime)||(c.programDateTime=null,c.rawProgramDateTime=null)}function g(c,m,e,r){c.relurl=m.URI,m.BYTERANGE&&c.setByteRange(m.BYTERANGE),c.level=e,c.sn="initSegment",r&&(c.levelkeys=r),c.initSegment=null}},"./src/loader/playlist-loader.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>f});var O=T("./src/polyfills/number.ts"),D=T("./src/events.ts"),M=T("./src/errors.ts"),P=T("./src/utils/logger.ts"),U=T("./src/loader/m3u8-parser.ts"),b=T("./src/types/loader.ts"),A=T("./src/utils/attr-list.ts");function S(_){var p=_.type;switch(p){case b.PlaylistContextType.AUDIO_TRACK:return b.PlaylistLevelType.AUDIO;case b.PlaylistContextType.SUBTITLE_TRACK:return b.PlaylistLevelType.SUBTITLE;default:return b.PlaylistLevelType.MAIN}}function E(_,p){var v=_.url;return(v===void 0||v.indexOf("data:")===0)&&(v=p.url),v}var x=function(){function _(v){this.hls=void 0,this.loaders=Object.create(null),this.hls=v,this.registerListeners()}var p=_.prototype;return p.startLoad=function(a){},p.stopLoad=function(){this.destroyInternalLoaders()},p.registerListeners=function(){var a=this.hls;a.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(D.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(D.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.on(D.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var a=this.hls;a.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(D.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(D.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.off(D.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(a){var s=this.hls.config,n=s.pLoader,d=s.loader,l=n||d,i=new l(s);return a.loader=i,this.loaders[a.type]=i,i},p.getInternalLoader=function(a){return this.loaders[a.type]},p.resetInternalLoader=function(a){this.loaders[a]&&delete this.loaders[a]},p.destroyInternalLoaders=function(){for(var a in this.loaders){var s=this.loaders[a];s&&s.destroy(),this.resetInternalLoader(a)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(a,s){var n=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:b.PlaylistContextType.MANIFEST,url:n,deliveryDirectives:null})},p.onLevelLoading=function(a,s){var n=s.id,d=s.level,l=s.url,i=s.deliveryDirectives;this.load({id:n,groupId:null,level:d,responseType:"text",type:b.PlaylistContextType.LEVEL,url:l,deliveryDirectives:i})},p.onAudioTrackLoading=function(a,s){var n=s.id,d=s.groupId,l=s.url,i=s.deliveryDirectives;this.load({id:n,groupId:d,level:null,responseType:"text",type:b.PlaylistContextType.AUDIO_TRACK,url:l,deliveryDirectives:i})},p.onSubtitleTrackLoading=function(a,s){var n=s.id,d=s.groupId,l=s.url,i=s.deliveryDirectives;this.load({id:n,groupId:d,level:null,responseType:"text",type:b.PlaylistContextType.SUBTITLE_TRACK,url:l,deliveryDirectives:i})},p.load=function(a){var s,n=this.hls.config,d=this.getInternalLoader(a);if(d){var l=d.context;if(l&&l.url===a.url){P.logger.trace("[playlist-loader]: playlist request ongoing");return}P.logger.log("[playlist-loader]: aborting previous loader for type: "+a.type),d.abort()}var i,u,g,c;switch(a.type){case b.PlaylistContextType.MANIFEST:i=n.manifestLoadingMaxRetry,u=n.manifestLoadingTimeOut,g=n.manifestLoadingRetryDelay,c=n.manifestLoadingMaxRetryTimeout;break;case b.PlaylistContextType.LEVEL:case b.PlaylistContextType.AUDIO_TRACK:case b.PlaylistContextType.SUBTITLE_TRACK:i=0,u=n.levelLoadingTimeOut;break;default:i=n.levelLoadingMaxRetry,u=n.levelLoadingTimeOut,g=n.levelLoadingRetryDelay,c=n.levelLoadingMaxRetryTimeout;break}if(d=this.createInternalLoader(a),(s=a.deliveryDirectives)!==null&&s!==void 0&&s.part){var m;if(a.type===b.PlaylistContextType.LEVEL&&a.level!==null?m=this.hls.levels[a.level].details:a.type===b.PlaylistContextType.AUDIO_TRACK&&a.id!==null?m=this.hls.audioTracks[a.id].details:a.type===b.PlaylistContextType.SUBTITLE_TRACK&&a.id!==null&&(m=this.hls.subtitleTracks[a.id].details),m){var e=m.partTarget,r=m.targetduration;e&&r&&(u=Math.min(Math.max(e*3,r*.8)*1e3,u))}}var t={timeout:u,maxRetry:i,retryDelay:g,maxRetryDelay:c,highWaterMark:0},o={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};d.load(a,t,o)},p.loadsuccess=function(a,s,n,d){d===void 0&&(d=null),this.resetInternalLoader(n.type);var l=a.data;if(l.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(a,n,"no EXTM3U delimiter",d);return}s.parsing.start=performance.now(),l.indexOf("#EXTINF:")>0||l.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(a,s,n,d):this.handleMasterPlaylist(a,s,n,d)},p.loaderror=function(a,s,n){n===void 0&&(n=null),this.handleNetworkError(s,n,!1,a)},p.loadtimeout=function(a,s,n){n===void 0&&(n=null),this.handleNetworkError(s,n,!0)},p.handleMasterPlaylist=function(a,s,n,d){var l=this.hls,i=a.data,u=E(a,n),g=U.default.parseMasterPlaylist(i,u),c=g.levels,m=g.sessionData,e=g.sessionKeys;if(!c.length){this.handleManifestParsingError(a,n,"no level found in manifest",d);return}var r=c.map(function(R){return{id:R.attrs.AUDIO,audioCodec:R.audioCodec}}),t=c.map(function(R){return{id:R.attrs.SUBTITLES,textCodec:R.textCodec}}),o=U.default.parseMasterPlaylistMedia(i,u,"AUDIO",r),y=U.default.parseMasterPlaylistMedia(i,u,"SUBTITLES",t),h=U.default.parseMasterPlaylistMedia(i,u,"CLOSED-CAPTIONS");if(o.length){var L=o.some(function(R){return!R.url});!L&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(P.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),o.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new A.AttrList({}),bitrate:0,url:""}))}l.trigger(D.Events.MANIFEST_LOADED,{levels:c,audioTracks:o,subtitles:y,captions:h,url:u,stats:s,networkDetails:d,sessionData:m,sessionKeys:e})},p.handleTrackOrLevelPlaylist=function(a,s,n,d){var l=this.hls,i=n.id,u=n.level,g=n.type,c=E(a,n),m=(0,O.isFiniteNumber)(i)?i:0,e=(0,O.isFiniteNumber)(u)?u:m,r=S(n),t=U.default.parseLevelPlaylist(a.data,c,e,r,m);if(!t.fragments.length){l.trigger(D.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:c,reason:"no fragments found in level",level:typeof n.level=="number"?n.level:void 0});return}if(g===b.PlaylistContextType.MANIFEST){var o={attrs:new A.AttrList({}),bitrate:0,details:t,name:"",url:c};l.trigger(D.Events.MANIFEST_LOADED,{levels:[o],audioTracks:[],url:c,stats:s,networkDetails:d,sessionData:null,sessionKeys:null})}s.parsing.end=performance.now(),n.levelDetails=t,this.handlePlaylistLoaded(a,s,n,d)},p.handleManifestParsingError=function(a,s,n,d){this.hls.trigger(D.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===b.PlaylistContextType.MANIFEST,url:a.url,reason:n,response:a,context:s,networkDetails:d})},p.handleNetworkError=function(a,s,n,d){n===void 0&&(n=!1),P.logger.warn("[playlist-loader]: A network "+(n?"timeout":"error")+" occurred while loading "+a.type+" level: "+a.level+" id: "+a.id+' group-id: "'+a.groupId+'"');var l=M.ErrorDetails.UNKNOWN,i=!1,u=this.getInternalLoader(a);switch(a.type){case b.PlaylistContextType.MANIFEST:l=n?M.ErrorDetails.MANIFEST_LOAD_TIMEOUT:M.ErrorDetails.MANIFEST_LOAD_ERROR,i=!0;break;case b.PlaylistContextType.LEVEL:l=n?M.ErrorDetails.LEVEL_LOAD_TIMEOUT:M.ErrorDetails.LEVEL_LOAD_ERROR,i=!1;break;case b.PlaylistContextType.AUDIO_TRACK:l=n?M.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:M.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,i=!1;break;case b.PlaylistContextType.SUBTITLE_TRACK:l=n?M.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:M.ErrorDetails.SUBTITLE_LOAD_ERROR,i=!1;break}u&&this.resetInternalLoader(a.type);var g={type:M.ErrorTypes.NETWORK_ERROR,details:l,fatal:i,url:a.url,loader:u,context:a,networkDetails:s};d&&(g.response=d),this.hls.trigger(D.Events.ERROR,g)},p.handlePlaylistLoaded=function(a,s,n,d){var l=n.type,i=n.level,u=n.id,g=n.groupId,c=n.loader,m=n.levelDetails,e=n.deliveryDirectives;if(!(m!=null&&m.targetduration)){this.handleManifestParsingError(a,n,"invalid target duration",d);return}if(!!c)switch(m.live&&(c.getCacheAge&&(m.ageHeader=c.getCacheAge()||0),(!c.getCacheAge||isNaN(m.ageHeader))&&(m.ageHeader=0)),l){case b.PlaylistContextType.MANIFEST:case b.PlaylistContextType.LEVEL:this.hls.trigger(D.Events.LEVEL_LOADED,{details:m,level:i||0,id:u||0,stats:s,networkDetails:d,deliveryDirectives:e});break;case b.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(D.Events.AUDIO_TRACK_LOADED,{details:m,id:u||0,groupId:g||"",stats:s,networkDetails:d,deliveryDirectives:e});break;case b.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(D.Events.SUBTITLE_TRACK_LOADED,{details:m,id:u||0,groupId:g||"",stats:s,networkDetails:d,deliveryDirectives:e});break}},_}();let f=x},"./src/polyfills/number.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{MAX_SAFE_INTEGER:()=>D,isFiniteNumber:()=>O});var O=Number.isFinite||function(M){return typeof M=="number"&&isFinite(M)},D=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>D});var O=function(){function M(){}return M.getSilentFrame=function(U,b){switch(U){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}},M}();let D=O},"./src/remux/mp4-generator.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>M});var O=Math.pow(2,32)-1,D=function(){function P(){}return P.init=function(){P.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 P.types)P.types.hasOwnProperty(b)&&(P.types[b]=[b.charCodeAt(0),b.charCodeAt(1),b.charCodeAt(2),b.charCodeAt(3)]);var A=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]),S=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]);P.HDLR_TYPES={video:A,audio:S};var E=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),x=new Uint8Array([0,0,0,0,0,0,0,0]);P.STTS=P.STSC=P.STCO=x,P.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),P.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),P.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),P.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var f=new Uint8Array([105,115,111,109]),_=new Uint8Array([97,118,99,49]),p=new Uint8Array([0,0,0,1]);P.FTYP=P.box(P.types.ftyp,f,p,f,_),P.DINF=P.box(P.types.dinf,P.box(P.types.dref,E))},P.box=function(b){for(var A=8,S=arguments.length,E=new Array(S>1?S-1:0),x=1;x<S;x++)E[x-1]=arguments[x];for(var f=E.length,_=f;f--;)A+=E[f].byteLength;var p=new Uint8Array(A);for(p[0]=A>>24&255,p[1]=A>>16&255,p[2]=A>>8&255,p[3]=A&255,p.set(b,4),f=0,A=8;f<_;f++)p.set(E[f],A),A+=E[f].byteLength;return p},P.hdlr=function(b){return P.box(P.types.hdlr,P.HDLR_TYPES[b])},P.mdat=function(b){return P.box(P.types.mdat,b)},P.mdhd=function(b,A){A*=b;var S=Math.floor(A/(O+1)),E=Math.floor(A%(O+1));return P.box(P.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,S>>24,S>>16&255,S>>8&255,S&255,E>>24,E>>16&255,E>>8&255,E&255,85,196,0,0]))},P.mdia=function(b){return P.box(P.types.mdia,P.mdhd(b.timescale,b.duration),P.hdlr(b.type),P.minf(b))},P.mfhd=function(b){return P.box(P.types.mfhd,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255]))},P.minf=function(b){return b.type==="audio"?P.box(P.types.minf,P.box(P.types.smhd,P.SMHD),P.DINF,P.stbl(b)):P.box(P.types.minf,P.box(P.types.vmhd,P.VMHD),P.DINF,P.stbl(b))},P.moof=function(b,A,S){return P.box(P.types.moof,P.mfhd(b),P.traf(S,A))},P.moov=function(b){for(var A=b.length,S=[];A--;)S[A]=P.trak(b[A]);return P.box.apply(null,[P.types.moov,P.mvhd(b[0].timescale,b[0].duration)].concat(S).concat(P.mvex(b)))},P.mvex=function(b){for(var A=b.length,S=[];A--;)S[A]=P.trex(b[A]);return P.box.apply(null,[P.types.mvex].concat(S))},P.mvhd=function(b,A){A*=b;var S=Math.floor(A/(O+1)),E=Math.floor(A%(O+1)),x=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,S>>24,S>>16&255,S>>8&255,S&255,E>>24,E>>16&255,E>>8&255,E&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 P.box(P.types.mvhd,x)},P.sdtp=function(b){var A=b.samples||[],S=new Uint8Array(4+A.length),E,x;for(E=0;E<A.length;E++)x=A[E].flags,S[E+4]=x.dependsOn<<4|x.isDependedOn<<2|x.hasRedundancy;return P.box(P.types.sdtp,S)},P.stbl=function(b){return P.box(P.types.stbl,P.stsd(b),P.box(P.types.stts,P.STTS),P.box(P.types.stsc,P.STSC),P.box(P.types.stsz,P.STSZ),P.box(P.types.stco,P.STCO))},P.avc1=function(b){var A=[],S=[],E,x,f;for(E=0;E<b.sps.length;E++)x=b.sps[E],f=x.byteLength,A.push(f>>>8&255),A.push(f&255),A=A.concat(Array.prototype.slice.call(x));for(E=0;E<b.pps.length;E++)x=b.pps[E],f=x.byteLength,S.push(f>>>8&255),S.push(f&255),S=S.concat(Array.prototype.slice.call(x));var _=P.box(P.types.avcC,new Uint8Array([1,A[3],A[4],A[5],255,224|b.sps.length].concat(A).concat([b.pps.length]).concat(S))),p=b.width,v=b.height,a=b.pixelRatio[0],s=b.pixelRatio[1];return P.box(P.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,p>>8&255,p&255,v>>8&255,v&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),_,P.box(P.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),P.box(P.types.pasp,new Uint8Array([a>>24,a>>16&255,a>>8&255,a&255,s>>24,s>>16&255,s>>8&255,s&255])))},P.esds=function(b){var A=b.config.length;return new Uint8Array([0,0,0,0,3,23+A,0,1,0,4,15+A,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([A]).concat(b.config).concat([6,1,2]))},P.mp4a=function(b){var A=b.samplerate;return P.box(P.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,A>>8&255,A&255,0,0]),P.box(P.types.esds,P.esds(b)))},P.mp3=function(b){var A=b.samplerate;return P.box(P.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,A>>8&255,A&255,0,0]))},P.stsd=function(b){return b.type==="audio"?b.segmentCodec==="mp3"&&b.codec==="mp3"?P.box(P.types.stsd,P.STSD,P.mp3(b)):P.box(P.types.stsd,P.STSD,P.mp4a(b)):P.box(P.types.stsd,P.STSD,P.avc1(b))},P.tkhd=function(b){var A=b.id,S=b.duration*b.timescale,E=b.width,x=b.height,f=Math.floor(S/(O+1)),_=Math.floor(S%(O+1));return P.box(P.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,A>>24&255,A>>16&255,A>>8&255,A&255,0,0,0,0,f>>24,f>>16&255,f>>8&255,f&255,_>>24,_>>16&255,_>>8&255,_&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,E>>8&255,E&255,0,0,x>>8&255,x&255,0,0]))},P.traf=function(b,A){var S=P.sdtp(b),E=b.id,x=Math.floor(A/(O+1)),f=Math.floor(A%(O+1));return P.box(P.types.traf,P.box(P.types.tfhd,new Uint8Array([0,0,0,0,E>>24,E>>16&255,E>>8&255,E&255])),P.box(P.types.tfdt,new Uint8Array([1,0,0,0,x>>24,x>>16&255,x>>8&255,x&255,f>>24,f>>16&255,f>>8&255,f&255])),P.trun(b,S.length+16+20+8+16+8+8),S)},P.trak=function(b){return b.duration=b.duration||4294967295,P.box(P.types.trak,P.tkhd(b),P.mdia(b))},P.trex=function(b){var A=b.id;return P.box(P.types.trex,new Uint8Array([0,0,0,0,A>>24,A>>16&255,A>>8&255,A&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},P.trun=function(b,A){var S=b.samples||[],E=S.length,x=12+16*E,f=new Uint8Array(x),_,p,v,a,s,n;for(A+=8+x,f.set([b.type==="video"?1:0,0,15,1,E>>>24&255,E>>>16&255,E>>>8&255,E&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255],0),_=0;_<E;_++)p=S[_],v=p.duration,a=p.size,s=p.flags,n=p.cts,f.set([v>>>24&255,v>>>16&255,v>>>8&255,v&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,s.degradPrio&240<<8,s.degradPrio&15,n>>>24&255,n>>>16&255,n>>>8&255,n&255],12+16*_);return P.box(P.types.trun,f)},P.initSegment=function(b){P.types||P.init();var A=P.moov(b),S=new Uint8Array(P.FTYP.byteLength+A.byteLength);return S.set(P.FTYP),S.set(A,P.FTYP.byteLength),S},P}();D.types=void 0,D.HDLR_TYPES=void 0,D.STTS=void 0,D.STSC=void 0,D.STCO=void 0,D.STSZ=void 0,D.VMHD=void 0,D.SMHD=void 0,D.STSD=void 0,D.FTYP=void 0,D.DINF=void 0;let M=D},"./src/remux/mp4-remuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>a,flushTextTrackMetadataCueSamples:()=>d,flushTextTrackUserdataCueSamples:()=>l,normalizePts:()=>s});var O=T("./src/polyfills/number.ts"),D=T("./src/remux/aac-helper.ts"),M=T("./src/remux/mp4-generator.ts"),P=T("./src/events.ts"),U=T("./src/errors.ts"),b=T("./src/utils/logger.ts"),A=T("./src/types/loader.ts"),S=T("./src/utils/timescale-conversion.ts");function E(){return E=Object.assign?Object.assign.bind():function(g){for(var c=1;c<arguments.length;c++){var m=arguments[c];for(var e in m)Object.prototype.hasOwnProperty.call(m,e)&&(g[e]=m[e])}return g},E.apply(this,arguments)}var x=10*1e3,f=1024,_=1152,p=null,v=null,a=function(){function g(m,e,r,t){if(t===void 0&&(t=""),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=m,this.config=e,this.typeSupported=r,this.ISGenerated=!1,p===null){var o=navigator.userAgent||"",y=o.match(/Chrome\/(\d+)/i);p=y?parseInt(y[1]):0}if(v===null){var h=navigator.userAgent.match(/Safari\/(\d+)/i);v=h?parseInt(h[1]):0}}var c=g.prototype;return c.destroy=function(){},c.resetTimeStamp=function(e){b.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},c.resetNextTimestamp=function(){b.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},c.resetInitSegment=function(){b.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},c.getVideoStartPts=function(e){var r=!1,t=e.reduce(function(o,y){var h=y.pts-o;return h<-4294967296?(r=!0,s(o,y.pts)):h>0?o:y.pts},e[0].pts);return r&&b.logger.debug("PTS rollover detected"),t},c.remux=function(e,r,t,o,y,h,L,R){var I,k,F,W,K,H,Y=y,q=y,ee=e.pid>-1,ae=r.pid>-1,re=r.samples.length,se=e.samples.length>0,le=L&&re>0||re>1,de=(!ee||se)&&(!ae||le)||this.ISGenerated||L;if(de){this.ISGenerated||(F=this.generateIS(e,r,y));var ue=this.isVideoContiguous,fe=-1,ce;if(le&&(fe=n(r.samples),!ue&&this.config.forceKeyFrameOnDiscontinuity))if(H=!0,fe>0){b.logger.warn("[mp4-remuxer]: Dropped "+fe+" out of "+re+" video samples due to a missing keyframe");var be=this.getVideoStartPts(r.samples);r.samples=r.samples.slice(fe),r.dropped+=fe,q+=(r.samples[0].pts-be)/r.inputTimeScale,ce=q}else fe===-1&&(b.logger.warn("[mp4-remuxer]: No keyframe found out of "+re+" video samples"),H=!1);if(this.ISGenerated){if(se&&le){var Pe=this.getVideoStartPts(r.samples),we=s(e.samples[0].pts,Pe)-Pe,pe=we/r.inputTimeScale;Y+=Math.max(0,pe),q+=Math.max(0,-pe)}if(se){if(e.samplerate||(b.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),F=this.generateIS(e,r,y)),k=this.remuxAudio(e,Y,this.isAudioContiguous,h,ae||le||R===A.PlaylistLevelType.AUDIO?q:void 0),le){var Me=k?k.endPTS-k.startPTS:0;r.inputTimeScale||(b.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),F=this.generateIS(e,r,y)),I=this.remuxVideo(r,q,ue,Me)}}else le&&(I=this.remuxVideo(r,q,ue,0));I&&(I.firstKeyFrame=fe,I.independent=fe!==-1,I.firstKeyFramePTS=ce)}}return this.ISGenerated&&(t.samples.length&&(K=d(t,y,this._initPTS,this._initDTS)),o.samples.length&&(W=l(o,y,this._initPTS))),{audio:k,video:I,initSegment:F,independent:H,text:W,id3:K}},c.generateIS=function(e,r,t){var o=e.samples,y=r.samples,h=this.typeSupported,L={},R=!(0,O.isFiniteNumber)(this._initPTS),I="audio/mp4",k,F,W;if(R&&(k=F=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":h.mpeg?(I="audio/mpeg",e.codec=""):h.mp3&&(e.codec="mp3");break}L.audio={id:"audio",container:I,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&h.mpeg?new Uint8Array(0):M.default.initSegment([e]),metadata:{channelCount:e.channelCount}},R&&(W=e.inputTimeScale,k=F=o[0].pts-Math.round(W*t))}if(r.sps&&r.pps&&y.length&&(r.timescale=r.inputTimeScale,L.video={id:"main",container:"video/mp4",codec:r.codec,initSegment:M.default.initSegment([r]),metadata:{width:r.width,height:r.height}},R)){W=r.inputTimeScale;var K=this.getVideoStartPts(y),H=Math.round(W*t);F=Math.min(F,s(y[0].dts,K)-H),k=Math.min(k,K-H)}if(Object.keys(L).length)return this.ISGenerated=!0,R&&(this._initPTS=k,this._initDTS=F),{tracks:L,initPTS:k,timescale:W}},c.remuxVideo=function(e,r,t,o){var y=e.inputTimeScale,h=e.samples,L=[],R=h.length,I=this._initPTS,k=this.nextAvcDts,F=8,W=this.videoSampleDuration,K,H,Y=Number.POSITIVE_INFINITY,q=Number.NEGATIVE_INFINITY,ee=!1;if(!t||k===null){var ae=r*y,re=h[0].pts-s(h[0].dts,h[0].pts);k=ae-re}for(var se=0;se<R;se++){var le=h[se];le.pts=s(le.pts-I,k),le.dts=s(le.dts-I,k),le.dts<h[se>0?se-1:se].dts&&(ee=!0)}ee&&h.sort(function(vt,Xt){var Cr=vt.dts-Xt.dts,Mr=vt.pts-Xt.pts;return Cr||Mr}),K=h[0].dts,H=h[h.length-1].dts;var de=H-K,ue=de?Math.round(de/(R-1)):W||e.inputTimeScale/30;if(t){var fe=K-k,ce=fe>ue,be=fe<-1;if((ce||be)&&(ce?b.logger.warn("AVC: "+(0,S.toMsFromMpegTsClock)(fe,!0)+" ms ("+fe+"dts) hole between fragments detected, filling it"):b.logger.warn("AVC: "+(0,S.toMsFromMpegTsClock)(-fe,!0)+" ms ("+fe+"dts) overlapping between fragments detected"),!be||k>h[0].pts)){K=k;var Pe=h[0].pts-fe;h[0].dts=K,h[0].pts=Pe,b.logger.log("Video: First PTS/DTS adjusted: "+(0,S.toMsFromMpegTsClock)(Pe,!0)+"/"+(0,S.toMsFromMpegTsClock)(K,!0)+", delta: "+(0,S.toMsFromMpegTsClock)(fe,!0)+" ms")}}K=Math.max(0,K);for(var we=0,pe=0,Me=0;Me<R;Me++){for(var Re=h[Me],ke=Re.units,Le=ke.length,Ue=0,He=0;He<Le;He++)Ue+=ke[He].data.length;pe+=Ue,we+=Le,Re.length=Ue,Re.dts=Math.max(Re.dts,K),Y=Math.min(Re.pts,Y),q=Math.max(Re.pts,q)}H=h[R-1].dts;var Be=pe+4*we+8,Je;try{Je=new Uint8Array(Be)}catch{this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:U.ErrorTypes.MUX_ERROR,details:U.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Be,reason:"fail allocating video mdat "+Be});return}var qe=new DataView(Je.buffer);qe.setUint32(0,Be),Je.set(M.default.types.mdat,4);for(var st=!1,Ze=Number.POSITIVE_INFINITY,ot=Number.POSITIVE_INFINITY,lt=Number.NEGATIVE_INFINITY,tt=Number.NEGATIVE_INFINITY,je=0;je<R;je++){for(var Ve=h[je],rt=Ve.units,gt=0,Ne=0,it=rt.length;Ne<it;Ne++){var nt=rt[Ne],Lt=nt.data,At=nt.data.byteLength;qe.setUint32(F,At),F+=4,Je.set(Lt,F),F+=At,gt+=4+At}var Dt=void 0;if(je<R-1)W=h[je+1].dts-Ve.dts,Dt=h[je+1].pts-Ve.pts;else{var Gt=this.config,Pt=je>0?Ve.dts-h[je-1].dts:ue;if(Dt=je>0?Ve.pts-h[je-1].pts:ue,Gt.stretchShortVideoTrack&&this.nextAudioPts!==null){var hr=Math.floor(Gt.maxBufferHole*y),Ht=(o?Y+o*y:this.nextAudioPts)-Ve.pts;Ht>hr?(W=Ht-Pt,W<0?W=Pt:st=!0,b.logger.log("[mp4-remuxer]: It is approximately "+Ht/90+" ms to the next segment; using duration "+W/90+" ms for the last video frame.")):W=Pt}else W=Pt}var Pr=Math.round(Ve.pts-Ve.dts);Ze=Math.min(Ze,W),lt=Math.max(lt,W),ot=Math.min(ot,Dt),tt=Math.max(tt,Dt),L.push(new i(Ve.key,W,gt,Pr))}if(L.length){if(p){if(p<70){var jt=L[0].flags;jt.dependsOn=2,jt.isNonSync=0}}else if(v&&tt-ot<lt-Ze&&ue/lt<.025&&L[0].cts===0){b.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Ot=K,ht=0,vr=L.length;ht<vr;ht++){var Vt=Ot+L[ht].duration,gr=Ot+L[ht].cts;if(ht<vr-1){var Yt=Vt+L[ht+1].cts;L[ht].duration=Yt-gr}else L[ht].duration=ht?L[ht-1].duration:ue;L[ht].cts=0,Ot=Vt}}}console.assert(W!==null,"mp4SampleDuration must be computed"),W=st||!W?ue:W,this.nextAvcDts=k=H+W,this.videoSampleDuration=W,this.isVideoContiguous=!0;var Rr=M.default.moof(e.sequenceNumber++,K,E({},e,{samples:L})),Ir="video",Or={data1:Rr,data2:Je,startPTS:Y/y,endPTS:(q+W)/y,startDTS:K/y,endDTS:k/y,type:Ir,hasAudio:!1,hasVideo:!0,nb:L.length,dropped:e.dropped};return e.samples=[],e.dropped=0,console.assert(Je.length,"MDAT length must not be zero"),Or},c.remuxAudio=function(e,r,t,o,y){var h=e.inputTimeScale,L=e.samplerate?e.samplerate:h,R=h/L,I=e.segmentCodec==="aac"?f:_,k=I*R,F=this._initPTS,W=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,K=[],H=y!==void 0,Y=e.samples,q=W?0:8,ee=this.nextAudioPts||-1,ae=r*h;if(this.isAudioContiguous=t=t||Y.length&&ee>0&&(o&&Math.abs(ae-ee)<9e3||Math.abs(s(Y[0].pts-F,ae)-ee)<20*k),Y.forEach(function(nt){nt.pts=s(nt.pts-F,ae)}),!t||ee<0){if(Y=Y.filter(function(nt){return nt.pts>=0}),!Y.length)return;y===0?ee=0:o&&!H?ee=Math.max(0,ae):ee=Y[0].pts}if(e.segmentCodec==="aac")for(var re=this.config.maxAudioFramesDrift,se=0,le=ee;se<Y.length;se++){var de=Y[se],ue=de.pts,fe=ue-le,ce=Math.abs(1e3*fe/h);if(fe<=-re*k&&H)se===0&&(b.logger.warn("Audio frame @ "+(ue/h).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*fe/h)+" ms."),this.nextAudioPts=ee=le=ue);else if(fe>=re*k&&ce<x&&H){var be=Math.round(fe/k);le=ue-be*k,le<0&&(be--,le+=k),se===0&&(this.nextAudioPts=ee=le),b.logger.warn("[mp4-remuxer]: Injecting "+be+" audio frame @ "+(le/h).toFixed(3)+"s due to "+Math.round(1e3*fe/h)+" ms gap.");for(var Pe=0;Pe<be;Pe++){var we=Math.max(le,0),pe=D.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);pe||(b.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),pe=de.unit.subarray()),Y.splice(se,0,{unit:pe,pts:we}),le+=k,se++}}de.pts=le,le+=k}for(var Me=null,Re=null,ke,Le=0,Ue=Y.length;Ue--;)Le+=Y[Ue].unit.byteLength;for(var He=0,Be=Y.length;He<Be;He++){var Je=Y[He],qe=Je.unit,st=Je.pts;if(Re!==null){var Ze=K[He-1];Ze.duration=Math.round((st-Re)/R)}else if(t&&e.segmentCodec==="aac"&&(st=ee),Me=st,Le>0){Le+=q;try{ke=new Uint8Array(Le)}catch{this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:U.ErrorTypes.MUX_ERROR,details:U.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Le,reason:"fail allocating audio mdat "+Le});return}if(!W){var ot=new DataView(ke.buffer);ot.setUint32(0,Le),ke.set(M.default.types.mdat,4)}}else return;ke.set(qe,q);var lt=qe.byteLength;q+=lt,K.push(new i(!0,I,lt,0)),Re=st}var tt=K.length;if(!!tt){var je=K[K.length-1];this.nextAudioPts=ee=Re+R*je.duration;var Ve=W?new Uint8Array(0):M.default.moof(e.sequenceNumber++,Me/R,E({},e,{samples:K}));e.samples=[];var rt=Me/h,gt=ee/h,Ne="audio",it={data1:Ve,data2:ke,startPTS:rt,endPTS:gt,startDTS:rt,endDTS:gt,type:Ne,hasAudio:!0,hasVideo:!1,nb:tt};return this.isAudioContiguous=!0,console.assert(ke.length,"MDAT length must not be zero"),it}},c.remuxEmptyAudio=function(e,r,t,o){var y=e.inputTimeScale,h=e.samplerate?e.samplerate:y,L=y/h,R=this.nextAudioPts,I=(R!==null?R:o.startDTS*y)+this._initDTS,k=o.endDTS*y+this._initDTS,F=L*f,W=Math.ceil((k-I)/F),K=D.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(b.logger.warn("[mp4-remuxer]: remux empty Audio"),!K){b.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var H=[],Y=0;Y<W;Y++){var q=I+Y*F;H.push({unit:K,pts:q,dts:q})}return e.samples=H,this.remuxAudio(e,r,t,!1)},g}();function s(g,c){var m;if(c===null)return g;for(c<g?m=-8589934592:m=8589934592;Math.abs(g-c)>4294967296;)g+=m;return g}function n(g){for(var c=0;c<g.length;c++)if(g[c].key)return c;return-1}function d(g,c,m,e){var r=g.samples.length;if(!!r){for(var t=g.inputTimeScale,o=0;o<r;o++){var y=g.samples[o];y.pts=s(y.pts-m,c*t)/t,y.dts=s(y.dts-e,c*t)/t}var h=g.samples;return g.samples=[],{samples:h}}}function l(g,c,m){var e=g.samples.length;if(!!e){for(var r=g.inputTimeScale,t=0;t<e;t++){var o=g.samples[t];o.pts=s(o.pts-m,c*r)/r}g.samples.sort(function(h,L){return h.pts-L.pts});var y=g.samples;return g.samples=[],{samples:y}}}var i=function(c,m,e,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=m,this.size=e,this.cts=r,this.flags=new u(c)},u=function(c){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=c?2:1,this.isNonSync=c?0:1}},"./src/remux/passthrough-remuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>S});var O=T("./src/polyfills/number.ts"),D=T("./src/remux/mp4-remuxer.ts"),M=T("./src/utils/mp4-tools.ts"),P=T("./src/loader/fragment.ts"),U=T("./src/utils/logger.ts"),b=function(){function E(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var x=E.prototype;return x.destroy=function(){},x.resetTimeStamp=function(_){this.initPTS=_,this.lastEndTime=null},x.resetNextTimestamp=function(){this.lastEndTime=null},x.resetInitSegment=function(_,p,v,a){this.audioCodec=p,this.videoCodec=v,this.generateInitSegment((0,M.patchEncyptionData)(_,a)),this.emitInitSegment=!0},x.generateInitSegment=function(_){var p=this.audioCodec,v=this.videoCodec;if(!_||!_.byteLength){this.initTracks=void 0,this.initData=void 0;return}var a=this.initData=(0,M.parseInitSegment)(_);p||(p=A(a.audio,P.ElementaryStreamTypes.AUDIO)),v||(v=A(a.video,P.ElementaryStreamTypes.VIDEO));var s={};a.audio&&a.video?s.audiovideo={container:"video/mp4",codec:p+","+v,initSegment:_,id:"main"}:a.audio?s.audio={container:"audio/mp4",codec:p,initSegment:_,id:"audio"}:a.video?s.video={container:"video/mp4",codec:v,initSegment:_,id:"main"}:U.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=s},x.remux=function(_,p,v,a,s){var n,d=this.initPTS,l=this.lastEndTime,i={audio:void 0,video:void 0,text:a,id3:v,initSegment:void 0};(0,O.isFiniteNumber)(l)||(l=this.lastEndTime=s||0);var u=p.samples;if(!u||!u.length)return i;var g={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(u),c=this.initData),!c||!c.length)return U.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1);var m=(0,M.getStartDTS)(c,u);(0,O.isFiniteNumber)(d)||(this.initPTS=g.initPTS=d=m-s);var e=(0,M.getDuration)(u,c),r=_?m-d:l,t=r+e;(0,M.offsetStartDTS)(c,u,d),e>0?this.lastEndTime=t:(U.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var o=!!c.audio,y=!!c.video,h="";o&&(h+="audio"),y&&(h+="video");var L={data1:u,startPTS:r,startDTS:r,endPTS:t,endDTS:t,type:h,hasAudio:o,hasVideo:y,nb:1,dropped:0};i.audio=L.type==="audio"?L:void 0,i.video=L.type!=="audio"?L:void 0,i.initSegment=g;var R=(n=this.initPTS)!=null?n:0;return i.id3=(0,D.flushTextTrackMetadataCueSamples)(v,s,R,R),a.samples.length&&(i.text=(0,D.flushTextTrackUserdataCueSamples)(a,s,R)),i},E}();function A(E,x){var f=E==null?void 0:E.codec;return f&&f.length>4?f:f==="hvc1"||f==="hev1"?"hvc1.1.c.L120.90":f==="av01"?"av01.0.04M.08":f==="avc1"||x===P.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}let S=b},"./src/task-loop.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>O});var O=function(){function D(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var M=D.prototype;return M.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},M.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},M.onHandlerDestroyed=function(){},M.hasInterval=function(){return!!this._tickInterval},M.hasNextTick=function(){return!!this._tickTimer},M.setInterval=function(U){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,U),!0)},M.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},M.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},M.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},M.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},M.doTick=function(){},D}()},"./src/types/cmcd.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{CMCDObjectType:()=>D,CMCDStreamType:()=>P,CMCDStreamingFormat:()=>M,CMCDVersion:()=>O});var O=1,D;(function(U){U.MANIFEST="m",U.AUDIO="a",U.VIDEO="v",U.MUXED="av",U.INIT="i",U.CAPTION="c",U.TIMED_TEXT="tt",U.KEY="k",U.OTHER="o"})(D||(D={}));var M;(function(U){U.DASH="d",U.HLS="h",U.SMOOTH="s",U.OTHER="o"})(M||(M={}));var P;(function(U){U.VOD="v",U.LIVE="l"})(P||(P={}))},"./src/types/demuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{MetadataSchema:()=>O});var O;(function(D){D.audioId3="org.id3",D.dateRange="com.apple.quicktime.HLS",D.emsg="https://aomedia.org/emsg/ID3"})(O||(O={}))},"./src/types/level.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{HdcpLevels:()=>U,HlsSkip:()=>b,HlsUrlParameters:()=>S,Level:()=>E,getSkipValue:()=>A});function O(x,f){for(var _=0;_<f.length;_++){var p=f[_];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(x,M(p.key),p)}}function D(x,f,_){return f&&O(x.prototype,f),_&&O(x,_),Object.defineProperty(x,"prototype",{writable:!1}),x}function M(x){var f=P(x,"string");return typeof f=="symbol"?f:String(f)}function P(x,f){if(typeof x!="object"||x===null)return x;var _=x[Symbol.toPrimitive];if(_!==void 0){var p=_.call(x,f||"default");if(typeof p!="object")return p;throw new TypeError("@@toPrimitive must return a primitive value.")}return(f==="string"?String:Number)(x)}var U=["NONE","TYPE-0","TYPE-1","TYPE-2",null],b;(function(x){x.No="",x.Yes="YES",x.v2="v2"})(b||(b={}));function A(x,f){var _=x.canSkipUntil,p=x.canSkipDateRanges,v=x.endSN,a=f!==void 0?f-v:0;return _&&a<_?p?b.v2:b.Yes:b.No}var S=function(){function x(_,p,v){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=_,this.part=p,this.skip=v}var f=x.prototype;return f.addDirectives=function(p){var v=new self.URL(p);return this.msn!==void 0&&v.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&v.searchParams.set("_HLS_part",this.part.toString()),this.skip&&v.searchParams.set("_HLS_skip",this.skip),v.href},x}(),E=function(){function x(f){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[f.url],this.attrs=f.attrs,this.bitrate=f.bitrate,f.details&&(this.details=f.details),this.id=f.id||0,this.name=f.name,this.width=f.width||0,this.height=f.height||0,this.audioCodec=f.audioCodec,this.videoCodec=f.videoCodec,this.unknownCodecs=f.unknownCodecs,this.codecSet=[f.videoCodec,f.audioCodec].filter(function(_){return _}).join(",").replace(/\.[^.,]+/g,"")}return D(x,[{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(_){var p=_%this.url.length;this._urlId!==p&&(this.details=void 0,this._urlId=p)}}]),x}()},"./src/types/loader.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{PlaylistContextType:()=>O,PlaylistLevelType:()=>D});var O;(function(M){M.MANIFEST="manifest",M.LEVEL="level",M.AUDIO_TRACK="audioTrack",M.SUBTITLE_TRACK="subtitleTrack"})(O||(O={}));var D;(function(M){M.MAIN="main",M.AUDIO="audio",M.SUBTITLE="subtitle"})(D||(D={}))},"./src/types/transmuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{ChunkMetadata:()=>O});var O=function(P,U,b,A,S,E){A===void 0&&(A=0),S===void 0&&(S=-1),E===void 0&&(E=!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=D(),this.buffering={audio:D(),video:D(),audiovideo:D()},this.level=P,this.sn=U,this.id=b,this.size=A,this.part=S,this.partial=E};function D(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{AttrList:()=>M});var O=/^(\d+)x(\d+)$/,D=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,M=function(){function P(b){typeof b=="string"&&(b=P.parseAttrList(b));for(var A in b)b.hasOwnProperty(A)&&(this[A]=b[A])}var U=P.prototype;return U.decimalInteger=function(A){var S=parseInt(this[A],10);return S>Number.MAX_SAFE_INTEGER?1/0:S},U.hexadecimalInteger=function(A){if(this[A]){var S=(this[A]||"0x").slice(2);S=(S.length&1?"0":"")+S;for(var E=new Uint8Array(S.length/2),x=0;x<S.length/2;x++)E[x]=parseInt(S.slice(x*2,x*2+2),16);return E}else return null},U.hexadecimalIntegerAsNumber=function(A){var S=parseInt(this[A],16);return S>Number.MAX_SAFE_INTEGER?1/0:S},U.decimalFloatingPoint=function(A){return parseFloat(this[A])},U.optionalFloat=function(A,S){var E=this[A];return E?parseFloat(E):S},U.enumeratedString=function(A){return this[A]},U.bool=function(A){return this[A]==="YES"},U.decimalResolution=function(A){var S=O.exec(this[A]);if(S!==null)return{width:parseInt(S[1],10),height:parseInt(S[2],10)}},P.parseAttrList=function(A){var S,E={},x='"';for(D.lastIndex=0;(S=D.exec(A))!==null;){var f=S[2];f.indexOf(x)===0&&f.lastIndexOf(x)===f.length-1&&(f=f.slice(1,-1)),E[S[1]]=f}return E},P}()},"./src/utils/binary-search.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>D});var O={search:function(P,U){for(var b=0,A=P.length-1,S=null,E=null;b<=A;){S=(b+A)/2|0,E=P[S];var x=U(E);if(x>0)b=S+1;else if(x<0)A=S-1;else return E}return null}};let D=O},"./src/utils/buffer-helper.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{BufferHelper:()=>M});var O=T("./src/utils/logger.ts"),D={length:0,start:function(){return 0},end:function(){return 0}},M=function(){function P(){}return P.isBuffered=function(b,A){try{if(b){for(var S=P.getBuffered(b),E=0;E<S.length;E++)if(A>=S.start(E)&&A<=S.end(E))return!0}}catch{}return!1},P.bufferInfo=function(b,A,S){try{if(b){var E=P.getBuffered(b),x=[],f;for(f=0;f<E.length;f++)x.push({start:E.start(f),end:E.end(f)});return this.bufferedInfo(x,A,S)}}catch{}return{len:0,start:A,end:A,nextStart:void 0}},P.bufferedInfo=function(b,A,S){A=Math.max(0,A),b.sort(function(i,u){var g=i.start-u.start;return g||u.end-i.end});var E=[];if(S)for(var x=0;x<b.length;x++){var f=E.length;if(f){var _=E[f-1].end;b[x].start-_<S?b[x].end>_&&(E[f-1].end=b[x].end):E.push(b[x])}else E.push(b[x])}else E=b;for(var p=0,v,a=A,s=A,n=0;n<E.length;n++){var d=E[n].start,l=E[n].end;if(A+S>=d&&A<l)a=d,s=l,p=s-A;else if(A+S<d){v=d;break}}return{len:p,start:a||0,end:s||0,nextStart:v}},P.getBuffered=function(b){try{return b.buffered}catch(A){return O.logger.log("failed to get media.buffered",A),D}},P}()},"./src/utils/cea-608-parser.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{CaptionScreen:()=>n,Row:()=>s,default:()=>c});var O=T("./src/utils/logger.ts"),D={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},M=function(e){var r=e;return D.hasOwnProperty(e)&&(r=D[e]),String.fromCharCode(r)},P=15,U=100,b={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},S={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},E={25:2,26:4,29:6,30:8,31:10,27:13,28:15},x=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],f;(function(m){m[m.ERROR=0]="ERROR",m[m.TEXT=1]="TEXT",m[m.WARNING=2]="WARNING",m[m.INFO=2]="INFO",m[m.DEBUG=3]="DEBUG",m[m.DATA=3]="DATA"})(f||(f={}));var _=function(){function m(){this.time=null,this.verboseLevel=f.ERROR}var e=m.prototype;return e.log=function(t,o){if(this.verboseLevel>=t){var y=typeof o=="function"?o():o;O.logger.log(this.time+" ["+t+"] "+y)}},m}(),p=function(e){for(var r=[],t=0;t<e.length;t++)r.push(e[t].toString(16));return r},v=function(){function m(r,t,o,y,h){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=r||"white",this.underline=t||!1,this.italics=o||!1,this.background=y||"black",this.flash=h||!1}var e=m.prototype;return e.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},e.setStyles=function(t){for(var o=["foreground","underline","italics","background","flash"],y=0;y<o.length;y++){var h=o[y];t.hasOwnProperty(h)&&(this[h]=t[h])}},e.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},e.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},e.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},e.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},m}(),a=function(){function m(r,t,o,y,h,L){this.uchar=void 0,this.penState=void 0,this.uchar=r||" ",this.penState=new v(t,o,y,h,L)}var e=m.prototype;return e.reset=function(){this.uchar=" ",this.penState.reset()},e.setChar=function(t,o){this.uchar=t,this.penState.copy(o)},e.setPenState=function(t){this.penState.copy(t)},e.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},e.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},e.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},m}(),s=function(){function m(r){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<U;t++)this.chars.push(new a);this.logger=r,this.pos=0,this.currPenState=new v}var e=m.prototype;return e.equals=function(t){for(var o=!0,y=0;y<U;y++)if(!this.chars[y].equals(t.chars[y])){o=!1;break}return o},e.copy=function(t){for(var o=0;o<U;o++)this.chars[o].copy(t.chars[o])},e.isEmpty=function(){for(var t=!0,o=0;o<U;o++)if(!this.chars[o].isEmpty()){t=!1;break}return t},e.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(f.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>U&&(this.logger.log(f.DEBUG,"Too large cursor position "+this.pos),this.pos=U)},e.moveCursor=function(t){var o=this.pos+t;if(t>1)for(var y=this.pos+1;y<o+1;y++)this.chars[y].setPenState(this.currPenState);this.setCursor(o)},e.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},e.insertChar=function(t){var o=this;t>=144&&this.backSpace();var y=M(t);if(this.pos>=U){this.logger.log(f.ERROR,function(){return"Cannot insert "+t.toString(16)+" ("+y+") at position "+o.pos+". Skipping it!"});return}this.chars[this.pos].setChar(y,this.currPenState),this.moveCursor(1)},e.clearFromPos=function(t){var o;for(o=t;o<U;o++)this.chars[o].reset()},e.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},e.clearToEndOfRow=function(){this.clearFromPos(this.pos)},e.getTextString=function(){for(var t=[],o=!0,y=0;y<U;y++){var h=this.chars[y].uchar;h!==" "&&(o=!1),t.push(h)}return o?"":t.join("")},e.setPenStyles=function(t){this.currPenState.setStyles(t);var o=this.chars[this.pos];o.setPenState(this.currPenState)},m}(),n=function(){function m(r){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<P;t++)this.rows.push(new s(r));this.logger=r,this.currRow=P-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var e=m.prototype;return e.reset=function(){for(var t=0;t<P;t++)this.rows[t].clear();this.currRow=P-1},e.equals=function(t){for(var o=!0,y=0;y<P;y++)if(!this.rows[y].equals(t.rows[y])){o=!1;break}return o},e.copy=function(t){for(var o=0;o<P;o++)this.rows[o].copy(t.rows[o])},e.isEmpty=function(){for(var t=!0,o=0;o<P;o++)if(!this.rows[o].isEmpty()){t=!1;break}return t},e.backSpace=function(){var t=this.rows[this.currRow];t.backSpace()},e.clearToEndOfRow=function(){var t=this.rows[this.currRow];t.clearToEndOfRow()},e.insertChar=function(t){var o=this.rows[this.currRow];o.insertChar(t)},e.setPen=function(t){var o=this.rows[this.currRow];o.setPenStyles(t)},e.moveCursor=function(t){var o=this.rows[this.currRow];o.moveCursor(t)},e.setCursor=function(t){this.logger.log(f.INFO,"setCursor: "+t);var o=this.rows[this.currRow];o.setCursor(t)},e.setPAC=function(t){this.logger.log(f.INFO,function(){return"pacData = "+JSON.stringify(t)});var o=t.row-1;if(this.nrRollUpRows&&o<this.nrRollUpRows-1&&(o=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==o){for(var y=0;y<P;y++)this.rows[y].clear();var h=this.currRow+1-this.nrRollUpRows,L=this.lastOutputScreen;if(L){var R=L.rows[h].cueStartTime,I=this.logger.time;if(R&&I!==null&&R<I)for(var k=0;k<this.nrRollUpRows;k++)this.rows[o-this.nrRollUpRows+k+1].copy(L.rows[h+k])}}this.currRow=o;var F=this.rows[this.currRow];if(t.indent!==null){var W=t.indent,K=Math.max(W-1,0);F.setCursor(t.indent),t.color=F.chars[K].penState.foreground}var H={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(H)},e.setBkgData=function(t){this.logger.log(f.INFO,function(){return"bkgData = "+JSON.stringify(t)}),this.backSpace(),this.setPen(t),this.insertChar(32)},e.setRollUpRows=function(t){this.nrRollUpRows=t},e.rollUp=function(){var t=this;if(this.nrRollUpRows===null){this.logger.log(f.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(f.TEXT,function(){return t.getDisplayText()});var o=this.currRow+1-this.nrRollUpRows,y=this.rows.splice(o,1)[0];y.clear(),this.rows.splice(this.currRow,0,y),this.logger.log(f.INFO,"Rolling up")},e.getDisplayText=function(t){t=t||!1;for(var o=[],y="",h=-1,L=0;L<P;L++){var R=this.rows[L].getTextString();R&&(h=L+1,t?o.push("Row "+h+": '"+R+"'"):o.push(R.trim()))}return o.length>0&&(t?y="["+o.join(" | ")+"]":y=o.join(`
|
|
22
|
+
`)),y},e.getTextAndFormat=function(){return this.rows},m}(),d=function(){function m(r,t,o){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=r,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new n(o),this.nonDisplayedMemory=new n(o),this.lastOutputScreen=new n(o),this.currRollUpRow=this.displayedMemory.rows[P-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=o}var e=m.prototype;return e.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[P-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},e.getHandler=function(){return this.outputFilter},e.setHandler=function(t){this.outputFilter=t},e.setPAC=function(t){this.writeScreen.setPAC(t)},e.setBkgData=function(t){this.writeScreen.setBkgData(t)},e.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(f.INFO,function(){return"MODE="+t}),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=t)},e.insertChars=function(t){for(var o=this,y=0;y<t.length;y++)this.writeScreen.insertChar(t[y]);var h=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(f.INFO,function(){return h+": "+o.writeScreen.getDisplayText(!0)}),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(f.TEXT,function(){return"DISPLAYED: "+o.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},e.ccRCL=function(){this.logger.log(f.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},e.ccBS=function(){this.logger.log(f.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},e.ccAOF=function(){},e.ccAON=function(){},e.ccDER=function(){this.logger.log(f.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},e.ccRU=function(t){this.logger.log(f.INFO,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},e.ccFON=function(){this.logger.log(f.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},e.ccRDC=function(){this.logger.log(f.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},e.ccTR=function(){this.logger.log(f.INFO,"TR"),this.setMode("MODE_TEXT")},e.ccRTD=function(){this.logger.log(f.INFO,"RTD"),this.setMode("MODE_TEXT")},e.ccEDM=function(){this.logger.log(f.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},e.ccCR=function(){this.logger.log(f.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},e.ccENM=function(){this.logger.log(f.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},e.ccEOC=function(){var t=this;if(this.logger.log(f.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var o=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=o,this.writeScreen=this.nonDisplayedMemory,this.logger.log(f.TEXT,function(){return"DISP: "+t.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},e.ccTO=function(t){this.logger.log(f.INFO,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},e.ccMIDROW=function(t){var o={flash:!1};if(o.underline=t%2===1,o.italics=t>=46,o.italics)o.foreground="white";else{var y=Math.floor(t/2)-16,h=["white","green","blue","cyan","red","yellow","magenta"];o.foreground=h[y]}this.logger.log(f.INFO,"MIDROW: "+JSON.stringify(o)),this.writeScreen.setPen(o)},e.outputDataUpdate=function(t){t===void 0&&(t=!1);var o=this.logger.time;o!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=o:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,o,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:o),this.lastOutputScreen.copy(this.displayedMemory))},e.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},m}(),l=function(){function m(r,t,o){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var y=new _;this.channels=[null,new d(r,t,y),new d(r+1,o,y)],this.cmdHistory=g(),this.logger=y}var e=m.prototype;return e.getHandler=function(t){return this.channels[t].getHandler()},e.setHandler=function(t,o){this.channels[t].setHandler(o)},e.addData=function(t,o){var y,h,L,R=!1;this.logger.time=t;for(var I=0;I<o.length;I+=2)if(h=o[I]&127,L=o[I+1]&127,!(h===0&&L===0)){if(this.logger.log(f.DATA,"["+p([o[I],o[I+1]])+"] -> ("+p([h,L])+")"),y=this.parseCmd(h,L),y||(y=this.parseMidrow(h,L)),y||(y=this.parsePAC(h,L)),y||(y=this.parseBackgroundAttributes(h,L)),!y&&(R=this.parseChars(h,L),R)){var k=this.currentChannel;if(k&&k>0){var F=this.channels[k];F.insertChars(R)}else this.logger.log(f.WARNING,"No channel found yet. TEXT-MODE?")}!y&&!R&&this.logger.log(f.WARNING,"Couldn't parse cleaned data "+p([h,L])+" orig: "+p([o[I],o[I+1]]))}},e.parseCmd=function(t,o){var y=this.cmdHistory,h=(t===20||t===28||t===21||t===29)&&o>=32&&o<=47,L=(t===23||t===31)&&o>=33&&o<=35;if(!(h||L))return!1;if(u(t,o,y))return i(null,null,y),this.logger.log(f.DEBUG,"Repeated command ("+p([t,o])+") is dropped"),!0;var R=t===20||t===21||t===23?1:2,I=this.channels[R];return t===20||t===21||t===28||t===29?o===32?I.ccRCL():o===33?I.ccBS():o===34?I.ccAOF():o===35?I.ccAON():o===36?I.ccDER():o===37?I.ccRU(2):o===38?I.ccRU(3):o===39?I.ccRU(4):o===40?I.ccFON():o===41?I.ccRDC():o===42?I.ccTR():o===43?I.ccRTD():o===44?I.ccEDM():o===45?I.ccCR():o===46?I.ccENM():o===47&&I.ccEOC():I.ccTO(o-32),i(t,o,y),this.currentChannel=R,!0},e.parseMidrow=function(t,o){var y=0;if((t===17||t===25)&&o>=32&&o<=47){if(t===17?y=1:y=2,y!==this.currentChannel)return this.logger.log(f.ERROR,"Mismatch channel in midrow parsing"),!1;var h=this.channels[y];return h?(h.ccMIDROW(o),this.logger.log(f.DEBUG,"MIDROW ("+p([t,o])+")"),!0):!1}return!1},e.parsePAC=function(t,o){var y,h=this.cmdHistory,L=(t>=17&&t<=23||t>=25&&t<=31)&&o>=64&&o<=127,R=(t===16||t===24)&&o>=64&&o<=95;if(!(L||R))return!1;if(u(t,o,h))return i(null,null,h),!0;var I=t<=23?1:2;o>=64&&o<=95?y=I===1?b[t]:S[t]:y=I===1?A[t]:E[t];var k=this.channels[I];return k?(k.setPAC(this.interpretPAC(y,o)),i(t,o,h),this.currentChannel=I,!0):!1},e.interpretPAC=function(t,o){var y,h={color:null,italics:!1,indent:null,underline:!1,row:t};return o>95?y=o-96:y=o-64,h.underline=(y&1)===1,y<=13?h.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(y/2)]:y<=15?(h.italics=!0,h.color="white"):h.indent=Math.floor((y-16)/2)*4,h},e.parseChars=function(t,o){var y,h=null,L=null;if(t>=25?(y=2,L=t-8):(y=1,L=t),L>=17&&L<=19){var R;L===17?R=o+80:L===18?R=o+112:R=o+144,this.logger.log(f.INFO,"Special char '"+M(R)+"' in channel "+y),h=[R]}else t>=32&&t<=127&&(h=o===0?[t]:[t,o]);if(h){var I=p(h);this.logger.log(f.DEBUG,"Char codes = "+I.join(",")),i(t,o,this.cmdHistory)}return h},e.parseBackgroundAttributes=function(t,o){var y=(t===16||t===24)&&o>=32&&o<=47,h=(t===23||t===31)&&o>=45&&o<=47;if(!(y||h))return!1;var L,R={};t===16||t===24?(L=Math.floor((o-32)/2),R.background=x[L],o%2===1&&(R.background=R.background+"_semi")):o===45?R.background="transparent":(R.foreground="black",o===47&&(R.underline=!0));var I=t<=23?1:2,k=this.channels[I];return k.setBkgData(R),i(t,o,this.cmdHistory),!0},e.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var o=this.channels[t];o&&o.reset()}this.cmdHistory=g()},e.cueSplitAtTime=function(t){for(var o=0;o<this.channels.length;o++){var y=this.channels[o];y&&y.cueSplitAtTime(t)}},m}();function i(m,e,r){r.a=m,r.b=e}function u(m,e,r){return r.a===m&&r.b===e}function g(){return{a:null,b:null}}let c=l},"./src/utils/codecs.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{isCodecSupportedInMp4:()=>M,isCodecType:()=>D});var O={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,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,dva1:!0,dvav:!0,dvh1:!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 D(P,U){var b=O[U];return!!b&&b[P.slice(0,4)]===!0}function M(P,U){return MediaSource.isTypeSupported((U||"video")+'/mp4;codecs="'+P+'"')}},"./src/utils/cues.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>b});var O=T("./src/utils/vttparser.ts"),D=T("./src/utils/webvtt-parser.ts"),M=T("./src/utils/texttrack-utils.ts"),P=/\s/,U={newCue:function(S,E,x,f){for(var _=[],p,v,a,s,n,d=self.VTTCue||self.TextTrackCue,l=0;l<f.rows.length;l++)if(p=f.rows[l],a=!0,s=0,n="",!p.isEmpty()){for(var i=0;i<p.chars.length;i++)P.test(p.chars[i].uchar)&&a?s++:(n+=p.chars[i].uchar,a=!1);p.cueStartTime=E,E===x&&(x+=1e-4),s>=16?s--:s++;var u=(0,O.fixLineBreaks)(n.trim()),g=(0,D.generateCueId)(E,x,u);(!S||!S.cues||!S.cues.getCueById(g))&&(v=new d(E,x,u),v.id=g,v.line=l+1,v.align="left",v.position=10+Math.min(80,Math.floor(s*8/32)*10),_.push(v))}return S&&_.length&&(_.sort(function(c,m){return c.line==="auto"||m.line==="auto"?0:c.line>8&&m.line>8?m.line-c.line:c.line-m.line}),_.forEach(function(c){return(0,M.addCueToTrack)(S,c)})),_}};let b=U},"./src/utils/discontinuities.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{adjustSlidingStart:()=>S,alignMediaPlaylistByPDT:()=>_,alignPDT:()=>f,alignStream:()=>E,findDiscontinuousReferenceFrag:()=>b,findFirstFragWithCC:()=>P,shouldAlignOnDiscontinuities:()=>U});var O=T("./src/polyfills/number.ts"),D=T("./src/utils/logger.ts"),M=T("./src/controller/level-helper.ts");function P(p,v){for(var a=null,s=0,n=p.length;s<n;s++){var d=p[s];if(d&&d.cc===v){a=d;break}}return a}function U(p,v,a){return!!(v.details&&(a.endCC>a.startCC||p&&p.cc<a.startCC))}function b(p,v,a){a===void 0&&(a=0);var s=p.fragments,n=v.fragments;if(!n.length||!s.length){D.logger.log("No fragments to align");return}var d=P(s,n[0].cc);if(!d||d&&!d.startPTS){D.logger.log("No frag in previous level to align on");return}return d}function A(p,v){if(p){var a=p.start+v;p.start=p.startPTS=a,p.endPTS=a+p.duration}}function S(p,v){for(var a=v.fragments,s=0,n=a.length;s<n;s++)A(a[s],p);v.fragmentHint&&A(v.fragmentHint,p),v.alignedSliding=!0}function E(p,v,a){!v||(x(p,a,v),!a.alignedSliding&&v.details&&f(a,v.details),!a.alignedSliding&&v.details&&!a.skippedSegments&&(0,M.adjustSliding)(v.details,a))}function x(p,v,a){if(U(p,a,v)){var s=b(a.details,v);s&&(0,O.isFiniteNumber)(s.start)&&(D.logger.log("Adjusting PTS using last level due to CC increase within current level "+v.url),S(s.start,v))}}function f(p,v){if(!(!v.fragments.length||!p.hasProgramDateTime||!v.hasProgramDateTime)){var a=v.fragments[0].programDateTime,s=p.fragments[0].programDateTime,n=(s-a)/1e3+v.fragments[0].start;n&&(0,O.isFiniteNumber)(n)&&(D.logger.log("Adjusting PTS using programDateTime delta "+(s-a)+"ms, sliding:"+n.toFixed(3)+" "+p.url+" "),S(n,p))}}function _(p,v){if(!(!p.hasProgramDateTime||!v.hasProgramDateTime)){var a=p.fragments,s=v.fragments;if(!(!a.length||!s.length)){var n=Math.round(s.length/2)-1,d=s[n],l=P(a,d.cc)||a[Math.round(a.length/2)-1],i=d.programDateTime,u=l.programDateTime;if(!(i===null||u===null)){var g=(u-i)/1e3-(l.start-d.start);S(g,p)}}}}},"./src/utils/ewma-bandwidth-estimator.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>M});var O=T("./src/utils/ewma.ts"),D=function(){function P(b,A,S){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=S,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new O.default(b),this.fast_=new O.default(A)}var U=P.prototype;return U.update=function(A,S){var E=this.slow_,x=this.fast_;this.slow_.halfLife!==A&&(this.slow_=new O.default(A,E.getEstimate(),E.getTotalWeight())),this.fast_.halfLife!==S&&(this.fast_=new O.default(S,x.getEstimate(),x.getTotalWeight()))},U.sample=function(A,S){A=Math.max(A,this.minDelayMs_);var E=8*S,x=A/1e3,f=E/x;this.fast_.sample(x,f),this.slow_.sample(x,f)},U.canEstimate=function(){var A=this.fast_;return A&&A.getTotalWeight()>=this.minWeight_},U.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},U.destroy=function(){},P}();let M=D},"./src/utils/ewma.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>D});var O=function(){function M(U,b,A){b===void 0&&(b=0),A===void 0&&(A=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=U,this.alpha_=U?Math.exp(Math.log(.5)/U):0,this.estimate_=b,this.totalWeight_=A}var P=M.prototype;return P.sample=function(b,A){var S=Math.pow(this.alpha_,b);this.estimate_=A*(1-S)+S*this.estimate_,this.totalWeight_+=b},P.getTotalWeight=function(){return this.totalWeight_},P.getEstimate=function(){if(this.alpha_){var b=1-Math.pow(this.alpha_,this.totalWeight_);if(b)return this.estimate_/b}return this.estimate_},M}();let D=O},"./src/utils/fetch-loader.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>n,fetchSupported:()=>_});var O=T("./src/polyfills/number.ts"),D=T("./src/loader/load-stats.ts"),M=T("./src/demux/chunk-cache.ts");function P(d,l){d.prototype=Object.create(l.prototype),d.prototype.constructor=d,E(d,l)}function U(d){var l=typeof Map=="function"?new Map:void 0;return U=function(u){if(u===null||!S(u))return u;if(typeof u!="function")throw new TypeError("Super expression must either be null or a function");if(typeof l!="undefined"){if(l.has(u))return l.get(u);l.set(u,g)}function g(){return b(u,arguments,x(this).constructor)}return g.prototype=Object.create(u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),E(g,u)},U(d)}function b(d,l,i){return A()?b=Reflect.construct.bind():b=function(g,c,m){var e=[null];e.push.apply(e,c);var r=Function.bind.apply(g,e),t=new r;return m&&E(t,m.prototype),t},b.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 S(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function E(d,l){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,g){return u.__proto__=g,u},E(d,l)}function x(d){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},x(d)}function f(){return f=Object.assign?Object.assign.bind():function(d){for(var l=1;l<arguments.length;l++){var i=arguments[l];for(var u in i)Object.prototype.hasOwnProperty.call(i,u)&&(d[u]=i[u])}return d},f.apply(this,arguments)}function _(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function d(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||a,this.controller=new self.AbortController,this.stats=new D.LoadStats}var l=d.prototype;return l.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},l.abortInternal=function(){var u=this.response;(!u||!u.ok)&&(this.stats.aborted=!0,this.controller.abort())},l.abort=function(){var u;this.abortInternal(),(u=this.callbacks)!==null&&u!==void 0&&u.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},l.load=function(u,g,c){var m=this,e=this.stats;if(e.loading.start)throw new Error("Loader can only be used once.");e.loading.start=self.performance.now();var r=v(u,this.controller.signal),t=c.onProgress,o=u.responseType==="arraybuffer",y=o?"byteLength":"length";this.context=u,this.config=g,this.callbacks=c,this.request=this.fetchSetup(u,r),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){m.abortInternal(),c.onTimeout(e,u,m.response)},g.timeout),self.fetch(this.request).then(function(h){if(m.response=m.loader=h,!h.ok){var L=h.status,R=h.statusText;throw new s(R||"fetch, bad network response",L,h)}return e.loading.first=Math.max(self.performance.now(),e.loading.start),e.total=parseInt(h.headers.get("Content-Length")||"0"),t&&(0,O.isFiniteNumber)(g.highWaterMark)?m.loadProgressively(h,e,u,g.highWaterMark,t):o?h.arrayBuffer():h.text()}).then(function(h){var L=m.response;self.clearTimeout(m.requestTimeout),e.loading.end=Math.max(self.performance.now(),e.loading.first);var R=h[y];R&&(e.loaded=e.total=R);var I={url:L.url,data:h};t&&!(0,O.isFiniteNumber)(g.highWaterMark)&&t(e,u,h,L),c.onSuccess(I,e,u,L)}).catch(function(h){if(self.clearTimeout(m.requestTimeout),!e.aborted){var L=h&&h.code||0,R=h?h.message:null;c.onError({code:L,text:R},u,h?h.details:null)}})},l.getCacheAge=function(){var u=null;if(this.response){var g=this.response.headers.get("age");u=g?parseFloat(g):null}return u},l.loadProgressively=function(u,g,c,m,e){m===void 0&&(m=0);var r=new M.default,t=u.body.getReader(),o=function y(){return t.read().then(function(h){if(h.done)return r.dataLength&&e(g,c,r.flush(),u),Promise.resolve(new ArrayBuffer(0));var L=h.value,R=L.length;return g.loaded+=R,R<m||r.dataLength?(r.push(L),r.dataLength>=m&&e(g,c,r.flush(),u)):e(g,c,L,u),y()}).catch(function(){return Promise.reject()})};return o()},d}();function v(d,l){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:l,headers:new self.Headers(f({},d.headers))};return d.rangeEnd&&i.headers.set("Range","bytes="+d.rangeStart+"-"+String(d.rangeEnd-1)),i}function a(d,l){return new self.Request(d.url,l)}var s=function(d){P(l,d);function l(i,u,g){var c;return c=d.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=u,c.details=g,c}return l}(U(Error));let n=p},"./src/utils/hex.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>D});var O={hexDump:function(P){for(var U="",b=0;b<P.length;b++){var A=P[b].toString(16);A.length<2&&(A="0"+A),U+=A}return U}};let D=O},"./src/utils/imsc1-ttml-parser.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{IMSC1_CODEC:()=>S,parseIMSC1:()=>_});var O=T("./src/utils/mp4-tools.ts"),D=T("./src/utils/vttparser.ts"),M=T("./src/utils/vttcue.ts"),P=T("./src/demux/id3.ts"),U=T("./src/utils/timescale-conversion.ts"),b=T("./src/utils/webvtt-parser.ts");function A(){return A=Object.assign?Object.assign.bind():function(c){for(var m=1;m<arguments.length;m++){var e=arguments[m];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(c[r]=e[r])}return c},A.apply(this,arguments)}var S="stpp.ttml.im1t",E=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,x=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,f={left:"start",center:"center",right:"end",start:"start",end:"end"};function _(c,m,e,r,t){var o=(0,O.findBox)(new Uint8Array(c),["mdat"]);if(o.length===0){t(new Error("Could not parse IMSC1 mdat"));return}var y=o.map(function(L){return(0,P.utf8ArrayToStr)(L)}),h=(0,U.toTimescaleFromScale)(m,1,e);try{y.forEach(function(L){return r(p(L,h))})}catch(L){t(L)}}function p(c,m){var e=new DOMParser,r=e.parseFromString(c,"text/xml"),t=r.getElementsByTagName("tt")[0];if(!t)throw new Error("Invalid ttml");var o={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},y=Object.keys(o).reduce(function(k,F){return k[F]=t.getAttribute("ttp:"+F)||o[F],k},{}),h=t.getAttribute("xml:space")!=="preserve",L=a(v(t,"styling","style")),R=a(v(t,"layout","region")),I=v(t,"body","[begin]");return[].map.call(I,function(k){var F=s(k,h);if(!F||!k.hasAttribute("begin"))return null;var W=i(k.getAttribute("begin"),y),K=i(k.getAttribute("dur"),y),H=i(k.getAttribute("end"),y);if(W===null)throw l(k);if(H===null){if(K===null)throw l(k);H=W+K}var Y=new M.default(W-m,H-m,F);Y.id=(0,b.generateCueId)(Y.startTime,Y.endTime,Y.text);var q=R[k.getAttribute("region")],ee=L[k.getAttribute("style")],ae=n(q,ee,L),re=ae.textAlign;if(re){var se=f[re];se&&(Y.lineAlign=se),Y.align=re}return A(Y,ae),Y}).filter(function(k){return k!==null})}function v(c,m,e){var r=c.getElementsByTagName(m)[0];return r?[].slice.call(r.querySelectorAll(e)):[]}function a(c){return c.reduce(function(m,e){var r=e.getAttribute("xml:id");return r&&(m[r]=e),m},{})}function s(c,m){return[].slice.call(c.childNodes).reduce(function(e,r,t){var o;return r.nodeName==="br"&&t?e+`
|
|
23
|
+
`:(o=r.childNodes)!==null&&o!==void 0&&o.length?s(r,m):m?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function n(c,m,e){var r="http://www.w3.org/ns/ttml#styling",t=null,o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],y=c!=null&&c.hasAttribute("style")?c.getAttribute("style"):null;return y&&e.hasOwnProperty(y)&&(t=e[y]),o.reduce(function(h,L){var R=d(m,r,L)||d(c,r,L)||d(t,r,L);return R&&(h[L]=R),h},{})}function d(c,m,e){return c&&c.hasAttributeNS(m,e)?c.getAttributeNS(m,e):null}function l(c){return new Error("Could not parse ttml timestamp "+c)}function i(c,m){if(!c)return null;var e=(0,D.parseTimeStamp)(c);return e===null&&(E.test(c)?e=u(c,m):x.test(c)&&(e=g(c,m))),e}function u(c,m){var e=E.exec(c),r=(e[4]|0)+(e[5]|0)/m.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+r/m.frameRate}function g(c,m){var e=x.exec(c),r=Number(e[1]),t=e[2];switch(t){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/m.frameRate;case"t":return r/m.tickRate}return r}},"./src/utils/keysystem-util.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{changeEndianness:()=>M,convertDataUriToArrayBytes:()=>P,strToUtf8array:()=>U});var O=T("./src/utils/numeric-encoding-utils.ts");function D(b){var A=U(b).subarray(0,16),S=new Uint8Array(16);return S.set(A,16-A.length),S}function M(b){var A=function(E,x,f){var _=E[x];E[x]=E[f],E[f]=_};A(b,0,3),A(b,1,2),A(b,4,5),A(b,6,7)}function P(b){var A=b.split(":"),S=null;if(A[0]==="data"&&A.length===2){var E=A[1].split(";"),x=E[E.length-1].split(",");if(x.length===2){var f=x[0]==="base64",_=x[1];f?(E.splice(-1,1),S=(0,O.base64Decode)(_)):S=D(_)}}return S}function U(b){return Uint8Array.from(unescape(encodeURIComponent(b)),function(A){return A.charCodeAt(0)})}},"./src/utils/logger.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{enableLogs:()=>b,logger:()=>A});var O=function(){},D={trace:O,debug:O,log:O,warn:O,info:O,error:O},M=D;function P(S){var E=self.console[S];return E?E.bind(self.console,"["+S+"] >"):O}function U(S){for(var E=arguments.length,x=new Array(E>1?E-1:0),f=1;f<E;f++)x[f-1]=arguments[f];x.forEach(function(_){M[_]=S[_]?S[_].bind(S):P(_)})}function b(S,E){if(self.console&&S===!0||typeof S=="object"){U(S,"debug","log","info","warn","error");try{M.log('Debug logs enabled for "'+E+'"')}catch{M=D}}else M=D}var A=M},"./src/utils/mediakeys-helper.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{KeySystemFormats:()=>D,KeySystemIds:()=>P,KeySystems:()=>O,getKeySystemsForConfig:()=>A,getSupportedMediaKeySystemConfigurations:()=>E,keySystemDomainToKeySystemFormat:()=>b,keySystemFormatToKeySystemDomain:()=>M,keySystemIdToKeySystemDomain:()=>U,requestMediaKeySystemAccess:()=>S});var O;(function(f){f.CLEARKEY="org.w3.clearkey",f.FAIRPLAY="com.apple.fps",f.PLAYREADY="com.microsoft.playready",f.WIDEVINE="com.widevine.alpha"})(O||(O={}));var D;(function(f){f.CLEARKEY="org.w3.clearkey",f.FAIRPLAY="com.apple.streamingkeydelivery",f.PLAYREADY="com.microsoft.playready",f.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"})(D||(D={}));function M(f){switch(f){case D.FAIRPLAY:return O.FAIRPLAY;case D.PLAYREADY:return O.PLAYREADY;case D.WIDEVINE:return O.WIDEVINE;case D.CLEARKEY:return O.CLEARKEY}}var P;(function(f){f.WIDEVINE="edef8ba979d64acea3c827dcd51d21ed"})(P||(P={}));function U(f){if(f===P.WIDEVINE)return O.WIDEVINE}function b(f){switch(f){case O.FAIRPLAY:return D.FAIRPLAY;case O.PLAYREADY:return D.PLAYREADY;case O.WIDEVINE:return D.WIDEVINE;case O.CLEARKEY:return D.CLEARKEY}}function A(f){var _=f.drmSystems,p=f.widevineLicenseUrl,v=_?[O.FAIRPLAY,O.WIDEVINE,O.PLAYREADY,O.CLEARKEY].filter(function(a){return!!_[a]}):[];return!v[O.WIDEVINE]&&p&&v.push(O.WIDEVINE),v}var S=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function E(f,_,p,v){var a;switch(f){case O.FAIRPLAY:a=["cenc","sinf"];break;case O.WIDEVINE:case O.PLAYREADY:a=["cenc"];break;case O.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+f)}return x(a,_,p,v)}function x(f,_,p,v){var a={initDataTypes:f,persistentState:v.persistentState||"not-allowed",distinctiveIdentifier:v.distinctiveIdentifier||"not-allowed",sessionTypes:v.sessionTypes||[v.sessionType||"temporary"],audioCapabilities:_.map(function(s){return{contentType:'audio/mp4; codecs="'+s+'"',robustness:v.audioRobustness||"",encryptionScheme:v.audioEncryptionScheme||null}}),videoCapabilities:p.map(function(s){return{contentType:'video/mp4; codecs="'+s+'"',robustness:v.videoRobustness||"",encryptionScheme:v.videoEncryptionScheme||null}})};return[a]}},"./src/utils/mediasource-helper.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{getMediaSource:()=>O});function O(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{RemuxerTrackIdConfig:()=>S,appendUint8Array:()=>m,bin2str:()=>E,computeRawDurationFromSamples:()=>u,discardEPB:()=>y,findBox:()=>v,getDuration:()=>i,getStartDTS:()=>l,mp4Box:()=>L,mp4pssh:()=>R,offsetStartDTS:()=>g,parseEmsg:()=>h,parseInitSegment:()=>s,parsePssh:()=>I,parseSEIMessageFromNALu:()=>o,parseSamples:()=>e,parseSegmentIndex:()=>a,parseSinf:()=>d,patchEncyptionData:()=>n,readSint32:()=>_,readUint16:()=>x,readUint32:()=>f,segmentValidRange:()=>c,writeUint32:()=>p});var O=T("./src/loader/fragment.ts"),D=T("./src/utils/typed-array.ts"),M=T("./src/demux/id3.ts"),P=T("./src/utils/logger.ts"),U=T("./src/utils/hex.ts"),b=Math.pow(2,32)-1,A=[].push,S={video:1,audio:2,id3:3,text:4};function E(k){return String.fromCharCode.apply(null,k)}function x(k,F){var W=k[F]<<8|k[F+1];return W<0?65536+W:W}function f(k,F){var W=_(k,F);return W<0?4294967296+W:W}function _(k,F){return k[F]<<24|k[F+1]<<16|k[F+2]<<8|k[F+3]}function p(k,F,W){k[F]=W>>24,k[F+1]=W>>16&255,k[F+2]=W>>8&255,k[F+3]=W&255}function v(k,F){var W=[];if(!F.length)return W;for(var K=k.byteLength,H=0;H<K;){var Y=f(k,H),q=E(k.subarray(H+4,H+8)),ee=Y>1?H+Y:K;if(q===F[0])if(F.length===1)W.push(k.subarray(H+8,ee));else{var ae=v(k.subarray(H+8,ee),F.slice(1));ae.length&&A.apply(W,ae)}H=ee}return W}function a(k){var F=[],W=k[0],K=8,H=f(k,K);K+=4;var Y=0,q=0;W===0?K+=8:K+=16,K+=2;var ee=k.length+q,ae=x(k,K);K+=2;for(var re=0;re<ae;re++){var se=K,le=f(k,se);se+=4;var de=le&2147483647,ue=(le&2147483648)>>>31;if(ue===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var fe=f(k,se);se+=4,F.push({referenceSize:de,subsegmentDuration:fe,info:{duration:fe/H,start:ee,end:ee+de-1}}),ee+=de,se+=4,K=se}return{earliestPresentationTime:Y,timescale:H,version:W,referencesCount:ae,references:F}}function s(k){for(var F=[],W=v(k,["moov","trak"]),K=0;K<W.length;K++){var H=W[K],Y=v(H,["tkhd"])[0];if(Y){var q=Y[0],ee=q===0?12:20,ae=f(Y,ee),re=v(H,["mdia","mdhd"])[0];if(re){q=re[0],ee=q===0?12:20;var se=f(re,ee),le=v(H,["mdia","hdlr"])[0];if(le){var de=E(le.subarray(8,12)),ue={soun:O.ElementaryStreamTypes.AUDIO,vide:O.ElementaryStreamTypes.VIDEO}[de];if(ue){var fe=v(H,["mdia","minf","stbl","stsd"])[0],ce=void 0;fe&&(ce=E(fe.subarray(12,16))),F[ae]={timescale:se,type:ue},F[ue]={timescale:se,id:ae,codec:ce}}}}}}var be=v(k,["moov","mvex","trex"]);return be.forEach(function(Pe){var we=f(Pe,4),pe=F[we];pe&&(pe.default={duration:f(Pe,12),flags:f(Pe,20)})}),F}function n(k,F){if(!k||!F)return k;var W=F.keyId;if(W&&F.isCommonEncryption){var K=v(k,["moov","trak"]);K.forEach(function(H){var Y=v(H,["mdia","minf","stbl","stsd"])[0],q=Y.subarray(8),ee=v(q,["enca"]),ae=ee.length>0;ae||(ee=v(q,["encv"])),ee.forEach(function(re){var se=ae?re.subarray(28):re.subarray(78),le=v(se,["sinf"]);le.forEach(function(de){var ue=d(de);if(ue){var fe=ue.subarray(8,24);fe.some(function(ce){return ce!==0})||(P.logger.log("[eme] Patching keyId in 'enc"+(ae?"a":"v")+">sinf>>tenc' box: "+U.default.hexDump(fe)+" -> "+U.default.hexDump(W)),ue.set(W,8))}})})})}return k}function d(k){var F=v(k,["schm"])[0];if(F){var W=E(F.subarray(4,8));if(W==="cbcs"||W==="cenc")return v(k,["schi","tenc"])[0]}return P.logger.error("[eme] missing 'schm' box"),null}function l(k,F){return v(F,["moof","traf"]).reduce(function(W,K){var H=v(K,["tfdt"])[0],Y=H[0],q=v(K,["tfhd"]).reduce(function(ee,ae){var re=f(ae,4),se=k[re];if(se){var le=f(H,4);Y===1&&(le*=Math.pow(2,32),le+=f(H,8));var de=se.timescale||9e4,ue=le/de;if(isFinite(ue)&&(ee===null||ue<ee))return ue}return ee},null);return q!==null&&isFinite(q)&&(W===null||q<W)?q:W},null)||0}function i(k,F){for(var W=0,K=0,H=0,Y=v(k,["moof","traf"]),q=0;q<Y.length;q++){var ee=Y[q],ae=v(ee,["tfhd"])[0],re=f(ae,4),se=F[re];if(!!se){var le=se.default,de=f(ae,0)|(le==null?void 0:le.flags),ue=le==null?void 0:le.duration;de&8&&(de&2?ue=f(ae,12):ue=f(ae,8));for(var fe=se.timescale||9e4,ce=v(ee,["trun"]),be=0;be<ce.length;be++){if(W=u(ce[be]),!W&&ue){var Pe=f(ce[be],4);W=ue*Pe}se.type===O.ElementaryStreamTypes.VIDEO?K+=W/fe:se.type===O.ElementaryStreamTypes.AUDIO&&(H+=W/fe)}}}if(K===0&&H===0){for(var we=0,pe=v(k,["sidx"]),Me=0;Me<pe.length;Me++){var Re=a(pe[Me]);Re!=null&&Re.references&&(we+=Re.references.reduce(function(ke,Le){return ke+Le.info.duration||0},0))}return we}return K||H}function u(k){var F=f(k,0),W=8;F&1&&(W+=4),F&4&&(W+=4);for(var K=0,H=f(k,4),Y=0;Y<H;Y++){if(F&256){var q=f(k,W);K+=q,W+=4}F&512&&(W+=4),F&1024&&(W+=4),F&2048&&(W+=4)}return K}function g(k,F,W){v(F,["moof","traf"]).forEach(function(K){v(K,["tfhd"]).forEach(function(H){var Y=f(H,4),q=k[Y];if(!!q){var ee=q.timescale||9e4;v(K,["tfdt"]).forEach(function(ae){var re=ae[0],se=f(ae,4);if(re===0)se-=W*ee,se=Math.max(se,0),p(ae,4,se);else{se*=Math.pow(2,32),se+=f(ae,8),se-=W*ee,se=Math.max(se,0);var le=Math.floor(se/(b+1)),de=Math.floor(se%(b+1));p(ae,4,le),p(ae,8,de)}})}})})}function c(k){var F={valid:null,remainder:null},W=v(k,["moof"]);if(W){if(W.length<2)return F.remainder=k,F}else return F;var K=W[W.length-1];return F.valid=(0,D.sliceUint8)(k,0,K.byteOffset-8),F.remainder=(0,D.sliceUint8)(k,K.byteOffset-8),F}function m(k,F){var W=new Uint8Array(k.length+F.length);return W.set(k),W.set(F,k.length),W}function e(k,F){var W=[],K=F.samples,H=F.timescale,Y=F.id,q=!1,ee=v(K,["moof"]);return ee.map(function(ae){var re=ae.byteOffset-8,se=v(ae,["traf"]);se.map(function(le){var de=v(le,["tfdt"]).map(function(ue){var fe=ue[0],ce=f(ue,4);return fe===1&&(ce*=Math.pow(2,32),ce+=f(ue,8)),ce/H})[0];return de!==void 0&&(k=de),v(le,["tfhd"]).map(function(ue){var fe=f(ue,4),ce=f(ue,0)&16777215,be=(ce&1)!==0,Pe=(ce&2)!==0,we=(ce&8)!==0,pe=0,Me=(ce&16)!==0,Re=0,ke=(ce&32)!==0,Le=8;fe===Y&&(be&&(Le+=8),Pe&&(Le+=4),we&&(pe=f(ue,Le),Le+=4),Me&&(Re=f(ue,Le),Le+=4),ke&&(Le+=4),F.type==="video"&&(q=r(F.codec)),v(le,["trun"]).map(function(Ue){var He=Ue[0],Be=f(Ue,0)&16777215,Je=(Be&1)!==0,qe=0,st=(Be&4)!==0,Ze=(Be&256)!==0,ot=0,lt=(Be&512)!==0,tt=0,je=(Be&1024)!==0,Ve=(Be&2048)!==0,rt=0,gt=f(Ue,4),Ne=8;Je&&(qe=f(Ue,Ne),Ne+=4),st&&(Ne+=4);for(var it=qe+re,nt=0;nt<gt;nt++){if(Ze?(ot=f(Ue,Ne),Ne+=4):ot=pe,lt?(tt=f(Ue,Ne),Ne+=4):tt=Re,je&&(Ne+=4),Ve&&(He===0?rt=f(Ue,Ne):rt=_(Ue,Ne),Ne+=4),F.type===O.ElementaryStreamTypes.VIDEO)for(var Lt=0;Lt<tt;){var At=f(K,it);if(it+=4,t(q,K[it])){var Dt=K.subarray(it,it+At);o(Dt,q?2:1,k+rt/H,W)}it+=At,Lt+=At+4}k+=ot/H}}))})})}),W}function r(k){if(!k)return!1;var F=k.indexOf("."),W=F<0?k:k.substring(0,F);return W==="hvc1"||W==="hev1"||W==="dvh1"||W==="dvhe"}function t(k,F){if(k){var W=F>>1&63;return W===39||W===40}else{var K=F&31;return K===6}}function o(k,F,W,K){var H=y(k),Y=0;Y+=F;for(var q=0,ee=0,ae=!1,re=0;Y<H.length;){q=0;do{if(Y>=H.length)break;re=H[Y++],q+=re}while(re===255);ee=0;do{if(Y>=H.length)break;re=H[Y++],ee+=re}while(re===255);var se=H.length-Y;if(!ae&&q===4&&Y<H.length){ae=!0;var le=H[Y++];if(le===181){var de=x(H,Y);if(Y+=2,de===49){var ue=f(H,Y);if(Y+=4,ue===1195456820){var fe=H[Y++];if(fe===3){var ce=H[Y++],be=31&ce,Pe=64&ce,we=Pe?2+be*3:0,pe=new Uint8Array(we);if(Pe){pe[0]=ce;for(var Me=1;Me<we;Me++)pe[Me]=H[Y++]}K.push({type:fe,payloadType:q,pts:W,bytes:pe})}}}}}else if(q===5&&ee<se){if(ae=!0,ee>16){for(var Re=[],ke=0;ke<16;ke++){var Le=H[Y++].toString(16);Re.push(Le.length==1?"0"+Le:Le),(ke===3||ke===5||ke===7||ke===9)&&Re.push("-")}for(var Ue=ee-16,He=new Uint8Array(Ue),Be=0;Be<Ue;Be++)He[Be]=H[Y++];K.push({payloadType:q,pts:W,uuid:Re.join(""),userData:(0,M.utf8ArrayToStr)(He),userDataBytes:He})}}else if(ee<se)Y+=ee;else if(ee>se)break}}function y(k){for(var F=k.byteLength,W=[],K=1;K<F-2;)k[K]===0&&k[K+1]===0&&k[K+2]===3?(W.push(K+2),K+=2):K++;if(W.length===0)return k;var H=F-W.length,Y=new Uint8Array(H),q=0;for(K=0;K<H;q++,K++)q===W[0]&&(q++,W.shift()),Y[K]=k[q];return Y}function h(k){var F=k[0],W="",K="",H=0,Y=0,q=0,ee=0,ae=0,re=0;if(F===0){for(;E(k.subarray(re,re+1))!=="\0";)W+=E(k.subarray(re,re+1)),re+=1;for(W+=E(k.subarray(re,re+1)),re+=1;E(k.subarray(re,re+1))!=="\0";)K+=E(k.subarray(re,re+1)),re+=1;K+=E(k.subarray(re,re+1)),re+=1,H=f(k,12),Y=f(k,16),ee=f(k,20),ae=f(k,24),re=28}else if(F===1){re+=4,H=f(k,re),re+=4;var se=f(k,re);re+=4;var le=f(k,re);for(re+=4,q=Math.pow(2,32)*se+le,Number.isSafeInteger(q)||(q=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),ee=f(k,re),re+=4,ae=f(k,re),re+=4;E(k.subarray(re,re+1))!=="\0";)W+=E(k.subarray(re,re+1)),re+=1;for(W+=E(k.subarray(re,re+1)),re+=1;E(k.subarray(re,re+1))!=="\0";)K+=E(k.subarray(re,re+1)),re+=1;K+=E(k.subarray(re,re+1)),re+=1}var de=k.subarray(re,k.byteLength);return{schemeIdUri:W,value:K,timeScale:H,presentationTime:q,presentationTimeDelta:Y,eventDuration:ee,id:ae,payload:de}}function L(k){for(var F=arguments.length,W=new Array(F>1?F-1:0),K=1;K<F;K++)W[K-1]=arguments[K];for(var H=W.length,Y=8,q=H;q--;)Y+=W[q].byteLength;var ee=new Uint8Array(Y);for(ee[0]=Y>>24&255,ee[1]=Y>>16&255,ee[2]=Y>>8&255,ee[3]=Y&255,ee.set(k,4),q=0,Y=8;q<H;q++)ee.set(W[q],Y),Y+=W[q].byteLength;return ee}function R(k,F,W){if(k.byteLength!==16)throw new RangeError("Invalid system id");var K,H;if(F){K=1,H=new Uint8Array(F.length*16);for(var Y=0;Y<F.length;Y++){var q=F[Y];if(q.byteLength!==16)throw new RangeError("Invalid key");H.set(q,Y*16)}}else K=0,H=new Uint8Array;var ee;K>0?(ee=new Uint8Array(4),F.length>0&&new DataView(ee.buffer).setUint32(0,F.length,!1)):ee=new Uint8Array;var ae=new Uint8Array(4);return W&&W.byteLength>0&&new DataView(ae.buffer).setUint32(0,W.byteLength,!1),L([112,115,115,104],new Uint8Array([K,0,0,0]),k,ee,H,ae,W||new Uint8Array)}function I(k){if(!(k instanceof ArrayBuffer)||k.byteLength<32)return null;var F={version:0,systemId:"",kids:null,data:null},W=new DataView(k),K=W.getUint32(0);if(k.byteLength!==K&&K>44)return null;var H=W.getUint32(4);if(H!==1886614376||(F.version=W.getUint32(8)>>>24,F.version>1))return null;F.systemId=U.default.hexDump(new Uint8Array(k,12,16));var Y=W.getUint32(28);if(F.version===0){if(K-32<Y)return null;F.data=new Uint8Array(k,32,Y)}else if(F.version===1){F.kids=[];for(var q=0;q<Y;q++)F.kids.push(new Uint8Array(k,32+q*16,16))}return F}},"./src/utils/numeric-encoding-utils.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{base64Decode:()=>b,base64DecodeToStr:()=>M,base64Encode:()=>P,base64ToBase64Url:()=>O,base64UrlEncode:()=>U,strToBase64Encode:()=>D});function O(A){return A.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function D(A){return btoa(A)}function M(A){return atob(A)}function P(A){return btoa(String.fromCharCode.apply(String,A))}function U(A){return O(P(A))}function b(A){return Uint8Array.from(atob(A),function(S){return S.charCodeAt(0)})}},"./src/utils/output-filter.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>O});var O=function(){function D(P,U){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=P,this.trackName=U}var M=D.prototype;return M.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},M.newCue=function(U,b,A){(this.startTime===null||this.startTime>U)&&(this.startTime=U),this.endTime=b,this.screen=A,this.timelineController.createCaptionsTrack(this.trackName)},M.reset=function(){this.cueRanges=[],this.startTime=null},D}()},"./src/utils/texttrack-utils.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{addCueToTrack:()=>M,clearCurrentCues:()=>P,getCuesInRange:()=>A,removeCuesInRange:()=>U,sendAddTrackEvent:()=>D});var O=T("./src/utils/logger.ts");function D(S,E){var x;try{x=new Event("addtrack")}catch{x=document.createEvent("Event"),x.initEvent("addtrack",!1,!1)}x.track=S,E.dispatchEvent(x)}function M(S,E){var x=S.mode;if(x==="disabled"&&(S.mode="hidden"),S.cues&&!S.cues.getCueById(E.id))try{if(S.addCue(E),!S.cues.getCueById(E.id))throw new Error("addCue is failed for: "+E)}catch(_){O.logger.debug("[texttrack-utils]: "+_);var f=new self.TextTrackCue(E.startTime,E.endTime,E.text);f.id=E.id,S.addCue(f)}x==="disabled"&&(S.mode=x)}function P(S){var E=S.mode;if(E==="disabled"&&(S.mode="hidden"),S.cues)for(var x=S.cues.length;x--;)S.removeCue(S.cues[x]);E==="disabled"&&(S.mode=E)}function U(S,E,x,f){var _=S.mode;if(_==="disabled"&&(S.mode="hidden"),S.cues&&S.cues.length>0)for(var p=A(S.cues,E,x),v=0;v<p.length;v++)(!f||f(p[v]))&&S.removeCue(p[v]);_==="disabled"&&(S.mode=_)}function b(S,E){if(E<S[0].startTime)return 0;var x=S.length-1;if(E>S[x].endTime)return-1;for(var f=0,_=x;f<=_;){var p=Math.floor((_+f)/2);if(E<S[p].startTime)_=p-1;else if(E>S[p].startTime&&f<x)f=p+1;else return p}return S[f].startTime-E<E-S[_].startTime?f:_}function A(S,E,x){var f=[],_=b(S,E);if(_>-1)for(var p=_,v=S.length;p<v;p++){var a=S[p];if(a.startTime>=E&&a.endTime<=x)f.push(a);else if(a.startTime>x)return f}return f}},"./src/utils/time-ranges.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>D});var O={toString:function(P){for(var U="",b=P.length,A=0;A<b;A++)U+="["+P.start(A).toFixed(3)+","+P.end(A).toFixed(3)+"]";return U}};let D=O},"./src/utils/timescale-conversion.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{toMpegTsClockFromTimescale:()=>U,toMsFromMpegTsClock:()=>P,toTimescaleFromBase:()=>D,toTimescaleFromScale:()=>M});var O=9e4;function D(b,A,S,E){S===void 0&&(S=1),E===void 0&&(E=!1);var x=b*A*S;return E?Math.round(x):x}function M(b,A,S,E){return S===void 0&&(S=1),E===void 0&&(E=!1),D(b,A,1/S,E)}function P(b,A){return A===void 0&&(A=!1),D(b,1e3,1/O,A)}function U(b,A){return A===void 0&&(A=1),D(b,O,1/A)}},"./src/utils/typed-array.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{sliceUint8:()=>O});function O(D,M,P){return Uint8Array.prototype.slice?D.slice(M,P):new Uint8Array(Array.prototype.slice.call(D,M,P))}},"./src/utils/vttcue.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>O});let O=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var D=["","lr","rl"],M=["start","middle","end","left","right"];function P(E,x){if(typeof x!="string"||!Array.isArray(E))return!1;var f=x.toLowerCase();return~E.indexOf(f)?f:!1}function U(E){return P(D,E)}function b(E){return P(M,E)}function A(E){for(var x=arguments.length,f=new Array(x>1?x-1:0),_=1;_<x;_++)f[_-1]=arguments[_];for(var p=1;p<arguments.length;p++){var v=arguments[p];for(var a in v)E[a]=v[a]}return E}function S(E,x,f){var _=this,p={enumerable:!0};_.hasBeenReset=!1;var v="",a=!1,s=E,n=x,d=f,l=null,i="",u=!0,g="auto",c="start",m=50,e="middle",r=50,t="middle";Object.defineProperty(_,"id",A({},p,{get:function(){return v},set:function(y){v=""+y}})),Object.defineProperty(_,"pauseOnExit",A({},p,{get:function(){return a},set:function(y){a=!!y}})),Object.defineProperty(_,"startTime",A({},p,{get:function(){return s},set:function(y){if(typeof y!="number")throw new TypeError("Start time must be set to a number.");s=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"endTime",A({},p,{get:function(){return n},set:function(y){if(typeof y!="number")throw new TypeError("End time must be set to a number.");n=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"text",A({},p,{get:function(){return d},set:function(y){d=""+y,this.hasBeenReset=!0}})),Object.defineProperty(_,"region",A({},p,{get:function(){return l},set:function(y){l=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"vertical",A({},p,{get:function(){return i},set:function(y){var h=U(y);if(h===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=h,this.hasBeenReset=!0}})),Object.defineProperty(_,"snapToLines",A({},p,{get:function(){return u},set:function(y){u=!!y,this.hasBeenReset=!0}})),Object.defineProperty(_,"line",A({},p,{get:function(){return g},set:function(y){if(typeof y!="number"&&y!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");g=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"lineAlign",A({},p,{get:function(){return c},set:function(y){var h=b(y);if(!h)throw new SyntaxError("An invalid or illegal string was specified.");c=h,this.hasBeenReset=!0}})),Object.defineProperty(_,"position",A({},p,{get:function(){return m},set:function(y){if(y<0||y>100)throw new Error("Position must be between 0 and 100.");m=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"positionAlign",A({},p,{get:function(){return e},set:function(y){var h=b(y);if(!h)throw new SyntaxError("An invalid or illegal string was specified.");e=h,this.hasBeenReset=!0}})),Object.defineProperty(_,"size",A({},p,{get:function(){return r},set:function(y){if(y<0||y>100)throw new Error("Size must be between 0 and 100.");r=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"align",A({},p,{get:function(){return t},set:function(y){var h=b(y);if(!h)throw new SyntaxError("An invalid or illegal string was specified.");t=h,this.hasBeenReset=!0}})),_.displayState=void 0}return S.prototype.getCueAsHTML=function(){var E=self.WebVTT;return E.convertCueToDOMTree(self,this.text)},S}()},"./src/utils/vttparser.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{VTTParser:()=>x,fixLineBreaks:()=>E,parseTimeStamp:()=>M});var O=T("./src/utils/vttcue.ts"),D=function(){function f(){}var _=f.prototype;return _.decode=function(v,a){if(!v)return"";if(typeof v!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(v))},f}();function M(f){function _(v,a,s,n){return(v|0)*3600+(a|0)*60+(s|0)+parseFloat(n||0)}var p=f.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?_(p[2],p[3],0,p[4]):_(p[1],p[2],p[3],p[4]):null}var P=function(){function f(){this.values=Object.create(null)}var _=f.prototype;return _.set=function(v,a){!this.get(v)&&a!==""&&(this.values[v]=a)},_.get=function(v,a,s){return s?this.has(v)?this.values[v]:a[s]:this.has(v)?this.values[v]:a},_.has=function(v){return v in this.values},_.alt=function(v,a,s){for(var n=0;n<s.length;++n)if(a===s[n]){this.set(v,a);break}},_.integer=function(v,a){/^-?\d+$/.test(a)&&this.set(v,parseInt(a,10))},_.percent=function(v,a){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(a)){var s=parseFloat(a);if(s>=0&&s<=100)return this.set(v,s),!0}return!1},f}();function U(f,_,p,v){var a=v?f.split(v):[f];for(var s in a)if(typeof a[s]=="string"){var n=a[s].split(p);if(n.length===2){var d=n[0],l=n[1];_(d,l)}}}var b=new O.default(0,0,""),A=b.align==="middle"?"middle":"center";function S(f,_,p){var v=f;function a(){var d=M(f);if(d===null)throw new Error("Malformed timestamp: "+v);return f=f.replace(/^[^\sa-zA-Z-]+/,""),d}function s(d,l){var i=new P;U(d,function(c,m){var e;switch(c){case"region":for(var r=p.length-1;r>=0;r--)if(p[r].id===m){i.set(c,p[r].region);break}break;case"vertical":i.alt(c,m,["rl","lr"]);break;case"line":e=m.split(","),i.integer(c,e[0]),i.percent(c,e[0])&&i.set("snapToLines",!1),i.alt(c,e[0],["auto"]),e.length===2&&i.alt("lineAlign",e[1],["start",A,"end"]);break;case"position":e=m.split(","),i.percent(c,e[0]),e.length===2&&i.alt("positionAlign",e[1],["start",A,"end","line-left","line-right","auto"]);break;case"size":i.percent(c,m);break;case"align":i.alt(c,m,["start",A,"end","left","right"]);break}},/:/,/\s/),l.region=i.get("region",null),l.vertical=i.get("vertical","");var u=i.get("line","auto");u==="auto"&&b.line===-1&&(u=-1),l.line=u,l.lineAlign=i.get("lineAlign","start"),l.snapToLines=i.get("snapToLines",!0),l.size=i.get("size",100),l.align=i.get("align",A);var g=i.get("position","auto");g==="auto"&&b.position===50&&(g=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=g}function n(){f=f.replace(/^\s+/,"")}if(n(),_.startTime=a(),n(),f.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+v);f=f.slice(3),n(),_.endTime=a(),n(),s(f,_)}function E(f){return f.replace(/<br(?: \/)?>/gi,`
|
|
24
|
+
`)}var x=function(){function f(){this.state="INITIAL",this.buffer="",this.decoder=new D,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var _=f.prototype;return _.parse=function(v){var a=this;v&&(a.buffer+=a.decoder.decode(v,{stream:!0}));function s(){var g=a.buffer,c=0;for(g=E(g);c<g.length&&g[c]!=="\r"&&g[c]!==`
|
|
25
|
+
`;)++c;var m=g.slice(0,c);return g[c]==="\r"&&++c,g[c]===`
|
|
26
|
+
`&&++c,a.buffer=g.slice(c),m}function n(g){U(g,function(c,m){},/:/)}try{var d="";if(a.state==="INITIAL"){if(!/\r\n|\n/.test(a.buffer))return this;d=s();var l=d.match(/^()?WEBVTT([ \t].*)?$/);if(!l||!l[0])throw new Error("Malformed WebVTT signature.");a.state="HEADER"}for(var i=!1;a.buffer;){if(!/\r\n|\n/.test(a.buffer))return this;switch(i?i=!1:d=s(),a.state){case"HEADER":/:/.test(d)?n(d):d||(a.state="ID");continue;case"NOTE":d||(a.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(d)){a.state="NOTE";break}if(!d)continue;if(a.cue=new O.default(0,0,""),a.state="CUE",d.indexOf("-->")===-1){a.cue.id=d;continue}case"CUE":if(!a.cue){a.state="BADCUE";continue}try{S(d,a.cue,a.regionList)}catch{a.cue=null,a.state="BADCUE";continue}a.state="CUETEXT";continue;case"CUETEXT":{var u=d.indexOf("-->")!==-1;if(!d||u&&(i=!0)){a.oncue&&a.cue&&a.oncue(a.cue),a.cue=null,a.state="ID";continue}if(a.cue===null)continue;a.cue.text&&(a.cue.text+=`
|
|
27
|
+
`),a.cue.text+=d}continue;case"BADCUE":d||(a.state="ID")}}}catch{a.state==="CUETEXT"&&a.cue&&a.oncue&&a.oncue(a.cue),a.cue=null,a.state=a.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},_.flush=function(){var v=this;try{if((v.cue||v.state==="HEADER")&&(v.buffer+=`
|
|
27
28
|
|
|
28
|
-
`,
|
|
29
|
+
`,v.parse()),v.state==="INITIAL"||v.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(a){v.onparsingerror&&v.onparsingerror(a)}return v.onflush&&v.onflush(),this},f}()},"./src/utils/webvtt-parser.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{generateCueId:()=>x,parseWebVTT:()=>_});var O=T("./src/polyfills/number.ts"),D=T("./src/utils/vttparser.ts"),M=T("./src/demux/id3.ts"),P=T("./src/utils/timescale-conversion.ts"),U=T("./src/remux/mp4-remuxer.ts"),b=/\r\n|\n\r|\n|\r/g,A=function(v,a,s){return s===void 0&&(s=0),v.slice(s,s+a.length)===a},S=function(v){var a=parseInt(v.slice(-3)),s=parseInt(v.slice(-6,-4)),n=parseInt(v.slice(-9,-7)),d=v.length>9?parseInt(v.substring(0,v.indexOf(":"))):0;if(!(0,O.isFiniteNumber)(a)||!(0,O.isFiniteNumber)(s)||!(0,O.isFiniteNumber)(n)||!(0,O.isFiniteNumber)(d))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+v);return a+=1e3*s,a+=60*1e3*n,a+=60*60*1e3*d,a},E=function(v){for(var a=5381,s=v.length;s;)a=a*33^v.charCodeAt(--s);return(a>>>0).toString()};function x(p,v,a){return E(p.toString())+E(v.toString())+E(a)}var f=function(v,a,s){var n=v[a],d=v[n.prevCC];if(!d||!d.new&&n.new){v.ccOffset=v.presentationOffset=n.start,n.new=!1;return}for(;(l=d)!==null&&l!==void 0&&l.new;){var l;v.ccOffset+=n.start-d.start,n.new=!1,n=d,d=v[n.prevCC]}v.presentationOffset=s};function _(p,v,a,s,n,d,l,i){var u=new D.VTTParser,g=(0,M.utf8ArrayToStr)(new Uint8Array(p)).trim().replace(b,`
|
|
29
30
|
`).split(`
|
|
30
|
-
`),
|
|
31
|
-
`)}),l.flush()}},"./src/utils/xhr-loader.ts":function(j,b,n){"use strict";n.r(b);var I=n("./src/utils/logger.ts"),L=n("./src/loader/load-stats.ts"),D=/^age:\s*[\d.]+\s*$/m,w=function(){function R(_){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=_?_.xhrSetup:null,this.stats=new L.LoadStats,this.retryDelay=0}var O=R.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,A){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=A,this.retryDelay=T.retryDelay,this.loadInternal()},O.loadInternal=function(){var y=this.config,T=this.context;if(!!y){var A=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.loaded=0;var m=this.xhrSetup;try{if(m)try{m(A,T.url)}catch{A.open("GET",T.url,!0),m(A,T.url)}A.readyState||A.open("GET",T.url,!0);var p=this.context.headers;if(p)for(var d in p)A.setRequestHeader(d,p[d])}catch(e){this.callbacks.onError({code:A.status,text:e.message},T,A);return}T.rangeEnd&&A.setRequestHeader("Range","bytes="+T.rangeStart+"-"+(T.rangeEnd-1)),A.onreadystatechange=this.readystatechange.bind(this),A.onprogress=this.loadprogress.bind(this),A.responseType=T.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),A.send()}},O.readystatechange=function(){var y=this.context,T=this.loader,A=this.stats;if(!(!y||!T)){var E=T.readyState,m=this.config;if(!A.aborted&&E>=2)if(self.clearTimeout(this.requestTimeout),A.loading.first===0&&(A.loading.first=Math.max(self.performance.now(),A.loading.start)),E===4){T.onreadystatechange=null,T.onprogress=null;var p=T.status;if(p>=200&&p<300){A.loading.end=Math.max(self.performance.now(),A.loading.first);var d,e;if(y.responseType==="arraybuffer"?(d=T.response,e=d.byteLength):(d=T.responseText,e=d.length),A.loaded=A.total=e,!this.callbacks)return;var o=this.callbacks.onProgress;if(o&&o(A,y,d,T),!this.callbacks)return;var h={url:T.responseURL,data:d};this.callbacks.onSuccess(h,A,y,T)}else A.retry>=m.maxRetry||p>=400&&p<499?(I.logger.error(p+" while loading "+y.url),this.callbacks.onError({code:p,text:T.statusText},y,T)):(I.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),A.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),m.timeout)}},O.loadtimeout=function(){I.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&&D.test(this.loader.getAllResponseHeaders())){var T=this.loader.getResponseHeader("age");y=T?parseFloat(T):null}return y},R}();b.default=w}}).default})});var Mt=class{addEventListener(){}removeEventListener(){}dispatchEvent(b){return!0}};if(typeof DocumentFragment=="undefined"){class j extends Mt{}globalThis.DocumentFragment=j}var Xt=class extends Mt{},Ur=class extends Mt{},Wn={get(j){},define(j,b,n){},upgrade(j){},whenDefined(j){return Promise.resolve(Xt)}},Qt,Nr=class{constructor(b,n={}){xe(this,Qt,void 0);be(this,Qt,n==null?void 0:n.detail)}get detail(){return se(this,Qt)}initCustomEvent(){}};Qt=new WeakMap;function Gn(j,b){return new Xt}var Ei={document:{createElement:Gn},DocumentFragment,customElements:Wn,CustomEvent:Nr,EventTarget:Mt,HTMLElement:Xt,HTMLVideoElement:Ur},yi=typeof window=="undefined"||typeof globalThis.customElements=="undefined",mt=yi?Ei:globalThis,Kr=yi?Ei.document:globalThis.document;var xr=pr(Ti(),1),bt=pr(yr(),1),Hr=pr(yr(),1),wt=pr(yr(),1),Jt=class extends Error{constructor(j,b=Jt.MEDIA_ERR_CUSTOM,n){var I;super(j),this.name="MediaError",this.code=b,this.fatal=n!=null?n:b>=Jt.MEDIA_ERR_NETWORK&&b<=Jt.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(I=Jt.defaultMessages[this.code])!=null?I:"")}},nt=Jt;nt.MEDIA_ERR_ABORTED=1,nt.MEDIA_ERR_NETWORK=2,nt.MEDIA_ERR_DECODE=3,nt.MEDIA_ERR_SRC_NOT_SUPPORTED=4,nt.MEDIA_ERR_ENCRYPTED=5,nt.MEDIA_ERR_CUSTOM=100,nt.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 Hn=j=>j==null,_i=(j,b)=>Hn(b)?!1:j in b,Vr={ANY:"any",MUTED:"muted"},Tr={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Ot={MSE:"mse",NATIVE:"native"},Yr={HEADER:"header",QUERY:"query",NONE:"none"},Qr=Object.values(Yr),Ft={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},zr={HLS:Ft.M3U8},xa=Object.keys(zr),Sa=[...Object.values(Ft),"hls","HLS"],Zt=(j,b,n,I)=>{j.addEventListener(b,n,I),j.addEventListener("teardown",()=>{j.removeEventListener(b,n)},{once:!0})};function Vn(j,b,n){b&&n>b&&(n=b);for(let I=0;I<j.length;I++)if(j.start(I)<=n&&j.end(I)>=n)return!0;return!1}var Yn=j=>{let b=j.indexOf("?");if(b<0)return[j];let n=j.slice(0,b),I=j.slice(b);return[n,I]},bi=j=>{let b=j.type;if(b){let I=b.toUpperCase();return _i(I,zr)?zr[I]:b}let{src:n}=j;return n?zn(n):""},zn=j=>{let b="";try{b=new URL(j).pathname}catch{console.error("invalid url")}let n=b.lastIndexOf(".");if(n<0)return"";let I=b.slice(n+1).toUpperCase();return _i(I,Ft)?Ft[I]:""},Xn=Object.values(Vr),xi=j=>typeof j=="boolean"||typeof j=="string"&&Xn.includes(j),Qn=({autoplay:j},b,n)=>{let I=!1,L=!1,D=xi(j)?j:!!j,w=()=>{I||Zt(b,"playing",()=>{I=!0},{once:!0})};if(w(),Zt(b,"loadstart",()=>{I=!1,w(),Gr(b,D)},{once:!0}),Zt(b,"loadstart",()=>{n||(L=!Number.isFinite(b.duration)),Gr(b,D)},{once:!0}),n&&n.once(Hr.default.Events.LEVEL_LOADED,(R,O)=>{var _;L=(_=O.details.live)!=null?_:!1}),!D){let R=()=>{!L||(n!=null&&n.liveSyncPosition?b.currentTime=n.liveSyncPosition:Number.isFinite(b.seekable.end(0))&&(b.currentTime=b.seekable.end(0)))};n&&Zt(b,"play",()=>{b.preload==="metadata"?n.once(Hr.default.Events.LEVEL_UPDATED,R):R()},{once:!0})}return R=>{I||(D=xi(R)?R:!!R,Gr(b,D))}},Gr=(j,b)=>{if(!b)return;let n=j.muted,I=()=>j.muted=n;switch(b){case Vr.ANY:j.play().catch(()=>{j.muted=!0,j.play().catch(I)});break;case Vr.MUTED:j.muted=!0,j.play().catch(I);break;default:j.play().catch(()=>{});break}},$n=({preload:j,src:b},n,I)=>{let L=T=>{T!=null&&["","none","metadata","auto"].includes(T)?n.setAttribute("preload",T):n.removeAttribute("preload")};if(!I)return L(j),L;let D=!1,w=!1,R=I.config.maxBufferLength,O=I.config.maxBufferSize,_=T=>{L(T);let A=T!=null?T:n.preload;w||A==="none"||(A==="metadata"?(I.config.maxBufferLength=1,I.config.maxBufferSize=1):(I.config.maxBufferLength=R,I.config.maxBufferSize=O),y())},y=()=>{!D&&b&&(D=!0,I.loadSource(b))};return Zt(n,"play",()=>{w=!0,I.config.maxBufferLength=R,I.config.maxBufferSize=O,y()},{once:!0}),_(j),_};function Jn(j,b){b.on(wt.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(L,{tracks:D})=>{D.forEach(w=>{var R;let O=(R=w.subtitleTrack)!=null?R:w.closedCaptions,_=b.subtitleTracks.findIndex(({lang:y,name:T,type:A})=>y==(O==null?void 0:O.lang)&&T===w.label&&A.toLowerCase()===w.kind);Zn(j,w.kind,w.label,O==null?void 0:O.lang,`${w.kind}${_}`)})});let n=()=>{var L;if(!b.subtitleTracks.length)return;let D=Array.from(j.textTracks).find(R=>R.id&&R.mode==="showing"&&["subtitles","captions"].includes(R.kind)),w=`${(L=b.subtitleTracks[b.subtitleTrack])==null?void 0:L.type.toLowerCase()}${b.subtitleTrack}`;if(D&&(b.subtitleTrack<0||(D==null?void 0:D.id)!==w)){let R=b.subtitleTracks.findIndex(({lang:O,name:_,type:y})=>O==D.language&&_===D.label&&y.toLowerCase()===D.kind);b.subtitleTrack=R}D&&(D==null?void 0:D.id)===w&&D.cues&&Array.from(D.cues).forEach(R=>{D.addCue(R)})};j.textTracks.addEventListener("change",n),b.on(wt.default.Events.CUES_PARSED,(L,{track:D,cues:w})=>{let R=j.textTracks.getTrackById(D);if(!R)return;let O=R.mode==="disabled";O&&(R.mode="hidden"),w.forEach(_=>{var y;(y=R.cues)!=null&&y.getCueById(_.id)||R.addCue(_)}),O&&(R.mode="disabled")}),b.once(wt.default.Events.DESTROYING,()=>{j.textTracks.removeEventListener("change",n),j.querySelectorAll("track[data-removeondestroy]").forEach(L=>{L.remove()})});let I=()=>{Array.from(j.textTracks).forEach(L=>{var D,w;if(!["subtitles","caption"].includes(L.kind)&&L.label==="thumbnails"){if(!((D=L.cues)!=null&&D.length)){let R=j.querySelector('track[label="thumbnails"]'),O=(w=R==null?void 0:R.getAttribute("src"))!=null?w:"";R==null||R.removeAttribute("src"),setTimeout(()=>{R==null||R.setAttribute("src",O)},0)}L.mode!=="hidden"&&(L.mode="hidden")}})};b.once(wt.default.Events.MANIFEST_LOADED,I),b.once(wt.default.Events.MEDIA_ATTACHED,I)}function Zn(j,b,n,I,L){let D=document.createElement("track");return D.kind=b,D.label=n,I&&(D.srclang=I),L&&(D.id=L),D.track.mode="disabled",D.setAttribute("data-removeondestroy",""),j.append(D),D.track}var Si,Di,qn=(Di=(Si=globalThis==null?void 0:globalThis.navigator)==null?void 0:Si.userAgent)!=null?Di:"",ea=qn.toLowerCase().indexOf("android")!==-1,kt=new WeakMap,Oi="mux.com",Ai,Li,Ri=(Li=(Ai=bt.default).isSupported)==null?void 0:Li.call(Ai),ta=ea,Pi=()=>xr.default.utils.now(),ra=xr.default.utils.generateUUID,Ii=(j,{domain:b=Oi}={})=>{if(!j)return;let[n,I=""]=Yn(j);return`https://stream.${b}/${n}.m3u8${I}`},ia=j=>{if(!j)return;let[b]=j.split("?");return b||void 0},na=j=>{if(!j||!j.startsWith("https://stream."))return;let[b]=new URL(j).pathname.slice(1).split(".m3u8");return b||void 0},aa=j=>{var b,n,I;return(b=j==null?void 0:j.metadata)!=null&&b.video_id?j.metadata.video_id:Fi(j)&&(I=(n=ia(j.playbackId))!=null?n:na(j.src))!=null?I:j.src},Ci=j=>{var b;return(b=kt.get(j))==null?void 0:b.error},Mi=(j,b,n)=>{$r(b,n);let{metadata:I={}}=j,{view_session_id:L=ra()}=I,D=aa(j);I.view_session_id=L,I.video_id=D,j.metadata=I,kt.set(b,{});let w=sa(j,b);la(j,b,w),ua(j,b,w);let R=Qn(j,b,w),O=$n(j,b,w);return{engine:w,setAutoplay:R,setPreload:O}},$r=(j,b)=>{let n=b==null?void 0:b.engine;n&&(n.detachMedia(),n.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",Bi),j.removeEventListener("error",Xr),j.removeEventListener("durationchange",ki),kt.delete(j),j.dispatchEvent(new Event("teardown")))};function wi(j,b){var n;let I=bi(j);if(I!==Ft.M3U8)return!0;let L=!I||((n=b.canPlayType(I))!=null?n:!0),{preferPlayback:D}=j,w=D===Ot.MSE,R=D===Ot.NATIVE;return L&&(R||!(Ri&&(w||ta)))}var sa=(j,b)=>{let{debug:n,streamType:I,startTime:L=-1,metadata:D,preferCmcd:w}=j,R=bi(j)===Ft.M3U8,O=wi(j,b);if(R&&!O&&Ri){let _={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},y=oa(I),T=w!==Yr.NONE?{useHeaders:w===Yr.HEADER,sessionId:D.view_session_id,contentId:D.video_id}:void 0;return new bt.default({debug:n,startPosition:L,cmcd:T,..._,...y})}},oa=j=>[Tr.LIVE,Tr.DVR].includes(j)?{backBufferLength:8}:[Tr.LL_LIVE,Tr.LL_DVR].includes(j)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},Fi=({playbackId:j,src:b,customDomain:n})=>{if(j)return!0;if(typeof b!="string")return!1;let I=window==null?void 0:window.location.href,L=new URL(b,I).hostname.toLocaleLowerCase();return L.includes(Oi)||!!n&&L.includes(n.toLocaleLowerCase())},la=(j,b,n)=>{var I;let{envKey:L}=j,D=Fi(j);if(L||D){let{playerInitTime:w,playerSoftwareName:R,playerSoftwareVersion:O,beaconCollectionDomain:_,debug:y,disableCookies:T}=j,A={...j.metadata,video_title:((I=j==null?void 0:j.metadata)==null?void 0:I.video_title)||void 0},E=m=>typeof m.player_error_code=="string"?!1:typeof j.errorTranslator=="function"?j.errorTranslator(m):m;xr.default.monitor(b,{debug:y,beaconCollectionDomain:_,hlsjs:n,Hls:n?bt.default:void 0,automaticErrorTracking:!1,errorTranslator:E,disableCookies:T,data:{...L?{env_key:L}:{},player_software_name:R,player_software:R,player_software_version:O,player_init_time:w,...A}})}},ua=(j,b,n)=>{var I;let L=wi(j,b),{src:D}=j;b&&L?(typeof D=="string"?(b.setAttribute("src",D),j.startTime&&(((I=kt.get(b))!=null?I:{}).startTime=j.startTime,b.addEventListener("durationchange",ki,{once:!0}))):b.removeAttribute("src"),b.addEventListener("error",Bi),b.addEventListener("error",Xr)):n&&D?(n.on(bt.default.Events.ERROR,(w,R)=>{let O={[bt.default.ErrorTypes.NETWORK_ERROR]:nt.MEDIA_ERR_NETWORK,[bt.default.ErrorTypes.MEDIA_ERROR]:nt.MEDIA_ERR_DECODE},_=new nt("",O[R.type]);_.fatal=R.fatal,_.data=R,b.dispatchEvent(new CustomEvent("error",{detail:_}))}),b.addEventListener("error",Xr),Jn(b,n),n.attachMedia(b)):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 ki(j){var b;let n=j.target,I=(b=kt.get(n))==null?void 0:b.startTime;if(!!I&&Vn(n.seekable,n.duration,I)){let L=n.preload==="auto";L&&(n.preload="none"),n.currentTime=I,L&&(n.preload="auto")}}async function Bi(j){if(!j.isTrusted)return;j.stopImmediatePropagation();let b=j.target;if(!(b!=null&&b.error))return;let{message:n,code:I}=b.error,L=new nt(n,I);if(b.src&&(I!==nt.MEDIA_ERR_DECODE||I!==void 0))try{let{status:D}=await fetch(b.src);L.data={response:{code:D}}}catch{}b.dispatchEvent(new CustomEvent("error",{detail:L}))}function Xr(j){var b,n;if(!(j instanceof CustomEvent)||!(j.detail instanceof nt))return;let I=j.target,L=j.detail;!L||!L.fatal||(((b=kt.get(I))!=null?b:{}).error=L,(n=I.mux)==null||n.emit("error",{player_error_code:L.code,player_error_message:L.message}))}var da=()=>{try{return"0.12.1"}catch{}return"UNKNOWN"},fa=da(),Ui=()=>fa;var Jr=class extends Set{add(b){super.add(new WeakRef(b))}forEach(b){super.forEach(n=>{let I=n.deref();I&&b(I)})}},ca=j=>{var b,n,I,L,D,Ni,R,Sr,_,pt,T,Dr,E,Ar,p,Ki,e,ji,h,Zr,i,r,l,c,t,a,u,qt,f,Wi,S,qr,P,Gi,k,ei,W,Hi,z,ti;return b=class extends j{constructor(){super();xe(this,u);xe(this,f);xe(this,S);xe(this,P);xe(this,k);xe(this,W);xe(this,z);zt(this,"castEnabled",!1);xe(this,i,{paused:!1});xe(this,r,void 0);xe(this,l,{});xe(this,c,void 0);xe(this,t,void 0);xe(this,a,void 0);b.instances.add(this),Ie(this,k,ei).call(this)}static get castElement(){return se(b,n)}static get castEnabled(){return se(b,I)}static get castState(){var X;return(X=se(b,_,pt))==null?void 0:X.getCastState()}static async exitCast(){try{await se(b,_,pt).endCurrentSession(!0)}catch(q){console.error(q);return}}get castPlayer(){if(b.castElement===this)return se(this,r)}attributeChangedCallback(X){if(!!this.castPlayer)switch(X){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(X={}){var q;Ie(q=b,h,Zr).call(q,X),be(b,n,this),Object.entries(se(this,l)).forEach(([ne,ae])=>{se(this,r).controller.addEventListener(ne,ae)});try{await se(b,_,pt).requestSession()}catch{be(b,n,void 0);return}se(this,i).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(ne){console.error(ne)}}async load(){var le,fe;if(!this.castPlayer)return super.load();let X=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),q=[...this.querySelectorAll("track")].filter(({kind:ie,src:ge})=>ge&&(ie==="subtitles"||ie==="captions")),ne=[],ae=0;q.length&&(X.tracks=q.map(ie=>{let ge=++ae;ne.length===0&&ie.track.mode==="showing"&&ne.push(ge);let pe=new chrome.cast.media.Track(ge,chrome.cast.media.TrackType.TEXT);return pe.trackContentId=ie.src,pe.trackContentType="text/vtt",pe.subtype=ie.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,pe.name=ie.label,pe.language=ie.srclang,pe})),this.castStreamType==="live"?X.streamType=chrome.cast.media.StreamType.LIVE:X.streamType=chrome.cast.media.StreamType.BUFFERED,X.metadata=new chrome.cast.media.GenericMediaMetadata,X.metadata.title=this.title,X.metadata.images=[{url:this.poster}];let re=new chrome.cast.media.LoadRequest(X);re.currentTime=(le=super.currentTime)!=null?le:0,re.autoplay=!se(this,i).paused,re.activeTrackIds=ne,await((fe=se(b,T,Dr))==null?void 0:fe.loadMedia(re)),this.dispatchEvent(new Event("volumechange"))}play(){var X;if(this.castPlayer){this.castPlayer.isPaused&&((X=this.castPlayer.controller)==null||X.playOrPause());return}return super.play()}pause(){var X;if(this.castPlayer){this.castPlayer.isPaused||(X=this.castPlayer.controller)==null||X.playOrPause();return}super.pause()}get castSrc(){var X,q,ne;return(ne=(q=this.getAttribute("cast-src"))!=null?q:(X=this.querySelector("source"))==null?void 0:X.src)!=null?ne:this.currentSrc}set castSrc(X){this.castSrc!=X&&this.setAttribute("cast-src",`${X}`)}get castContentType(){var X;return(X=this.getAttribute("cast-content-type"))!=null?X:void 0}set castContentType(X){this.setAttribute("cast-content-type",`${X}`)}get castStreamType(){var X;return(X=this.getAttribute("cast-stream-type"))!=null?X:void 0}set castStreamType(X){this.setAttribute("cast-stream-type",`${X}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var X;return this.castPlayer?(X=this.castPlayer)==null?void 0:X.isMuted:super.muted}set muted(X){var q;if(this.castPlayer){(X&&!this.castPlayer.isMuted||!X&&this.castPlayer.isMuted)&&((q=this.castPlayer.controller)==null||q.muteOrUnmute());return}super.muted=X}get volume(){var X,q;return this.castPlayer?(q=(X=this.castPlayer)==null?void 0:X.volumeLevel)!=null?q:1:super.volume}set volume(X){var q;if(this.castPlayer){this.castPlayer.volumeLevel=X,(q=this.castPlayer.controller)==null||q.setVolumeLevel();return}super.volume=X}get duration(){var X,q;return this.castPlayer&&se(this,u,qt)?(q=(X=this.castPlayer)==null?void 0:X.duration)!=null?q:NaN:super.duration}get currentTime(){var X,q;return this.castPlayer&&se(this,u,qt)?(q=(X=this.castPlayer)==null?void 0:X.currentTime)!=null?q:0:super.currentTime}set currentTime(X){var q;if(this.castPlayer){this.castPlayer.currentTime=X,(q=this.castPlayer.controller)==null||q.seek();return}super.currentTime=X}get onentercast(){return se(this,c)}set onentercast(X){se(this,c)&&(this.removeEventListener("entercast",se(this,c)),be(this,c,null)),typeof X=="function"&&(be(this,c,X),this.addEventListener("entercast",X))}get onleavecast(){return se(this,t)}set onleavecast(X){se(this,t)&&(this.removeEventListener("leavecast",se(this,t)),be(this,t,null)),typeof X=="function"&&(be(this,t,X),this.addEventListener("leavecast",X))}get oncastchange(){return se(this,a)}set oncastchange(X){se(this,a)&&(this.removeEventListener("castchange",se(this,a)),be(this,a,null)),typeof X=="function"&&(be(this,a,X),this.addEventListener("castchange",X))}},n=new WeakMap,I=new WeakMap,L=new WeakMap,D=new WeakSet,Ni=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},R=new WeakSet,Sr=function(){return typeof cast!="undefined"&&cast.framework},_=new WeakSet,pt=function(){if(se(b,R,Sr))return cast.framework.CastContext.getInstance()},T=new WeakSet,Dr=function(){var X;return(X=se(b,_,pt))==null?void 0:X.getCurrentSession()},E=new WeakSet,Ar=function(){var X;return(X=se(b,T,Dr))==null?void 0:X.getSessionObj().media[0]},p=new WeakSet,Ki=function(X){return new Promise((q,ne)=>{se(b,E,Ar).editTracksInfo(X,q,ne)})},e=new WeakSet,ji=function(X){return new Promise((q,ne)=>{se(b,E,Ar).getStatus(X,q,ne)})},h=new WeakSet,Zr=function(X){return se(b,_,pt).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...X})},i=new WeakMap,r=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakMap,a=new WeakMap,u=new WeakSet,qt=function(){var X;return(X=this.castPlayer)==null?void 0:X.isMediaLoaded},f=new WeakSet,Wi=function(){se(b,n)===this&&(Object.entries(se(this,l)).forEach(([X,q])=>{se(this,r).controller.removeEventListener(X,q)}),be(b,n,void 0),this.muted=se(this,r).isMuted,this.currentTime=se(this,r).savedPlayerState.currentTime,se(this,r).savedPlayerState.isPaused===!1&&this.play())},S=new WeakSet,qr=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:se(b,_,pt).getCastState()}))},P=new WeakSet,Gi=async function(){var q,ne;let{SESSION_RESUMED:X}=cast.framework.SessionState;if(se(b,_,pt).getSessionState()===X&&this.castSrc===((q=se(b,E,Ar))==null?void 0:q.media.contentId)){be(b,n,this),Object.entries(se(this,l)).forEach(([ae,re])=>{se(this,r).controller.addEventListener(ae,re)});try{await Ie(ne=b,e,ji).call(ne,new chrome.cast.media.GetStatusRequest)}catch(ae){console.error(ae)}se(this,l)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),se(this,l)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},k=new WeakSet,ei=function(){var X;!se(b,R,Sr)||this.castEnabled||(this.castEnabled=!0,Ie(X=b,h,Zr).call(X),this.textTracks.addEventListener("change",Ie(this,z,ti).bind(this)),Ie(this,S,qr).call(this),be(this,r,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(se(this,r)),be(this,l,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:q})=>{q===!1&&Ie(this,f,Wi).call(this),this.dispatchEvent(new Event(q?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!se(this,u,qt)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var q,ne;((q=this.castPlayer)==null?void 0:q.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(ne=this.castPlayer)==null?void 0:ne.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!se(this,u,qt)||(await Promise.resolve(),Ie(this,W,Hi).call(this))}}))},W=new WeakSet,Hi=function(){Ie(this,z,ti).call(this)},z=new WeakSet,ti=async function(){var De,Me,Oe,je,Pe,Be;if(!this.castPlayer)return;let q=((Me=(De=se(this,r).mediaInfo)==null?void 0:De.tracks)!=null?Me:[]).filter(({type:Ee})=>Ee===chrome.cast.media.TrackType.TEXT),ne=[...this.textTracks].filter(({kind:Ee})=>Ee==="subtitles"||Ee==="captions"),ae=q.map(({language:Ee,name:we,trackId:Ue})=>{var Ne;let{mode:Ye}=(Ne=ne.find(Je=>Je.language===Ee&&Je.label===we))!=null?Ne:{};return Ye?{mode:Ye,trackId:Ue}:!1}).filter(Boolean),le=ae.filter(({mode:Ee})=>Ee!=="showing").map(({trackId:Ee})=>Ee),fe=ae.find(({mode:Ee})=>Ee==="showing"),ie=(Pe=(je=(Oe=se(b,T,Dr))==null?void 0:Oe.getSessionObj().media[0])==null?void 0:je.activeTrackIds)!=null?Pe:[],ge=ie;if(ie.length&&(ge=ge.filter(Ee=>!le.includes(Ee))),fe!=null&&fe.trackId&&(ge=[...ge,fe.trackId]),ge=[...new Set(ge)],!((Ee,we)=>Ee.length===we.length&&Ee.every(Ue=>we.includes(Ue)))(ie,ge))try{let Ee=new chrome.cast.media.EditTracksInfoRequest(ge);await Ie(Be=b,p,Ki).call(Be,Ee)}catch(Ee){console.error(Ee)}},xe(b,D),xe(b,R),xe(b,_),xe(b,T),xe(b,E),xe(b,p),xe(b,e),xe(b,h),zt(b,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),zt(b,"instances",new Jr),xe(b,n,void 0),xe(b,I,!1),zt(b,"initCast",()=>{var X;se(b,D,Ni)?se(b,R,Sr)?se(X=b,L).call(X,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var q;return se(q=b,L).call(q,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var q;return se(q=b,L).call(q,chrome.cast.isAvailable)})}}),xe(b,L,X=>{if(X){be(b,I,!0);let{CAST_STATE_CHANGED:q}=cast.framework.CastContextEventType;se(b,_,pt).addEventListener(q,ae=>{b.instances.forEach(re=>{var le;return Ie(le=re,S,qr).call(le,ae)})});let{SESSION_STATE_CHANGED:ne}=cast.framework.CastContextEventType;se(b,_,pt).addEventListener(ne,ae=>{b.instances.forEach(re=>{var le;return Ie(le=re,P,Gi).call(le,ae)})}),b.instances.forEach(ae=>{var re;return Ie(re=ae,k,ei).call(re)})}}),b};if(globalThis.HTMLVideoElement&&globalThis.customElements){let j=ca(HTMLVideoElement);globalThis.customElements.get("castable-video")||(globalThis.customElements.define("castable-video",j,{extends:"video"}),globalThis.CastableVideoElement=j),j.initCast()}var Vi=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],Yi=Kr.createElement("template");Yi.innerHTML=`
|
|
31
|
+
`),c=[],m=(0,P.toMpegTsClockFromTimescale)(v,a),e="00:00.000",r=0,t=0,o,y=!0;u.oncue=function(h){var L=s[n],R=s.ccOffset,I=(r-m)/9e4;L!=null&&L.new&&(t!==void 0?R=s.ccOffset=L.start:f(s,n,I)),I&&(R=I-s.presentationOffset);var k=h.endTime-h.startTime,F=(0,U.normalizePts)((h.startTime+R-t)*9e4,d*9e4)/9e4;h.startTime=Math.max(F,0),h.endTime=Math.max(F+k,0);var W=h.text.trim();h.text=decodeURIComponent(encodeURIComponent(W)),h.id||(h.id=x(h.startTime,h.endTime,W)),h.endTime>0&&c.push(h)},u.onparsingerror=function(h){o=h},u.onflush=function(){if(o){i(o);return}l(c)},g.forEach(function(h){if(y)if(A(h,"X-TIMESTAMP-MAP=")){y=!1,h.slice(16).split(",").forEach(function(L){A(L,"LOCAL:")?e=L.slice(6):A(L,"MPEGTS:")&&(r=parseInt(L.slice(7)))});try{t=S(e)/1e3}catch(L){o=L}return}else h===""&&(y=!1);u.parse(h+`
|
|
32
|
+
`)}),u.flush()}},"./src/utils/xhr-loader.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>U});var O=T("./src/utils/logger.ts"),D=T("./src/loader/load-stats.ts"),M=/^age:\s*[\d.]+\s*$/m,P=function(){function b(S){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=S?S.xhrSetup:null,this.stats=new D.LoadStats,this.retryDelay=0}var A=b.prototype;return A.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},A.abortInternal=function(){var E=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),E&&(E.onreadystatechange=null,E.onprogress=null,E.readyState!==4&&(this.stats.aborted=!0,E.abort()))},A.abort=function(){var E;this.abortInternal(),(E=this.callbacks)!==null&&E!==void 0&&E.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},A.load=function(E,x,f){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=E,this.config=x,this.callbacks=f,this.retryDelay=x.retryDelay,this.loadInternal()},A.loadInternal=function(){var E=this.config,x=this.context;if(!!E){var f=this.loader=new self.XMLHttpRequest,_=this.stats;_.loading.first=0,_.loaded=0;var p=this.xhrSetup;try{if(p)try{p(f,x.url)}catch{f.open("GET",x.url,!0),p(f,x.url)}f.readyState||f.open("GET",x.url,!0);var v=this.context.headers;if(v)for(var a in v)f.setRequestHeader(a,v[a])}catch(s){this.callbacks.onError({code:f.status,text:s.message},x,f);return}x.rangeEnd&&f.setRequestHeader("Range","bytes="+x.rangeStart+"-"+(x.rangeEnd-1)),f.onreadystatechange=this.readystatechange.bind(this),f.onprogress=this.loadprogress.bind(this),f.responseType=x.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),E.timeout),f.send()}},A.readystatechange=function(){var E=this.context,x=this.loader,f=this.stats;if(!(!E||!x)){var _=x.readyState,p=this.config;if(!f.aborted&&_>=2)if(self.clearTimeout(this.requestTimeout),f.loading.first===0&&(f.loading.first=Math.max(self.performance.now(),f.loading.start)),_===4){x.onreadystatechange=null,x.onprogress=null;var v=x.status,a=x.responseType==="arraybuffer";if(v>=200&&v<300&&(a&&x.response||x.responseText!==null)){f.loading.end=Math.max(self.performance.now(),f.loading.first);var s,n;if(a?(s=x.response,n=s.byteLength):(s=x.responseText,n=s.length),f.loaded=f.total=n,!this.callbacks)return;var d=this.callbacks.onProgress;if(d&&d(f,E,s,x),!this.callbacks)return;var l={url:x.responseURL,data:s};this.callbacks.onSuccess(l,f,E,x)}else f.retry>=p.maxRetry||v>=400&&v<499?(O.logger.error(v+" while loading "+E.url),this.callbacks.onError({code:v,text:x.statusText},E,x)):(O.logger.warn(v+" while loading "+E.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,p.maxRetryDelay),f.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),p.timeout)}},A.loadtimeout=function(){O.logger.warn("timeout while loading "+this.context.url);var E=this.callbacks;E&&(this.abortInternal(),E.onTimeout(this.stats,this.context,this.loader))},A.loadprogress=function(E){var x=this.stats;x.loaded=E.loaded,E.lengthComputable&&(x.total=E.total)},A.getCacheAge=function(){var E=null;if(this.loader&&M.test(this.loader.getAllResponseHeaders())){var x=this.loader.getResponseHeader("age");E=x?parseFloat(x):null}return E},b}();let U=P},"./node_modules/eventemitter3/index.js":Q=>{"use strict";var B=Object.prototype.hasOwnProperty,T="~";function O(){}Object.create&&(O.prototype=Object.create(null),new O().__proto__||(T=!1));function D(b,A,S){this.fn=b,this.context=A,this.once=S||!1}function M(b,A,S,E,x){if(typeof S!="function")throw new TypeError("The listener must be a function");var f=new D(S,E||b,x),_=T?T+A:A;return b._events[_]?b._events[_].fn?b._events[_]=[b._events[_],f]:b._events[_].push(f):(b._events[_]=f,b._eventsCount++),b}function P(b,A){--b._eventsCount===0?b._events=new O:delete b._events[A]}function U(){this._events=new O,this._eventsCount=0}U.prototype.eventNames=function(){var A=[],S,E;if(this._eventsCount===0)return A;for(E in S=this._events)B.call(S,E)&&A.push(T?E.slice(1):E);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(S)):A},U.prototype.listeners=function(A){var S=T?T+A:A,E=this._events[S];if(!E)return[];if(E.fn)return[E.fn];for(var x=0,f=E.length,_=new Array(f);x<f;x++)_[x]=E[x].fn;return _},U.prototype.listenerCount=function(A){var S=T?T+A:A,E=this._events[S];return E?E.fn?1:E.length:0},U.prototype.emit=function(A,S,E,x,f,_){var p=T?T+A:A;if(!this._events[p])return!1;var v=this._events[p],a=arguments.length,s,n;if(v.fn){switch(v.once&&this.removeListener(A,v.fn,void 0,!0),a){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,S),!0;case 3:return v.fn.call(v.context,S,E),!0;case 4:return v.fn.call(v.context,S,E,x),!0;case 5:return v.fn.call(v.context,S,E,x,f),!0;case 6:return v.fn.call(v.context,S,E,x,f,_),!0}for(n=1,s=new Array(a-1);n<a;n++)s[n-1]=arguments[n];v.fn.apply(v.context,s)}else{var d=v.length,l;for(n=0;n<d;n++)switch(v[n].once&&this.removeListener(A,v[n].fn,void 0,!0),a){case 1:v[n].fn.call(v[n].context);break;case 2:v[n].fn.call(v[n].context,S);break;case 3:v[n].fn.call(v[n].context,S,E);break;case 4:v[n].fn.call(v[n].context,S,E,x);break;default:if(!s)for(l=1,s=new Array(a-1);l<a;l++)s[l-1]=arguments[l];v[n].fn.apply(v[n].context,s)}}return!0},U.prototype.on=function(A,S,E){return M(this,A,S,E,!1)},U.prototype.once=function(A,S,E){return M(this,A,S,E,!0)},U.prototype.removeListener=function(A,S,E,x){var f=T?T+A:A;if(!this._events[f])return this;if(!S)return P(this,f),this;var _=this._events[f];if(_.fn)_.fn===S&&(!x||_.once)&&(!E||_.context===E)&&P(this,f);else{for(var p=0,v=[],a=_.length;p<a;p++)(_[p].fn!==S||x&&!_[p].once||E&&_[p].context!==E)&&v.push(_[p]);v.length?this._events[f]=v.length===1?v[0]:v:P(this,f)}return this},U.prototype.removeAllListeners=function(A){var S;return A?(S=T?T+A:A,this._events[S]&&P(this,S)):(this._events=new O,this._eventsCount=0),this},U.prototype.off=U.prototype.removeListener,U.prototype.addListener=U.prototype.on,U.prefixed=T,U.EventEmitter=U,Q.exports=U},"./node_modules/url-toolkit/src/url-toolkit.js":function(Q){(function(B){var T=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,O=/^(?=([^\/?#]*))\1([^]*)$/,D=/(?:\/|^)\.(?=\/)/g,M=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,P={buildAbsoluteURL:function(U,b,A){if(A=A||{},U=U.trim(),b=b.trim(),!b){if(!A.alwaysNormalize)return U;var S=P.parseURL(U);if(!S)throw new Error("Error trying to parse base URL.");return S.path=P.normalizePath(S.path),P.buildURLFromParts(S)}var E=P.parseURL(b);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return A.alwaysNormalize?(E.path=P.normalizePath(E.path),P.buildURLFromParts(E)):b;var x=P.parseURL(U);if(!x)throw new Error("Error trying to parse base URL.");if(!x.netLoc&&x.path&&x.path[0]!=="/"){var f=O.exec(x.path);x.netLoc=f[1],x.path=f[2]}x.netLoc&&!x.path&&(x.path="/");var _={scheme:x.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(_.netLoc=x.netLoc,E.path[0]!=="/"))if(!E.path)_.path=x.path,E.params||(_.params=x.params,E.query||(_.query=x.query));else{var p=x.path,v=p.substring(0,p.lastIndexOf("/")+1)+E.path;_.path=P.normalizePath(v)}return _.path===null&&(_.path=A.alwaysNormalize?P.normalizePath(E.path):E.path),P.buildURLFromParts(_)},parseURL:function(U){var b=T.exec(U);return b?{scheme:b[1]||"",netLoc:b[2]||"",path:b[3]||"",params:b[4]||"",query:b[5]||"",fragment:b[6]||""}:null},normalizePath:function(U){for(U=U.split("").reverse().join("").replace(D,"");U.length!==(U=U.replace(M,"")).length;);return U.split("").reverse().join("")},buildURLFromParts:function(U){return U.scheme+U.netLoc+U.path+U.params+U.query+U.fragment}};Q.exports=P})(this)}},X={};function V(Q){var B=X[Q];if(B!==void 0)return B.exports;var T=X[Q]={exports:{}};return $[Q].call(T.exports,T,T.exports,V),T.exports}V.m=$,V.n=Q=>{var B=Q&&Q.__esModule?()=>Q.default:()=>Q;return V.d(B,{a:B}),B},V.d=(Q,B)=>{for(var T in B)V.o(B,T)&&!V.o(Q,T)&&Object.defineProperty(Q,T,{enumerable:!0,get:B[T]})},V.o=(Q,B)=>Object.prototype.hasOwnProperty.call(Q,B),V.r=Q=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(Q,"__esModule",{value:!0})};var ie=V("./src/hls.ts");return ie=ie.default,ie})())});var wt=class{addEventListener(){}removeEventListener(){}dispatchEvent(X){return!0}};if(typeof DocumentFragment=="undefined"){class $ extends wt{}globalThis.DocumentFragment=$}var Zt=class extends wt{},Gr=class extends wt{},$n={get($){},define($,X,V){},upgrade($){},whenDefined($){return Promise.resolve(Zt)}},er,Hr=class{constructor(X,V={}){Ae(this,er,void 0);Fe(this,er,V==null?void 0:V.detail)}get detail(){return he(this,er)}initCustomEvent(){}};er=new WeakMap;function Jn($,X){return new Zt}var Di={document:{createElement:Jn},DocumentFragment,customElements:$n,CustomEvent:Hr,EventTarget:wt,HTMLElement:Zt,HTMLVideoElement:Gr},bi=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Tt=bi?Di:globalThis,jr=bi?Di.document:globalThis.document;var xr=Er(Li(),1),Rt=Er(Tr(),1),zr=Er(Tr(),1),kt=Er(Tr(),1),rr=class extends Error{constructor($,X=rr.MEDIA_ERR_CUSTOM,V){var ie;super($),this.name="MediaError",this.code=X,this.fatal=V!=null?V:X>=rr.MEDIA_ERR_NETWORK&&X<=rr.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(ie=rr.defaultMessages[this.code])!=null?ie:"")}},ct=rr;ct.MEDIA_ERR_ABORTED=1,ct.MEDIA_ERR_NETWORK=2,ct.MEDIA_ERR_DECODE=3,ct.MEDIA_ERR_SRC_NOT_SUPPORTED=4,ct.MEDIA_ERR_ENCRYPTED=5,ct.MEDIA_ERR_CUSTOM=100,ct.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 qn=$=>$==null,Mi=($,X)=>qn(X)?!1:$ in X,Qr={ANY:"any",MUTED:"muted"},Sr={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},It={MSE:"mse",NATIVE:"native"},$r={HEADER:"header",QUERY:"query",NONE:"none"},Zr=Object.values($r),Ut={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Jr={HLS:Ut.M3U8},Ra=Object.keys(Jr),Ia=[...Object.values(Ut),"hls","HLS"],Ft=($,X,V,ie,Q=$)=>{Q.addEventListener(X,V,ie),$.addEventListener("teardown",()=>{Q.removeEventListener(X,V)},{once:!0})};function Zn($,X,V){X&&V>X&&(V=X);for(let ie=0;ie<$.length;ie++)if($.start(ie)<=V&&$.end(ie)>=V)return!0;return!1}var ea=$=>{let X=$.indexOf("?");if(X<0)return[$];let V=$.slice(0,X),ie=$.slice(X);return[V,ie]},wi=$=>{let X=$.type;if(X){let ie=X.toUpperCase();return Mi(ie,Jr)?Jr[ie]:X}let{src:V}=$;return V?ta(V):""},ta=$=>{let X="";try{X=new URL($).pathname}catch{console.error("invalid url")}let V=X.lastIndexOf(".");if(V<0)return"";let ie=X.slice(V+1).toUpperCase();return Mi(ie,Ut)?Ut[ie]:""},ra=Object.values(Qr),Pi=$=>typeof $=="boolean"||typeof $=="string"&&ra.includes($),ia=({autoplay:$},X,V)=>{let ie=!1,Q=!1,B=Pi($)?$:!!$,T=()=>{ie||Ft(X,"playing",()=>{ie=!0},{once:!0})};if(T(),Ft(X,"loadstart",()=>{ie=!1,T(),Xr(X,B)},{once:!0}),Ft(X,"loadstart",()=>{V||(Q=!Number.isFinite(X.duration)),Xr(X,B)},{once:!0}),V&&V.once(zr.default.Events.LEVEL_LOADED,(O,D)=>{var M;Q=(M=D.details.live)!=null?M:!1}),!B){let O=()=>{!Q||(V!=null&&V.liveSyncPosition?X.currentTime=V.liveSyncPosition:Number.isFinite(X.seekable.end(0))&&(X.currentTime=X.seekable.end(0)))};V&&Ft(X,"play",()=>{X.preload==="metadata"?V.once(zr.default.Events.LEVEL_UPDATED,O):O()},{once:!0})}return O=>{ie||(B=Pi(O)?O:!!O,Xr(X,B))}},Xr=($,X)=>{if(!X)return;let V=$.muted,ie=()=>$.muted=V;switch(X){case Qr.ANY:$.play().catch(()=>{$.muted=!0,$.play().catch(ie)});break;case Qr.MUTED:$.muted=!0,$.play().catch(ie);break;default:$.play().catch(()=>{});break}},na=({preload:$,src:X},V,ie)=>{let Q=U=>{U!=null&&["","none","metadata","auto"].includes(U)?V.setAttribute("preload",U):V.removeAttribute("preload")};if(!ie)return Q($),Q;let B=!1,T=!1,O=ie.config.maxBufferLength,D=ie.config.maxBufferSize,M=U=>{Q(U);let b=U!=null?U:V.preload;T||b==="none"||(b==="metadata"?(ie.config.maxBufferLength=1,ie.config.maxBufferSize=1):(ie.config.maxBufferLength=O,ie.config.maxBufferSize=D),P())},P=()=>{!B&&X&&(B=!0,ie.loadSource(X))};return Ft(V,"play",()=>{T=!0,ie.config.maxBufferLength=O,ie.config.maxBufferSize=D,P()},{once:!0}),M($),M};function aa($,X){X.on(kt.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(Q,{tracks:B})=>{B.forEach(T=>{var O;let D=(O=T.subtitleTrack)!=null?O:T.closedCaptions,M=X.subtitleTracks.findIndex(({lang:P,name:U,type:b})=>P==(D==null?void 0:D.lang)&&U===T.label&&b.toLowerCase()===T.kind);ki($,T.kind,T.label,D==null?void 0:D.lang,`${T.kind}${M}`)})});let V=()=>{var Q;if(!X.subtitleTracks.length)return;let B=Array.from($.textTracks).find(O=>O.id&&O.mode==="showing"&&["subtitles","captions"].includes(O.kind)),T=`${(Q=X.subtitleTracks[X.subtitleTrack])==null?void 0:Q.type.toLowerCase()}${X.subtitleTrack}`;if(B&&(X.subtitleTrack<0||(B==null?void 0:B.id)!==T)){let O=X.subtitleTracks.findIndex(({lang:D,name:M,type:P})=>D==B.language&&M===B.label&&P.toLowerCase()===B.kind);X.subtitleTrack=O}B&&(B==null?void 0:B.id)===T&&B.cues&&Array.from(B.cues).forEach(O=>{B.addCue(O)})};$.textTracks.addEventListener("change",V),X.on(kt.default.Events.CUES_PARSED,(Q,{track:B,cues:T})=>{let O=$.textTracks.getTrackById(B);if(!O)return;let D=O.mode==="disabled";D&&(O.mode="hidden"),T.forEach(M=>{var P;(P=O.cues)!=null&&P.getCueById(M.id)||O.addCue(M)}),D&&(O.mode="disabled")}),X.once(kt.default.Events.DESTROYING,()=>{$.textTracks.removeEventListener("change",V),$.querySelectorAll("track[data-removeondestroy]").forEach(Q=>{Q.remove()})});let ie=()=>{Array.from($.textTracks).forEach(Q=>{var B,T;if(!["subtitles","caption"].includes(Q.kind)&&Q.label==="thumbnails"){if(!((B=Q.cues)!=null&&B.length)){let O=$.querySelector('track[label="thumbnails"]'),D=(T=O==null?void 0:O.getAttribute("src"))!=null?T:"";O==null||O.removeAttribute("src"),setTimeout(()=>{O==null||O.setAttribute("src",D)},0)}Q.mode!=="hidden"&&(Q.mode="hidden")}})};X.once(kt.default.Events.MANIFEST_LOADED,ie),X.once(kt.default.Events.MEDIA_ATTACHED,ie)}function ki($,X,V,ie,Q){let B=document.createElement("track");return B.kind=X,B.label=V,ie&&(B.srclang=ie),Q&&(B.id=Q),B.track.mode="disabled",B.setAttribute("data-removeondestroy",""),$.append(B),B.track}var ir="cuepoints",ei=Object.freeze({label:ir}),ti=($,{label:X=ir}=ei)=>{var V;return(V=Array.from($.querySelectorAll("track")).find(ie=>ie.track.label===X&&ie.track.kind==="metadata"))==null?void 0:V.track};async function ri($,X,V=ei){let ie=ti($,V);if(!ie){let{label:Q=ir}=V;ie=ki($,"metadata",Q),ie.mode="hidden",await new Promise(B=>setTimeout(()=>B(void 0),0))}return[...X].sort(({time:Q},{time:B})=>B-Q).forEach(({time:Q,value:B})=>{var T,O;let D=Array.prototype.findIndex.call(ie==null?void 0:ie.cues,A=>A.startTime>=Q),M=(T=ie==null?void 0:ie.cues)==null?void 0:T[D],P=M?M.startTime:Number.isFinite($.duration)?$.duration:Number.MAX_SAFE_INTEGER,U=(O=ie==null?void 0:ie.cues)==null?void 0:O[D-1];U&&(U.endTime=Q);let b=new VTTCue(Q,P,JSON.stringify(B!=null?B:null));ie.addCue(b)}),ie}var Fi=$=>({time:$.startTime,value:JSON.parse($.text)});function Ui($,X={label:ir}){let V=ti($,X);return V!=null&&V.cues?Array.from(V.cues,ie=>Fi(ie)):[]}function ii($,X={label:ir}){var V;let ie=ti($,X);if((V=ie==null?void 0:ie.activeCues)!=null&&V.length)return Fi(ie.activeCues[0])}async function sa($,X=ei){let V=await ri($,[],X);return Ft($,"cuechange",()=>{let ie=ii($);if(ie){let Q=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:ie});$.dispatchEvent(Q)}},{},V),V}var Ri,Ii,oa=(Ii=(Ri=globalThis==null?void 0:globalThis.navigator)==null?void 0:Ri.userAgent)!=null?Ii:"",la=oa.toLowerCase().indexOf("android")!==-1,Nt=new WeakMap,Ni="mux.com",Oi,Ci,Bi=(Ci=(Oi=Rt.default).isSupported)==null?void 0:Ci.call(Oi),ua=la,Ki=()=>xr.default.utils.now(),da=xr.default.utils.generateUUID,Wi=($,{domain:X=Ni}={})=>{if(!$)return;let[V,ie=""]=ea($);return`https://stream.${X}/${V}.m3u8${ie}`},fa=$=>{if(!$)return;let[X]=$.split("?");return X||void 0},ca=$=>{if(!$||!$.startsWith("https://stream."))return;let[X]=new URL($).pathname.slice(1).split(".m3u8");return X||void 0},ha=$=>{var X,V,ie;return(X=$==null?void 0:$.metadata)!=null&&X.video_id?$.metadata.video_id:Vi($)&&(ie=(V=fa($.playbackId))!=null?V:ca($.src))!=null?ie:$.src},Gi=$=>{var X;return(X=Nt.get($))==null?void 0:X.error},Hi=($,X,V)=>{ni(X,V);let{metadata:ie={}}=$,{view_session_id:Q=da()}=ie,B=ha($);ie.view_session_id=Q,ie.video_id=B,$.metadata=ie,Nt.set(X,{});let T=va($,X);ma($,X,T),pa($,X,T),sa(X);let O=ia($,X,T),D=na($,X,T);return{engine:T,setAutoplay:O,setPreload:D}},ni=($,X)=>{let V=X==null?void 0:X.engine;V&&(V.detachMedia(),V.destroy()),($==null?void 0:$.mux)&&!$.mux.deleted&&($.mux.destroy(),delete $.mux),$&&($.removeAttribute("src"),$.load(),$.removeEventListener("error",Xi),$.removeEventListener("error",qr),$.removeEventListener("durationchange",Yi),Nt.delete($),$.dispatchEvent(new Event("teardown")))};function ji($,X){var V;let ie=wi($);if(ie!==Ut.M3U8)return!0;let Q=!ie||((V=X.canPlayType(ie))!=null?V:!0),{preferPlayback:B}=$,T=B===It.MSE,O=B===It.NATIVE;return Q&&(O||!(Bi&&(T||ua)))}var va=($,X)=>{let{debug:V,streamType:ie,startTime:Q=-1,metadata:B,preferCmcd:T}=$,O=wi($)===Ut.M3U8,D=ji($,X);if(O&&!D&&Bi){let M={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},P=ga(ie),U=T!==$r.NONE?{useHeaders:T===$r.HEADER,sessionId:B.view_session_id,contentId:B.video_id}:void 0;return new Rt.default({debug:V,startPosition:Q,cmcd:U,...M,...P})}},ga=$=>[Sr.LIVE,Sr.DVR].includes($)?{backBufferLength:8}:[Sr.LL_LIVE,Sr.LL_DVR].includes($)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},Vi=({playbackId:$,src:X,customDomain:V})=>{if($)return!0;if(typeof X!="string")return!1;let ie=window==null?void 0:window.location.href,Q=new URL(X,ie).hostname.toLocaleLowerCase();return Q.includes(Ni)||!!V&&Q.includes(V.toLocaleLowerCase())},ma=($,X,V)=>{var ie;let{envKey:Q}=$,B=Vi($);if(Q||B){let{playerInitTime:T,playerSoftwareName:O,playerSoftwareVersion:D,beaconCollectionDomain:M,debug:P,disableCookies:U}=$,b={...$.metadata,video_title:((ie=$==null?void 0:$.metadata)==null?void 0:ie.video_title)||void 0},A=S=>typeof S.player_error_code=="string"?!1:typeof $.errorTranslator=="function"?$.errorTranslator(S):S;xr.default.monitor(X,{debug:P,beaconCollectionDomain:M,hlsjs:V,Hls:V?Rt.default:void 0,automaticErrorTracking:!1,errorTranslator:A,disableCookies:U,data:{...Q?{env_key:Q}:{},player_software_name:O,player_software:O,player_software_version:D,player_init_time:T,...b}})}},pa=($,X,V)=>{var ie;let Q=ji($,X),{src:B}=$;X&&Q?(typeof B=="string"?(X.setAttribute("src",B),$.startTime&&(((ie=Nt.get(X))!=null?ie:{}).startTime=$.startTime,X.addEventListener("durationchange",Yi,{once:!0}))):X.removeAttribute("src"),X.addEventListener("error",Xi),X.addEventListener("error",qr)):V&&B?(V.on(Rt.default.Events.ERROR,(T,O)=>{let D={[Rt.default.ErrorTypes.NETWORK_ERROR]:ct.MEDIA_ERR_NETWORK,[Rt.default.ErrorTypes.MEDIA_ERROR]:ct.MEDIA_ERR_DECODE},M=new ct("",D[O.type]);M.fatal=O.fatal,M.data=O,X.dispatchEvent(new CustomEvent("error",{detail:M}))}),X.addEventListener("error",qr),aa(X,V),V.attachMedia(X)):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 Yi($){var X;let V=$.target,ie=(X=Nt.get(V))==null?void 0:X.startTime;if(!!ie&&Zn(V.seekable,V.duration,ie)){let Q=V.preload==="auto";Q&&(V.preload="none"),V.currentTime=ie,Q&&(V.preload="auto")}}async function Xi($){if(!$.isTrusted)return;$.stopImmediatePropagation();let X=$.target;if(!(X!=null&&X.error))return;let{message:V,code:ie}=X.error,Q=new ct(V,ie);if(X.src&&(ie!==ct.MEDIA_ERR_DECODE||ie!==void 0))try{let{status:B}=await fetch(X.src);Q.data={response:{code:B}}}catch{}X.dispatchEvent(new CustomEvent("error",{detail:Q}))}function qr($){var X,V;if(!($ instanceof CustomEvent)||!($.detail instanceof ct))return;let ie=$.target,Q=$.detail;!Q||!Q.fatal||(((X=Nt.get(ie))!=null?X:{}).error=Q,(V=ie.mux)==null||V.emit("error",{player_error_code:Q.code,player_error_message:Q.message}))}var ya=()=>{try{return"0.13.0"}catch{}return"UNKNOWN"},Ea=ya(),zi=()=>Ea;var ai=class extends Set{add(X){super.add(new WeakRef(X))}forEach(X){super.forEach(V=>{let ie=V.deref();ie&&X(ie)})}},_a=$=>{var X,V,ie,Q,B,Qi,O,Ar,M,St,U,Dr,A,br,E,$i,f,Ji,p,si,a,s,n,d,l,i,u,nr,c,qi,e,oi,t,Zi,y,li,L,en,I,ui;return X=class extends ${constructor(){super();Ae(this,u);Ae(this,c);Ae(this,e);Ae(this,t);Ae(this,y);Ae(this,L);Ae(this,I);qt(this,"castEnabled",!1);Ae(this,a,{paused:!1});Ae(this,s,void 0);Ae(this,n,{});Ae(this,d,void 0);Ae(this,l,void 0);Ae(this,i,void 0);X.instances.add(this),Ke(this,y,li).call(this)}static get castElement(){return he(X,V)}static get castEnabled(){return he(X,ie)}static get castState(){var K;return(K=he(X,M,St))==null?void 0:K.getCastState()}static async exitCast(){try{await he(X,M,St).endCurrentSession(!0)}catch(H){console.error(H);return}}get castPlayer(){if(X.castElement===this)return he(this,s)}attributeChangedCallback(K){if(!!this.castPlayer)switch(K){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(K={}){var H;Ke(H=X,p,si).call(H,K),Fe(X,V,this),Object.entries(he(this,n)).forEach(([Y,q])=>{he(this,s).controller.addEventListener(Y,q)});try{await he(X,M,St).requestSession()}catch{Fe(X,V,void 0);return}he(this,a).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(Y){console.error(Y)}}async load(){var ae,re;if(!this.castPlayer)return super.load();let K=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),H=[...this.querySelectorAll("track")].filter(({kind:se,src:le})=>le&&(se==="subtitles"||se==="captions")),Y=[],q=0;H.length&&(K.tracks=H.map(se=>{let le=++q;Y.length===0&&se.track.mode==="showing"&&Y.push(le);let de=new chrome.cast.media.Track(le,chrome.cast.media.TrackType.TEXT);return de.trackContentId=se.src,de.trackContentType="text/vtt",de.subtype=se.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,de.name=se.label,de.language=se.srclang,de})),this.castStreamType==="live"?K.streamType=chrome.cast.media.StreamType.LIVE:K.streamType=chrome.cast.media.StreamType.BUFFERED,K.metadata=new chrome.cast.media.GenericMediaMetadata,K.metadata.title=this.title,K.metadata.images=[{url:this.poster}];let ee=new chrome.cast.media.LoadRequest(K);ee.currentTime=(ae=super.currentTime)!=null?ae:0,ee.autoplay=!he(this,a).paused,ee.activeTrackIds=Y,await((re=he(X,U,Dr))==null?void 0:re.loadMedia(ee)),this.dispatchEvent(new Event("volumechange"))}play(){var K;if(this.castPlayer){this.castPlayer.isPaused&&((K=this.castPlayer.controller)==null||K.playOrPause());return}return super.play()}pause(){var K;if(this.castPlayer){this.castPlayer.isPaused||(K=this.castPlayer.controller)==null||K.playOrPause();return}super.pause()}get castSrc(){var K,H,Y;return(Y=(H=this.getAttribute("cast-src"))!=null?H:(K=this.querySelector("source"))==null?void 0:K.src)!=null?Y:this.currentSrc}set castSrc(K){this.castSrc!=K&&this.setAttribute("cast-src",`${K}`)}get castContentType(){var K;return(K=this.getAttribute("cast-content-type"))!=null?K:void 0}set castContentType(K){this.setAttribute("cast-content-type",`${K}`)}get castStreamType(){var K;return(K=this.getAttribute("cast-stream-type"))!=null?K:void 0}set castStreamType(K){this.setAttribute("cast-stream-type",`${K}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var K;return this.castPlayer?(K=this.castPlayer)==null?void 0:K.isMuted:super.muted}set muted(K){var H;if(this.castPlayer){(K&&!this.castPlayer.isMuted||!K&&this.castPlayer.isMuted)&&((H=this.castPlayer.controller)==null||H.muteOrUnmute());return}super.muted=K}get volume(){var K,H;return this.castPlayer?(H=(K=this.castPlayer)==null?void 0:K.volumeLevel)!=null?H:1:super.volume}set volume(K){var H;if(this.castPlayer){this.castPlayer.volumeLevel=K,(H=this.castPlayer.controller)==null||H.setVolumeLevel();return}super.volume=K}get duration(){var K,H;return this.castPlayer&&he(this,u,nr)?(H=(K=this.castPlayer)==null?void 0:K.duration)!=null?H:NaN:super.duration}get currentTime(){var K,H;return this.castPlayer&&he(this,u,nr)?(H=(K=this.castPlayer)==null?void 0:K.currentTime)!=null?H:0:super.currentTime}set currentTime(K){var H;if(this.castPlayer){this.castPlayer.currentTime=K,(H=this.castPlayer.controller)==null||H.seek();return}super.currentTime=K}get onentercast(){return he(this,d)}set onentercast(K){he(this,d)&&(this.removeEventListener("entercast",he(this,d)),Fe(this,d,null)),typeof K=="function"&&(Fe(this,d,K),this.addEventListener("entercast",K))}get onleavecast(){return he(this,l)}set onleavecast(K){he(this,l)&&(this.removeEventListener("leavecast",he(this,l)),Fe(this,l,null)),typeof K=="function"&&(Fe(this,l,K),this.addEventListener("leavecast",K))}get oncastchange(){return he(this,i)}set oncastchange(K){he(this,i)&&(this.removeEventListener("castchange",he(this,i)),Fe(this,i,null)),typeof K=="function"&&(Fe(this,i,K),this.addEventListener("castchange",K))}},V=new WeakMap,ie=new WeakMap,Q=new WeakMap,B=new WeakSet,Qi=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},O=new WeakSet,Ar=function(){return typeof cast!="undefined"&&cast.framework},M=new WeakSet,St=function(){if(he(X,O,Ar))return cast.framework.CastContext.getInstance()},U=new WeakSet,Dr=function(){var K;return(K=he(X,M,St))==null?void 0:K.getCurrentSession()},A=new WeakSet,br=function(){var K;return(K=he(X,U,Dr))==null?void 0:K.getSessionObj().media[0]},E=new WeakSet,$i=function(K){return new Promise((H,Y)=>{he(X,A,br).editTracksInfo(K,H,Y)})},f=new WeakSet,Ji=function(K){return new Promise((H,Y)=>{he(X,A,br).getStatus(K,H,Y)})},p=new WeakSet,si=function(K){return he(X,M,St).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...K})},a=new WeakMap,s=new WeakMap,n=new WeakMap,d=new WeakMap,l=new WeakMap,i=new WeakMap,u=new WeakSet,nr=function(){var K;return(K=this.castPlayer)==null?void 0:K.isMediaLoaded},c=new WeakSet,qi=function(){he(X,V)===this&&(Object.entries(he(this,n)).forEach(([K,H])=>{he(this,s).controller.removeEventListener(K,H)}),Fe(X,V,void 0),this.muted=he(this,s).isMuted,this.currentTime=he(this,s).savedPlayerState.currentTime,he(this,s).savedPlayerState.isPaused===!1&&this.play())},e=new WeakSet,oi=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:he(X,M,St).getCastState()}))},t=new WeakSet,Zi=async function(){var H,Y;let{SESSION_RESUMED:K}=cast.framework.SessionState;if(he(X,M,St).getSessionState()===K&&this.castSrc===((H=he(X,A,br))==null?void 0:H.media.contentId)){Fe(X,V,this),Object.entries(he(this,n)).forEach(([q,ee])=>{he(this,s).controller.addEventListener(q,ee)});try{await Ke(Y=X,f,Ji).call(Y,new chrome.cast.media.GetStatusRequest)}catch(q){console.error(q)}he(this,n)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),he(this,n)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},y=new WeakSet,li=function(){var K;!he(X,O,Ar)||this.castEnabled||(this.castEnabled=!0,Ke(K=X,p,si).call(K),this.textTracks.addEventListener("change",Ke(this,I,ui).bind(this)),Ke(this,e,oi).call(this),Fe(this,s,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(he(this,s)),Fe(this,n,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:H})=>{H===!1&&Ke(this,c,qi).call(this),this.dispatchEvent(new Event(H?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!he(this,u,nr)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var H,Y;((H=this.castPlayer)==null?void 0:H.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(Y=this.castPlayer)==null?void 0:Y.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!he(this,u,nr)||(await Promise.resolve(),Ke(this,L,en).call(this))}}))},L=new WeakSet,en=function(){Ke(this,I,ui).call(this)},I=new WeakSet,ui=async function(){var ue,fe,ce,be,Pe,we;if(!this.castPlayer)return;let H=((fe=(ue=he(this,s).mediaInfo)==null?void 0:ue.tracks)!=null?fe:[]).filter(({type:pe})=>pe===chrome.cast.media.TrackType.TEXT),Y=[...this.textTracks].filter(({kind:pe})=>pe==="subtitles"||pe==="captions"),q=H.map(({language:pe,name:Me,trackId:Re})=>{var Le;let{mode:ke}=(Le=Y.find(Ue=>Ue.language===pe&&Ue.label===Me))!=null?Le:{};return ke?{mode:ke,trackId:Re}:!1}).filter(Boolean),ae=q.filter(({mode:pe})=>pe!=="showing").map(({trackId:pe})=>pe),re=q.find(({mode:pe})=>pe==="showing"),se=(Pe=(be=(ce=he(X,U,Dr))==null?void 0:ce.getSessionObj().media[0])==null?void 0:be.activeTrackIds)!=null?Pe:[],le=se;if(se.length&&(le=le.filter(pe=>!ae.includes(pe))),re!=null&&re.trackId&&(le=[...le,re.trackId]),le=[...new Set(le)],!((pe,Me)=>pe.length===Me.length&&pe.every(Re=>Me.includes(Re)))(se,le))try{let pe=new chrome.cast.media.EditTracksInfoRequest(le);await Ke(we=X,E,$i).call(we,pe)}catch(pe){console.error(pe)}},Ae(X,B),Ae(X,O),Ae(X,M),Ae(X,U),Ae(X,A),Ae(X,E),Ae(X,f),Ae(X,p),qt(X,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),qt(X,"instances",new ai),Ae(X,V,void 0),Ae(X,ie,!1),qt(X,"initCast",()=>{var K;he(X,B,Qi)?he(X,O,Ar)?he(K=X,Q).call(K,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var H;return he(H=X,Q).call(H,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var H;return he(H=X,Q).call(H,chrome.cast.isAvailable)})}}),Ae(X,Q,K=>{if(K){Fe(X,ie,!0);let{CAST_STATE_CHANGED:H}=cast.framework.CastContextEventType;he(X,M,St).addEventListener(H,q=>{X.instances.forEach(ee=>{var ae;return Ke(ae=ee,e,oi).call(ae,q)})});let{SESSION_STATE_CHANGED:Y}=cast.framework.CastContextEventType;he(X,M,St).addEventListener(Y,q=>{X.instances.forEach(ee=>{var ae;return Ke(ae=ee,t,Zi).call(ae,q)})}),X.instances.forEach(q=>{var ee;return Ke(ee=q,y,li).call(ee)})}}),X};if(globalThis.HTMLVideoElement&&globalThis.customElements){let $=_a(HTMLVideoElement);globalThis.customElements.get("castable-video")||(globalThis.customElements.define("castable-video",$,{extends:"video"}),globalThis.CastableVideoElement=$),$.initCast()}var tn=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],rn=jr.createElement("template");rn.innerHTML=`
|
|
32
33
|
<style>
|
|
33
34
|
:host {
|
|
34
35
|
display: inline-block;
|
|
@@ -48,7 +49,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
48
49
|
</style>
|
|
49
50
|
<video is="castable-video" part="video" crossorigin></video>
|
|
50
51
|
<slot></slot>
|
|
51
|
-
`;var
|
|
52
|
+
`;var ar,Bt,Lr,sr,di,bt=class extends Tt.HTMLElement{constructor(){super();Ae(this,Bt);Ae(this,sr);Ae(this,ar,void 0);this.attachShadow({mode:"open"}),this.isConnected&&Ke(this,Bt,Lr).call(this)}static get observedAttributes(){let V=[],ie=B=>B.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(B=>{let T=!1;try{typeof this.prototype[B]=="function"&&(T=!0)}catch{}!T&&B!==B.toUpperCase()&&V.push(B.toLowerCase(),ie(B))});let Q=Object.getPrototypeOf(this).observedAttributes;return Q&&(V=V.concat(Q)),V}attributeChangedCallback(V,ie,Q){Ke(this,Bt,Lr).call(this),Ke(this,sr,di).call(this,V,ie,Q)}connectedCallback(){Ke(this,Bt,Lr).call(this)}};ar=new WeakMap,Bt=new WeakSet,Lr=function(){if(he(this,ar))return;Fe(this,ar,!0),this.shadowRoot.append(rn.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),tn.forEach(ie=>{this.nativeEl.addEventListener(ie,Q=>{this.dispatchEvent(new CustomEvent(Q.type,{detail:Q.detail}))})});let V=this.shadowRoot.querySelector("slot");V.addEventListener("slotchange",()=>{V.assignedElements().forEach(ie=>{!["track","source"].includes(ie.localName)||this.nativeEl.append(ie)})}),Array.prototype.forEach.call(this.attributes,ie=>{Ke(this,sr,di).call(this,ie.name,null,ie.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},sr=new WeakSet,di=function(V,ie,Q){let B=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),T=Sa(B,V),O=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;T&&!O?typeof this[T]=="boolean"?Q===null?this[T]=!1:this[T]=!0:this[T]=Q:Q===null?this.nativeEl.removeAttribute(V):["id","class"].indexOf(V)===-1&&this.nativeEl.setAttribute(V,Q)};var nn=[],an=jr.createElement("video",{is:"castable-video"}),Ta=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let $=Object.getPrototypeOf(an);$&&$!==Tt.HTMLElement.prototype;$=Object.getPrototypeOf($))Object.getOwnPropertyNames($).forEach(X=>{Ta.indexOf(X)===-1&&nn.push(X)});nn.forEach($=>{if($ in bt.prototype)return;if(typeof an[$]=="function")bt.prototype[$]=function(){return this.nativeEl[$].apply(this.nativeEl,arguments)};else{let V={get(){return this.nativeEl[$]}};$!==$.toUpperCase()&&(V.set=function(ie){this.nativeEl[$]=ie}),Object.defineProperty(bt.prototype,$,V)}});function Sa($,X){let V=null;return $.forEach(ie=>{ie.toLowerCase()==X.toLowerCase()&&(V=ie)}),V}Tt.customElements.get("custom-video")||(Tt.customElements.define("custom-video",bt),Tt.CustomVideoElement=bt);var fi=bt;var De={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_PLAYBACK:"prefer-playback",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_SOFTWARE_NAME:"player-software-name",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DISABLE_COOKIES:"disable-cookies",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time",PREFER_CMCD:"prefer-cmcd"},xa=Object.values(De),Aa=zi(),Da="mux-video",xt,Kt,lr,Wt,ur,dr,fr,cr,ci,or=class extends fi{constructor(){super();Ae(this,cr);Ae(this,xt,void 0);Ae(this,Kt,void 0);Ae(this,lr,void 0);Ae(this,Wt,{});Ae(this,ur,void 0);Ae(this,dr,void 0);Ae(this,fr,void 0);Fe(this,lr,Ki())}static get observedAttributes(){var V;return[...xa,...(V=fi.observedAttributes)!=null?V:[]]}get preferCmcd(){var V;return(V=this.getAttribute(De.PREFER_CMCD))!=null?V:void 0}set preferCmcd(V){V!==this.preferCmcd&&(V?Zr.includes(V)?this.setAttribute(De.PREFER_CMCD,V):console.warn(`Invalid value for preferCmcd. Must be one of ${Zr.join()}`):this.removeAttribute(De.PREFER_CMCD))}get playerInitTime(){return he(this,lr)}get playerSoftwareName(){var V;return(V=he(this,dr))!=null?V:Da}set playerSoftwareName(V){Fe(this,dr,V)}get playerSoftwareVersion(){var V;return(V=he(this,ur))!=null?V:Aa}set playerSoftwareVersion(V){Fe(this,ur,V)}get _hls(){var V;return(V=he(this,xt))==null?void 0:V.engine}get mux(){return this.nativeEl.mux}get error(){var V;return(V=Gi(this.nativeEl))!=null?V:null}get errorTranslator(){return he(this,fr)}set errorTranslator(V){Fe(this,fr,V)}get src(){return this.getAttribute("src")}set src(V){V!==this.src&&(V==null?this.removeAttribute("src"):this.setAttribute("src",V))}get type(){var V;return(V=this.getAttribute(De.TYPE))!=null?V:void 0}set type(V){V!==this.type&&(V?this.setAttribute(De.TYPE,V):this.removeAttribute(De.TYPE))}get autoplay(){let V=this.getAttribute("autoplay");return V===null?!1:V===""?!0:V}set autoplay(V){let ie=this.autoplay;V!==ie&&(V?this.setAttribute("autoplay",typeof V=="string"?V:""):this.removeAttribute("autoplay"))}get preload(){let V=this.getAttribute("preload");return V===""?"auto":["none","metadata","auto"].includes(V)?V:super.preload}set preload(V){V!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(V)?this.setAttribute("preload",V):this.removeAttribute("preload"))}get debug(){return this.getAttribute(De.DEBUG)!=null}set debug(V){V!==this.debug&&(V?this.setAttribute(De.DEBUG,""):this.removeAttribute(De.DEBUG))}get disableCookies(){return this.hasAttribute(De.DISABLE_COOKIES)}set disableCookies(V){V!==this.disableCookies&&(V?this.setAttribute(De.DISABLE_COOKIES,""):this.removeAttribute(De.DISABLE_COOKIES))}get startTime(){let V=this.getAttribute(De.START_TIME);if(V==null)return;let ie=+V;return Number.isNaN(ie)?void 0:ie}set startTime(V){V!==this.startTime&&(V==null?this.removeAttribute(De.START_TIME):this.setAttribute(De.START_TIME,`${V}`))}get playbackId(){var V;return(V=this.getAttribute(De.PLAYBACK_ID))!=null?V:void 0}set playbackId(V){V!==this.playbackId&&(V?this.setAttribute(De.PLAYBACK_ID,V):this.removeAttribute(De.PLAYBACK_ID))}get customDomain(){var V;return(V=this.getAttribute(De.CUSTOM_DOMAIN))!=null?V:void 0}set customDomain(V){V!==this.customDomain&&(V?this.setAttribute(De.CUSTOM_DOMAIN,V):this.removeAttribute(De.CUSTOM_DOMAIN))}get envKey(){var V;return(V=this.getAttribute(De.ENV_KEY))!=null?V:void 0}set envKey(V){V!==this.envKey&&(V?this.setAttribute(De.ENV_KEY,V):this.removeAttribute(De.ENV_KEY))}get beaconCollectionDomain(){var V;return(V=this.getAttribute(De.BEACON_COLLECTION_DOMAIN))!=null?V:void 0}set beaconCollectionDomain(V){V!==this.beaconCollectionDomain&&(V?this.setAttribute(De.BEACON_COLLECTION_DOMAIN,V):this.removeAttribute(De.BEACON_COLLECTION_DOMAIN))}get streamType(){var V;return(V=this.getAttribute(De.STREAM_TYPE))!=null?V:void 0}set streamType(V){V!==this.streamType&&(V?this.setAttribute(De.STREAM_TYPE,V):this.removeAttribute(De.STREAM_TYPE))}async addCuePoints(V){return ri(this.nativeEl,V)}get activeCuePoint(){return ii(this.nativeEl)}get cuePoints(){return Ui(this.nativeEl)}get preferPlayback(){let V=this.getAttribute(De.PREFER_PLAYBACK);if(V===It.MSE||V===It.NATIVE)return V}set preferPlayback(V){V!==this.preferPlayback&&(V===It.MSE||V===It.NATIVE?this.setAttribute(De.PREFER_PLAYBACK,V):this.removeAttribute(De.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(ie=>ie.startsWith("metadata-")&&![De.METADATA_URL].includes(ie)).reduce((ie,Q)=>{let B=this.getAttribute(Q);return B!=null&&(ie[Q.replace(/^metadata-/,"").replace(/-/g,"_")]=B),ie},{}),...he(this,Wt)}}set metadata(V){Fe(this,Wt,V!=null?V:{}),this.mux&&this.mux.emit("hb",he(this,Wt))}load(){Fe(this,xt,Hi(this,this.nativeEl,he(this,xt)))}unload(){ni(this.nativeEl,he(this,xt)),Fe(this,xt,void 0)}attributeChangedCallback(V,ie,Q){var B,T;switch(super.attributeChangedCallback(V,ie,Q),V){case De.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=Q!=null?Q:void 0;break;case De.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=Q!=null?Q:void 0;break;case"src":{let O=!!ie,D=!!Q;!O&&D?Ke(this,cr,ci).call(this):O&&!D?this.unload():O&&D&&(this.unload(),Ke(this,cr,ci).call(this));break}case"autoplay":if(Q===ie)break;(B=he(this,xt))==null||B.setAutoplay(this.autoplay);break;case"preload":if(Q===ie)break;(T=he(this,xt))==null||T.setPreload(Q);break;case De.PLAYBACK_ID:this.src=Wi(Q!=null?Q:void 0,{domain:this.customDomain});break;case De.DEBUG:{let O=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=O);break}case De.METADATA_URL:Q&&fetch(Q).then(O=>O.json()).then(O=>this.metadata=O).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${Q}!`));break;default:break}}disconnectedCallback(){this.unload()}};xt=new WeakMap,Kt=new WeakMap,lr=new WeakMap,Wt=new WeakMap,ur=new WeakMap,dr=new WeakMap,fr=new WeakMap,cr=new WeakSet,ci=async function(){he(this,Kt)||(await Fe(this,Kt,Promise.resolve()),Fe(this,Kt,null),this.load())};Tt.customElements.get("mux-video")||(Tt.customElements.define("mux-video",or),Tt.MuxVideoElement=or);var Xa=or;export{De as Attributes,ct as MediaError,tn as VideoEvents,Xa as default};
|
|
52
53
|
/*!
|
|
53
54
|
* JavaScript Cookie v2.1.3
|
|
54
55
|
* https://github.com/js-cookie/js-cookie
|