@mux/mux-player 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,33 +1,33 @@
1
- var Pd=Object.create;var Xs=Object.defineProperty;var kd=Object.getOwnPropertyDescriptor;var wd=Object.getOwnPropertyNames;var Ud=Object.getPrototypeOf,Nd=Object.prototype.hasOwnProperty;var Qs=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var Bd=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of wd(t))!Nd.call(r,a)&&a!==e&&Xs(r,a,{get:()=>t[a],enumerable:!(s=kd(t,a))||s.enumerable});return r};var tn=(r,t,e)=>(e=r!=null?Pd(Ud(r)):{},Bd(t||!r||!r.__esModule?Xs(e,"default",{value:r,enumerable:!0}):e,r));var ma=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)};var xe=(r,t,e)=>(ma(r,t,"read from private field"),e?e.call(r):t.get(r)),Ne=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},mt=(r,t,e,s)=>(ma(r,t,"write to private field"),s?s.call(r,e):t.set(r,e),e);var Fe=(r,t,e)=>(ma(r,t,"access private method"),e);var ol=Qs((xn,cs)=>{(function(){var r,t;r=this,t=function(){return function(){var e={80:function(u,R,C){u.exports=C(728).default},728:function(u,R,C){"use strict";C.d(R,{default:function(){return Od}});var O=C(48),L=C.n(O),b=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){var k=16*Math.random()|0;return(U==="x"?k:3&k|8).toString(16)})},x=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},I=function(U){return U&&U.nodeName!==void 0?(U.muxId||(U.muxId=U.id||x()),U.muxId):U},_=function(U){var k;U&&U.nodeName!==void 0?U=I(k=U):k=document.querySelector(U);var w=k&&k.nodeName?k.nodeName.toLowerCase():"";return[k,U,w]},A=C(640),S=C.n(A),v=S().methodFactory;S().methodFactory=function(U,k,w){var K=v(U,k,w);return function(){for(var W=["[mux]"],z=0;z<arguments.length;z++)W.push(arguments[z]);K.apply(void 0,W)}},S().setLevel(S().getLevel());var i=S();function d(){return(L().doNotTrack||L().navigator&&L().navigator.doNotTrack)==="1"}var p={now:function(){var U=L().performance,k=U&&U.timing,w=U&&U.timeOrigin||k&&k.navigationStart;return typeof w=="number"&&typeof U.now=="function"?w+U.now():Date.now()}},T=C(678),l=C.n(T),o=function(U){return h(U)[0]},h=function(U){if(typeof U!="string"||U==="")return["localhost"];var k,w=(U.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return w&&(k=(w.match(/[^\.]+\.[^\.]+$/)||[])[0]),[w,k]},E={exists:function(){var U=L().performance;return(U&&U.timing)!==void 0},domContentLoadedEventEnd:function(){var U=L().performance,k=U&&U.timing;return k&&k.domContentLoadedEventEnd},navigationStart:function(){var U=L().performance,k=U&&U.timing;return k&&k.navigationStart}};function n(U,k,w){w=w===void 0?1:w,U[k]=U[k]||0,U[k]+=w}var c=["x-cdn","content-type","x-request-id"];function m(U){var k={};return(U=U||"").trim().split(/[\r\n]+/).forEach(function(w){if(w){var K=w.split(": "),W=K.shift();W&&(c.indexOf(W.toLowerCase())>=0||W.toLowerCase().indexOf("x-litix-")===0)&&(k[W]=K.join(": "))}}),k}var f=function(U){var k={};for(var w in U){var K=U[w];K["DATA-ID"].search("io.litix.data.")!==-1&&(k[K["DATA-ID"].replace("io.litix.data.","")]=K.VALUE)}return k};function g(U,k){var w=Object.keys(U);if(Object.getOwnPropertySymbols){var K=Object.getOwnPropertySymbols(U);k&&(K=K.filter(function(W){return Object.getOwnPropertyDescriptor(U,W).enumerable})),w.push.apply(w,K)}return w}function y(U){for(var k=1;k<arguments.length;k++){var w=arguments[k]!=null?arguments[k]:{};k%2?g(Object(w),!0).forEach(function(K){M(U,K,w[K])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(w)):g(Object(w)).forEach(function(K){Object.defineProperty(U,K,Object.getOwnPropertyDescriptor(w,K))})}return U}function M(U,k,w){return k in U?Object.defineProperty(U,k,{value:w,enumerable:!0,configurable:!0,writable:!0}):U[k]=w,U}var D=function(U){if(!U)return{};var k=E.navigationStart(),w=U.loading,K=w?w.start:U.trequest,W=w?w.first:U.tfirst,z=w?w.end:U.tload;return{bytesLoaded:U.total,requestStart:Math.round(k+K),responseStart:Math.round(k+W),responseEnd:Math.round(k+z)}},P=function(U){if(U&&typeof U.getAllResponseHeaders=="function")return m(U.getAllResponseHeaders())},B=function(U,k){if(!U||typeof U.getRequests!="function")return{};var w=U.getRequests({state:"executed"});if(w.length===0)return{};var K,W=w[w.length-1],z=o(W.url),Y=W.bytesLoaded,Z=new Date(W.requestStartDate).getTime(),q=new Date(W.firstByteDate).getTime(),Q=new Date(W.requestEndDate).getTime(),oe=isNaN(W.duration)?0:W.duration,Ae=typeof k.getMetricsFor=="function"?k.getMetricsFor(W.mediaType).HttpList:k.getDashMetrics().getHttpRequests(W.mediaType);return Ae.length>0&&(K=m(Ae[Ae.length-1]._responseHeaders||"")),{requestStart:Z,requestResponseStart:q,requestResponseEnd:Q,requestBytesLoaded:Y,requestResponseHeaders:K,requestMediaDuration:oe,requestHostname:z}},N=function(U,k){var w=k.getQualityFor(U),K=k.getCurrentTrackFor(U).bitrateList;return K?{currentLevel:w,renditionWidth:K[w].width||null,renditionHeight:K[w].height||null,renditionBitrate:K[w].bandwidth}:{}};function F(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var H=0,V=function(){function U(){(function(W,z){if(!(W instanceof z))throw new TypeError("Cannot call a class as a function")})(this,U)}var k,w,K;return k=U,w=[{key:"on",value:function(W,z,Y){return z._eventEmitterGuid=z._eventEmitterGuid||++H,this._listeners=this._listeners||{},this._listeners[W]=this._listeners[W]||[],Y&&(z=z.bind(Y)),this._listeners[W].push(z),z}},{key:"off",value:function(W,z){var Y=this._listeners&&this._listeners[W];Y&&Y.forEach(function(Z,q){Z._eventEmitterGuid===z._eventEmitterGuid&&Y.splice(q,1)})}},{key:"one",value:function(W,z,Y){var Z=this;z._eventEmitterGuid=z._eventEmitterGuid||++H;var q=function Q(){Z.off(W,Q),z.apply(Y||this,arguments)};q._eventEmitterGuid=z._eventEmitterGuid,this.on(W,q)}},{key:"emit",value:function(W,z){var Y=this;if(this._listeners){z=z||{};var Z=this._listeners["before*"]||[],q=this._listeners[W]||[],Q=this._listeners["after"+W]||[],oe=function(Ae,Pe){(Ae=Ae.slice()).forEach(function(Ie){Ie.call(Y,{type:W},Pe)})};oe(Z,z),oe(q,z),oe(Q,z)}}}],w&&F(k.prototype,w),K&&F(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}(),X=V;function $(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var j=function(){function U(W){var z=this;(function(Y,Z){if(!(Y instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,W.on("playing",function(){z._playheadShouldBeProgressing=!0}),W.on("play",this._startPlaybackHeartbeatInterval.bind(this)),W.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),W.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),W.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),W.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),W.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),W.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),W.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),W.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),W.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("seeked",function(){W.data.player_is_paused?z._stopPlaybackHeartbeatInterval():z._startPlaybackHeartbeatInterval()}),W.on("timeupdate",function(){z._playbackHeartbeatInterval!==null&&W.emit("playbackheartbeat")}),W.on("devicesleep",function(Y,Z){z._playbackHeartbeatInterval!==null&&(L().clearInterval(z._playbackHeartbeatInterval),W.emit("playbackheartbeatend",{viewer_time:Z.viewer_time}),z._playbackHeartbeatInterval=null)})}var k,w,K;return k=U,(w=[{key:"_startPlaybackHeartbeatInterval",value:function(){var W=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=L().setInterval(function(){W.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(L().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&$(k.prototype,w),K&&$(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}();function J(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function ee(U,k,w){return k&&J(U.prototype,k),w&&J(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var te=ee(function U(k){var w=this;(function(K,W){if(!(K instanceof W))throw new TypeError("Cannot call a class as a function")})(this,U),k.on("viewinit",function(){w.viewErrored=!1}),k.on("error",function(){try{var K=k.errorTranslator({player_error_code:k.data.player_error_code,player_error_message:k.data.player_error_message});K?(k.data.player_error_code=K.player_error_code,k.data.player_error_message=K.player_error_message,w.viewErrored=!0):(delete k.data.player_error_code,delete k.data.player_error_message)}catch(W){k.mux.log.warn("Exception in error translator callback.",W),w.viewErrored=!0}})});function se(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var ue=function(){function U(W){(function(z,Y){if(!(z instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W,this._watchTimeTrackerLastCheckedTime=null,W.on("playbackheartbeat",this._updateWatchTime.bind(this)),W.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var k,w,K;return k=U,(w=[{key:"_updateWatchTime",value:function(W,z){var Y=z.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=Y),n(this.pm.data,"view_watch_time",Y-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=Y}},{key:"_clearWatchTimeState",value:function(W,z){this._updateWatchTime(W,z),this._watchTimeTrackerLastCheckedTime=null}}])&&se(k.prototype,w),K&&se(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}();function ie(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var he=function(){function U(W){(function(z,Y){if(!(z instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W,this._playbackTimeTrackerLastPlayheadPosition=-1,W.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),W.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),W.on("seeking",this._clearPlaybackTimeState.bind(this))}var k,w,K;return k=U,(w=[{key:"_updatePlaybackTime",value:function(){var W=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&W>this._playbackTimeTrackerLastPlayheadPosition){var z=W-this._playbackTimeTrackerLastPlayheadPosition;z<=1e3&&n(this.pm.data,"view_content_playback_time",z)}this._playbackTimeTrackerLastPlayheadPosition=W}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&ie(k.prototype,w),K&&ie(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}();function me(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var ne=function(){function U(W){(function(Y,Z){if(!(Y instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W;var z=this._updatePlayheadTime.bind(this);W.on("playbackheartbeat",z),W.on("playbackheartbeatend",z),W.on("timeupdate",z),W.on("destroy",function(){W.off("timeupdate",z)})}var k,w,K;return k=U,(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(W,z){var Y=this,Z=function(){Y.pm.currentFragmentPDT&&Y.pm.currentFragmentStart&&(Y.pm.data.player_program_time=Y.pm.currentFragmentPDT+Y.pm.data.player_playhead_time-Y.pm.currentFragmentStart)};if(z&&z.player_playhead_time)this.pm.data.player_playhead_time=z.player_playhead_time,Z(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var q=this.pm.getPlayheadTime();q!==void 0&&(this.pm.data.player_playhead_time=q,Z(),this._updateMaxPlayheadPosition())}}}])&&me(k.prototype,w),K&&me(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}();function Re(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function Le(U,k,w){return k&&Re(U.prototype,k),w&&Re(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var De=Le(function U(k){if(function(W,z){if(!(W instanceof z))throw new TypeError("Cannot call a class as a function")}(this,U),!k.disableRebufferTracking){var w,K=function(){if(w){var W=k.data.viewer_time-w;n(k.data,"view_rebuffer_duration",W),w=k.data.viewer_time}k.data.view_watch_time>=0&&k.data.view_rebuffer_count>0&&(k.data.view_rebuffer_frequency=k.data.view_rebuffer_count/k.data.view_watch_time,k.data.view_rebuffer_percentage=k.data.view_rebuffer_duration/k.data.view_watch_time)};k.on("playbackheartbeat",function(){return K()}),k.on("rebufferstart",function(){w||(n(k.data,"view_rebuffer_count",1),w=k.data.viewer_time,k.one("rebufferend",function(){K(),w=void 0}))})}});function _e(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var ke=function(){function U(W){var z=this;(function(Y,Z){if(!(Y instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W,W.disableRebufferTracking||W.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,W.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),W.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),W.on("seeking",function(){z._cleanupRebufferTracker(null,{viewer_time:p.now()})}))}var k,w,K;return k=U,w=[{key:"_checkIfRebuffering",value:function(W,z){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(W,z);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var Y=z.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&Y>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=z.viewer_time}else this._cleanupRebufferTracker(W,z,!0);else this._prepareRebufferTrackerState(z.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(W){this._lastCheckedTime=W,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=W}},{key:"_cleanupRebufferTracker",value:function(W,z){var Y=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:z.viewer_time});else{if(this._lastCheckedTime===null)return;var Z=this.pm.data.player_playhead_time-this._lastPlayheadTime,q=z.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&Z>0&&q-Z>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+q-Z}))}Y?this._prepareRebufferTrackerState(z.viewer_time):this._clearRebufferTrackerState()}}],w&&_e(k.prototype,w),K&&_e(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}(),Qe=ke;function He(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var qe=function(){function U(W){var z=this;(function(Y,Z){if(!(Y instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W,W.on("viewinit",function(){var Y=W.data,Z=Y.view_id;if(!Y.view_program_changed){var q=function(Q,oe){var Ae=oe.viewer_time;Q.type==="playing"&&W.data.view_time_to_first_frame===void 0?z.calculateTimeToFirstFrame(Ae||p.now(),Z):Q.type!=="adplaying"||W.data.view_time_to_first_frame!==void 0&&!z._inPrerollPosition()||z.calculateTimeToFirstFrame(Ae||p.now(),Z)};W.one("playing",q),W.one("adplaying",q),W.one("viewend",function(){W.off("playing",q),W.off("adplaying",q)})}})}var k,w,K;return k=U,(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(W,z){z===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:W}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}])&&He(k.prototype,w),K&&He(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}();function Ke(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function st(U,k,w){return k&&Ke(U.prototype,k),w&&Ke(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var dt=st(function U(k){var w=this;(function(K,W){if(!(K instanceof W))throw new TypeError("Cannot call a class as a function")})(this,U),k.on("viewinit",function(){w._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(K){k.on(K,function(){if(w._lastPlayheadPosition>=0&&k.data.player_playhead_time>=0&&w._lastPlayerWidth>=0&&w._lastSourceWidth>0&&w._lastPlayerHeight>=0&&w._lastSourceHeight>0){var W=k.data.player_playhead_time-w._lastPlayheadPosition;if(W<0)return void(w._lastPlayheadPosition=-1);var z=Math.min(w._lastPlayerWidth/w._lastSourceWidth,w._lastPlayerHeight/w._lastSourceHeight),Y=Math.max(0,z-1),Z=Math.max(0,1-z);k.data.view_max_upscale_percentage=Math.max(k.data.view_max_upscale_percentage||0,Y),k.data.view_max_downscale_percentage=Math.max(k.data.view_max_downscale_percentage||0,Z),n(k.data,"view_total_content_playback_time",W),n(k.data,"view_total_upscaling",Y*W),n(k.data,"view_total_downscaling",Z*W)}w._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(K){k.on(K,function(){w._lastPlayheadPosition=k.data.player_playhead_time,w._lastPlayerWidth=k.data.player_width,w._lastPlayerHeight=k.data.player_height,w._lastSourceWidth=k.data.video_source_width,w._lastSourceHeight=k.data.video_source_height})})});function ct(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function ot(U,k,w){return k&&ct(U.prototype,k),w&&ct(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var Dt=ot(function U(k){var w=this;(function(K,W){if(!(K instanceof W))throw new TypeError("Cannot call a class as a function")})(this,U),this.isSeeking=!1,k.on("seeking",function(K,W){l()(k.data,W),w._lastSeekingTime=p.now(),w.isSeeking===!1&&(w.isSeeking=!0,k.send("seeking"))}),k.on("seeked",function(){w.isSeeking=!1;var K=w._lastSeekingTime||p.now(),W=p.now()-K;n(k.data,"view_seek_count",1),n(k.data,"view_seek_duration",W);var z=k.data.view_max_seek_time||0;k.data.view_max_seek_time=Math.max(z,W)}),k.on("viewend",function(){w.isSeeking=!1})});function et(U,k){return function(w){if(Array.isArray(w))return w}(U)||function(w,K){var W=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(W!=null){var z,Y,Z=[],q=!0,Q=!1;try{for(W=W.call(w);!(q=(z=W.next()).done)&&(Z.push(z.value),!K||Z.length!==K);q=!0);}catch(oe){Q=!0,Y=oe}finally{try{q||W.return==null||W.return()}finally{if(Q)throw Y}}return Z}}(U,k)||function(w,K){if(w){if(typeof w=="string")return It(w,K);var W=Object.prototype.toString.call(w).slice(8,-1);return W==="Object"&&w.constructor&&(W=w.constructor.name),W==="Map"||W==="Set"?Array.from(w):W==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(W)?It(w,K):void 0}}(U,k)||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 It(U,k){(k==null||k>U.length)&&(k=U.length);for(var w=0,K=new Array(k);w<k;w++)K[w]=U[w];return K}function $e(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var Ze=function(U,k){U.push(k),U.sort(function(w,K){return w.viewer_time-K.viewer_time})},Et=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Je=function(){function U(W){var z=this;(function(Z,q){if(!(Z instanceof q))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W,W.on("viewinit",function(){z.isAdBreak=!1,z._currentAdRequestNumber=0,z._currentAdResponseNumber=0,z._adRequests=[],z._adResponses=[],z._adHasPlayed=!1,z._wouldBeNewAdPlay=!0,z._prerollPlayTime=void 0}),Et.forEach(function(Z){return W.on(Z,z._updateAdData.bind(z))});var Y=function(){z.isAdBreak=!1};W.on("adbreakstart",function(){z.isAdBreak=!0}),W.on("play",Y),W.on("playing",Y),W.on("viewend",Y),W.on("adrequest",function(Z,q){q=l()({ad_request_id:"generatedAdRequestId"+z._currentAdRequestNumber++},q),Ze(z._adRequests,q),n(W.data,"view_ad_request_count"),z.inPrerollPosition()&&(W.data.view_preroll_requested=!0,z._adHasPlayed||n(W.data,"view_preroll_request_count"))}),W.on("adresponse",function(Z,q){q=l()({ad_request_id:"generatedAdRequestId"+z._currentAdResponseNumber++},q),Ze(z._adResponses,q);var Q=z.findAdRequest(q.ad_request_id);Q&&n(W.data,"view_ad_request_time",Math.max(0,q.viewer_time-Q.viewer_time))}),W.on("adplay",function(Z,q){z._adHasPlayed=!0,z._wouldBeNewAdPlay&&(z._wouldBeNewAdPlay=!1,n(W.data,"view_ad_played_count")),z.inPrerollPosition()&&!W.data.view_preroll_played&&(W.data.view_preroll_played=!0,z._adRequests.length>0&&(W.data.view_preroll_request_time=Math.max(0,q.viewer_time-z._adRequests[0].viewer_time)),W.data.view_start&&(W.data.view_startup_preroll_request_time=Math.max(0,q.viewer_time-W.data.view_start)),z._prerollPlayTime=q.viewer_time)}),W.on("adplaying",function(Z,q){z.inPrerollPosition()&&W.data.view_preroll_load_time===void 0&&z._prerollPlayTime!==void 0&&(W.data.view_preroll_load_time=q.viewer_time-z._prerollPlayTime,W.data.view_startup_preroll_load_time=q.viewer_time-z._prerollPlayTime)}),W.on("adended",function(){z._wouldBeNewAdPlay=!0}),W.on("aderror",function(){z._wouldBeNewAdPlay=!0})}var k,w,K;return k=U,(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(W){for(var z=0;z<this._adRequests.length;z++)if(this._adRequests[z].ad_request_id===W)return this._adRequests[z]}},{key:"_updateAdData",value:function(W,z){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&z.ad_tag_url){var Y=et(h(z.ad_tag_url),2),Z=Y[0],q=Y[1];this.pm.data.view_preroll_ad_tag_domain=q,this.pm.data.view_preroll_ad_tag_hostname=Z}if(!this.pm.data.view_preroll_ad_asset_hostname&&z.ad_asset_url){var Q=et(h(z.ad_asset_url),2),oe=Q[0],Ae=Q[1];this.pm.data.view_preroll_ad_asset_domain=Ae,this.pm.data.view_preroll_ad_asset_hostname=oe}}}}])&&$e(k.prototype,w),K&&$e(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}();function Ge(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function Pt(U,k,w){return k&&Ge(U.prototype,k),w&&Ge(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ft=Pt(function U(k){var w,K;(function(Z,q){if(!(Z instanceof q))throw new TypeError("Cannot call a class as a function")})(this,U);var W=function(){k.disableRebufferTracking||w&&(n(k.data,"view_waiting_rebuffer_duration",p.now()-w),w=!1,L().clearInterval(K))},z=!1,Y=function(){z=!1,W()};k.on("waiting",function(){z&&(k.disableRebufferTracking||(n(k.data,"view_waiting_rebuffer_count",1),w=p.now(),K=L().setInterval(function(){if(w){var Z=p.now();n(k.data,"view_waiting_rebuffer_duration",Z-w),w=Z}},250)))}),k.on("playing",function(){W(),z=!0}),k.on("pause",Y),k.on("seeking",Y)});function Wt(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function pr(U,k,w){return k&&Wt(U.prototype,k),w&&Wt(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var At=pr(function U(k){var w=this;(function(z,Y){if(!(z instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,U);var K=function(){w.lastWallClockTime=p.now(),k.on("before*",W)},W=function(z){var Y=p.now(),Z=w.lastWallClockTime;w.lastWallClockTime=Y,Y-Z>3e4&&(k.emit("devicesleep",{viewer_time:Z}),l()(k.data,{viewer_time:Z}),k.send("devicesleep"),k.emit("devicewake",{viewer_time:Y}),l()(k.data,{viewer_time:Y}),k.send("devicewake"))};k.one("playbackheartbeat",K),k.on("playbackheartbeatend",function(){k.off("before*",W),k.one("playbackheartbeat",K)})}),Br=C(375),Er=C(655),kt=C.n(Er),Ht="muxData",wt=function(){var U;try{U=Br.parse(kt().get(Ht)||"")}catch{U={}}return U},yr=function(U){try{kt().set(Ht,Br.stringify(U),{expires:7300})}catch{}},ur=function(){var U=wt();return U.mux_viewer_id=U.mux_viewer_id||b(),U.msn=U.msn||Math.random(),yr(U),{mux_viewer_id:U.mux_viewer_id,mux_sample_number:U.msn}};function na(U,k){var w=k.beaconCollectionDomain,K=k.beaconDomain;if(w)return"https://"+w;var W=K||"litix.io";return(U=U||"inferred").match(/^[a-z0-9]+$/)?"https://"+U+"."+W:"https://img.litix.io/a.gif"}var ci=function(){var U;switch(Fr()){case"cellular":U="cellular";break;case"ethernet":U="wired";break;case"wifi":U="wifi";break;case void 0:break;default:U="other"}return U},Fr=function(){var U=L().navigator,k=U&&(U.connection||U.mozConnection||U.webkitConnection);return k&&k.type};ci.getConnectionFromAPI=Fr;var _t=ci,Xi=Qi({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"}),fi=Qi({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function Qi(U){var k={};for(var w in U)U.hasOwnProperty(w)&&(k[U[w]]=w);return k}function hi(U){var k={},w={};return Object.keys(U).forEach(function(K){var W=!1;if(U.hasOwnProperty(K)&&U[K]!==void 0){var z=K.split("_"),Y=z[0],Z=Xi[Y];Z||(i.info("Data key word `"+z[0]+"` not expected in "+K),Z=Y+"_"),z.splice(1).forEach(function(q){q==="url"&&(W=!0),fi[q]?Z+=fi[q]:Number(q)&&Math.floor(Number(q))===Number(q)?Z+=q:(i.info("Data key word `"+q+"` not expected in "+K),Z+="_"+q+"_")}),W?w[Z]=U[K]:k[Z]=U[K]}}),l()(k,w)}var aa={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},sa=["hb","requestcompleted","requestfailed","requestcanceled"],Ut=function(U,k){this._beaconUrl=U||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=l()({},aa,k)};Ut.prototype.queueEvent=function(U,k){var w=l()({},k);return(this._eventQueue.length<=this._options.maxQueueLength||U==="eventrateexceeded")&&(this._eventQueue.push(w),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},Ut.prototype.flushEvents=function(){this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()},Ut.prototype.destroy=function(){var U=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,U?this._clearBeaconQueue():this.flushEvents(),L().clearTimeout(this._sendTimeout)},Ut.prototype._clearBeaconQueue=function(){var U=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,k=this._eventQueue.slice(U);U>0&&l()(k[k.length-1],hi({mux_view_message:"event queue truncated"}));var w=this._createPayload(k);Kr(this._beaconUrl,w,!0,function(){})},Ut.prototype._sendBeaconQueue=function(){var U=this;if(!this._postInFlight){var k=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var w=this._createPayload(k),K=p.now();Kr(this._beaconUrl,w,!1,function(W,z){z?(U._eventQueue=k.concat(U._eventQueue),U._failureCount+=1,i.info("Error sending beacon: "+z)):U._failureCount=0,U._roundTripTime=p.now()-K,U._postInFlight=!1})}},Ut.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var U=Math.pow(2,this._failureCount-1);return(1+(U*=Math.random()))*this._options.baseTimeBetweenBeacons},Ut.prototype._startBeaconSending=function(){var U=this;L().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=L().setTimeout(function(){U._eventQueue.length&&U._sendBeaconQueue(),U._startBeaconSending()},this._getNextBeaconTime()))},Ut.prototype._createPayload=function(U){var k,w,K,W=this,z={transmission_timestamp:Math.round(p.now())};this._roundTripTime&&(z.rtt_ms=Math.round(this._roundTripTime));var Y=function(){k=JSON.stringify({metadata:z,events:w||U}),K=k.length/1024},Z=function(){return K<=W._options.maxPayloadKBSize};return Y(),Z()||(i.info("Payload size is too big ("+K+" kb). Removing unnecessary events."),w=U.filter(function(q){return sa.indexOf(q.e)===-1}),Y()),Z()||(i.info("Payload size still too big ("+K+" kb). Cropping fields.."),w.forEach(function(q){for(var Q in q){var oe=q[Q];typeof oe=="string"&&oe.length>51200&&(q[Q]=oe.substring(0,51200))}}),Y()),k};var Kr=function(U,k,w,K){if(w&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(U,k))K();else if(L().fetch)L().fetch(U,{method:"POST",body:k,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(z){return K(null,z.ok?null:"Error")}).catch(function(z){return K(null,z)});else{if(L().XMLHttpRequest){var W=new(L()).XMLHttpRequest;return W.onreadystatechange=function(){if(W.readyState===4)return K(null,W.status!==200?"error":void 0)},W.open("POST",U),W.setRequestHeader("Content-Type","text/plain"),void W.send(k)}K()}},Zi=Ut;function Tr(U){return Tr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},Tr(U)}var oa=["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"],ed=["viewstart","error","ended","viewend"],Ji=function(U,k){var w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=U,this.envKey=k,this.eventQueue=new Zi(na(k,w)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=w.sampleRate,this.disableCookies=w.disableCookies,this.respectDoNotTrack=w.respectDoNotTrack;var K=w.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:K.name,viewer_application_version:K.version,viewer_application_engine:K.layout,viewer_device_name:K.product,viewer_device_category:"",viewer_device_manufacturer:K.manufacturer,viewer_os_family:K.os&&K.os.family,viewer_os_architecture:K.os&&K.os.architecture,viewer_os_version:K.os&&K.os.version};var W=_t();W&&(this.pageLevelData=l()(this.pageLevelData,{viewer_connection_type:W})),L()!==void 0&&L().location&&L().location.href&&(this.pageLevelData.page_url=L().location.href),this.viewerData=this.disableCookies?{}:ur()};Ji.prototype.send=function(U,k){if(U){if(this.respectDoNotTrack&&d())return i.info("Not sending `"+U+"` because Do Not Track is enabled");if(!k||Tr(k)!=="object")return i.error("A data object was expected in send() but was not provided");var w,K,W=this.disableCookies?{}:(w=wt(),K=p.now(),w.session_start&&(w.sst=w.session_start,delete w.session_start),w.session_id&&(w.sid=w.session_id,delete w.session_id),w.session_expires&&(w.sex=w.session_expires,delete w.session_expires),(!w.sex||w.sex<K)&&(w.sid=b(),w.sst=K),w.sex=K+15e5,yr(w),{session_id:w.sid,session_start:w.sst,session_expires:w.sex}),z={};l()(z,this.pageLevelData),l()(z,k),l()(z,W),l()(z,this.viewerData),z.event=U,z.env_key=this.envKey,z.user_id&&(z.viewer_user_id=z.user_id,delete z.user_id);var Y=z.mux_sample_number>=this.sampleRate,Z=hi(this._deduplicateBeaconData(U,z));if(this.lastEventTime=this.mux.utils.now(),Y)return i.info("Not sending event due to sample rate restriction",U,z,Z);if(this.envKey||i.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",U,z,Z),!this.rateLimited){if(i.info("Sending event",U,z,Z),this.rateLimited=!this.eventQueue.queueEvent(U,Z),this.mux.WINDOW_UNLOADING&&U==="viewend")this.eventQueue.destroy(!0);else if((ed.indexOf(U)>=0||this.mux.WINDOW_HIDDEN&&U==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return z.event="eventrateexceeded",Z=hi(z),this.eventQueue.queueEvent(z.event,Z),i.error("Beaconing disabled due to rate limit.")}}},Ji.prototype.destroy=function(){this.eventQueue.destroy(!1)},Ji.prototype._deduplicateBeaconData=function(U,k){var w=this,K={},W=k.view_id;if(!W||U==="viewstart"||U==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)K=l()({},k),W&&(this.previousBeaconData=K),W&&U==="viewend"&&(this.previousBeaconData=null);else{var z=U.indexOf("request")===0;Object.keys(k).forEach(function(Y){var Z=k[Y];(Z!==w.previousBeaconData[Y]||oa.indexOf(Y)>-1||function(q,Q,oe,Ae){return!(!q||Q.indexOf("request_")!==0||Q!=="request_response_headers"&&Tr(oe)==="object"&&Tr(Ae)==="object"&&Object.keys(oe||{}).length===Object.keys(Ae||{}).length)}(z,Y,Z,w.previousBeaconData[Y])||function(q,Q){return q==="renditionchange"&&Q.indexOf("video_source_")===0}(U,Y))&&(K[Y]=Z,w.previousBeaconData[Y]=Z)})}return K};var td=Ji;function Ws(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function rd(U,k,w){return k&&Ws(U.prototype,k),w&&Ws(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var id=rd(function U(k){(function(Q,oe){if(!(Q instanceof oe))throw new TypeError("Cannot call a class as a function")})(this,U);var w=0,K=0,W=0,z=0,Y=0,Z=0,q=0;k.on("requestcompleted",function(Q,oe){var Ae,Pe,Ie=oe.request_start,ve=oe.request_response_start,Ee=oe.request_response_end,we=oe.request_bytes_loaded;if(z++,ve?(Ae=ve-Ie,Pe=Ee-ve):Pe=Ee-Ie,Pe>0&&we>0){var yt=we/Pe*8e3;Y++,K+=we,W+=Pe,k.data.view_min_request_throughput=Math.min(k.data.view_min_request_throughput||1/0,yt),k.data.view_average_request_throughput=K/W*8e3,k.data.view_request_count=z,Ae>0&&(w+=Ae,k.data.view_max_request_latency=Math.max(k.data.view_max_request_latency||0,Ae),k.data.view_average_request_latency=w/Y)}}),k.on("requestfailed",function(Q,oe){z++,Z++,k.data.view_request_count=z,k.data.view_request_failed_count=Z}),k.on("requestcanceled",function(Q,oe){z++,q++,k.data.view_request_count=z,k.data.view_request_canceled_count=q})});function Hs(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function nd(U,k,w){return k&&Hs(U.prototype,k),w&&Hs(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ad=nd(function U(k){var w=this;(function(K,W){if(!(K instanceof W))throw new TypeError("Cannot call a class as a function")})(this,U),k.on("before*",function(K,W){var z=W.viewer_time,Y=p.now(),Z=w._lastEventTime;if(w._lastEventTime=Y,Z&&Y-Z>36e5){var q=Object.keys(k.data).reduce(function(Q,oe){return oe.indexOf("video_")===0?l()(Q,function(Ae,Pe,Ie){return Pe in Ae?Object.defineProperty(Ae,Pe,{value:Ie,enumerable:!0,configurable:!0,writable:!0}):Ae[Pe]=Ie,Ae}({},oe,k.data[oe])):Q},{});k.mux.log.info("Received event after at least an hour inactivity, creating a new view"),k.emit("viewinit",l()({viewer_time:z},q)),k.playbackHeartbeat._playheadShouldBeProgressing&&K.type!=="play"&&K.type!=="adbreakstart"&&(k.emit("play",{viewer_time:z}),K.type!=="playing"&&k.emit("playing",{viewer_time:z}))}})});function la(U){return la=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},la(U)}function sd(U,k){return function(w){if(Array.isArray(w))return w}(U)||function(w,K){var W=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(W!=null){var z,Y,Z=[],q=!0,Q=!1;try{for(W=W.call(w);!(q=(z=W.next()).done)&&(Z.push(z.value),!K||Z.length!==K);q=!0);}catch(oe){Q=!0,Y=oe}finally{try{q||W.return==null||W.return()}finally{if(Q)throw Y}}return Z}}(U,k)||function(w,K){if(w){if(typeof w=="string")return Gs(w,K);var W=Object.prototype.toString.call(w).slice(8,-1);return W==="Object"&&w.constructor&&(W=w.constructor.name),W==="Map"||W==="Set"?Array.from(w):W==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(W)?Gs(w,K):void 0}}(U,k)||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 Gs(U,k){(k==null||k>U.length)&&(k=U.length);for(var w=0,K=new Array(k);w<k;w++)K[w]=U[w];return K}function js(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function ua(U,k){return ua=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(w,K){return w.__proto__=K,w},ua(U,k)}function od(U){var k=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,K=qi(U);if(k){var W=qi(this).constructor;w=Reflect.construct(K,arguments,W)}else w=K.apply(this,arguments);return ld(this,w)}}function ld(U,k){if(k&&(la(k)==="object"||typeof k=="function"))return k;if(k!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return rt(U)}function rt(U){if(U===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return U}function qi(U){return qi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(k){return k.__proto__||Object.getPrototypeOf(k)},qi(U)}var ud=["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"],dd=function(U){(function(Y,Z){if(typeof Z!="function"&&Z!==null)throw new TypeError("Super expression must either be null or a function");Y.prototype=Object.create(Z&&Z.prototype,{constructor:{value:Y,writable:!0,configurable:!0}}),Object.defineProperty(Y,"prototype",{writable:!1}),Z&&ua(Y,Z)})(z,U);var k,w,K,W=od(z);function z(Y,Z,q){var Q;(function(ve,Ee){if(!(ve instanceof Ee))throw new TypeError("Cannot call a class as a function")})(this,z),(Q=W.call(this)).DOM_CONTENT_LOADED_EVENT_END=E.domContentLoadedEventEnd(),Q.NAVIGATION_START=E.navigationStart(),Q.mux=Y,Q.id=Z,(q=l()({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}},q)).data=q.data||{},q.data.property_key&&(q.data.env_key=q.data.property_key,delete q.data.property_key),i.setLevel(q.debug?"debug":"warn"),Q.getPlayheadTime=q.getPlayheadTime,Q.getStateData=q.getStateData||function(){return{}},Q.getAdData=q.getAdData||function(){},Q.minimumRebufferDuration=q.minimumRebufferDuration,Q.sustainedRebufferThreshold=q.sustainedRebufferThreshold,Q.playbackHeartbeatTime=q.playbackHeartbeatTime,Q.disableRebufferTracking=q.disableRebufferTracking,Q.disableRebufferTracking&&Q.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),Q.disablePlayheadRebufferTracking=q.disablePlayheadRebufferTracking,Q.errorTranslator=q.errorTranslator,Q.playbackEventDispatcher=new td(Y,q.data.env_key,q),Q.data={player_instance_id:b(),mux_sample_rate:q.sampleRate,beacon_domain:q.beaconCollectionDomain?q.beaconCollectionDomain:q.beaconDomain},Q.data.view_sequence_number=1,Q.data.player_sequence_number=1,Q.oldEmit=Q.emit,Q.emit=function(ve,Ee){Ee=l()({viewer_time:this.mux.utils.now()},Ee),this.oldEmit(ve,Ee)};var oe=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(rt(Q));Q.on("viewinit",function(ve,Ee){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),l()(this.data,Ee),this._initializeViewData(),this.one("play",oe),this.one("adbreakstart",oe)});var Ae=function(ve){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",ve)}.bind(rt(Q));if(Q.on("videochange",function(ve,Ee){Ae(Ee)}),Q.on("programchange",function(ve,Ee){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."),Ae(l()(Ee,{view_program_changed:!0})),oe(),this.emit("play"),this.emit("playing")}),Q.on("fragmentchange",function(ve,Ee){this.currentFragmentPDT=Ee.currentFragmentPDT,this.currentFragmentStart=Ee.currentFragmentStart}),Q.on("destroy",Q.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var Pe=function(){var ve=Q.data.view_start!==void 0;Q.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",ve&&Q.mux.WINDOW_HIDDEN&&(Q.data.player_is_paused||Q.emit("hb"))};window.addEventListener("visibilitychange",Pe,!1);var Ie=function(ve){ve.persisted||Q.destroy()};window.addEventListener("pagehide",Ie,!1),Q.on("destroy",function(){window.removeEventListener("visibilitychange",Pe),window.removeEventListener("pagehide",Ie)})}return Q.on("playerready",function(ve,Ee){l()(this.data,Ee)}),ud.forEach(function(ve){Q.on(ve,function(Ee,we){ve.indexOf("ad")!==0&&this._updateStateData(),l()(this.data,we),this._sanitizeData()}),Q.on("after"+ve,function(){(ve!=="error"||this.errorTracker.viewErrored)&&this.send(ve)})}),Q.on("viewend",function(ve,Ee){l()(Q.data,Ee)}),Q.one("playerready",function(ve){var Ee=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=Ee-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),Q.longResumeTracker=new ad(rt(Q)),Q.errorTracker=new te(rt(Q)),new At(rt(Q)),Q.seekingTracker=new Dt(rt(Q)),Q.playheadTime=new ne(rt(Q)),Q.playbackHeartbeat=new j(rt(Q)),new dt(rt(Q)),Q.watchTimeTracker=new ue(rt(Q)),new he(rt(Q)),Q.adTracker=new Je(rt(Q)),new Qe(rt(Q)),new De(rt(Q)),new qe(rt(Q)),new ft(rt(Q)),new id(rt(Q)),q.hlsjs&&Q.addHLSJS(q),q.dashjs&&Q.addDashJS(q),Q.emit("viewinit",q.data),Q}return k=z,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(Y){var Z=l()({},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(Ae){Z[Ae]=void 0}),Z.video_source_url=Z.video_source_url||Z.player_source_url,Z.video_source_url){var q=sd(h(Z.video_source_url),2),Q=q[0],oe=q[1];Z.video_source_domain=oe,Z.video_source_hostname=Q}delete Z.ad_request_id,this.playbackEventDispatcher.send(Y,Z),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){l()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var Y=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(Z){var q=parseInt(Y.data[Z],10);Y.data[Z]=isNaN(q)?void 0:q}),["player_source_url","video_source_url"].forEach(function(Z){if(Y.data[Z]){var q=Y.data[Z].toLowerCase();q.indexOf("data:")!==0&&q.indexOf("blob:")!==0||(Y.data[Z]="MSE style URL")}})}},{key:"_resetVideoData",value:function(Y,Z){var q=this;Object.keys(this.data).forEach(function(Q){Q.indexOf("video_")===0&&delete q.data[Q]})}},{key:"_resetViewData",value:function(){var Y=this;Object.keys(this.data).forEach(function(Z){Z.indexOf("view_")===0&&delete Y.data[Z]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(Y,Z){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var Y=this,Z=this.data.view_id=b(),q=function(){Z===Y.data.view_id&&n(Y.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",q):q()}},{key:"_restartHeartBeat",value:function(){var Y=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){Y.data.player_is_paused||Y.emit("hb")},1e4))}},{key:"addHLSJS",value:function(Y){Y.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=Y.hlsjs,function(Z,q,Q){var oe=arguments.length>4?arguments[4]:void 0,Ae=Z.log,Pe=Z.utils.secondsToMs,Ie=function(Oe){var ge,Se=parseInt(oe.version);return Se===1&&Oe.programDateTime!==null&&(ge=Oe.programDateTime),Se===0&&Oe.pdt!==null&&(ge=Oe.pdt),ge};if(E.exists()){var ve=function(Oe,ge){return Z.emit(q,Oe,ge)},Ee=function(Oe,ge){var Se=ge.levels,ye=ge.audioTracks,Me=ge.url,Ye=ge.stats,We=ge.networkDetails,Rt=ge.sessionData,Lt={},Gt={};Se.forEach(function($t,gi){Lt[gi]={width:$t.width,height:$t.height,bitrate:$t.bitrate,attrs:$t.attrs}}),ye.forEach(function($t,gi){Gt[gi]={name:$t.name,language:$t.lang,bitrate:$t.bitrate}});var jt=D(Ye),Vt=jt.bytesLoaded,vt=jt.requestStart,ha=jt.responseStart,va=jt.responseEnd;ve("requestcompleted",y(y({},f(Rt)),{},{request_event_type:Oe,request_bytes_loaded:Vt,request_start:vt,request_response_start:ha,request_response_end:va,request_type:"manifest",request_hostname:o(Me),request_response_headers:P(We),request_rendition_lists:{media:Lt,audio:Gt,video:{}}}))};Q.on(oe.Events.MANIFEST_LOADED,Ee);var we=function(Oe,ge){var Se=ge.details,ye=ge.level,Me=ge.networkDetails,Ye=ge.stats,We=D(Ye),Rt=We.bytesLoaded,Lt=We.requestStart,Gt=We.responseStart,jt=We.responseEnd,Vt=Se.fragments[Se.fragments.length-1],vt=Ie(Vt)+Pe(Vt.duration);ve("requestcompleted",{request_event_type:Oe,request_bytes_loaded:Rt,request_start:Lt,request_response_start:Gt,request_response_end:jt,request_current_level:ye,request_type:"manifest",request_hostname:o(Se.url),request_response_headers:P(Me),video_holdback:Se.holdBack&&Pe(Se.holdBack),video_part_holdback:Se.partHoldBack&&Pe(Se.partHoldBack),video_part_target_duration:Se.partTarget&&Pe(Se.partTarget),video_target_duration:Se.targetduration&&Pe(Se.targetduration),video_source_is_live:Se.live,player_manifest_newest_program_time:isNaN(vt)?void 0:vt})};Q.on(oe.Events.LEVEL_LOADED,we);var yt=function(Oe,ge){var Se=ge.details,ye=ge.networkDetails,Me=ge.stats,Ye=D(Me),We=Ye.bytesLoaded,Rt=Ye.requestStart,Lt=Ye.responseStart,Gt=Ye.responseEnd;ve("requestcompleted",{request_event_type:Oe,request_bytes_loaded:We,request_start:Rt,request_response_start:Lt,request_response_end:Gt,request_type:"manifest",request_hostname:o(Se.url),request_response_headers:P(ye)})};Q.on(oe.Events.AUDIO_TRACK_LOADED,yt);var St=function(Oe,ge){var Se=ge.stats,ye=ge.networkDetails,Me=ge.frag;Se=Se||Me.stats;var Ye=D(Se),We={request_event_type:Oe,request_bytes_loaded:Ye.bytesLoaded,request_start:Ye.requestStart,request_response_start:Ye.responseStart,request_response_end:Ye.responseEnd,request_hostname:ye?o(ye.responseURL):void 0,request_response_headers:P(ye),request_media_duration:Me.duration};Me.type==="main"?(We.request_type="media",We.request_current_level=Me.level,We.request_video_width=(Q.levels[Me.level]||{}).width,We.request_video_height=(Q.levels[Me.level]||{}).height):We.request_type=Me.type,ve("requestcompleted",We)};Q.on(oe.Events.FRAG_LOADED,St);var br=function(Oe,ge){var Se=ge.frag,ye=Se.start,Me={currentFragmentPDT:Ie(Se),currentFragmentStart:Pe(ye)};ve("fragmentchange",Me)};Q.on(oe.Events.FRAG_CHANGED,br);var Ue=function(Oe,ge){var Se=ge.type,ye=ge.details,Me=ge.response,Ye=ge.fatal,We=ge.context,Rt=ge.frag;if(ye===oe.ErrorDetails.MANIFEST_LOAD_ERROR||ye===oe.ErrorDetails.MANIFEST_LOAD_TIMEOUT||ye===oe.ErrorDetails.FRAG_LOAD_ERROR||ye===oe.ErrorDetails.FRAG_LOAD_TIMEOUT||ye===oe.ErrorDetails.LEVEL_LOAD_ERROR||ye===oe.ErrorDetails.LEVEL_LOAD_TIMEOUT){var Lt=Rt&&Rt.url||We&&We.url||"";ve("requestfailed",{request_error:ye,request_url:Lt,request_hostname:o(Lt),request_type:ye===oe.ErrorDetails.FRAG_LOAD_ERROR||ye===oe.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:Me&&Me.code,request_error_text:Me&&Me.text})}Ye&&ve("error",{player_error_code:Se,player_error_message:ye})};Q.on(oe.Events.ERROR,Ue);var xt=function(Oe,ge){var Se=ge.frag,ye=Se&&Se._url||"";ve("requestcanceled",{request_event_type:Oe,request_url:ye,request_type:"media",request_hostname:o(ye)})};Q.on(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,xt);var ht=function(Oe,ge){var Se=ge.level,ye=Q.levels[Se];if(ye&&ye.attrs&&ye.attrs.BANDWIDTH){var Me,Ye=ye.attrs.BANDWIDTH,We=parseFloat(ye.attrs["FRAME-RATE"]);isNaN(We)||(Me=We),Ye?ve("renditionchange",{video_source_fps:Me,video_source_bitrate:Ye,video_source_width:ye.width,video_source_height:ye.height}):Ae.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};Q.on(oe.Events.LEVEL_SWITCHED,ht),Q._stopMuxMonitor=function(){Q.off(oe.Events.MANIFEST_LOADED,Ee),Q.off(oe.Events.LEVEL_LOADED,we),Q.off(oe.Events.AUDIO_TRACK_LOADED,yt),Q.off(oe.Events.FRAG_LOADED,St),Q.off(oe.Events.FRAG_CHANGED,br),Q.off(oe.Events.ERROR,Ue),Q.off(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,xt),Q.off(oe.Events.LEVEL_SWITCHED,ht),Q.off(oe.Events.DESTROYING,Q._stopMuxMonitor),delete Q._stopMuxMonitor},Q.on(oe.Events.DESTROYING,Q._stopMuxMonitor)}else Ae.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,Y.hlsjs,{},Y.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var Y;this.hlsjs&&((Y=this.hlsjs)&&typeof Y._stopMuxMonitor=="function"&&Y._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(Y){Y.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=Y.dashjs,function(Z,q,Q){var oe=Z.log;if(Q&&Q.on){var Ae=function(Ue,xt){return Z.emit(q,Ue,xt)},Pe=function(Ue){var xt=Ue.type,ht=(Ue.data||{}).url;Ae("requestcompleted",{request_event_type:xt,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:o(ht)})};Q.on("manifestLoaded",Pe);var Ie={},ve=function(Ue){var xt=Ue.type,ht=Ue.fragmentModel,Oe=(Ue.chunk||{}).mediaInfo||{},ge=Oe.type,Se=Oe.bitrateList,ye={};(Se=Se||[]).forEach(function(Vt,vt){ye[vt]={},ye[vt].width=Vt.width,ye[vt].height=Vt.height,ye[vt].bitrate=Vt.bandwidth,ye[vt].attrs={}}),ge==="video"?Ie.video=ye:ge==="audio"?Ie.audio=ye:Ie.media=ye;var Me=B(ht,Q),Ye=Me.requestStart,We=Me.requestResponseStart,Rt=Me.requestResponseEnd,Lt=Me.requestResponseHeaders,Gt=Me.requestMediaDuration,jt=Me.requestHostname;Ae("requestcompleted",{request_event_type:xt,request_start:Ye,request_response_start:We,request_response_end:Rt,request_bytes_loaded:-1,request_type:ge+"_init",request_response_headers:Lt,request_hostname:jt,request_media_duration:Gt,request_rendition_lists:Ie})};Q.on("initFragmentLoaded",ve);var Ee=function(Ue){var xt=Ue.type,ht=Ue.fragmentModel,Oe=Ue.chunk||{},ge=Oe.mediaInfo,Se=Oe.start,ye=(ge||{}).type,Me=B(ht,Q),Ye=Me.requestStart,We=Me.requestResponseStart,Rt=Me.requestResponseEnd,Lt=Me.requestBytesLoaded,Gt=Me.requestResponseHeaders,jt=Me.requestMediaDuration,Vt=Me.requestHostname,vt=N(ye,Q),ha=vt.currentLevel,va=vt.renditionWidth,$t=vt.renditionHeight,gi=vt.renditionBitrate;Ae("requestcompleted",{request_event_type:xt,request_start:Ye,request_response_start:We,request_response_end:Rt,request_bytes_loaded:Lt,request_type:ye,request_response_headers:Gt,request_hostname:Vt,request_media_start_time:Se,request_media_duration:jt,request_current_level:ha,request_labeled_bitrate:gi,request_video_width:va,request_video_height:$t})};Q.on("mediaFragmentLoaded",Ee);var we={video:void 0,audio:void 0,totalBitrate:void 0},yt=function(){if(we.video&&typeof we.video.bitrate=="number"){if(we.video.width&&we.video.height){var Ue=we.video.bitrate;return we.audio&&typeof we.audio.bitrate=="number"&&(Ue+=we.audio.bitrate),Ue!==we.totalBitrate?(we.totalBitrate=Ue,{video_source_bitrate:Ue,video_source_height:we.video.height,video_source_width:we.video.width}):void 0}oe.warn("have bitrate info for video but missing width/height")}},St=function(Ue,xt,ht){if(typeof Ue.newQuality=="number"){var Oe=Ue.mediaType;if(Oe==="audio"||Oe==="video"){var ge=Q.getBitrateInfoListFor(Oe).find(function(ye){return ye.qualityIndex===Ue.newQuality});if(ge&&typeof ge.bitrate=="number"){we[Oe]=ge;var Se=yt();Se&&Ae("renditionchange",Se)}else oe.warn("missing bitrate info for ".concat(Oe))}}else oe.warn("missing evt.newQuality in qualityChangeRendered event",Ue)};Q.on("qualityChangeRendered",St);var br=function(Ue){var xt=Ue.error,ht=Ue.event,Oe=(ht=ht||{}).request||{},ge=L().event&&L().event.currentTarget||{};Ae("requestfailed",{request_error:xt+"_"+ht.id+"_"+Oe.type,request_url:ht.url,request_hostname:o(ht.url),request_type:Oe.mediaType,request_error_code:ge.status,request_error_type:ge.statusText})};Q.on("error",br),Q._stopMuxMonitor=function(){Q.off("manifestLoaded",Pe),Q.off("initFragmentLoaded",ve),Q.off("mediaFragmentLoaded",Ee),Q.off("qualityChangeRendered",St),Q.off("error",br),delete Q._stopMuxMonitor}}else oe.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,Y.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var Y;this.dashjs&&((Y=this.dashjs)&&typeof Y._stopMuxMonitor=="function"&&Y._stopMuxMonitor(),this.dashjs=void 0)}}],w&&js(k.prototype,w),K&&js(k,K),Object.defineProperty(k,"prototype",{writable:!1}),z}(X),cd=dd,fd=C(153),vi=C.n(fd);function da(U){return da=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},da(U)}function Vs(U,k){return function(w){if(Array.isArray(w))return w}(U)||function(w,K){var W=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(W!=null){var z,Y,Z=[],q=!0,Q=!1;try{for(W=W.call(w);!(q=(z=W.next()).done)&&(Z.push(z.value),!K||Z.length!==K);q=!0);}catch(oe){Q=!0,Y=oe}finally{try{q||W.return==null||W.return()}finally{if(Q)throw Y}}return Z}}(U,k)||function(w,K){if(w){if(typeof w=="string")return $s(w,K);var W=Object.prototype.toString.call(w).slice(8,-1);return W==="Object"&&w.constructor&&(W=w.constructor.name),W==="Map"||W==="Set"?Array.from(w):W==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(W)?$s(w,K):void 0}}(U,k)||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 $s(U,k){(k==null||k>U.length)&&(k=U.length);for(var w=0,K=new Array(k);w<k;w++)K[w]=U[w];return K}var Wr,hd=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],vd={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};L()&&L().WeakMap&&(Wr=new WeakMap);var md="#EXT-X-TARGETDURATION",gd="#EXT-X-PART-INF",pd="#EXT-X-SERVER-CONTROL",Ed="#EXTINF",yd="#EXT-X-PROGRAM-DATE-TIME",Td="#EXT-X-VERSION",bd="#EXT-X-SESSION-DATA",en=function(U){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(U),this.manifest};en.prototype.process=function(U){var k;for(this.buffer+=U,k=this.buffer.indexOf(`
1
+ var Hd=Object.create;var no=Object.defineProperty;var Gd=Object.getOwnPropertyDescriptor;var jd=Object.getOwnPropertyNames;var Vd=Object.getPrototypeOf,$d=Object.prototype.hasOwnProperty;var ao=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var Yd=(r,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of jd(t))!$d.call(r,s)&&s!==e&&no(r,s,{get:()=>t[s],enumerable:!(a=Gd(t,s))||a.enumerable});return r};var sn=(r,t,e)=>(e=r!=null?Hd(Vd(r)):{},Yd(t||!r||!r.__esModule?no(e,"default",{value:r,enumerable:!0}):e,r));var _a=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)};var xe=(r,t,e)=>(_a(r,t,"read from private field"),e?e.call(r):t.get(r)),Be=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},gt=(r,t,e,a)=>(_a(r,t,"write to private field"),a?a.call(r,e):t.set(r,e),e);var Fe=(r,t,e)=>(_a(r,t,"access private method"),e);var gl=ao((In,Ts)=>{(function(){var r,t;r=this,t=function(){return function(){var e={80:function(u,R,C){u.exports=C(728).default},728:function(u,R,C){"use strict";C.d(R,{default:function(){return Wd}});var O=C(48),L=C.n(O),b=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){var k=16*Math.random()|0;return(U==="x"?k:3&k|8).toString(16)})},x=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},I=function(U){return U&&U.nodeName!==void 0?(U.muxId||(U.muxId=U.id||x()),U.muxId):U},_=function(U){var k;U&&U.nodeName!==void 0?U=I(k=U):k=document.querySelector(U);var w=k&&k.nodeName?k.nodeName.toLowerCase():"";return[k,U,w]},A=C(640),S=C.n(A),m=S().methodFactory;S().methodFactory=function(U,k,w){var K=m(U,k,w);return function(){for(var W=["[mux]"],z=0;z<arguments.length;z++)W.push(arguments[z]);K.apply(void 0,W)}},S().setLevel(S().getLevel());var i=S();function d(){return(L().doNotTrack||L().navigator&&L().navigator.doNotTrack)==="1"}var p={now:function(){var U=L().performance,k=U&&U.timing,w=U&&U.timeOrigin||k&&k.navigationStart;return typeof w=="number"&&typeof U.now=="function"?w+U.now():Date.now()}},T=C(678),l=C.n(T),o=function(U){return h(U)[0]},h=function(U){if(typeof U!="string"||U==="")return["localhost"];var k,w=(U.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return w&&(k=(w.match(/[^\.]+\.[^\.]+$/)||[])[0]),[w,k]},E={exists:function(){var U=L().performance;return(U&&U.timing)!==void 0},domContentLoadedEventEnd:function(){var U=L().performance,k=U&&U.timing;return k&&k.domContentLoadedEventEnd},navigationStart:function(){var U=L().performance,k=U&&U.timing;return k&&k.navigationStart}};function n(U,k,w){w=w===void 0?1:w,U[k]=U[k]||0,U[k]+=w}var c=["x-cdn","content-type","x-request-id"];function v(U){var k={};return(U=U||"").trim().split(/[\r\n]+/).forEach(function(w){if(w){var K=w.split(": "),W=K.shift();W&&(c.indexOf(W.toLowerCase())>=0||W.toLowerCase().indexOf("x-litix-")===0)&&(k[W]=K.join(": "))}}),k}var f=function(U){var k={};for(var w in U){var K=U[w];K["DATA-ID"].search("io.litix.data.")!==-1&&(k[K["DATA-ID"].replace("io.litix.data.","")]=K.VALUE)}return k};function g(U,k){var w=Object.keys(U);if(Object.getOwnPropertySymbols){var K=Object.getOwnPropertySymbols(U);k&&(K=K.filter(function(W){return Object.getOwnPropertyDescriptor(U,W).enumerable})),w.push.apply(w,K)}return w}function y(U){for(var k=1;k<arguments.length;k++){var w=arguments[k]!=null?arguments[k]:{};k%2?g(Object(w),!0).forEach(function(K){M(U,K,w[K])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(w)):g(Object(w)).forEach(function(K){Object.defineProperty(U,K,Object.getOwnPropertyDescriptor(w,K))})}return U}function M(U,k,w){return k in U?Object.defineProperty(U,k,{value:w,enumerable:!0,configurable:!0,writable:!0}):U[k]=w,U}var D=function(U){if(!U)return{};var k=E.navigationStart(),w=U.loading,K=w?w.start:U.trequest,W=w?w.first:U.tfirst,z=w?w.end:U.tload;return{bytesLoaded:U.total,requestStart:Math.round(k+K),responseStart:Math.round(k+W),responseEnd:Math.round(k+z)}},P=function(U){if(U&&typeof U.getAllResponseHeaders=="function")return v(U.getAllResponseHeaders())},B=function(U,k){if(!U||typeof U.getRequests!="function")return{};var w=U.getRequests({state:"executed"});if(w.length===0)return{};var K,W=w[w.length-1],z=o(W.url),Y=W.bytesLoaded,Z=new Date(W.requestStartDate).getTime(),q=new Date(W.firstByteDate).getTime(),Q=new Date(W.requestEndDate).getTime(),oe=isNaN(W.duration)?0:W.duration,Ae=typeof k.getMetricsFor=="function"?k.getMetricsFor(W.mediaType).HttpList:k.getDashMetrics().getHttpRequests(W.mediaType);return Ae.length>0&&(K=v(Ae[Ae.length-1]._responseHeaders||"")),{requestStart:Z,requestResponseStart:q,requestResponseEnd:Q,requestBytesLoaded:Y,requestResponseHeaders:K,requestMediaDuration:oe,requestHostname:z}},N=function(U,k){var w=k.getQualityFor(U),K=k.getCurrentTrackFor(U).bitrateList;return K?{currentLevel:w,renditionWidth:K[w].width||null,renditionHeight:K[w].height||null,renditionBitrate:K[w].bandwidth}:{}};function F(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var H=0,V=function(){function U(){(function(W,z){if(!(W instanceof z))throw new TypeError("Cannot call a class as a function")})(this,U)}var k,w,K;return k=U,w=[{key:"on",value:function(W,z,Y){return z._eventEmitterGuid=z._eventEmitterGuid||++H,this._listeners=this._listeners||{},this._listeners[W]=this._listeners[W]||[],Y&&(z=z.bind(Y)),this._listeners[W].push(z),z}},{key:"off",value:function(W,z){var Y=this._listeners&&this._listeners[W];Y&&Y.forEach(function(Z,q){Z._eventEmitterGuid===z._eventEmitterGuid&&Y.splice(q,1)})}},{key:"one",value:function(W,z,Y){var Z=this;z._eventEmitterGuid=z._eventEmitterGuid||++H;var q=function Q(){Z.off(W,Q),z.apply(Y||this,arguments)};q._eventEmitterGuid=z._eventEmitterGuid,this.on(W,q)}},{key:"emit",value:function(W,z){var Y=this;if(this._listeners){z=z||{};var Z=this._listeners["before*"]||[],q=this._listeners[W]||[],Q=this._listeners["after"+W]||[],oe=function(Ae,ke){(Ae=Ae.slice()).forEach(function(Ie){Ie.call(Y,{type:W},ke)})};oe(Z,z),oe(q,z),oe(Q,z)}}}],w&&F(k.prototype,w),K&&F(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}(),X=V;function $(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var j=function(){function U(W){var z=this;(function(Y,Z){if(!(Y instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,W.on("playing",function(){z._playheadShouldBeProgressing=!0}),W.on("play",this._startPlaybackHeartbeatInterval.bind(this)),W.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),W.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),W.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),W.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),W.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),W.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),W.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),W.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),W.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),W.on("seeked",function(){W.data.player_is_paused?z._stopPlaybackHeartbeatInterval():z._startPlaybackHeartbeatInterval()}),W.on("timeupdate",function(){z._playbackHeartbeatInterval!==null&&W.emit("playbackheartbeat")}),W.on("devicesleep",function(Y,Z){z._playbackHeartbeatInterval!==null&&(L().clearInterval(z._playbackHeartbeatInterval),W.emit("playbackheartbeatend",{viewer_time:Z.viewer_time}),z._playbackHeartbeatInterval=null)})}var k,w,K;return k=U,(w=[{key:"_startPlaybackHeartbeatInterval",value:function(){var W=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=L().setInterval(function(){W.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(L().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&$(k.prototype,w),K&&$(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}();function J(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function ee(U,k,w){return k&&J(U.prototype,k),w&&J(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var te=ee(function U(k){var w=this;(function(K,W){if(!(K instanceof W))throw new TypeError("Cannot call a class as a function")})(this,U),k.on("viewinit",function(){w.viewErrored=!1}),k.on("error",function(){try{var K=k.errorTranslator({player_error_code:k.data.player_error_code,player_error_message:k.data.player_error_message});K?(k.data.player_error_code=K.player_error_code,k.data.player_error_message=K.player_error_message,w.viewErrored=!0):(delete k.data.player_error_code,delete k.data.player_error_message)}catch(W){k.mux.log.warn("Exception in error translator callback.",W),w.viewErrored=!0}})});function le(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var ue=function(){function U(W){(function(z,Y){if(!(z instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W,this._watchTimeTrackerLastCheckedTime=null,W.on("playbackheartbeat",this._updateWatchTime.bind(this)),W.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var k,w,K;return k=U,(w=[{key:"_updateWatchTime",value:function(W,z){var Y=z.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=Y),n(this.pm.data,"view_watch_time",Y-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=Y}},{key:"_clearWatchTimeState",value:function(W,z){this._updateWatchTime(W,z),this._watchTimeTrackerLastCheckedTime=null}}])&&le(k.prototype,w),K&&le(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}();function ie(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var he=function(){function U(W){(function(z,Y){if(!(z instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W,this._playbackTimeTrackerLastPlayheadPosition=-1,W.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),W.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),W.on("seeking",this._clearPlaybackTimeState.bind(this))}var k,w,K;return k=U,(w=[{key:"_updatePlaybackTime",value:function(){var W=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&W>this._playbackTimeTrackerLastPlayheadPosition){var z=W-this._playbackTimeTrackerLastPlayheadPosition;z<=1e3&&n(this.pm.data,"view_content_playback_time",z)}this._playbackTimeTrackerLastPlayheadPosition=W}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&ie(k.prototype,w),K&&ie(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}();function ve(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var ae=function(){function U(W){(function(Y,Z){if(!(Y instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W;var z=this._updatePlayheadTime.bind(this);W.on("playbackheartbeat",z),W.on("playbackheartbeatend",z),W.on("timeupdate",z),W.on("destroy",function(){W.off("timeupdate",z)})}var k,w,K;return k=U,(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(W,z){var Y=this,Z=function(){Y.pm.currentFragmentPDT&&Y.pm.currentFragmentStart&&(Y.pm.data.player_program_time=Y.pm.currentFragmentPDT+Y.pm.data.player_playhead_time-Y.pm.currentFragmentStart)};if(z&&z.player_playhead_time)this.pm.data.player_playhead_time=z.player_playhead_time,Z(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var q=this.pm.getPlayheadTime();q!==void 0&&(this.pm.data.player_playhead_time=q,Z(),this._updateMaxPlayheadPosition())}}}])&&ve(k.prototype,w),K&&ve(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}();function Re(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function Le(U,k,w){return k&&Re(U.prototype,k),w&&Re(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var De=Le(function U(k){if(function(W,z){if(!(W instanceof z))throw new TypeError("Cannot call a class as a function")}(this,U),!k.disableRebufferTracking){var w,K=function(){if(w){var W=k.data.viewer_time-w;n(k.data,"view_rebuffer_duration",W),w=k.data.viewer_time}k.data.view_watch_time>=0&&k.data.view_rebuffer_count>0&&(k.data.view_rebuffer_frequency=k.data.view_rebuffer_count/k.data.view_watch_time,k.data.view_rebuffer_percentage=k.data.view_rebuffer_duration/k.data.view_watch_time)};k.on("playbackheartbeat",function(){return K()}),k.on("rebufferstart",function(){w||(n(k.data,"view_rebuffer_count",1),w=k.data.viewer_time,k.one("rebufferend",function(){K(),w=void 0}))})}});function _e(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var we=function(){function U(W){var z=this;(function(Y,Z){if(!(Y instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W,W.disableRebufferTracking||W.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,W.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),W.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),W.on("seeking",function(){z._cleanupRebufferTracker(null,{viewer_time:p.now()})}))}var k,w,K;return k=U,w=[{key:"_checkIfRebuffering",value:function(W,z){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(W,z);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var Y=z.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&Y>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=z.viewer_time}else this._cleanupRebufferTracker(W,z,!0);else this._prepareRebufferTrackerState(z.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(W){this._lastCheckedTime=W,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=W}},{key:"_cleanupRebufferTracker",value:function(W,z){var Y=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:z.viewer_time});else{if(this._lastCheckedTime===null)return;var Z=this.pm.data.player_playhead_time-this._lastPlayheadTime,q=z.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&Z>0&&q-Z>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+q-Z}))}Y?this._prepareRebufferTrackerState(z.viewer_time):this._clearRebufferTrackerState()}}],w&&_e(k.prototype,w),K&&_e(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}(),Ze=we;function He(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var tt=function(){function U(W){var z=this;(function(Y,Z){if(!(Y instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W,W.on("viewinit",function(){var Y=W.data,Z=Y.view_id;if(!Y.view_program_changed){var q=function(Q,oe){var Ae=oe.viewer_time;Q.type==="playing"&&W.data.view_time_to_first_frame===void 0?z.calculateTimeToFirstFrame(Ae||p.now(),Z):Q.type!=="adplaying"||W.data.view_time_to_first_frame!==void 0&&!z._inPrerollPosition()||z.calculateTimeToFirstFrame(Ae||p.now(),Z)};W.one("playing",q),W.one("adplaying",q),W.one("viewend",function(){W.off("playing",q),W.off("adplaying",q)})}})}var k,w,K;return k=U,(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(W,z){z===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:W}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}])&&He(k.prototype,w),K&&He(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}();function Ke(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function ot(U,k,w){return k&&Ke(U.prototype,k),w&&Ke(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ct=ot(function U(k){var w=this;(function(K,W){if(!(K instanceof W))throw new TypeError("Cannot call a class as a function")})(this,U),k.on("viewinit",function(){w._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(K){k.on(K,function(){if(w._lastPlayheadPosition>=0&&k.data.player_playhead_time>=0&&w._lastPlayerWidth>=0&&w._lastSourceWidth>0&&w._lastPlayerHeight>=0&&w._lastSourceHeight>0){var W=k.data.player_playhead_time-w._lastPlayheadPosition;if(W<0)return void(w._lastPlayheadPosition=-1);var z=Math.min(w._lastPlayerWidth/w._lastSourceWidth,w._lastPlayerHeight/w._lastSourceHeight),Y=Math.max(0,z-1),Z=Math.max(0,1-z);k.data.view_max_upscale_percentage=Math.max(k.data.view_max_upscale_percentage||0,Y),k.data.view_max_downscale_percentage=Math.max(k.data.view_max_downscale_percentage||0,Z),n(k.data,"view_total_content_playback_time",W),n(k.data,"view_total_upscaling",Y*W),n(k.data,"view_total_downscaling",Z*W)}w._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(K){k.on(K,function(){w._lastPlayheadPosition=k.data.player_playhead_time,w._lastPlayerWidth=k.data.player_width,w._lastPlayerHeight=k.data.player_height,w._lastSourceWidth=k.data.video_source_width,w._lastSourceHeight=k.data.video_source_height})})});function ft(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function lt(U,k,w){return k&&ft(U.prototype,k),w&&ft(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var It=lt(function U(k){var w=this;(function(K,W){if(!(K instanceof W))throw new TypeError("Cannot call a class as a function")})(this,U),this.isSeeking=!1,k.on("seeking",function(K,W){l()(k.data,W),w._lastSeekingTime=p.now(),w.isSeeking===!1&&(w.isSeeking=!0,k.send("seeking"))}),k.on("seeked",function(){w.isSeeking=!1;var K=w._lastSeekingTime||p.now(),W=p.now()-K;n(k.data,"view_seek_count",1),n(k.data,"view_seek_duration",W);var z=k.data.view_max_seek_time||0;k.data.view_max_seek_time=Math.max(z,W)}),k.on("viewend",function(){w.isSeeking=!1})});function rt(U,k){return function(w){if(Array.isArray(w))return w}(U)||function(w,K){var W=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(W!=null){var z,Y,Z=[],q=!0,Q=!1;try{for(W=W.call(w);!(q=(z=W.next()).done)&&(Z.push(z.value),!K||Z.length!==K);q=!0);}catch(oe){Q=!0,Y=oe}finally{try{q||W.return==null||W.return()}finally{if(Q)throw Y}}return Z}}(U,k)||function(w,K){if(w){if(typeof w=="string")return Mt(w,K);var W=Object.prototype.toString.call(w).slice(8,-1);return W==="Object"&&w.constructor&&(W=w.constructor.name),W==="Map"||W==="Set"?Array.from(w):W==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(W)?Mt(w,K):void 0}}(U,k)||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 Mt(U,k){(k==null||k>U.length)&&(k=U.length);for(var w=0,K=new Array(k);w<k;w++)K[w]=U[w];return K}function Ye(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}var Je=function(U,k){U.push(k),U.sort(function(w,K){return w.viewer_time-K.viewer_time})},yt=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],qe=function(){function U(W){var z=this;(function(Z,q){if(!(Z instanceof q))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=W,W.on("viewinit",function(){z.isAdBreak=!1,z._currentAdRequestNumber=0,z._currentAdResponseNumber=0,z._adRequests=[],z._adResponses=[],z._adHasPlayed=!1,z._wouldBeNewAdPlay=!0,z._prerollPlayTime=void 0}),yt.forEach(function(Z){return W.on(Z,z._updateAdData.bind(z))});var Y=function(){z.isAdBreak=!1};W.on("adbreakstart",function(){z.isAdBreak=!0}),W.on("play",Y),W.on("playing",Y),W.on("viewend",Y),W.on("adrequest",function(Z,q){q=l()({ad_request_id:"generatedAdRequestId"+z._currentAdRequestNumber++},q),Je(z._adRequests,q),n(W.data,"view_ad_request_count"),z.inPrerollPosition()&&(W.data.view_preroll_requested=!0,z._adHasPlayed||n(W.data,"view_preroll_request_count"))}),W.on("adresponse",function(Z,q){q=l()({ad_request_id:"generatedAdRequestId"+z._currentAdResponseNumber++},q),Je(z._adResponses,q);var Q=z.findAdRequest(q.ad_request_id);Q&&n(W.data,"view_ad_request_time",Math.max(0,q.viewer_time-Q.viewer_time))}),W.on("adplay",function(Z,q){z._adHasPlayed=!0,z._wouldBeNewAdPlay&&(z._wouldBeNewAdPlay=!1,n(W.data,"view_ad_played_count")),z.inPrerollPosition()&&!W.data.view_preroll_played&&(W.data.view_preroll_played=!0,z._adRequests.length>0&&(W.data.view_preroll_request_time=Math.max(0,q.viewer_time-z._adRequests[0].viewer_time)),W.data.view_start&&(W.data.view_startup_preroll_request_time=Math.max(0,q.viewer_time-W.data.view_start)),z._prerollPlayTime=q.viewer_time)}),W.on("adplaying",function(Z,q){z.inPrerollPosition()&&W.data.view_preroll_load_time===void 0&&z._prerollPlayTime!==void 0&&(W.data.view_preroll_load_time=q.viewer_time-z._prerollPlayTime,W.data.view_startup_preroll_load_time=q.viewer_time-z._prerollPlayTime)}),W.on("adended",function(){z._wouldBeNewAdPlay=!0}),W.on("aderror",function(){z._wouldBeNewAdPlay=!0})}var k,w,K;return k=U,(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(W){for(var z=0;z<this._adRequests.length;z++)if(this._adRequests[z].ad_request_id===W)return this._adRequests[z]}},{key:"_updateAdData",value:function(W,z){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&z.ad_tag_url){var Y=rt(h(z.ad_tag_url),2),Z=Y[0],q=Y[1];this.pm.data.view_preroll_ad_tag_domain=q,this.pm.data.view_preroll_ad_tag_hostname=Z}if(!this.pm.data.view_preroll_ad_asset_hostname&&z.ad_asset_url){var Q=rt(h(z.ad_asset_url),2),oe=Q[0],Ae=Q[1];this.pm.data.view_preroll_ad_asset_domain=Ae,this.pm.data.view_preroll_ad_asset_hostname=oe}}}}])&&Ye(k.prototype,w),K&&Ye(k,K),Object.defineProperty(k,"prototype",{writable:!1}),U}();function Ge(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function kt(U,k,w){return k&&Ge(U.prototype,k),w&&Ge(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ht=kt(function U(k){var w,K;(function(Z,q){if(!(Z instanceof q))throw new TypeError("Cannot call a class as a function")})(this,U);var W=function(){k.disableRebufferTracking||w&&(n(k.data,"view_waiting_rebuffer_duration",p.now()-w),w=!1,L().clearInterval(K))},z=!1,Y=function(){z=!1,W()};k.on("waiting",function(){z&&(k.disableRebufferTracking||(n(k.data,"view_waiting_rebuffer_count",1),w=p.now(),K=L().setInterval(function(){if(w){var Z=p.now();n(k.data,"view_waiting_rebuffer_duration",Z-w),w=Z}},250)))}),k.on("playing",function(){W(),z=!0}),k.on("pause",Y),k.on("seeking",Y)});function Ht(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function Ar(U,k,w){return k&&Ht(U.prototype,k),w&&Ht(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var _t=Ar(function U(k){var w=this;(function(z,Y){if(!(z instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,U);var K=function(){w.lastWallClockTime=p.now(),k.on("before*",W)},W=function(z){var Y=p.now(),Z=w.lastWallClockTime;w.lastWallClockTime=Y,Y-Z>3e4&&(k.emit("devicesleep",{viewer_time:Z}),l()(k.data,{viewer_time:Z}),k.send("devicesleep"),k.emit("devicewake",{viewer_time:Y}),l()(k.data,{viewer_time:Y}),k.send("devicewake"))};k.one("playbackheartbeat",K),k.on("playbackheartbeatend",function(){k.off("before*",W),k.one("playbackheartbeat",K)})}),Fr=C(375),_r=C(655),wt=C.n(_r),Gt="muxData",Ut=function(){var U;try{U=Fr.parse(wt().get(Gt)||"")}catch{U={}}return U},Sr=function(U){try{wt().set(Gt,Fr.stringify(U),{expires:7300})}catch{}},fr=function(){var U=Ut();return U.mux_viewer_id=U.mux_viewer_id||b(),U.msn=U.msn||Math.random(),Sr(U),{mux_viewer_id:U.mux_viewer_id,mux_sample_number:U.msn}};function fa(U,k){var w=k.beaconCollectionDomain,K=k.beaconDomain;if(w)return"https://"+w;var W=K||"litix.io";return(U=U||"inferred").match(/^[a-z0-9]+$/)?"https://"+U+"."+W:"https://img.litix.io/a.gif"}var hi=function(){var U;switch(Kr()){case"cellular":U="cellular";break;case"ethernet":U="wired";break;case"wifi":U="wifi";break;case void 0:break;default:U="other"}return U},Kr=function(){var U=L().navigator,k=U&&(U.connection||U.mozConnection||U.webkitConnection);return k&&k.type};hi.getConnectionFromAPI=Kr;var St=hi,qi=en({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"}),mi=en({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function en(U){var k={};for(var w in U)U.hasOwnProperty(w)&&(k[U[w]]=w);return k}function vi(U){var k={},w={};return Object.keys(U).forEach(function(K){var W=!1;if(U.hasOwnProperty(K)&&U[K]!==void 0){var z=K.split("_"),Y=z[0],Z=qi[Y];Z||(i.info("Data key word `"+z[0]+"` not expected in "+K),Z=Y+"_"),z.splice(1).forEach(function(q){q==="url"&&(W=!0),mi[q]?Z+=mi[q]:Number(q)&&Math.floor(Number(q))===Number(q)?Z+=q:(i.info("Data key word `"+q+"` not expected in "+K),Z+="_"+q+"_")}),W?w[Z]=U[K]:k[Z]=U[K]}}),l()(k,w)}var ha={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},ma=["hb","requestcompleted","requestfailed","requestcanceled"],Nt=function(U,k){this._beaconUrl=U||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=l()({},ha,k)};Nt.prototype.queueEvent=function(U,k){var w=l()({},k);return(this._eventQueue.length<=this._options.maxQueueLength||U==="eventrateexceeded")&&(this._eventQueue.push(w),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},Nt.prototype.flushEvents=function(){this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()},Nt.prototype.destroy=function(){var U=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,U?this._clearBeaconQueue():this.flushEvents(),L().clearTimeout(this._sendTimeout)},Nt.prototype._clearBeaconQueue=function(){var U=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,k=this._eventQueue.slice(U);U>0&&l()(k[k.length-1],vi({mux_view_message:"event queue truncated"}));var w=this._createPayload(k);Wr(this._beaconUrl,w,!0,function(){})},Nt.prototype._sendBeaconQueue=function(){var U=this;if(!this._postInFlight){var k=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var w=this._createPayload(k),K=p.now();Wr(this._beaconUrl,w,!1,function(W,z){z?(U._eventQueue=k.concat(U._eventQueue),U._failureCount+=1,i.info("Error sending beacon: "+z)):U._failureCount=0,U._roundTripTime=p.now()-K,U._postInFlight=!1})}},Nt.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var U=Math.pow(2,this._failureCount-1);return(1+(U*=Math.random()))*this._options.baseTimeBetweenBeacons},Nt.prototype._startBeaconSending=function(){var U=this;L().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=L().setTimeout(function(){U._eventQueue.length&&U._sendBeaconQueue(),U._startBeaconSending()},this._getNextBeaconTime()))},Nt.prototype._createPayload=function(U){var k,w,K,W=this,z={transmission_timestamp:Math.round(p.now())};this._roundTripTime&&(z.rtt_ms=Math.round(this._roundTripTime));var Y=function(){k=JSON.stringify({metadata:z,events:w||U}),K=k.length/1024},Z=function(){return K<=W._options.maxPayloadKBSize};return Y(),Z()||(i.info("Payload size is too big ("+K+" kb). Removing unnecessary events."),w=U.filter(function(q){return ma.indexOf(q.e)===-1}),Y()),Z()||(i.info("Payload size still too big ("+K+" kb). Cropping fields.."),w.forEach(function(q){for(var Q in q){var oe=q[Q];typeof oe=="string"&&oe.length>51200&&(q[Q]=oe.substring(0,51200))}}),Y()),k};var Wr=function(U,k,w,K){if(w&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(U,k))K();else if(L().fetch)L().fetch(U,{method:"POST",body:k,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(z){return K(null,z.ok?null:"Error")}).catch(function(z){return K(null,z)});else{if(L().XMLHttpRequest){var W=new(L()).XMLHttpRequest;return W.onreadystatechange=function(){if(W.readyState===4)return K(null,W.status!==200?"error":void 0)},W.open("POST",U),W.setRequestHeader("Content-Type","text/plain"),void W.send(k)}K()}},tn=Nt;function xr(U){return xr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},xr(U)}var va=["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"],ud=["viewstart","error","ended","viewend"],rn=function(U,k){var w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=U,this.envKey=k,this.eventQueue=new tn(fa(k,w)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=w.sampleRate,this.disableCookies=w.disableCookies,this.respectDoNotTrack=w.respectDoNotTrack;var K=w.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:K.name,viewer_application_version:K.version,viewer_application_engine:K.layout,viewer_device_name:K.product,viewer_device_category:"",viewer_device_manufacturer:K.manufacturer,viewer_os_family:K.os&&K.os.family,viewer_os_architecture:K.os&&K.os.architecture,viewer_os_version:K.os&&K.os.version};var W=St();W&&(this.pageLevelData=l()(this.pageLevelData,{viewer_connection_type:W})),L()!==void 0&&L().location&&L().location.href&&(this.pageLevelData.page_url=L().location.href),this.viewerData=this.disableCookies?{}:fr()};rn.prototype.send=function(U,k){if(U){if(this.respectDoNotTrack&&d())return i.info("Not sending `"+U+"` because Do Not Track is enabled");if(!k||xr(k)!=="object")return i.error("A data object was expected in send() but was not provided");var w,K,W=this.disableCookies?{}:(w=Ut(),K=p.now(),w.session_start&&(w.sst=w.session_start,delete w.session_start),w.session_id&&(w.sid=w.session_id,delete w.session_id),w.session_expires&&(w.sex=w.session_expires,delete w.session_expires),(!w.sex||w.sex<K)&&(w.sid=b(),w.sst=K),w.sex=K+15e5,Sr(w),{session_id:w.sid,session_start:w.sst,session_expires:w.sex}),z={};l()(z,this.pageLevelData),l()(z,k),l()(z,W),l()(z,this.viewerData),z.event=U,z.env_key=this.envKey,z.user_id&&(z.viewer_user_id=z.user_id,delete z.user_id);var Y=z.mux_sample_number>=this.sampleRate,Z=vi(this._deduplicateBeaconData(U,z));if(this.lastEventTime=this.mux.utils.now(),Y)return i.info("Not sending event due to sample rate restriction",U,z,Z);if(this.envKey||i.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",U,z,Z),!this.rateLimited){if(i.info("Sending event",U,z,Z),this.rateLimited=!this.eventQueue.queueEvent(U,Z),this.mux.WINDOW_UNLOADING&&U==="viewend")this.eventQueue.destroy(!0);else if((ud.indexOf(U)>=0||this.mux.WINDOW_HIDDEN&&U==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return z.event="eventrateexceeded",Z=vi(z),this.eventQueue.queueEvent(z.event,Z),i.error("Beaconing disabled due to rate limit.")}}},rn.prototype.destroy=function(){this.eventQueue.destroy(!1)},rn.prototype._deduplicateBeaconData=function(U,k){var w=this,K={},W=k.view_id;if(!W||U==="viewstart"||U==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)K=l()({},k),W&&(this.previousBeaconData=K),W&&U==="viewend"&&(this.previousBeaconData=null);else{var z=U.indexOf("request")===0;Object.keys(k).forEach(function(Y){var Z=k[Y];(Z!==w.previousBeaconData[Y]||va.indexOf(Y)>-1||function(q,Q,oe,Ae){return!(!q||Q.indexOf("request_")!==0||Q!=="request_response_headers"&&xr(oe)==="object"&&xr(Ae)==="object"&&Object.keys(oe||{}).length===Object.keys(Ae||{}).length)}(z,Y,Z,w.previousBeaconData[Y])||function(q,Q){return q==="renditionchange"&&Q.indexOf("video_source_")===0}(U,Y))&&(K[Y]=Z,w.previousBeaconData[Y]=Z)})}return K};var dd=rn;function Qs(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function cd(U,k,w){return k&&Qs(U.prototype,k),w&&Qs(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var fd=cd(function U(k){(function(Q,oe){if(!(Q instanceof oe))throw new TypeError("Cannot call a class as a function")})(this,U);var w=0,K=0,W=0,z=0,Y=0,Z=0,q=0;k.on("requestcompleted",function(Q,oe){var Ae,ke,Ie=oe.request_start,me=oe.request_response_start,ye=oe.request_response_end,Ue=oe.request_bytes_loaded;if(z++,me?(Ae=me-Ie,ke=ye-me):ke=ye-Ie,ke>0&&Ue>0){var Tt=Ue/ke*8e3;Y++,K+=Ue,W+=ke,k.data.view_min_request_throughput=Math.min(k.data.view_min_request_throughput||1/0,Tt),k.data.view_average_request_throughput=K/W*8e3,k.data.view_request_count=z,Ae>0&&(w+=Ae,k.data.view_max_request_latency=Math.max(k.data.view_max_request_latency||0,Ae),k.data.view_average_request_latency=w/Y)}}),k.on("requestfailed",function(Q,oe){z++,Z++,k.data.view_request_count=z,k.data.view_request_failed_count=Z}),k.on("requestcanceled",function(Q,oe){z++,q++,k.data.view_request_count=z,k.data.view_request_canceled_count=q})});function Zs(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function hd(U,k,w){return k&&Zs(U.prototype,k),w&&Zs(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var md=hd(function U(k){var w=this;(function(K,W){if(!(K instanceof W))throw new TypeError("Cannot call a class as a function")})(this,U),k.on("before*",function(K,W){var z=W.viewer_time,Y=p.now(),Z=w._lastEventTime;if(w._lastEventTime=Y,Z&&Y-Z>36e5){var q=Object.keys(k.data).reduce(function(Q,oe){return oe.indexOf("video_")===0?l()(Q,function(Ae,ke,Ie){return ke in Ae?Object.defineProperty(Ae,ke,{value:Ie,enumerable:!0,configurable:!0,writable:!0}):Ae[ke]=Ie,Ae}({},oe,k.data[oe])):Q},{});k.mux.log.info("Received event after at least an hour inactivity, creating a new view"),k.emit("viewinit",l()({viewer_time:z},q)),k.playbackHeartbeat._playheadShouldBeProgressing&&K.type!=="play"&&K.type!=="adbreakstart"&&(k.emit("play",{viewer_time:z}),K.type!=="playing"&&k.emit("playing",{viewer_time:z}))}})});function ga(U){return ga=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},ga(U)}function vd(U,k){return function(w){if(Array.isArray(w))return w}(U)||function(w,K){var W=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(W!=null){var z,Y,Z=[],q=!0,Q=!1;try{for(W=W.call(w);!(q=(z=W.next()).done)&&(Z.push(z.value),!K||Z.length!==K);q=!0);}catch(oe){Q=!0,Y=oe}finally{try{q||W.return==null||W.return()}finally{if(Q)throw Y}}return Z}}(U,k)||function(w,K){if(w){if(typeof w=="string")return Js(w,K);var W=Object.prototype.toString.call(w).slice(8,-1);return W==="Object"&&w.constructor&&(W=w.constructor.name),W==="Map"||W==="Set"?Array.from(w):W==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(W)?Js(w,K):void 0}}(U,k)||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 Js(U,k){(k==null||k>U.length)&&(k=U.length);for(var w=0,K=new Array(k);w<k;w++)K[w]=U[w];return K}function qs(U,k){for(var w=0;w<k.length;w++){var K=k[w];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(U,K.key,K)}}function pa(U,k){return pa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(w,K){return w.__proto__=K,w},pa(U,k)}function gd(U){var k=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,K=nn(U);if(k){var W=nn(this).constructor;w=Reflect.construct(K,arguments,W)}else w=K.apply(this,arguments);return pd(this,w)}}function pd(U,k){if(k&&(ga(k)==="object"||typeof k=="function"))return k;if(k!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return nt(U)}function nt(U){if(U===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return U}function nn(U){return nn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(k){return k.__proto__||Object.getPrototypeOf(k)},nn(U)}var Ed=["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"],yd=function(U){(function(Y,Z){if(typeof Z!="function"&&Z!==null)throw new TypeError("Super expression must either be null or a function");Y.prototype=Object.create(Z&&Z.prototype,{constructor:{value:Y,writable:!0,configurable:!0}}),Object.defineProperty(Y,"prototype",{writable:!1}),Z&&pa(Y,Z)})(z,U);var k,w,K,W=gd(z);function z(Y,Z,q){var Q;(function(me,ye){if(!(me instanceof ye))throw new TypeError("Cannot call a class as a function")})(this,z),(Q=W.call(this)).DOM_CONTENT_LOADED_EVENT_END=E.domContentLoadedEventEnd(),Q.NAVIGATION_START=E.navigationStart(),Q.mux=Y,Q.id=Z,(q=l()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(me){return me}},q)).data=q.data||{},q.data.property_key&&(q.data.env_key=q.data.property_key,delete q.data.property_key),i.setLevel(q.debug?"debug":"warn"),Q.getPlayheadTime=q.getPlayheadTime,Q.getStateData=q.getStateData||function(){return{}},Q.getAdData=q.getAdData||function(){},Q.minimumRebufferDuration=q.minimumRebufferDuration,Q.sustainedRebufferThreshold=q.sustainedRebufferThreshold,Q.playbackHeartbeatTime=q.playbackHeartbeatTime,Q.disableRebufferTracking=q.disableRebufferTracking,Q.disableRebufferTracking&&Q.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),Q.disablePlayheadRebufferTracking=q.disablePlayheadRebufferTracking,Q.errorTranslator=q.errorTranslator,Q.playbackEventDispatcher=new dd(Y,q.data.env_key,q),Q.data={player_instance_id:b(),mux_sample_rate:q.sampleRate,beacon_domain:q.beaconCollectionDomain?q.beaconCollectionDomain:q.beaconDomain},Q.data.view_sequence_number=1,Q.data.player_sequence_number=1,Q.oldEmit=Q.emit,Q.emit=function(me,ye){ye=l()({viewer_time:this.mux.utils.now()},ye),this.oldEmit(me,ye)};var oe=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(nt(Q));Q.on("viewinit",function(me,ye){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),l()(this.data,ye),this._initializeViewData(),this.one("play",oe),this.one("adbreakstart",oe)});var Ae=function(me){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",me)}.bind(nt(Q));if(Q.on("videochange",function(me,ye){Ae(ye)}),Q.on("programchange",function(me,ye){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."),Ae(l()(ye,{view_program_changed:!0})),oe(),this.emit("play"),this.emit("playing")}),Q.on("fragmentchange",function(me,ye){this.currentFragmentPDT=ye.currentFragmentPDT,this.currentFragmentStart=ye.currentFragmentStart}),Q.on("destroy",Q.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ke=function(){var me=Q.data.view_start!==void 0;Q.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",me&&Q.mux.WINDOW_HIDDEN&&(Q.data.player_is_paused||Q.emit("hb"))};window.addEventListener("visibilitychange",ke,!1);var Ie=function(me){me.persisted||Q.destroy()};window.addEventListener("pagehide",Ie,!1),Q.on("destroy",function(){window.removeEventListener("visibilitychange",ke),window.removeEventListener("pagehide",Ie)})}return Q.on("playerready",function(me,ye){l()(this.data,ye)}),Ed.forEach(function(me){Q.on(me,function(ye,Ue){me.indexOf("ad")!==0&&this._updateStateData(),l()(this.data,Ue),this._sanitizeData()}),Q.on("after"+me,function(){(me!=="error"||this.errorTracker.viewErrored)&&this.send(me)})}),Q.on("viewend",function(me,ye){l()(Q.data,ye)}),Q.one("playerready",function(me){var ye=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=ye-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),Q.longResumeTracker=new md(nt(Q)),Q.errorTracker=new te(nt(Q)),new _t(nt(Q)),Q.seekingTracker=new It(nt(Q)),Q.playheadTime=new ae(nt(Q)),Q.playbackHeartbeat=new j(nt(Q)),new ct(nt(Q)),Q.watchTimeTracker=new ue(nt(Q)),new he(nt(Q)),Q.adTracker=new qe(nt(Q)),new Ze(nt(Q)),new De(nt(Q)),new tt(nt(Q)),new ht(nt(Q)),new fd(nt(Q)),q.hlsjs&&Q.addHLSJS(q),q.dashjs&&Q.addDashJS(q),Q.emit("viewinit",q.data),Q}return k=z,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(Y){var Z=l()({},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(Ae){Z[Ae]=void 0}),Z.video_source_url=Z.video_source_url||Z.player_source_url,Z.video_source_url){var q=vd(h(Z.video_source_url),2),Q=q[0],oe=q[1];Z.video_source_domain=oe,Z.video_source_hostname=Q}delete Z.ad_request_id,this.playbackEventDispatcher.send(Y,Z),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){l()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var Y=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(Z){var q=parseInt(Y.data[Z],10);Y.data[Z]=isNaN(q)?void 0:q}),["player_source_url","video_source_url"].forEach(function(Z){if(Y.data[Z]){var q=Y.data[Z].toLowerCase();q.indexOf("data:")!==0&&q.indexOf("blob:")!==0||(Y.data[Z]="MSE style URL")}})}},{key:"_resetVideoData",value:function(Y,Z){var q=this;Object.keys(this.data).forEach(function(Q){Q.indexOf("video_")===0&&delete q.data[Q]})}},{key:"_resetViewData",value:function(){var Y=this;Object.keys(this.data).forEach(function(Z){Z.indexOf("view_")===0&&delete Y.data[Z]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(Y,Z){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var Y=this,Z=this.data.view_id=b(),q=function(){Z===Y.data.view_id&&n(Y.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",q):q()}},{key:"_restartHeartBeat",value:function(){var Y=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){Y.data.player_is_paused||Y.emit("hb")},1e4))}},{key:"addHLSJS",value:function(Y){Y.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=Y.hlsjs,function(Z,q,Q){var oe=arguments.length>4?arguments[4]:void 0,Ae=Z.log,ke=Z.utils.secondsToMs,Ie=function(Pe){var ge,Se=parseInt(oe.version);return Se===1&&Pe.programDateTime!==null&&(ge=Pe.programDateTime),Se===0&&Pe.pdt!==null&&(ge=Pe.pdt),ge};if(E.exists()){var me=function(Pe,ge){return Z.emit(q,Pe,ge)},ye=function(Pe,ge){var Se=ge.levels,Te=ge.audioTracks,Me=ge.url,ze=ge.stats,We=ge.networkDetails,Ct=ge.sessionData,Dt={},jt={};Se.forEach(function(Yt,Ei){Dt[Ei]={width:Yt.width,height:Yt.height,bitrate:Yt.bitrate,attrs:Yt.attrs}}),Te.forEach(function(Yt,Ei){jt[Ei]={name:Yt.name,language:Yt.lang,bitrate:Yt.bitrate}});var Vt=D(ze),$t=Vt.bytesLoaded,vt=Vt.requestStart,ba=Vt.responseStart,Aa=Vt.responseEnd;me("requestcompleted",y(y({},f(Ct)),{},{request_event_type:Pe,request_bytes_loaded:$t,request_start:vt,request_response_start:ba,request_response_end:Aa,request_type:"manifest",request_hostname:o(Me),request_response_headers:P(We),request_rendition_lists:{media:Dt,audio:jt,video:{}}}))};Q.on(oe.Events.MANIFEST_LOADED,ye);var Ue=function(Pe,ge){var Se=ge.details,Te=ge.level,Me=ge.networkDetails,ze=ge.stats,We=D(ze),Ct=We.bytesLoaded,Dt=We.requestStart,jt=We.responseStart,Vt=We.responseEnd,$t=Se.fragments[Se.fragments.length-1],vt=Ie($t)+ke($t.duration);me("requestcompleted",{request_event_type:Pe,request_bytes_loaded:Ct,request_start:Dt,request_response_start:jt,request_response_end:Vt,request_current_level:Te,request_type:"manifest",request_hostname:o(Se.url),request_response_headers:P(Me),video_holdback:Se.holdBack&&ke(Se.holdBack),video_part_holdback:Se.partHoldBack&&ke(Se.partHoldBack),video_part_target_duration:Se.partTarget&&ke(Se.partTarget),video_target_duration:Se.targetduration&&ke(Se.targetduration),video_source_is_live:Se.live,player_manifest_newest_program_time:isNaN(vt)?void 0:vt})};Q.on(oe.Events.LEVEL_LOADED,Ue);var Tt=function(Pe,ge){var Se=ge.details,Te=ge.networkDetails,Me=ge.stats,ze=D(Me),We=ze.bytesLoaded,Ct=ze.requestStart,Dt=ze.responseStart,jt=ze.responseEnd;me("requestcompleted",{request_event_type:Pe,request_bytes_loaded:We,request_start:Ct,request_response_start:Dt,request_response_end:jt,request_type:"manifest",request_hostname:o(Se.url),request_response_headers:P(Te)})};Q.on(oe.Events.AUDIO_TRACK_LOADED,Tt);var xt=function(Pe,ge){var Se=ge.stats,Te=ge.networkDetails,Me=ge.frag;Se=Se||Me.stats;var ze=D(Se),We={request_event_type:Pe,request_bytes_loaded:ze.bytesLoaded,request_start:ze.requestStart,request_response_start:ze.responseStart,request_response_end:ze.responseEnd,request_hostname:Te?o(Te.responseURL):void 0,request_response_headers:P(Te),request_media_duration:Me.duration};Me.type==="main"?(We.request_type="media",We.request_current_level=Me.level,We.request_video_width=(Q.levels[Me.level]||{}).width,We.request_video_height=(Q.levels[Me.level]||{}).height):We.request_type=Me.type,me("requestcompleted",We)};Q.on(oe.Events.FRAG_LOADED,xt);var Lr=function(Pe,ge){var Se=ge.frag,Te=Se.start,Me={currentFragmentPDT:Ie(Se),currentFragmentStart:ke(Te)};me("fragmentchange",Me)};Q.on(oe.Events.FRAG_CHANGED,Lr);var Ne=function(Pe,ge){var Se=ge.type,Te=ge.details,Me=ge.response,ze=ge.fatal,We=ge.context,Ct=ge.frag;if(Te===oe.ErrorDetails.MANIFEST_LOAD_ERROR||Te===oe.ErrorDetails.MANIFEST_LOAD_TIMEOUT||Te===oe.ErrorDetails.FRAG_LOAD_ERROR||Te===oe.ErrorDetails.FRAG_LOAD_TIMEOUT||Te===oe.ErrorDetails.LEVEL_LOAD_ERROR||Te===oe.ErrorDetails.LEVEL_LOAD_TIMEOUT){var Dt=Ct&&Ct.url||We&&We.url||"";me("requestfailed",{request_error:Te,request_url:Dt,request_hostname:o(Dt),request_type:Te===oe.ErrorDetails.FRAG_LOAD_ERROR||Te===oe.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:Me&&Me.code,request_error_text:Me&&Me.text})}ze&&me("error",{player_error_code:Se,player_error_message:Te})};Q.on(oe.Events.ERROR,Ne);var Lt=function(Pe,ge){var Se=ge.frag,Te=Se&&Se._url||"";me("requestcanceled",{request_event_type:Pe,request_url:Te,request_type:"media",request_hostname:o(Te)})};Q.on(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,Lt);var mt=function(Pe,ge){var Se=ge.level,Te=Q.levels[Se];if(Te&&Te.attrs&&Te.attrs.BANDWIDTH){var Me,ze=Te.attrs.BANDWIDTH,We=parseFloat(Te.attrs["FRAME-RATE"]);isNaN(We)||(Me=We),ze?me("renditionchange",{video_source_fps:Me,video_source_bitrate:ze,video_source_width:Te.width,video_source_height:Te.height}):Ae.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};Q.on(oe.Events.LEVEL_SWITCHED,mt),Q._stopMuxMonitor=function(){Q.off(oe.Events.MANIFEST_LOADED,ye),Q.off(oe.Events.LEVEL_LOADED,Ue),Q.off(oe.Events.AUDIO_TRACK_LOADED,Tt),Q.off(oe.Events.FRAG_LOADED,xt),Q.off(oe.Events.FRAG_CHANGED,Lr),Q.off(oe.Events.ERROR,Ne),Q.off(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,Lt),Q.off(oe.Events.LEVEL_SWITCHED,mt),Q.off(oe.Events.DESTROYING,Q._stopMuxMonitor),delete Q._stopMuxMonitor},Q.on(oe.Events.DESTROYING,Q._stopMuxMonitor)}else Ae.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,Y.hlsjs,{},Y.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var Y;this.hlsjs&&((Y=this.hlsjs)&&typeof Y._stopMuxMonitor=="function"&&Y._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(Y){Y.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=Y.dashjs,function(Z,q,Q){var oe=Z.log;if(Q&&Q.on){var Ae=function(Ne,Lt){return Z.emit(q,Ne,Lt)},ke=function(Ne){var Lt=Ne.type,mt=(Ne.data||{}).url;Ae("requestcompleted",{request_event_type:Lt,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:o(mt)})};Q.on("manifestLoaded",ke);var Ie={},me=function(Ne){var Lt=Ne.type,mt=Ne.fragmentModel,Pe=(Ne.chunk||{}).mediaInfo||{},ge=Pe.type,Se=Pe.bitrateList,Te={};(Se=Se||[]).forEach(function($t,vt){Te[vt]={},Te[vt].width=$t.width,Te[vt].height=$t.height,Te[vt].bitrate=$t.bandwidth,Te[vt].attrs={}}),ge==="video"?Ie.video=Te:ge==="audio"?Ie.audio=Te:Ie.media=Te;var Me=B(mt,Q),ze=Me.requestStart,We=Me.requestResponseStart,Ct=Me.requestResponseEnd,Dt=Me.requestResponseHeaders,jt=Me.requestMediaDuration,Vt=Me.requestHostname;Ae("requestcompleted",{request_event_type:Lt,request_start:ze,request_response_start:We,request_response_end:Ct,request_bytes_loaded:-1,request_type:ge+"_init",request_response_headers:Dt,request_hostname:Vt,request_media_duration:jt,request_rendition_lists:Ie})};Q.on("initFragmentLoaded",me);var ye=function(Ne){var Lt=Ne.type,mt=Ne.fragmentModel,Pe=Ne.chunk||{},ge=Pe.mediaInfo,Se=Pe.start,Te=(ge||{}).type,Me=B(mt,Q),ze=Me.requestStart,We=Me.requestResponseStart,Ct=Me.requestResponseEnd,Dt=Me.requestBytesLoaded,jt=Me.requestResponseHeaders,Vt=Me.requestMediaDuration,$t=Me.requestHostname,vt=N(Te,Q),ba=vt.currentLevel,Aa=vt.renditionWidth,Yt=vt.renditionHeight,Ei=vt.renditionBitrate;Ae("requestcompleted",{request_event_type:Lt,request_start:ze,request_response_start:We,request_response_end:Ct,request_bytes_loaded:Dt,request_type:Te,request_response_headers:jt,request_hostname:$t,request_media_start_time:Se,request_media_duration:Vt,request_current_level:ba,request_labeled_bitrate:Ei,request_video_width:Aa,request_video_height:Yt})};Q.on("mediaFragmentLoaded",ye);var Ue={video:void 0,audio:void 0,totalBitrate:void 0},Tt=function(){if(Ue.video&&typeof Ue.video.bitrate=="number"){if(Ue.video.width&&Ue.video.height){var Ne=Ue.video.bitrate;return Ue.audio&&typeof Ue.audio.bitrate=="number"&&(Ne+=Ue.audio.bitrate),Ne!==Ue.totalBitrate?(Ue.totalBitrate=Ne,{video_source_bitrate:Ne,video_source_height:Ue.video.height,video_source_width:Ue.video.width}):void 0}oe.warn("have bitrate info for video but missing width/height")}},xt=function(Ne,Lt,mt){if(typeof Ne.newQuality=="number"){var Pe=Ne.mediaType;if(Pe==="audio"||Pe==="video"){var ge=Q.getBitrateInfoListFor(Pe).find(function(Te){return Te.qualityIndex===Ne.newQuality});if(ge&&typeof ge.bitrate=="number"){Ue[Pe]=ge;var Se=Tt();Se&&Ae("renditionchange",Se)}else oe.warn("missing bitrate info for ".concat(Pe))}}else oe.warn("missing evt.newQuality in qualityChangeRendered event",Ne)};Q.on("qualityChangeRendered",xt);var Lr=function(Ne){var Lt=Ne.error,mt=Ne.event,Pe=(mt=mt||{}).request||{},ge=L().event&&L().event.currentTarget||{};Ae("requestfailed",{request_error:Lt+"_"+mt.id+"_"+Pe.type,request_url:mt.url,request_hostname:o(mt.url),request_type:Pe.mediaType,request_error_code:ge.status,request_error_type:ge.statusText})};Q.on("error",Lr),Q._stopMuxMonitor=function(){Q.off("manifestLoaded",ke),Q.off("initFragmentLoaded",me),Q.off("mediaFragmentLoaded",ye),Q.off("qualityChangeRendered",xt),Q.off("error",Lr),delete Q._stopMuxMonitor}}else oe.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,Y.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var Y;this.dashjs&&((Y=this.dashjs)&&typeof Y._stopMuxMonitor=="function"&&Y._stopMuxMonitor(),this.dashjs=void 0)}}],w&&qs(k.prototype,w),K&&qs(k,K),Object.defineProperty(k,"prototype",{writable:!1}),z}(X),Td=yd,bd=C(153),gi=C.n(bd);function Ea(U){return Ea=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},Ea(U)}function eo(U,k){return function(w){if(Array.isArray(w))return w}(U)||function(w,K){var W=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(W!=null){var z,Y,Z=[],q=!0,Q=!1;try{for(W=W.call(w);!(q=(z=W.next()).done)&&(Z.push(z.value),!K||Z.length!==K);q=!0);}catch(oe){Q=!0,Y=oe}finally{try{q||W.return==null||W.return()}finally{if(Q)throw Y}}return Z}}(U,k)||function(w,K){if(w){if(typeof w=="string")return to(w,K);var W=Object.prototype.toString.call(w).slice(8,-1);return W==="Object"&&w.constructor&&(W=w.constructor.name),W==="Map"||W==="Set"?Array.from(w):W==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(W)?to(w,K):void 0}}(U,k)||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 to(U,k){(k==null||k>U.length)&&(k=U.length);for(var w=0,K=new Array(k);w<k;w++)K[w]=U[w];return K}var Hr,Ad=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],_d={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};L()&&L().WeakMap&&(Hr=new WeakMap);var Sd="#EXT-X-TARGETDURATION",xd="#EXT-X-PART-INF",Ld="#EXT-X-SERVER-CONTROL",Dd="#EXTINF",Id="#EXT-X-PROGRAM-DATE-TIME",Md="#EXT-X-VERSION",Rd="#EXT-X-SESSION-DATA",an=function(U){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(U),this.manifest};an.prototype.process=function(U){var k;for(this.buffer+=U,k=this.buffer.indexOf(`
5
5
  `);k>-1;k=this.buffer.indexOf(`
6
- `))this.processLine(this.buffer.substring(0,k)),this.buffer=this.buffer.substring(k+1)},en.prototype.processLine=function(U){var k=U.indexOf(":"),w=xd(U,k),K=w[0],W=w.length===2?fa(w[1]):void 0;if(K[0]!=="#")this.currentUri.uri=K,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(K){case md:if(!isFinite(W)||W<0)return;this.manifest.targetDuration=W,this.setHoldBack();break;case gd:ca(this.manifest,w),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case pd:ca(this.manifest,w),this.setHoldBack();break;case Ed:W===0?this.currentUri.duration=.01:W>0&&(this.currentUri.duration=W);break;case yd:var z=W,Y=new Date(z);this.manifest.dateTimeString||(this.manifest.dateTimeString=z,this.manifest.dateTimeObject=Y),this.currentUri.dateTimeString=z,this.currentUri.dateTimeObject=Y;break;case Td:ca(this.manifest,w);break;case bd:var Z=Ld(w[1]),q=f(Z);l()(this.manifest.sessionData,q)}},en.prototype.setHoldBack=function(){var U=this.manifest,k=U.serverControl,w=U.targetDuration,K=U.partTargetDuration;if(k){var W="holdBack",z="partHoldBack",Y=w&&3*w,Z=K&&2*K;w&&!k.hasOwnProperty(W)&&(k[W]=Y),Y&&k[W]<Y&&(k[W]=Y),K&&!k.hasOwnProperty(z)&&(k[z]=3*K),K&&k[z]<Z&&(k[z]=Z)}};var ca=function(U,k){var w,K=Ys(k[0].replace("#EXT-X-",""));Sd(k[1])?(w={},w=l()(_d(k[1]),w)):w=fa(k[1]),U[K]=w},Ys=function(U){return U.toLowerCase().replace(/-(\w)/g,function(k){return k[1].toUpperCase()})},fa=function(U){if(U.toLowerCase()==="yes"||U.toLowerCase()==="no")return U.toLowerCase()==="yes";var k=U.indexOf(":")!==-1?U:parseFloat(U);return isNaN(k)?U:k},Ad=function(U){var k={},w=U.split("=");return w.length>1&&(k[Ys(w[0])]=fa(w[1])),k},_d=function(U){for(var k=U.split(","),w={},K=0;k.length>K;K++){var W=k[K],z=Ad(W);w=l()(z,w)}return w},Sd=function(U){return U.indexOf("=")>-1},xd=function(U,k){return k===-1?[U]:[U.substring(0,k),U.substring(k+1)]},Ld=function(U){var k={};if(U){var w=U.search(",");return[U.slice(0,w),U.slice(w+1)].forEach(function(K,W){for(var z=K.replace(/['"]+/g,"").split("="),Y=0;Y<z.length;Y++)z[Y]==="DATA-ID"&&(k["DATA-ID"]=z[1-Y]),z[Y]==="VALUE"&&(k.VALUE=z[1-Y])}),{data:k}}},Dd=en,Id={safeCall:function(U,k,w,K){var W=K;if(U&&typeof U[k]=="function")try{W=U[k].apply(U,w)}catch(z){i.info("safeCall error",z)}return W},safeIncrement:n,getComputedStyle:function(U,k){var w;if(U&&k&&L()&&typeof L().getComputedStyle=="function")return Wr&&Wr.has(U)&&(w=Wr.get(U)),w||(w=L().getComputedStyle(U,null),Wr&&Wr.set(U,w)),w.getPropertyValue(k)},secondsToMs:function(U){return Math.floor(1e3*U)},assign:l(),headersStringToObject:m,extractHostnameAndDomain:h,extractHostname:o,manifestParser:Dd,generateShortID:x,generateUUID:b,now:p.now},Md={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 Rd(U,k){return function(w){if(Array.isArray(w))return w}(U)||function(w,K){var W=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(W!=null){var z,Y,Z=[],q=!0,Q=!1;try{for(W=W.call(w);!(q=(z=W.next()).done)&&(Z.push(z.value),!K||Z.length!==K);q=!0);}catch(oe){Q=!0,Y=oe}finally{try{q||W.return==null||W.return()}finally{if(Q)throw Y}}return Z}}(U,k)||function(w,K){if(w){if(typeof w=="string")return zs(w,K);var W=Object.prototype.toString.call(w).slice(8,-1);return W==="Object"&&w.constructor&&(W=w.constructor.name),W==="Map"||W==="Set"?Array.from(w):W==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(W)?zs(w,K):void 0}}(U,k)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
7
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function zs(U,k){(k==null||k>U.length)&&(k=U.length);for(var w=0,K=new Array(k);w<k;w++)K[w]=U[w];return K}var Mt={},mi=function U(k){var w=arguments;typeof k=="string"?U.hasOwnProperty(k)?L().setTimeout(function(){w=Array.prototype.splice.call(w,1),U[k].apply(null,w)},0):i.warn("`"+k+"` is an unknown task"):typeof k=="function"?L().setTimeout(function(){k(U)},0):i.warn("`"+k+"` is invalid.")},Cd={loaded:p.now(),NAME:"mux-embed",VERSION:"4.14.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(U,k){return function(w,K,W){var z=Vs(_(K),3),Y=z[0],Z=z[1],q=z[2],Q=w.log,oe=w.utils.getComputedStyle,Ae=w.utils.secondsToMs;if(!Y)return Q.error("No element was found with the `"+Z+"` query selector.");if(q!=="video"&&q!=="audio")return Q.error("The element of `"+Z+"` was not a media element.");Y.mux&&(Y.mux.destroy(),delete Y.mux,Q.warn("Already monitoring this video element, replacing existing event listeners")),(W=l()({automaticErrorTracking:!0},W)).data=l()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:w.VERSION},W.data),W.getPlayheadTime=function(){return Ae(Y.currentTime)},W.getStateData=function(){var Ie=this.hlsjs&&this.hlsjs.url,ve=this.dashjs&&da(this.dashjs.getSource==="function")&&this.dashjs.getSource(),Ee={player_is_paused:Y.paused,player_playhead_time:Ae(Y.currentTime),player_width:parseInt(oe(Y,"width")),player_height:parseInt(oe(Y,"height")),player_autoplay_on:Y.autoplay,player_preload_on:Y.preload,player_language_code:Y.lang,player_is_fullscreen:vi()&&!!(vi().fullscreenElement||vi().webkitFullscreenElement||vi().mozFullScreenElement||vi().msFullscreenElement),video_poster_url:Y.poster,video_source_url:Ie||ve||Y.currentSrc,video_source_duration:Ae(Y.duration),video_source_height:Y.videoHeight,video_source_width:Y.videoWidth},we=W.getPlayheadTime();if(Y.getStartDate&&we>0){var yt=Y.getStartDate();if(yt&&typeof yt.getTime=="function"&&yt.getTime()){var St=yt.getTime();if(Ee.player_program_time=St+we,Y.seekable.length>0){var br=St+Y.seekable.end(Y.seekable.length-1);Ee.player_live_edge_program_time=br}}}return Ee},Y.mux=Y.mux||{},Y.mux.deleted=!1,Y.mux.emit=function(Ie,ve){w.emit(Z,Ie,ve)};var Pe=function(){Q.error("The monitor for this video element has already been destroyed.")};Y.mux.destroy=function(){Object.keys(Y.mux.listeners).forEach(function(Ie){Y.removeEventListener(Ie,Y.mux.listeners[Ie],!1)}),delete Y.mux.listeners,Y.mux.destroy=Pe,Y.mux.swapElement=Pe,Y.mux.emit=Pe,Y.mux.addHLSJS=Pe,Y.mux.addDashJS=Pe,Y.mux.removeHLSJS=Pe,Y.mux.removeDashJS=Pe,Y.mux.deleted=!0,w.emit(Z,"destroy")},Y.mux.swapElement=function(Ie){var ve=Vs(_(Ie),3),Ee=ve[0],we=ve[1],yt=ve[2];return Ee?yt!=="video"&&yt!=="audio"?w.log.error("The element of `"+we+"` was not a media element."):(Ee.muxId=Y.muxId,delete Y.muxId,Ee.mux=Ee.mux||{},Ee.mux.listeners=l()({},Y.mux.listeners),delete Y.mux.listeners,Object.keys(Ee.mux.listeners).forEach(function(St){Y.removeEventListener(St,Ee.mux.listeners[St],!1),Ee.addEventListener(St,Ee.mux.listeners[St],!1)}),Ee.mux.swapElement=Y.mux.swapElement,Ee.mux.destroy=Y.mux.destroy,delete Y.mux,void(Y=Ee)):w.log.error("No element was found with the `"+we+"` query selector.")},Y.mux.addHLSJS=function(Ie){w.addHLSJS(Z,Ie)},Y.mux.addDashJS=function(Ie){w.addDashJS(Z,Ie)},Y.mux.removeHLSJS=function(){w.removeHLSJS(Z)},Y.mux.removeDashJS=function(){w.removeDashJS(Z)},w.init(Z,W),w.emit(Z,"playerready"),Y.paused||(w.emit(Z,"play"),Y.readyState>2&&w.emit(Z,"playing")),Y.mux.listeners={},hd.forEach(function(Ie){(Ie!=="error"||W.automaticErrorTracking)&&(Y.mux.listeners[Ie]=function(){var ve={};if(Ie==="error"){if(!Y.error||Y.error.code===1)return;ve.player_error_code=Y.error.code,ve.player_error_message=vd[Y.error.code]||Y.error.message}w.emit(Z,Ie,ve)},Y.addEventListener(Ie,Y.mux.listeners[Ie],!1))})}(mi,U,k)},destroyMonitor:function(U){var k=Rd(_(U),1)[0];k&&k.mux&&typeof k.mux.destroy=="function"?k.mux.destroy():i.error("A video element monitor for `"+U+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(U,k){var w=I(U);Mt[w]?Mt[w].addHLSJS(k):i.error("A monitor for `"+w+"` has not been initialized.")},addDashJS:function(U,k){var w=I(U);Mt[w]?Mt[w].addDashJS(k):i.error("A monitor for `"+w+"` has not been initialized.")},removeHLSJS:function(U){var k=I(U);Mt[k]?Mt[k].removeHLSJS():i.error("A monitor for `"+k+"` has not been initialized.")},removeDashJS:function(U){var k=I(U);Mt[k]?Mt[k].removeDashJS():i.error("A monitor for `"+k+"` has not been initialized.")},init:function(U,k){d()&&k&&k.respectDoNotTrack&&i.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var w=I(U);Mt[w]=new cd(mi,w,k)},emit:function(U,k,w){var K=I(U);Mt[K]?(Mt[K].emit(k,w),k==="destroy"&&delete Mt[K]):i.error("A monitor for `"+K+"` has not been initialized.")},checkDoNotTrack:d,log:i,utils:Id,events:Md,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(mi,Cd),L()!==void 0&&typeof L().addEventListener=="function"&&L().addEventListener("pagehide",function(U){U.persisted||(mi.WINDOW_UNLOADING=!0)},!1);var Od=mi},655:function(u,R,C){var O,L;function b(x){return b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(I){return typeof I}:function(I){return I&&typeof Symbol=="function"&&I.constructor===Symbol&&I!==Symbol.prototype?"symbol":typeof I},b(x);}(function(x){var I=!1;if((L=typeof(O=x)=="function"?O.call(R,C,R,u):O)===void 0||(u.exports=L),I=!0,b(R)==="object"&&(u.exports=x(),I=!0),!I){var _=window.Cookies,A=window.Cookies=x();A.noConflict=function(){return window.Cookies=_,A}}})(function(){var x=function(){for(var I=0,_={};I<arguments.length;I++){var A=arguments[I];for(var S in A)_[S]=A[S]}return _};return function I(_){function A(S,v,i){var d;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(i=x({path:"/"},A.defaults,i)).expires=="number"){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*i.expires),i.expires=p}try{d=JSON.stringify(v),/^[\{\[]/.test(d)&&(v=d)}catch{}return v=_.write?_.write(v,S):encodeURIComponent(String(v)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),S=(S=(S=encodeURIComponent(String(S))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[S,"=",v,i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}S||(d={});for(var T=document.cookie?document.cookie.split("; "):[],l=/(%[0-9A-Z]{2})+/g,o=0;o<T.length;o++){var h=T[o].split("="),E=h.slice(1).join("=");E.charAt(0)==='"'&&(E=E.slice(1,-1));try{var n=h[0].replace(l,decodeURIComponent);if(E=_.read?_.read(E,n):_(E,n)||E.replace(l,decodeURIComponent),this.json)try{E=JSON.parse(E)}catch{}if(S===n){d=E;break}S||(d[n]=E)}catch{}}return d}}return A.set=A,A.get=function(S){return A.call(A,S)},A.getJSON=function(){return A.apply({json:!0},[].slice.call(arguments))},A.defaults={},A.remove=function(S,v){A(S,"",x(v,{expires:-1}))},A.withConverter=I,A}(function(){})})},153:function(u,R,C){var O,L=C.g!==void 0?C.g:typeof window!="undefined"?window:{},b=C(558);typeof document!="undefined"?O=document:(O=L["__GLOBAL_DOCUMENT_CACHE@4"])||(O=L["__GLOBAL_DOCUMENT_CACHE@4"]=b),u.exports=O},48:function(u,R,C){var O;O=typeof window!="undefined"?window:C.g!==void 0?C.g:typeof self!="undefined"?self:{},u.exports=O},678:function(u){var R=9007199254740991,C="[object Arguments]",O="[object Function]",L="[object GeneratorFunction]",b=/^(?:0|[1-9]\d*)$/;function x(M,D,P){switch(P.length){case 0:return M.call(D);case 1:return M.call(D,P[0]);case 2:return M.call(D,P[0],P[1]);case 3:return M.call(D,P[0],P[1],P[2])}return M.apply(D,P)}var I,_,A=Object.prototype,S=A.hasOwnProperty,v=A.toString,i=A.propertyIsEnumerable,d=(I=Object.keys,_=Object,function(M){return I(_(M))}),p=Math.max,T=!i.call({valueOf:1},"valueOf");function l(M,D){var P=c(M)||function(H){return function(V){return function(X){return!!X&&typeof X=="object"}(V)&&m(V)}(H)&&S.call(H,"callee")&&(!i.call(H,"callee")||v.call(H)==C)}(M)?function(H,V){for(var X=-1,$=Array(H);++X<H;)$[X]=V(X);return $}(M.length,String):[],B=P.length,N=!!B;for(var F in M)!D&&!S.call(M,F)||N&&(F=="length"||h(F,B))||P.push(F);return P}function o(M,D,P){var B=M[D];S.call(M,D)&&n(B,P)&&(P!==void 0||D in M)||(M[D]=P)}function h(M,D){return!!(D=D==null?R:D)&&(typeof M=="number"||b.test(M))&&M>-1&&M%1==0&&M<D}function E(M){var D=M&&M.constructor;return M===(typeof D=="function"&&D.prototype||A)}function n(M,D){return M===D||M!=M&&D!=D}var c=Array.isArray;function m(M){return M!=null&&function(D){return typeof D=="number"&&D>-1&&D%1==0&&D<=R}(M.length)&&!function(D){var P=f(D)?v.call(D):"";return P==O||P==L}(M)}function f(M){var D=typeof M;return!!M&&(D=="object"||D=="function")}var g,y=(g=function(M,D){if(T||E(D)||m(D))(function(B,N,F,H){F||(F={});for(var V=-1,X=N.length;++V<X;){var $=N[V],j=H?H(F[$],B[$],$,F,B):void 0;o(F,$,j===void 0?B[$]:j)}})(D,function(B){return m(B)?l(B):function(N){if(!E(N))return d(N);var F=[];for(var H in Object(N))S.call(N,H)&&H!="constructor"&&F.push(H);return F}(B)}(D),M);else for(var P in D)S.call(D,P)&&o(M,P,D[P])},function(M,D){return D=p(D===void 0?M.length-1:D,0),function(){for(var P=arguments,B=-1,N=p(P.length-D,0),F=Array(N);++B<N;)F[B]=P[D+B];B=-1;for(var H=Array(D+1);++B<D;)H[B]=P[B];return H[D]=F,x(M,this,H)}}(function(M,D){var P=-1,B=D.length,N=B>1?D[B-1]:void 0,F=B>2?D[2]:void 0;for(N=g.length>3&&typeof N=="function"?(B--,N):void 0,F&&function(V,X,$){if(!f($))return!1;var j=typeof X;return!!(j=="number"?m($)&&h(X,$.length):j=="string"&&X in $)&&n($[X],V)}(D[0],D[1],F)&&(N=B<3?void 0:N,B=1),M=Object(M);++P<B;){var H=D[P];H&&g(M,H,P,N)}return M}));u.exports=y},640:function(u,R,C){var O,L;(function(b,x){"use strict";O=function(){var I=function(){},_="undefined",A=typeof window!==_&&typeof window.navigator!==_&&/Trident\/|MSIE /.test(window.navigator.userAgent),S=["trace","debug","info","warn","error"];function v(c,m){var f=c[m];if(typeof f.bind=="function")return f.bind(c);try{return Function.prototype.bind.call(f,c)}catch{return function(){return Function.prototype.apply.apply(f,[c,arguments])}}}function i(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function d(c){return c==="debug"&&(c="log"),typeof console!==_&&(c==="trace"&&A?i:console[c]!==void 0?v(console,c):console.log!==void 0?v(console,"log"):I)}function p(c,m){for(var f=0;f<S.length;f++){var g=S[f];this[g]=f<c?I:this.methodFactory(g,c,m)}this.log=this.debug}function T(c,m,f){return function(){typeof console!==_&&(p.call(this,m,f),this[c].apply(this,arguments))}}function l(c,m,f){return d(c)||T.apply(this,arguments)}function o(c,m,f){var g,y=this;m=m==null?"WARN":m;var M="loglevel";function D(F){var H=(S[F]||"silent").toUpperCase();if(typeof window!==_&&M){try{return void(window.localStorage[M]=H)}catch{}try{window.document.cookie=encodeURIComponent(M)+"="+H+";"}catch{}}}function P(){var F;if(typeof window!==_&&M){try{F=window.localStorage[M]}catch{}if(typeof F===_)try{var H=window.document.cookie,V=H.indexOf(encodeURIComponent(M)+"=");V!==-1&&(F=/^([^;]+)/.exec(H.slice(V))[1])}catch{}return y.levels[F]===void 0&&(F=void 0),F}}function B(){if(typeof window!==_&&M){try{return void window.localStorage.removeItem(M)}catch{}try{window.document.cookie=encodeURIComponent(M)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof c=="string"?M+=":"+c:typeof c=="symbol"&&(M=void 0),y.name=c,y.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},y.methodFactory=f||l,y.getLevel=function(){return g},y.setLevel=function(F,H){if(typeof F=="string"&&y.levels[F.toUpperCase()]!==void 0&&(F=y.levels[F.toUpperCase()]),!(typeof F=="number"&&F>=0&&F<=y.levels.SILENT))throw"log.setLevel() called with invalid level: "+F;if(g=F,H!==!1&&D(F),p.call(y,F,c),typeof console===_&&F<y.levels.SILENT)return"No console available for logging"},y.setDefaultLevel=function(F){m=F,P()||y.setLevel(F,!1)},y.resetLevel=function(){y.setLevel(m,!1),B()},y.enableAll=function(F){y.setLevel(y.levels.TRACE,F)},y.disableAll=function(F){y.setLevel(y.levels.SILENT,F)};var N=P();N==null&&(N=m),y.setLevel(N,!1)}var h=new o,E={};h.getLogger=function(c){if(typeof c!="symbol"&&typeof c!="string"||c==="")throw new TypeError("You must supply a name when creating a logger.");var m=E[c];return m||(m=E[c]=new o(c,h.getLevel(),h.methodFactory)),m};var n=typeof window!==_?window.log:void 0;return h.noConflict=function(){return typeof window!==_&&window.log===h&&(window.log=n),h},h.getLoggers=function(){return E},h.default=h,h},(L=typeof O=="function"?O.call(R,C,R,u):O)===void 0||(u.exports=L)})()},375:function(u,R){"use strict";var C=Object.prototype.hasOwnProperty;function O(b){try{return decodeURIComponent(b.replace(/\+/g," "))}catch{return null}}function L(b){try{return encodeURIComponent(b)}catch{return null}}R.stringify=function(b,x){x=x||"";var I,_,A=[];for(_ in typeof x!="string"&&(x="?"),b)if(C.call(b,_)){if((I=b[_])||I!=null&&!isNaN(I)||(I=""),_=L(_),I=L(I),_===null||I===null)continue;A.push(_+"="+I)}return A.length?x+A.join("&"):""},R.parse=function(b){for(var x,I=/([^=?#&]+)=?([^&]*)/g,_={};x=I.exec(b);){var A=O(x[1]),S=O(x[2]);A===null||S===null||A in _||(_[A]=S)}return _}},558:function(){}},s={};function a(u){var R=s[u];if(R!==void 0)return R.exports;var C=s[u]={exports:{}};return e[u].call(C.exports,C,C.exports,a),C.exports}return a.n=function(u){var R=u&&u.__esModule?function(){return u.default}:function(){return u};return a.d(R,{a:R}),R},a.d=function(u,R){for(var C in R)a.o(R,C)&&!a.o(u,C)&&Object.defineProperty(u,C,{enumerable:!0,get:R[C]})},a.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),a.o=function(u,R){return Object.prototype.hasOwnProperty.call(u,R)},a(80)}()},typeof xn=="object"&&typeof cs=="object"?cs.exports=t():typeof xn=="object"?xn.mux=t():r.mux=t()})()});var Ln=Qs((Pi,fs)=>{typeof window!="undefined"&&function(t,e){typeof Pi=="object"&&typeof fs=="object"?fs.exports=e():typeof define=="function"&&define.amd?define([],e):typeof Pi=="object"?Pi.Hls=e():t.Hls=e()}(Pi,function(){return function(r){var t={};function e(s){if(t[s])return t[s].exports;var a=t[s]={i:s,l:!1,exports:{}};return r[s].call(a.exports,a,a.exports,e),a.l=!0,a.exports}return e.m=r,e.c=t,e.d=function(s,a,u){e.o(s,a)||Object.defineProperty(s,a,{enumerable:!0,get:u})},e.r=function(s){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},e.t=function(s,a){if(a&1&&(s=e(s)),a&8||a&4&&typeof s=="object"&&s&&s.__esModule)return s;var u=Object.create(null);if(e.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:s}),a&2&&typeof s!="string")for(var R in s)e.d(u,R,function(C){return s[C]}.bind(null,R));return u},e.n=function(s){var a=s&&s.__esModule?function(){return s.default}:function(){return s};return e.d(a,"a",a),a},e.o=function(s,a){return Object.prototype.hasOwnProperty.call(s,a)},e.p="/dist/",e(e.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(r,t,e){"use strict";var s=Object.prototype.hasOwnProperty,a="~";function u(){}Object.create&&(u.prototype=Object.create(null),new u().__proto__||(a=!1));function R(b,x,I){this.fn=b,this.context=x,this.once=I||!1}function C(b,x,I,_,A){if(typeof I!="function")throw new TypeError("The listener must be a function");var S=new R(I,_||b,A),v=a?a+x:x;return b._events[v]?b._events[v].fn?b._events[v]=[b._events[v],S]:b._events[v].push(S):(b._events[v]=S,b._eventsCount++),b}function O(b,x){--b._eventsCount===0?b._events=new u:delete b._events[x]}function L(){this._events=new u,this._eventsCount=0}L.prototype.eventNames=function(){var x=[],I,_;if(this._eventsCount===0)return x;for(_ in I=this._events)s.call(I,_)&&x.push(a?_.slice(1):_);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(I)):x},L.prototype.listeners=function(x){var I=a?a+x:x,_=this._events[I];if(!_)return[];if(_.fn)return[_.fn];for(var A=0,S=_.length,v=new Array(S);A<S;A++)v[A]=_[A].fn;return v},L.prototype.listenerCount=function(x){var I=a?a+x:x,_=this._events[I];return _?_.fn?1:_.length:0},L.prototype.emit=function(x,I,_,A,S,v){var i=a?a+x:x;if(!this._events[i])return!1;var d=this._events[i],p=arguments.length,T,l;if(d.fn){switch(d.once&&this.removeListener(x,d.fn,void 0,!0),p){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,I),!0;case 3:return d.fn.call(d.context,I,_),!0;case 4:return d.fn.call(d.context,I,_,A),!0;case 5:return d.fn.call(d.context,I,_,A,S),!0;case 6:return d.fn.call(d.context,I,_,A,S,v),!0}for(l=1,T=new Array(p-1);l<p;l++)T[l-1]=arguments[l];d.fn.apply(d.context,T)}else{var o=d.length,h;for(l=0;l<o;l++)switch(d[l].once&&this.removeListener(x,d[l].fn,void 0,!0),p){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,I);break;case 3:d[l].fn.call(d[l].context,I,_);break;case 4:d[l].fn.call(d[l].context,I,_,A);break;default:if(!T)for(h=1,T=new Array(p-1);h<p;h++)T[h-1]=arguments[h];d[l].fn.apply(d[l].context,T)}}return!0},L.prototype.on=function(x,I,_){return C(this,x,I,_,!1)},L.prototype.once=function(x,I,_){return C(this,x,I,_,!0)},L.prototype.removeListener=function(x,I,_,A){var S=a?a+x:x;if(!this._events[S])return this;if(!I)return O(this,S),this;var v=this._events[S];if(v.fn)v.fn===I&&(!A||v.once)&&(!_||v.context===_)&&O(this,S);else{for(var i=0,d=[],p=v.length;i<p;i++)(v[i].fn!==I||A&&!v[i].once||_&&v[i].context!==_)&&d.push(v[i]);d.length?this._events[S]=d.length===1?d[0]:d:O(this,S)}return this},L.prototype.removeAllListeners=function(x){var I;return x?(I=a?a+x:x,this._events[I]&&O(this,I)):(this._events=new u,this._eventsCount=0),this},L.prototype.off=L.prototype.removeListener,L.prototype.addListener=L.prototype.on,L.prefixed=a,L.EventEmitter=L,r.exports=L},"./node_modules/url-toolkit/src/url-toolkit.js":function(r,t,e){(function(s){var a=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,u=/^(?=([^\/?#]*))\1([^]*)$/,R=/(?:\/|^)\.(?=\/)/g,C=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(L,b,x){if(x=x||{},L=L.trim(),b=b.trim(),!b){if(!x.alwaysNormalize)return L;var I=O.parseURL(L);if(!I)throw new Error("Error trying to parse base URL.");return I.path=O.normalizePath(I.path),O.buildURLFromParts(I)}var _=O.parseURL(b);if(!_)throw new Error("Error trying to parse relative URL.");if(_.scheme)return x.alwaysNormalize?(_.path=O.normalizePath(_.path),O.buildURLFromParts(_)):b;var A=O.parseURL(L);if(!A)throw new Error("Error trying to parse base URL.");if(!A.netLoc&&A.path&&A.path[0]!=="/"){var S=u.exec(A.path);A.netLoc=S[1],A.path=S[2]}A.netLoc&&!A.path&&(A.path="/");var v={scheme:A.scheme,netLoc:_.netLoc,path:null,params:_.params,query:_.query,fragment:_.fragment};if(!_.netLoc&&(v.netLoc=A.netLoc,_.path[0]!=="/"))if(!_.path)v.path=A.path,_.params||(v.params=A.params,_.query||(v.query=A.query));else{var i=A.path,d=i.substring(0,i.lastIndexOf("/")+1)+_.path;v.path=O.normalizePath(d)}return v.path===null&&(v.path=x.alwaysNormalize?O.normalizePath(_.path):_.path),O.buildURLFromParts(v)},parseURL:function(L){var b=a.exec(L);return b?{scheme:b[1]||"",netLoc:b[2]||"",path:b[3]||"",params:b[4]||"",query:b[5]||"",fragment:b[6]||""}:null},normalizePath:function(L){for(L=L.split("").reverse().join("").replace(R,"");L.length!==(L=L.replace(C,"")).length;);return L.split("").reverse().join("")},buildURLFromParts:function(L){return L.scheme+L.netLoc+L.path+L.params+L.query+L.fragment}};r.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(r,t,e){function s(x){var I={};function _(S){if(I[S])return I[S].exports;var v=I[S]={i:S,l:!1,exports:{}};return x[S].call(v.exports,v,v.exports,_),v.l=!0,v.exports}_.m=x,_.c=I,_.i=function(S){return S},_.d=function(S,v,i){_.o(S,v)||Object.defineProperty(S,v,{configurable:!1,enumerable:!0,get:i})},_.r=function(S){Object.defineProperty(S,"__esModule",{value:!0})},_.n=function(S){var v=S&&S.__esModule?function(){return S.default}:function(){return S};return _.d(v,"a",v),v},_.o=function(S,v){return Object.prototype.hasOwnProperty.call(S,v)},_.p="/",_.oe=function(S){throw console.error(S),S};var A=_(_.s=ENTRY_MODULE);return A.default||A}var a="[\\.|\\-|\\+|\\w|/|@]+",u="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+a+").*?\\)";function R(x){return(x+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function C(x){return!isNaN(1*x)}function O(x,I,_){var A={};A[_]=[];var S=I.toString(),v=S.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!v)return A;for(var i=v[1],d=new RegExp("(\\\\n|\\W)"+R(i)+u,"g"),p;p=d.exec(S);)p[3]!=="dll-reference"&&A[_].push(p[3]);for(d=new RegExp("\\("+R(i)+'\\("(dll-reference\\s('+a+'))"\\)\\)'+u,"g");p=d.exec(S);)x[p[2]]||(A[_].push(p[1]),x[p[2]]=e(p[1]).m),A[p[2]]=A[p[2]]||[],A[p[2]].push(p[4]);for(var T=Object.keys(A),l=0;l<T.length;l++)for(var o=0;o<A[T[l]].length;o++)C(A[T[l]][o])&&(A[T[l]][o]=1*A[T[l]][o]);return A}function L(x){var I=Object.keys(x);return I.reduce(function(_,A){return _||x[A].length>0},!1)}function b(x,I){for(var _={main:[I]},A={main:[]},S={main:{}};L(_);)for(var v=Object.keys(_),i=0;i<v.length;i++){var d=v[i],p=_[d],T=p.pop();if(S[d]=S[d]||{},!(S[d][T]||!x[d][T])){S[d][T]=!0,A[d]=A[d]||[],A[d].push(T);for(var l=O(x,x[d][T],d),o=Object.keys(l),h=0;h<o.length;h++)_[o[h]]=_[o[h]]||[],_[o[h]]=_[o[h]].concat(l[o[h]])}}return A}r.exports=function(x,I){I=I||{};var _={main:e.m},A=I.all?{main:Object.keys(_.main)}:b(_,x),S="";Object.keys(A).filter(function(T){return T!=="main"}).forEach(function(T){for(var l=0;A[T][l];)l++;A[T].push(l),_[T][l]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",S=S+"var "+T+" = ("+s.toString().replace("ENTRY_MODULE",JSON.stringify(l))+")({"+A[T].map(function(o){return""+JSON.stringify(o)+": "+_[T][o].toString()}).join(",")+`});
8
- `}),S=S+"new (("+s.toString().replace("ENTRY_MODULE",JSON.stringify(x))+")({"+A.main.map(function(T){return""+JSON.stringify(T)+": "+_.main[T].toString()}).join(",")+"}))(self);";var v=new window.Blob([S],{type:"text/javascript"});if(I.bare)return v;var i=window.URL||window.webkitURL||window.mozURL||window.msURL,d=i.createObjectURL(v),p=new window.Worker(d);return p.objectURL=d,p}},"./src/config.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"hlsDefaultConfig",function(){return h}),e.d(t,"mergeConfig",function(){return n}),e.d(t,"enableStreamingMode",function(){return c});var s=e("./src/controller/abr-controller.ts"),a=e("./src/controller/audio-stream-controller.ts"),u=e("./src/controller/audio-track-controller.ts"),R=e("./src/controller/subtitle-stream-controller.ts"),C=e("./src/controller/subtitle-track-controller.ts"),O=e("./src/controller/buffer-controller.ts"),L=e("./src/controller/timeline-controller.ts"),b=e("./src/controller/cap-level-controller.ts"),x=e("./src/controller/fps-controller.ts"),I=e("./src/controller/eme-controller.ts"),_=e("./src/controller/cmcd-controller.ts"),A=e("./src/utils/xhr-loader.ts"),S=e("./src/utils/fetch-loader.ts"),v=e("./src/utils/cues.ts"),i=e("./src/utils/mediakeys-helper.ts"),d=e("./src/utils/logger.ts");function p(){return p=Object.assign?Object.assign.bind():function(m){for(var f=1;f<arguments.length;f++){var g=arguments[f];for(var y in g)Object.prototype.hasOwnProperty.call(g,y)&&(m[y]=g[y])}return m},p.apply(this,arguments)}function T(m,f){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(m);f&&(y=y.filter(function(M){return Object.getOwnPropertyDescriptor(m,M).enumerable})),g.push.apply(g,y)}return g}function l(m){for(var f=1;f<arguments.length;f++){var g=arguments[f]!=null?arguments[f]:{};f%2?T(Object(g),!0).forEach(function(y){o(m,y,g[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):T(Object(g)).forEach(function(y){Object.defineProperty(m,y,Object.getOwnPropertyDescriptor(g,y))})}return m}function o(m,f,g){return f in m?Object.defineProperty(m,f,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[f]=g,m}var h=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:A.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:s.default,bufferController:O.default,capLevelController:b.default,fpsController:x.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:i.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},E()),{},{subtitleStreamController:R.SubtitleStreamController,subtitleTrackController:C.default,timelineController:L.TimelineController,audioStreamController:a.default,audioTrackController:u.default,emeController:I.default,cmcdController:_.default});function E(){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 n(m,f){if((f.liveSyncDurationCount||f.liveMaxLatencyDurationCount)&&(f.liveSyncDuration||f.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(f.liveMaxLatencyDurationCount!==void 0&&(f.liveSyncDurationCount===void 0||f.liveMaxLatencyDurationCount<=f.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(f.liveMaxLatencyDuration!==void 0&&(f.liveSyncDuration===void 0||f.liveMaxLatencyDuration<=f.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return p({},m,f)}function c(m){var f=m.loader;if(f!==S.default&&f!==A.default)d.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),m.progressive=!1;else{var g=Object(S.fetchSupported)();g&&(m.loader=S.default,m.progressive=!0,m.enableSoftwareAES=!0,d.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/polyfills/number.ts"),a=e("./src/utils/ewma-bandwidth-estimator.ts"),u=e("./src/events.ts"),R=e("./src/utils/buffer-helper.ts"),C=e("./src/errors.ts"),O=e("./src/types/loader.ts"),L=e("./src/utils/logger.ts");function b(_,A){for(var S=0;S<A.length;S++){var v=A[S];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(_,v.key,v)}}function x(_,A,S){return A&&b(_.prototype,A),S&&b(_,S),Object.defineProperty(_,"prototype",{writable:!1}),_}var I=function(){function _(S){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=S;var v=S.config;this.bwEstimator=new a.default(v.abrEwmaSlowVoD,v.abrEwmaFastVoD,v.abrEwmaDefaultEstimate),this.registerListeners()}var A=_.prototype;return A.registerListeners=function(){var v=this.hls;v.on(u.Events.FRAG_LOADING,this.onFragLoading,this),v.on(u.Events.FRAG_LOADED,this.onFragLoaded,this),v.on(u.Events.FRAG_BUFFERED,this.onFragBuffered,this),v.on(u.Events.LEVEL_LOADED,this.onLevelLoaded,this),v.on(u.Events.ERROR,this.onError,this)},A.unregisterListeners=function(){var v=this.hls;v.off(u.Events.FRAG_LOADING,this.onFragLoading,this),v.off(u.Events.FRAG_LOADED,this.onFragLoaded,this),v.off(u.Events.FRAG_BUFFERED,this.onFragBuffered,this),v.off(u.Events.LEVEL_LOADED,this.onLevelLoaded,this),v.off(u.Events.ERROR,this.onError,this)},A.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},A.onFragLoading=function(v,i){var d=i.frag;if(d.type===O.PlaylistLevelType.MAIN&&!this.timer){var p;this.fragCurrent=d,this.partCurrent=(p=i.part)!=null?p:null,this.timer=self.setInterval(this.onCheck,100)}},A.onLevelLoaded=function(v,i){var d=this.hls.config;i.details.live?this.bwEstimator.update(d.abrEwmaSlowLive,d.abrEwmaFastLive):this.bwEstimator.update(d.abrEwmaSlowVoD,d.abrEwmaFastVoD)},A._abandonRulesCheck=function(){var v=this.fragCurrent,i=this.partCurrent,d=this.hls,p=d.autoLevelEnabled,T=d.config,l=d.media;if(!(!v||!l)){var o=i?i.stats:v.stats,h=i?i.duration:v.duration;if(o.aborted){L.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!p||l.paused||!l.playbackRate||!l.readyState)){var E=performance.now()-o.loading.start,n=Math.abs(l.playbackRate);if(!(E<=500*h/n)){var c=d.levels,m=d.minAutoLevel,f=c[v.level],g=o.total||Math.max(o.loaded,Math.round(h*f.maxBitrate/8)),y=Math.max(1,o.bwEstimate?o.bwEstimate/8:o.loaded*1e3/E),M=(g-o.loaded)/y,D=l.currentTime,P=(R.BufferHelper.bufferInfo(l,D,T.maxBufferHole).end-D)/n;if(!(P>=2*h/n||M<=P)){var B=Number.POSITIVE_INFINITY,N;for(N=v.level-1;N>m;N--){var F=c[N].maxBitrate;if(B=h*F/(8*.8*y),B<P)break}if(!(B>=M)){var H=this.bwEstimator.getEstimate();L.logger.warn("Fragment "+v.sn+(i?" part "+i.index:"")+" of level "+v.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+N+`
9
- Current BW estimate: `+(Object(s.isFiniteNumber)(H)?(H/1024).toFixed(3):"Unknown")+` Kb/s
6
+ `))this.processLine(this.buffer.substring(0,k)),this.buffer=this.buffer.substring(k+1)},an.prototype.processLine=function(U){var k=U.indexOf(":"),w=kd(U,k),K=w[0],W=w.length===2?Ta(w[1]):void 0;if(K[0]!=="#")this.currentUri.uri=K,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(K){case Sd:if(!isFinite(W)||W<0)return;this.manifest.targetDuration=W,this.setHoldBack();break;case xd:ya(this.manifest,w),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Ld:ya(this.manifest,w),this.setHoldBack();break;case Dd:W===0?this.currentUri.duration=.01:W>0&&(this.currentUri.duration=W);break;case Id:var z=W,Y=new Date(z);this.manifest.dateTimeString||(this.manifest.dateTimeString=z,this.manifest.dateTimeObject=Y),this.currentUri.dateTimeString=z,this.currentUri.dateTimeObject=Y;break;case Md:ya(this.manifest,w);break;case Rd:var Z=wd(w[1]),q=f(Z);l()(this.manifest.sessionData,q)}},an.prototype.setHoldBack=function(){var U=this.manifest,k=U.serverControl,w=U.targetDuration,K=U.partTargetDuration;if(k){var W="holdBack",z="partHoldBack",Y=w&&3*w,Z=K&&2*K;w&&!k.hasOwnProperty(W)&&(k[W]=Y),Y&&k[W]<Y&&(k[W]=Y),K&&!k.hasOwnProperty(z)&&(k[z]=3*K),K&&k[z]<Z&&(k[z]=Z)}};var ya=function(U,k){var w,K=ro(k[0].replace("#EXT-X-",""));Pd(k[1])?(w={},w=l()(Od(k[1]),w)):w=Ta(k[1]),U[K]=w},ro=function(U){return U.toLowerCase().replace(/-(\w)/g,function(k){return k[1].toUpperCase()})},Ta=function(U){if(U.toLowerCase()==="yes"||U.toLowerCase()==="no")return U.toLowerCase()==="yes";var k=U.indexOf(":")!==-1?U:parseFloat(U);return isNaN(k)?U:k},Cd=function(U){var k={},w=U.split("=");return w.length>1&&(k[ro(w[0])]=Ta(w[1])),k},Od=function(U){for(var k=U.split(","),w={},K=0;k.length>K;K++){var W=k[K],z=Cd(W);w=l()(z,w)}return w},Pd=function(U){return U.indexOf("=")>-1},kd=function(U,k){return k===-1?[U]:[U.substring(0,k),U.substring(k+1)]},wd=function(U){var k={};if(U){var w=U.search(",");return[U.slice(0,w),U.slice(w+1)].forEach(function(K,W){for(var z=K.replace(/['"]+/g,"").split("="),Y=0;Y<z.length;Y++)z[Y]==="DATA-ID"&&(k["DATA-ID"]=z[1-Y]),z[Y]==="VALUE"&&(k.VALUE=z[1-Y])}),{data:k}}},Ud=an,Nd={safeCall:function(U,k,w,K){var W=K;if(U&&typeof U[k]=="function")try{W=U[k].apply(U,w)}catch(z){i.info("safeCall error",z)}return W},safeIncrement:n,getComputedStyle:function(U,k){var w;if(U&&k&&L()&&typeof L().getComputedStyle=="function")return Hr&&Hr.has(U)&&(w=Hr.get(U)),w||(w=L().getComputedStyle(U,null),Hr&&Hr.set(U,w)),w.getPropertyValue(k)},secondsToMs:function(U){return Math.floor(1e3*U)},assign:l(),headersStringToObject:v,extractHostnameAndDomain:h,extractHostname:o,manifestParser:Ud,generateShortID:x,generateUUID:b,now:p.now},Bd={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 Fd(U,k){return function(w){if(Array.isArray(w))return w}(U)||function(w,K){var W=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(W!=null){var z,Y,Z=[],q=!0,Q=!1;try{for(W=W.call(w);!(q=(z=W.next()).done)&&(Z.push(z.value),!K||Z.length!==K);q=!0);}catch(oe){Q=!0,Y=oe}finally{try{q||W.return==null||W.return()}finally{if(Q)throw Y}}return Z}}(U,k)||function(w,K){if(w){if(typeof w=="string")return io(w,K);var W=Object.prototype.toString.call(w).slice(8,-1);return W==="Object"&&w.constructor&&(W=w.constructor.name),W==="Map"||W==="Set"?Array.from(w):W==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(W)?io(w,K):void 0}}(U,k)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
7
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function io(U,k){(k==null||k>U.length)&&(k=U.length);for(var w=0,K=new Array(k);w<k;w++)K[w]=U[w];return K}var Rt={},pi=function U(k){var w=arguments;typeof k=="string"?U.hasOwnProperty(k)?L().setTimeout(function(){w=Array.prototype.splice.call(w,1),U[k].apply(null,w)},0):i.warn("`"+k+"` is an unknown task"):typeof k=="function"?L().setTimeout(function(){k(U)},0):i.warn("`"+k+"` is invalid.")},Kd={loaded:p.now(),NAME:"mux-embed",VERSION:"4.14.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(U,k){return function(w,K,W){var z=eo(_(K),3),Y=z[0],Z=z[1],q=z[2],Q=w.log,oe=w.utils.getComputedStyle,Ae=w.utils.secondsToMs;if(!Y)return Q.error("No element was found with the `"+Z+"` query selector.");if(q!=="video"&&q!=="audio")return Q.error("The element of `"+Z+"` was not a media element.");Y.mux&&(Y.mux.destroy(),delete Y.mux,Q.warn("Already monitoring this video element, replacing existing event listeners")),(W=l()({automaticErrorTracking:!0},W)).data=l()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:w.VERSION},W.data),W.getPlayheadTime=function(){return Ae(Y.currentTime)},W.getStateData=function(){var Ie=this.hlsjs&&this.hlsjs.url,me=this.dashjs&&Ea(this.dashjs.getSource==="function")&&this.dashjs.getSource(),ye={player_is_paused:Y.paused,player_playhead_time:Ae(Y.currentTime),player_width:parseInt(oe(Y,"width")),player_height:parseInt(oe(Y,"height")),player_autoplay_on:Y.autoplay,player_preload_on:Y.preload,player_language_code:Y.lang,player_is_fullscreen:gi()&&!!(gi().fullscreenElement||gi().webkitFullscreenElement||gi().mozFullScreenElement||gi().msFullscreenElement),video_poster_url:Y.poster,video_source_url:Ie||me||Y.currentSrc,video_source_duration:Ae(Y.duration),video_source_height:Y.videoHeight,video_source_width:Y.videoWidth},Ue=W.getPlayheadTime();if(Y.getStartDate&&Ue>0){var Tt=Y.getStartDate();if(Tt&&typeof Tt.getTime=="function"&&Tt.getTime()){var xt=Tt.getTime();if(ye.player_program_time=xt+Ue,Y.seekable.length>0){var Lr=xt+Y.seekable.end(Y.seekable.length-1);ye.player_live_edge_program_time=Lr}}}return ye},Y.mux=Y.mux||{},Y.mux.deleted=!1,Y.mux.emit=function(Ie,me){w.emit(Z,Ie,me)};var ke=function(){Q.error("The monitor for this video element has already been destroyed.")};Y.mux.destroy=function(){Object.keys(Y.mux.listeners).forEach(function(Ie){Y.removeEventListener(Ie,Y.mux.listeners[Ie],!1)}),delete Y.mux.listeners,Y.mux.destroy=ke,Y.mux.swapElement=ke,Y.mux.emit=ke,Y.mux.addHLSJS=ke,Y.mux.addDashJS=ke,Y.mux.removeHLSJS=ke,Y.mux.removeDashJS=ke,Y.mux.deleted=!0,w.emit(Z,"destroy")},Y.mux.swapElement=function(Ie){var me=eo(_(Ie),3),ye=me[0],Ue=me[1],Tt=me[2];return ye?Tt!=="video"&&Tt!=="audio"?w.log.error("The element of `"+Ue+"` was not a media element."):(ye.muxId=Y.muxId,delete Y.muxId,ye.mux=ye.mux||{},ye.mux.listeners=l()({},Y.mux.listeners),delete Y.mux.listeners,Object.keys(ye.mux.listeners).forEach(function(xt){Y.removeEventListener(xt,ye.mux.listeners[xt],!1),ye.addEventListener(xt,ye.mux.listeners[xt],!1)}),ye.mux.swapElement=Y.mux.swapElement,ye.mux.destroy=Y.mux.destroy,delete Y.mux,void(Y=ye)):w.log.error("No element was found with the `"+Ue+"` query selector.")},Y.mux.addHLSJS=function(Ie){w.addHLSJS(Z,Ie)},Y.mux.addDashJS=function(Ie){w.addDashJS(Z,Ie)},Y.mux.removeHLSJS=function(){w.removeHLSJS(Z)},Y.mux.removeDashJS=function(){w.removeDashJS(Z)},w.init(Z,W),w.emit(Z,"playerready"),Y.paused||(w.emit(Z,"play"),Y.readyState>2&&w.emit(Z,"playing")),Y.mux.listeners={},Ad.forEach(function(Ie){(Ie!=="error"||W.automaticErrorTracking)&&(Y.mux.listeners[Ie]=function(){var me={};if(Ie==="error"){if(!Y.error||Y.error.code===1)return;me.player_error_code=Y.error.code,me.player_error_message=_d[Y.error.code]||Y.error.message}w.emit(Z,Ie,me)},Y.addEventListener(Ie,Y.mux.listeners[Ie],!1))})}(pi,U,k)},destroyMonitor:function(U){var k=Fd(_(U),1)[0];k&&k.mux&&typeof k.mux.destroy=="function"?k.mux.destroy():i.error("A video element monitor for `"+U+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(U,k){var w=I(U);Rt[w]?Rt[w].addHLSJS(k):i.error("A monitor for `"+w+"` has not been initialized.")},addDashJS:function(U,k){var w=I(U);Rt[w]?Rt[w].addDashJS(k):i.error("A monitor for `"+w+"` has not been initialized.")},removeHLSJS:function(U){var k=I(U);Rt[k]?Rt[k].removeHLSJS():i.error("A monitor for `"+k+"` has not been initialized.")},removeDashJS:function(U){var k=I(U);Rt[k]?Rt[k].removeDashJS():i.error("A monitor for `"+k+"` has not been initialized.")},init:function(U,k){d()&&k&&k.respectDoNotTrack&&i.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var w=I(U);Rt[w]=new Td(pi,w,k)},emit:function(U,k,w){var K=I(U);Rt[K]?(Rt[K].emit(k,w),k==="destroy"&&delete Rt[K]):i.error("A monitor for `"+K+"` has not been initialized.")},checkDoNotTrack:d,log:i,utils:Nd,events:Bd,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(pi,Kd),L()!==void 0&&typeof L().addEventListener=="function"&&L().addEventListener("pagehide",function(U){U.persisted||(pi.WINDOW_UNLOADING=!0)},!1);var Wd=pi},655:function(u,R,C){var O,L;function b(x){return b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(I){return typeof I}:function(I){return I&&typeof Symbol=="function"&&I.constructor===Symbol&&I!==Symbol.prototype?"symbol":typeof I},b(x);}(function(x){var I=!1;if((L=typeof(O=x)=="function"?O.call(R,C,R,u):O)===void 0||(u.exports=L),I=!0,b(R)==="object"&&(u.exports=x(),I=!0),!I){var _=window.Cookies,A=window.Cookies=x();A.noConflict=function(){return window.Cookies=_,A}}})(function(){var x=function(){for(var I=0,_={};I<arguments.length;I++){var A=arguments[I];for(var S in A)_[S]=A[S]}return _};return function I(_){function A(S,m,i){var d;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(i=x({path:"/"},A.defaults,i)).expires=="number"){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*i.expires),i.expires=p}try{d=JSON.stringify(m),/^[\{\[]/.test(d)&&(m=d)}catch{}return m=_.write?_.write(m,S):encodeURIComponent(String(m)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),S=(S=(S=encodeURIComponent(String(S))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[S,"=",m,i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}S||(d={});for(var T=document.cookie?document.cookie.split("; "):[],l=/(%[0-9A-Z]{2})+/g,o=0;o<T.length;o++){var h=T[o].split("="),E=h.slice(1).join("=");E.charAt(0)==='"'&&(E=E.slice(1,-1));try{var n=h[0].replace(l,decodeURIComponent);if(E=_.read?_.read(E,n):_(E,n)||E.replace(l,decodeURIComponent),this.json)try{E=JSON.parse(E)}catch{}if(S===n){d=E;break}S||(d[n]=E)}catch{}}return d}}return A.set=A,A.get=function(S){return A.call(A,S)},A.getJSON=function(){return A.apply({json:!0},[].slice.call(arguments))},A.defaults={},A.remove=function(S,m){A(S,"",x(m,{expires:-1}))},A.withConverter=I,A}(function(){})})},153:function(u,R,C){var O,L=C.g!==void 0?C.g:typeof window!="undefined"?window:{},b=C(558);typeof document!="undefined"?O=document:(O=L["__GLOBAL_DOCUMENT_CACHE@4"])||(O=L["__GLOBAL_DOCUMENT_CACHE@4"]=b),u.exports=O},48:function(u,R,C){var O;O=typeof window!="undefined"?window:C.g!==void 0?C.g:typeof self!="undefined"?self:{},u.exports=O},678:function(u){var R=9007199254740991,C="[object Arguments]",O="[object Function]",L="[object GeneratorFunction]",b=/^(?:0|[1-9]\d*)$/;function x(M,D,P){switch(P.length){case 0:return M.call(D);case 1:return M.call(D,P[0]);case 2:return M.call(D,P[0],P[1]);case 3:return M.call(D,P[0],P[1],P[2])}return M.apply(D,P)}var I,_,A=Object.prototype,S=A.hasOwnProperty,m=A.toString,i=A.propertyIsEnumerable,d=(I=Object.keys,_=Object,function(M){return I(_(M))}),p=Math.max,T=!i.call({valueOf:1},"valueOf");function l(M,D){var P=c(M)||function(H){return function(V){return function(X){return!!X&&typeof X=="object"}(V)&&v(V)}(H)&&S.call(H,"callee")&&(!i.call(H,"callee")||m.call(H)==C)}(M)?function(H,V){for(var X=-1,$=Array(H);++X<H;)$[X]=V(X);return $}(M.length,String):[],B=P.length,N=!!B;for(var F in M)!D&&!S.call(M,F)||N&&(F=="length"||h(F,B))||P.push(F);return P}function o(M,D,P){var B=M[D];S.call(M,D)&&n(B,P)&&(P!==void 0||D in M)||(M[D]=P)}function h(M,D){return!!(D=D==null?R:D)&&(typeof M=="number"||b.test(M))&&M>-1&&M%1==0&&M<D}function E(M){var D=M&&M.constructor;return M===(typeof D=="function"&&D.prototype||A)}function n(M,D){return M===D||M!=M&&D!=D}var c=Array.isArray;function v(M){return M!=null&&function(D){return typeof D=="number"&&D>-1&&D%1==0&&D<=R}(M.length)&&!function(D){var P=f(D)?m.call(D):"";return P==O||P==L}(M)}function f(M){var D=typeof M;return!!M&&(D=="object"||D=="function")}var g,y=(g=function(M,D){if(T||E(D)||v(D))(function(B,N,F,H){F||(F={});for(var V=-1,X=N.length;++V<X;){var $=N[V],j=H?H(F[$],B[$],$,F,B):void 0;o(F,$,j===void 0?B[$]:j)}})(D,function(B){return v(B)?l(B):function(N){if(!E(N))return d(N);var F=[];for(var H in Object(N))S.call(N,H)&&H!="constructor"&&F.push(H);return F}(B)}(D),M);else for(var P in D)S.call(D,P)&&o(M,P,D[P])},function(M,D){return D=p(D===void 0?M.length-1:D,0),function(){for(var P=arguments,B=-1,N=p(P.length-D,0),F=Array(N);++B<N;)F[B]=P[D+B];B=-1;for(var H=Array(D+1);++B<D;)H[B]=P[B];return H[D]=F,x(M,this,H)}}(function(M,D){var P=-1,B=D.length,N=B>1?D[B-1]:void 0,F=B>2?D[2]:void 0;for(N=g.length>3&&typeof N=="function"?(B--,N):void 0,F&&function(V,X,$){if(!f($))return!1;var j=typeof X;return!!(j=="number"?v($)&&h(X,$.length):j=="string"&&X in $)&&n($[X],V)}(D[0],D[1],F)&&(N=B<3?void 0:N,B=1),M=Object(M);++P<B;){var H=D[P];H&&g(M,H,P,N)}return M}));u.exports=y},640:function(u,R,C){var O,L;(function(b,x){"use strict";O=function(){var I=function(){},_="undefined",A=typeof window!==_&&typeof window.navigator!==_&&/Trident\/|MSIE /.test(window.navigator.userAgent),S=["trace","debug","info","warn","error"];function m(c,v){var f=c[v];if(typeof f.bind=="function")return f.bind(c);try{return Function.prototype.bind.call(f,c)}catch{return function(){return Function.prototype.apply.apply(f,[c,arguments])}}}function i(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function d(c){return c==="debug"&&(c="log"),typeof console!==_&&(c==="trace"&&A?i:console[c]!==void 0?m(console,c):console.log!==void 0?m(console,"log"):I)}function p(c,v){for(var f=0;f<S.length;f++){var g=S[f];this[g]=f<c?I:this.methodFactory(g,c,v)}this.log=this.debug}function T(c,v,f){return function(){typeof console!==_&&(p.call(this,v,f),this[c].apply(this,arguments))}}function l(c,v,f){return d(c)||T.apply(this,arguments)}function o(c,v,f){var g,y=this;v=v==null?"WARN":v;var M="loglevel";function D(F){var H=(S[F]||"silent").toUpperCase();if(typeof window!==_&&M){try{return void(window.localStorage[M]=H)}catch{}try{window.document.cookie=encodeURIComponent(M)+"="+H+";"}catch{}}}function P(){var F;if(typeof window!==_&&M){try{F=window.localStorage[M]}catch{}if(typeof F===_)try{var H=window.document.cookie,V=H.indexOf(encodeURIComponent(M)+"=");V!==-1&&(F=/^([^;]+)/.exec(H.slice(V))[1])}catch{}return y.levels[F]===void 0&&(F=void 0),F}}function B(){if(typeof window!==_&&M){try{return void window.localStorage.removeItem(M)}catch{}try{window.document.cookie=encodeURIComponent(M)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof c=="string"?M+=":"+c:typeof c=="symbol"&&(M=void 0),y.name=c,y.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},y.methodFactory=f||l,y.getLevel=function(){return g},y.setLevel=function(F,H){if(typeof F=="string"&&y.levels[F.toUpperCase()]!==void 0&&(F=y.levels[F.toUpperCase()]),!(typeof F=="number"&&F>=0&&F<=y.levels.SILENT))throw"log.setLevel() called with invalid level: "+F;if(g=F,H!==!1&&D(F),p.call(y,F,c),typeof console===_&&F<y.levels.SILENT)return"No console available for logging"},y.setDefaultLevel=function(F){v=F,P()||y.setLevel(F,!1)},y.resetLevel=function(){y.setLevel(v,!1),B()},y.enableAll=function(F){y.setLevel(y.levels.TRACE,F)},y.disableAll=function(F){y.setLevel(y.levels.SILENT,F)};var N=P();N==null&&(N=v),y.setLevel(N,!1)}var h=new o,E={};h.getLogger=function(c){if(typeof c!="symbol"&&typeof c!="string"||c==="")throw new TypeError("You must supply a name when creating a logger.");var v=E[c];return v||(v=E[c]=new o(c,h.getLevel(),h.methodFactory)),v};var n=typeof window!==_?window.log:void 0;return h.noConflict=function(){return typeof window!==_&&window.log===h&&(window.log=n),h},h.getLoggers=function(){return E},h.default=h,h},(L=typeof O=="function"?O.call(R,C,R,u):O)===void 0||(u.exports=L)})()},375:function(u,R){"use strict";var C=Object.prototype.hasOwnProperty;function O(b){try{return decodeURIComponent(b.replace(/\+/g," "))}catch{return null}}function L(b){try{return encodeURIComponent(b)}catch{return null}}R.stringify=function(b,x){x=x||"";var I,_,A=[];for(_ in typeof x!="string"&&(x="?"),b)if(C.call(b,_)){if((I=b[_])||I!=null&&!isNaN(I)||(I=""),_=L(_),I=L(I),_===null||I===null)continue;A.push(_+"="+I)}return A.length?x+A.join("&"):""},R.parse=function(b){for(var x,I=/([^=?#&]+)=?([^&]*)/g,_={};x=I.exec(b);){var A=O(x[1]),S=O(x[2]);A===null||S===null||A in _||(_[A]=S)}return _}},558:function(){}},a={};function s(u){var R=a[u];if(R!==void 0)return R.exports;var C=a[u]={exports:{}};return e[u].call(C.exports,C,C.exports,s),C.exports}return s.n=function(u){var R=u&&u.__esModule?function(){return u.default}:function(){return u};return s.d(R,{a:R}),R},s.d=function(u,R){for(var C in R)s.o(R,C)&&!s.o(u,C)&&Object.defineProperty(u,C,{enumerable:!0,get:R[C]})},s.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),s.o=function(u,R){return Object.prototype.hasOwnProperty.call(u,R)},s(80)}()},typeof In=="object"&&typeof Ts=="object"?Ts.exports=t():typeof In=="object"?In.mux=t():r.mux=t()})()});var Mn=ao((wi,bs)=>{typeof window!="undefined"&&function(t,e){typeof wi=="object"&&typeof bs=="object"?bs.exports=e():typeof define=="function"&&define.amd?define([],e):typeof wi=="object"?wi.Hls=e():t.Hls=e()}(wi,function(){return function(r){var t={};function e(a){if(t[a])return t[a].exports;var s=t[a]={i:a,l:!1,exports:{}};return r[a].call(s.exports,s,s.exports,e),s.l=!0,s.exports}return e.m=r,e.c=t,e.d=function(a,s,u){e.o(a,s)||Object.defineProperty(a,s,{enumerable:!0,get:u})},e.r=function(a){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},e.t=function(a,s){if(s&1&&(a=e(a)),s&8||s&4&&typeof a=="object"&&a&&a.__esModule)return a;var u=Object.create(null);if(e.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:a}),s&2&&typeof a!="string")for(var R in a)e.d(u,R,function(C){return a[C]}.bind(null,R));return u},e.n=function(a){var s=a&&a.__esModule?function(){return a.default}:function(){return a};return e.d(s,"a",s),s},e.o=function(a,s){return Object.prototype.hasOwnProperty.call(a,s)},e.p="/dist/",e(e.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(r,t,e){"use strict";var a=Object.prototype.hasOwnProperty,s="~";function u(){}Object.create&&(u.prototype=Object.create(null),new u().__proto__||(s=!1));function R(b,x,I){this.fn=b,this.context=x,this.once=I||!1}function C(b,x,I,_,A){if(typeof I!="function")throw new TypeError("The listener must be a function");var S=new R(I,_||b,A),m=s?s+x:x;return b._events[m]?b._events[m].fn?b._events[m]=[b._events[m],S]:b._events[m].push(S):(b._events[m]=S,b._eventsCount++),b}function O(b,x){--b._eventsCount===0?b._events=new u:delete b._events[x]}function L(){this._events=new u,this._eventsCount=0}L.prototype.eventNames=function(){var x=[],I,_;if(this._eventsCount===0)return x;for(_ in I=this._events)a.call(I,_)&&x.push(s?_.slice(1):_);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(I)):x},L.prototype.listeners=function(x){var I=s?s+x:x,_=this._events[I];if(!_)return[];if(_.fn)return[_.fn];for(var A=0,S=_.length,m=new Array(S);A<S;A++)m[A]=_[A].fn;return m},L.prototype.listenerCount=function(x){var I=s?s+x:x,_=this._events[I];return _?_.fn?1:_.length:0},L.prototype.emit=function(x,I,_,A,S,m){var i=s?s+x:x;if(!this._events[i])return!1;var d=this._events[i],p=arguments.length,T,l;if(d.fn){switch(d.once&&this.removeListener(x,d.fn,void 0,!0),p){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,I),!0;case 3:return d.fn.call(d.context,I,_),!0;case 4:return d.fn.call(d.context,I,_,A),!0;case 5:return d.fn.call(d.context,I,_,A,S),!0;case 6:return d.fn.call(d.context,I,_,A,S,m),!0}for(l=1,T=new Array(p-1);l<p;l++)T[l-1]=arguments[l];d.fn.apply(d.context,T)}else{var o=d.length,h;for(l=0;l<o;l++)switch(d[l].once&&this.removeListener(x,d[l].fn,void 0,!0),p){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,I);break;case 3:d[l].fn.call(d[l].context,I,_);break;case 4:d[l].fn.call(d[l].context,I,_,A);break;default:if(!T)for(h=1,T=new Array(p-1);h<p;h++)T[h-1]=arguments[h];d[l].fn.apply(d[l].context,T)}}return!0},L.prototype.on=function(x,I,_){return C(this,x,I,_,!1)},L.prototype.once=function(x,I,_){return C(this,x,I,_,!0)},L.prototype.removeListener=function(x,I,_,A){var S=s?s+x:x;if(!this._events[S])return this;if(!I)return O(this,S),this;var m=this._events[S];if(m.fn)m.fn===I&&(!A||m.once)&&(!_||m.context===_)&&O(this,S);else{for(var i=0,d=[],p=m.length;i<p;i++)(m[i].fn!==I||A&&!m[i].once||_&&m[i].context!==_)&&d.push(m[i]);d.length?this._events[S]=d.length===1?d[0]:d:O(this,S)}return this},L.prototype.removeAllListeners=function(x){var I;return x?(I=s?s+x:x,this._events[I]&&O(this,I)):(this._events=new u,this._eventsCount=0),this},L.prototype.off=L.prototype.removeListener,L.prototype.addListener=L.prototype.on,L.prefixed=s,L.EventEmitter=L,r.exports=L},"./node_modules/url-toolkit/src/url-toolkit.js":function(r,t,e){(function(a){var s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,u=/^(?=([^\/?#]*))\1([^]*)$/,R=/(?:\/|^)\.(?=\/)/g,C=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(L,b,x){if(x=x||{},L=L.trim(),b=b.trim(),!b){if(!x.alwaysNormalize)return L;var I=O.parseURL(L);if(!I)throw new Error("Error trying to parse base URL.");return I.path=O.normalizePath(I.path),O.buildURLFromParts(I)}var _=O.parseURL(b);if(!_)throw new Error("Error trying to parse relative URL.");if(_.scheme)return x.alwaysNormalize?(_.path=O.normalizePath(_.path),O.buildURLFromParts(_)):b;var A=O.parseURL(L);if(!A)throw new Error("Error trying to parse base URL.");if(!A.netLoc&&A.path&&A.path[0]!=="/"){var S=u.exec(A.path);A.netLoc=S[1],A.path=S[2]}A.netLoc&&!A.path&&(A.path="/");var m={scheme:A.scheme,netLoc:_.netLoc,path:null,params:_.params,query:_.query,fragment:_.fragment};if(!_.netLoc&&(m.netLoc=A.netLoc,_.path[0]!=="/"))if(!_.path)m.path=A.path,_.params||(m.params=A.params,_.query||(m.query=A.query));else{var i=A.path,d=i.substring(0,i.lastIndexOf("/")+1)+_.path;m.path=O.normalizePath(d)}return m.path===null&&(m.path=x.alwaysNormalize?O.normalizePath(_.path):_.path),O.buildURLFromParts(m)},parseURL:function(L){var b=s.exec(L);return b?{scheme:b[1]||"",netLoc:b[2]||"",path:b[3]||"",params:b[4]||"",query:b[5]||"",fragment:b[6]||""}:null},normalizePath:function(L){for(L=L.split("").reverse().join("").replace(R,"");L.length!==(L=L.replace(C,"")).length;);return L.split("").reverse().join("")},buildURLFromParts:function(L){return L.scheme+L.netLoc+L.path+L.params+L.query+L.fragment}};r.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(r,t,e){function a(x){var I={};function _(S){if(I[S])return I[S].exports;var m=I[S]={i:S,l:!1,exports:{}};return x[S].call(m.exports,m,m.exports,_),m.l=!0,m.exports}_.m=x,_.c=I,_.i=function(S){return S},_.d=function(S,m,i){_.o(S,m)||Object.defineProperty(S,m,{configurable:!1,enumerable:!0,get:i})},_.r=function(S){Object.defineProperty(S,"__esModule",{value:!0})},_.n=function(S){var m=S&&S.__esModule?function(){return S.default}:function(){return S};return _.d(m,"a",m),m},_.o=function(S,m){return Object.prototype.hasOwnProperty.call(S,m)},_.p="/",_.oe=function(S){throw console.error(S),S};var A=_(_.s=ENTRY_MODULE);return A.default||A}var s="[\\.|\\-|\\+|\\w|/|@]+",u="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+s+").*?\\)";function R(x){return(x+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function C(x){return!isNaN(1*x)}function O(x,I,_){var A={};A[_]=[];var S=I.toString(),m=S.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!m)return A;for(var i=m[1],d=new RegExp("(\\\\n|\\W)"+R(i)+u,"g"),p;p=d.exec(S);)p[3]!=="dll-reference"&&A[_].push(p[3]);for(d=new RegExp("\\("+R(i)+'\\("(dll-reference\\s('+s+'))"\\)\\)'+u,"g");p=d.exec(S);)x[p[2]]||(A[_].push(p[1]),x[p[2]]=e(p[1]).m),A[p[2]]=A[p[2]]||[],A[p[2]].push(p[4]);for(var T=Object.keys(A),l=0;l<T.length;l++)for(var o=0;o<A[T[l]].length;o++)C(A[T[l]][o])&&(A[T[l]][o]=1*A[T[l]][o]);return A}function L(x){var I=Object.keys(x);return I.reduce(function(_,A){return _||x[A].length>0},!1)}function b(x,I){for(var _={main:[I]},A={main:[]},S={main:{}};L(_);)for(var m=Object.keys(_),i=0;i<m.length;i++){var d=m[i],p=_[d],T=p.pop();if(S[d]=S[d]||{},!(S[d][T]||!x[d][T])){S[d][T]=!0,A[d]=A[d]||[],A[d].push(T);for(var l=O(x,x[d][T],d),o=Object.keys(l),h=0;h<o.length;h++)_[o[h]]=_[o[h]]||[],_[o[h]]=_[o[h]].concat(l[o[h]])}}return A}r.exports=function(x,I){I=I||{};var _={main:e.m},A=I.all?{main:Object.keys(_.main)}:b(_,x),S="";Object.keys(A).filter(function(T){return T!=="main"}).forEach(function(T){for(var l=0;A[T][l];)l++;A[T].push(l),_[T][l]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",S=S+"var "+T+" = ("+a.toString().replace("ENTRY_MODULE",JSON.stringify(l))+")({"+A[T].map(function(o){return""+JSON.stringify(o)+": "+_[T][o].toString()}).join(",")+`});
8
+ `}),S=S+"new (("+a.toString().replace("ENTRY_MODULE",JSON.stringify(x))+")({"+A.main.map(function(T){return""+JSON.stringify(T)+": "+_.main[T].toString()}).join(",")+"}))(self);";var m=new window.Blob([S],{type:"text/javascript"});if(I.bare)return m;var i=window.URL||window.webkitURL||window.mozURL||window.msURL,d=i.createObjectURL(m),p=new window.Worker(d);return p.objectURL=d,p}},"./src/config.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"hlsDefaultConfig",function(){return h}),e.d(t,"mergeConfig",function(){return n}),e.d(t,"enableStreamingMode",function(){return c});var a=e("./src/controller/abr-controller.ts"),s=e("./src/controller/audio-stream-controller.ts"),u=e("./src/controller/audio-track-controller.ts"),R=e("./src/controller/subtitle-stream-controller.ts"),C=e("./src/controller/subtitle-track-controller.ts"),O=e("./src/controller/buffer-controller.ts"),L=e("./src/controller/timeline-controller.ts"),b=e("./src/controller/cap-level-controller.ts"),x=e("./src/controller/fps-controller.ts"),I=e("./src/controller/eme-controller.ts"),_=e("./src/controller/cmcd-controller.ts"),A=e("./src/utils/xhr-loader.ts"),S=e("./src/utils/fetch-loader.ts"),m=e("./src/utils/cues.ts"),i=e("./src/utils/mediakeys-helper.ts"),d=e("./src/utils/logger.ts");function p(){return p=Object.assign?Object.assign.bind():function(v){for(var f=1;f<arguments.length;f++){var g=arguments[f];for(var y in g)Object.prototype.hasOwnProperty.call(g,y)&&(v[y]=g[y])}return v},p.apply(this,arguments)}function T(v,f){var g=Object.keys(v);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(v);f&&(y=y.filter(function(M){return Object.getOwnPropertyDescriptor(v,M).enumerable})),g.push.apply(g,y)}return g}function l(v){for(var f=1;f<arguments.length;f++){var g=arguments[f]!=null?arguments[f]:{};f%2?T(Object(g),!0).forEach(function(y){o(v,y,g[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(g)):T(Object(g)).forEach(function(y){Object.defineProperty(v,y,Object.getOwnPropertyDescriptor(g,y))})}return v}function o(v,f,g){return f in v?Object.defineProperty(v,f,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[f]=g,v}var h=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:A.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:a.default,bufferController:O.default,capLevelController:b.default,fpsController:x.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:i.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},E()),{},{subtitleStreamController:R.SubtitleStreamController,subtitleTrackController:C.default,timelineController:L.TimelineController,audioStreamController:s.default,audioTrackController:u.default,emeController:I.default,cmcdController:_.default});function E(){return{cueHandler:m.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 n(v,f){if((f.liveSyncDurationCount||f.liveMaxLatencyDurationCount)&&(f.liveSyncDuration||f.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(f.liveMaxLatencyDurationCount!==void 0&&(f.liveSyncDurationCount===void 0||f.liveMaxLatencyDurationCount<=f.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(f.liveMaxLatencyDuration!==void 0&&(f.liveSyncDuration===void 0||f.liveMaxLatencyDuration<=f.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return p({},v,f)}function c(v){var f=v.loader;if(f!==S.default&&f!==A.default)d.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),v.progressive=!1;else{var g=Object(S.fetchSupported)();g&&(v.loader=S.default,v.progressive=!0,v.enableSoftwareAES=!0,d.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/polyfills/number.ts"),s=e("./src/utils/ewma-bandwidth-estimator.ts"),u=e("./src/events.ts"),R=e("./src/utils/buffer-helper.ts"),C=e("./src/errors.ts"),O=e("./src/types/loader.ts"),L=e("./src/utils/logger.ts");function b(_,A){for(var S=0;S<A.length;S++){var m=A[S];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(_,m.key,m)}}function x(_,A,S){return A&&b(_.prototype,A),S&&b(_,S),Object.defineProperty(_,"prototype",{writable:!1}),_}var I=function(){function _(S){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=S;var m=S.config;this.bwEstimator=new s.default(m.abrEwmaSlowVoD,m.abrEwmaFastVoD,m.abrEwmaDefaultEstimate),this.registerListeners()}var A=_.prototype;return A.registerListeners=function(){var m=this.hls;m.on(u.Events.FRAG_LOADING,this.onFragLoading,this),m.on(u.Events.FRAG_LOADED,this.onFragLoaded,this),m.on(u.Events.FRAG_BUFFERED,this.onFragBuffered,this),m.on(u.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.on(u.Events.ERROR,this.onError,this)},A.unregisterListeners=function(){var m=this.hls;m.off(u.Events.FRAG_LOADING,this.onFragLoading,this),m.off(u.Events.FRAG_LOADED,this.onFragLoaded,this),m.off(u.Events.FRAG_BUFFERED,this.onFragBuffered,this),m.off(u.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.off(u.Events.ERROR,this.onError,this)},A.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},A.onFragLoading=function(m,i){var d=i.frag;if(d.type===O.PlaylistLevelType.MAIN&&!this.timer){var p;this.fragCurrent=d,this.partCurrent=(p=i.part)!=null?p:null,this.timer=self.setInterval(this.onCheck,100)}},A.onLevelLoaded=function(m,i){var d=this.hls.config;i.details.live?this.bwEstimator.update(d.abrEwmaSlowLive,d.abrEwmaFastLive):this.bwEstimator.update(d.abrEwmaSlowVoD,d.abrEwmaFastVoD)},A._abandonRulesCheck=function(){var m=this.fragCurrent,i=this.partCurrent,d=this.hls,p=d.autoLevelEnabled,T=d.config,l=d.media;if(!(!m||!l)){var o=i?i.stats:m.stats,h=i?i.duration:m.duration;if(o.aborted){L.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!p||l.paused||!l.playbackRate||!l.readyState)){var E=performance.now()-o.loading.start,n=Math.abs(l.playbackRate);if(!(E<=500*h/n)){var c=d.levels,v=d.minAutoLevel,f=c[m.level],g=o.total||Math.max(o.loaded,Math.round(h*f.maxBitrate/8)),y=Math.max(1,o.bwEstimate?o.bwEstimate/8:o.loaded*1e3/E),M=(g-o.loaded)/y,D=l.currentTime,P=(R.BufferHelper.bufferInfo(l,D,T.maxBufferHole).end-D)/n;if(!(P>=2*h/n||M<=P)){var B=Number.POSITIVE_INFINITY,N;for(N=m.level-1;N>v;N--){var F=c[N].maxBitrate;if(B=h*F/(8*.8*y),B<P)break}if(!(B>=M)){var H=this.bwEstimator.getEstimate();L.logger.warn("Fragment "+m.sn+(i?" part "+i.index:"")+" of level "+m.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+N+`
9
+ Current BW estimate: `+(Object(a.isFiniteNumber)(H)?(H/1024).toFixed(3):"Unknown")+` Kb/s
10
10
  Estimated load time for current fragment: `+M.toFixed(3)+` s
11
11
  Estimated load time for the next fragment: `+B.toFixed(3)+` s
12
- Time to underbuffer: `+P.toFixed(3)+" s"),d.nextLoadLevel=N,this.bwEstimator.sample(E,o.loaded),this.clearTimer(),v.loader&&(this.fragCurrent=this.partCurrent=null,v.loader.abort()),d.trigger(u.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:v,part:i,stats:o})}}}}}},A.onFragLoaded=function(v,i){var d=i.frag,p=i.part;if(d.type===O.PlaylistLevelType.MAIN&&Object(s.isFiniteNumber)(d.sn)){var T=p?p.stats:d.stats,l=p?p.duration:d.duration;if(this.clearTimer(),this.lastLoadedFragLevel=d.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var o=this.hls.levels[d.level],h=(o.loaded?o.loaded.bytes:0)+T.loaded,E=(o.loaded?o.loaded.duration:0)+l;o.loaded={bytes:h,duration:E},o.realBitrate=Math.round(8*h/E)}if(d.bitrateTest){var n={stats:T,frag:d,part:p,id:d.type};this.onFragBuffered(u.Events.FRAG_BUFFERED,n)}}},A.onFragBuffered=function(v,i){var d=i.frag,p=i.part,T=p?p.stats:d.stats;if(!T.aborted&&!(d.type!==O.PlaylistLevelType.MAIN||d.sn==="initSegment")){var l=T.parsing.end-T.loading.start;this.bwEstimator.sample(l,T.loaded),T.bwEstimate=this.bwEstimator.getEstimate(),d.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}},A.onError=function(v,i){switch(i.details){case C.ErrorDetails.FRAG_LOAD_ERROR:case C.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},A.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},A.getNextABRAutoLevel=function(){var v=this.fragCurrent,i=this.partCurrent,d=this.hls,p=d.maxAutoLevel,T=d.config,l=d.minAutoLevel,o=d.media,h=i?i.duration:v?v.duration:0,E=o?o.currentTime:0,n=o&&o.playbackRate!==0?Math.abs(o.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():T.abrEwmaDefaultEstimate,m=(R.BufferHelper.bufferInfo(o,E,T.maxBufferHole).end-E)/n,f=this.findBestLevel(c,l,p,m,T.abrBandWidthFactor,T.abrBandWidthUpFactor);if(f>=0)return f;L.logger.trace((m?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var g=h?Math.min(h,T.maxStarvationDelay):T.maxStarvationDelay,y=T.abrBandWidthFactor,M=T.abrBandWidthUpFactor;if(!m){var D=this.bitrateTestDelay;if(D){var P=h?Math.min(h,T.maxLoadingDelay):T.maxLoadingDelay;g=P-D,L.logger.trace("bitrate test took "+Math.round(1e3*D)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),y=M=1}}return f=this.findBestLevel(c,l,p,m+g,y,M),Math.max(f,0)},A.findBestLevel=function(v,i,d,p,T,l){for(var o,h=this.fragCurrent,E=this.partCurrent,n=this.lastLoadedFragLevel,c=this.hls.levels,m=c[n],f=!!(m!=null&&(o=m.details)!==null&&o!==void 0&&o.live),g=m==null?void 0:m.codecSet,y=E?E.duration:h?h.duration:0,M=d;M>=i;M--){var D=c[M];if(!(!D||g&&D.codecSet!==g)){var P=D.details,B=(E?P==null?void 0:P.partTarget:P==null?void 0:P.averagetargetduration)||y,N=void 0;M<=n?N=T*v:N=l*v;var F=c[M].maxBitrate,H=F*B/N;if(L.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+M+"/"+Math.round(N)+"/"+F+"/"+B+"/"+p+"/"+H),N>F&&(!H||f&&!this.bitrateTestDelay||H<p))return M}}return-1},x(_,[{key:"nextAutoLevel",get:function(){var v=this._nextAutoLevel,i=this.bwEstimator;if(v!==-1&&!i.canEstimate())return v;var d=this.getNextABRAutoLevel();return v!==-1&&this.hls.levels[d].loadError?v:(v!==-1&&(d=Math.min(v,d)),d)},set:function(v){this._nextAutoLevel=v}}]),_}();t.default=I},"./src/controller/audio-stream-controller.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/polyfills/number.ts"),a=e("./src/controller/base-stream-controller.ts"),u=e("./src/events.ts"),R=e("./src/utils/buffer-helper.ts"),C=e("./src/controller/fragment-tracker.ts"),O=e("./src/types/level.ts"),L=e("./src/types/loader.ts"),b=e("./src/loader/fragment.ts"),x=e("./src/demux/chunk-cache.ts"),I=e("./src/demux/transmuxer-interface.ts"),_=e("./src/types/transmuxer.ts"),A=e("./src/controller/fragment-finders.ts"),S=e("./src/utils/discontinuities.ts"),v=e("./src/errors.ts");function i(){return i=Object.assign?Object.assign.bind():function(o){for(var h=1;h<arguments.length;h++){var E=arguments[h];for(var n in E)Object.prototype.hasOwnProperty.call(E,n)&&(o[n]=E[n])}return o},i.apply(this,arguments)}function d(o,h){o.prototype=Object.create(h.prototype),o.prototype.constructor=o,p(o,h)}function p(o,h){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,c){return n.__proto__=c,n},p(o,h)}var T=100,l=function(o){d(h,o);function h(n,c){var m;return m=o.call(this,n,c,"[audio-stream-controller]")||this,m.videoBuffer=null,m.videoTrackCC=-1,m.waitingVideoCC=-1,m.audioSwitch=!1,m.trackId=-1,m.waitingData=null,m.mainDetails=null,m.bufferFlushed=!1,m.cachedTrackLoadedData=null,m._registerListeners(),m}var E=h.prototype;return E.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},E._registerListeners=function(){var c=this.hls;c.on(u.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(u.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(u.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(u.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(u.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),c.on(u.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.on(u.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),c.on(u.Events.ERROR,this.onError,this),c.on(u.Events.BUFFER_RESET,this.onBufferReset,this),c.on(u.Events.BUFFER_CREATED,this.onBufferCreated,this),c.on(u.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.on(u.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.on(u.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E._unregisterListeners=function(){var c=this.hls;c.off(u.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(u.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(u.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(u.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(u.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),c.off(u.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.off(u.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),c.off(u.Events.ERROR,this.onError,this),c.off(u.Events.BUFFER_RESET,this.onBufferReset,this),c.off(u.Events.BUFFER_CREATED,this.onBufferCreated,this),c.off(u.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.off(u.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.off(u.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E.onInitPtsFound=function(c,m){var f=m.frag,g=m.id,y=m.initPTS;if(g==="main"){var M=f.cc;this.initPTS[f.cc]=y,this.log("InitPTS for cc: "+M+" found from main: "+y),this.videoTrackCC=M,this.state===a.State.WAITING_INIT_PTS&&this.tick()}},E.startLoad=function(c){if(!this.levels){this.startPosition=c,this.state=a.State.STOPPED;return}var m=this.lastCurrentTime;this.stopLoad(),this.setInterval(T),this.fragLoadError=0,m>0&&c===-1?(this.log("Override startPosition with lastCurrentTime @"+m.toFixed(3)),c=m,this.state=a.State.IDLE):(this.loadedmetadata=!1,this.state=a.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()},E.doTick=function(){switch(this.state){case a.State.IDLE:this.doTickIdle();break;case a.State.WAITING_TRACK:{var c,m=this.levels,f=this.trackId,g=m==null||(c=m[f])===null||c===void 0?void 0:c.details;if(g){if(this.waitForCdnTuneIn(g))break;this.state=a.State.WAITING_INIT_PTS}break}case a.State.FRAG_LOADING_WAITING_RETRY:{var y,M=performance.now(),D=this.retryDate;(!D||M>=D||(y=this.media)!==null&&y!==void 0&&y.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=a.State.IDLE);break}case a.State.WAITING_INIT_PTS:{var P=this.waitingData;if(P){var B=P.frag,N=P.part,F=P.cache,H=P.complete;if(this.initPTS[B.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=a.State.FRAG_LOADING;var V=F.flush(),X={frag:B,part:N,payload:V,networkDetails:null};this._handleFragmentLoadProgress(X),H&&o.prototype._handleFragmentLoadComplete.call(this,X)}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 $=this.getLoadPosition(),j=R.BufferHelper.bufferInfo(this.mediaBuffer,$,this.config.maxBufferHole),J=Object(A.fragmentWithinToleranceTest)(j.end,this.config.maxFragLookUpTolerance,B);J<0&&(this.log("Waiting fragment cc ("+B.cc+") @ "+B.start+" cancelled because another fragment at "+j.end+" is needed"),this.clearWaitingFragment())}}else this.state=a.State.IDLE}}this.onTickEnd()},E.clearWaitingFragment=function(){var c=this.waitingData;c&&(this.fragmentTracker.removeFragment(c.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=a.State.IDLE)},E.resetLoadingState=function(){this.clearWaitingFragment(),o.prototype.resetLoadingState.call(this)},E.onTickEnd=function(){var c=this.media;if(!(!c||!c.readyState)){var m=this.mediaBuffer?this.mediaBuffer:c,f=m.buffered;!this.loadedmetadata&&f.length&&(this.loadedmetadata=!0),this.lastCurrentTime=c.currentTime}},E.doTickIdle=function(){var c,m,f=this.hls,g=this.levels,y=this.media,M=this.trackId,D=f.config;if(!(!g||!g[M])&&!(!y&&(this.startFragRequested||!D.startFragPrefetch))){var P=g[M],B=P.details;if(!B||B.live&&this.levelLastLoaded!==M||this.waitForCdnTuneIn(B)){this.state=a.State.WAITING_TRACK;return}var N=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&N&&(this.bufferFlushed=!1,this.afterBufferFlushed(N,b.ElementaryStreamTypes.AUDIO,L.PlaylistLevelType.AUDIO));var F=this.getFwdBufferInfo(N,L.PlaylistLevelType.AUDIO);if(F!==null){var H=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,L.PlaylistLevelType.MAIN),V=F.len,X=this.getMaxBufferLength(H==null?void 0:H.len),$=this.audioSwitch;if(!(V>=X&&!$)){if(!$&&this._streamEnded(F,B)){f.trigger(u.Events.BUFFER_EOS,{type:"audio"}),this.state=a.State.ENDED;return}var j=B.fragments,J=j[0].start,ee=F.end;if($&&y){var te=this.getLoadPosition();ee=te,B.PTSKnown&&te<J&&(F.end>J||F.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),y.currentTime=J+.05)}if(!(H&&ee>H.end+B.targetduration)&&!((!H||!H.len)&&F.len)){var se=this.getNextFragment(ee,B);if(!se){this.bufferFlushed=!0;return}((c=se.decryptdata)===null||c===void 0?void 0:c.keyFormat)==="identity"&&!((m=se.decryptdata)!==null&&m!==void 0&&m.key)?this.loadKey(se,B):this.loadFragment(se,B,ee)}}}}},E.getMaxBufferLength=function(c){var m=o.prototype.getMaxBufferLength.call(this);return c?Math.max(m,c):m},E.onMediaDetaching=function(){this.videoBuffer=null,o.prototype.onMediaDetaching.call(this)},E.onAudioTracksUpdated=function(c,m){var f=m.audioTracks;this.resetTransmuxer(),this.levels=f.map(function(g){return new O.Level(g)})},E.onAudioTrackSwitching=function(c,m){var f=!!m.url;this.trackId=m.id;var g=this.fragCurrent;g!=null&&g.loader&&g.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),f?this.setInterval(T):this.resetTransmuxer(),f?(this.audioSwitch=!0,this.state=a.State.IDLE):this.state=a.State.STOPPED,this.tick()},E.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},E.onLevelLoaded=function(c,m){this.mainDetails=m.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(u.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},E.onAudioTrackLoaded=function(c,m){var f;if(this.mainDetails==null){this.cachedTrackLoadedData=m;return}var g=this.levels,y=m.details,M=m.id;if(!g){this.warn("Audio tracks were reset while loading level "+M);return}this.log("Track "+M+" loaded ["+y.startSN+","+y.endSN+"],duration:"+y.totalduration);var D=g[M],P=0;if(y.live||(f=D.details)!==null&&f!==void 0&&f.live){var B=this.mainDetails;if(y.fragments[0]||(y.deltaUpdateFailed=!0),y.deltaUpdateFailed||!B)return;!D.details&&y.hasProgramDateTime&&B.hasProgramDateTime?(Object(S.alignMediaPlaylistByPDT)(y,B),P=y.fragments[0].start):P=this.alignPlaylists(y,D.details)}D.details=y,this.levelLastLoaded=M,!this.startFragRequested&&(this.mainDetails||!y.live)&&this.setStartPosition(D.details,P),this.state===a.State.WAITING_TRACK&&!this.waitForCdnTuneIn(y)&&(this.state=a.State.IDLE),this.tick()},E._handleFragmentLoadProgress=function(c){var m,f=c.frag,g=c.part,y=c.payload,M=this.config,D=this.trackId,P=this.levels;if(!P){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+f.sn+" of level "+f.level+" will not be buffered");return}var B=P[D];console.assert(B,"Audio track is defined on fragment load progress");var N=B.details;console.assert(N,"Audio track details are defined on fragment load progress");var F=M.defaultAudioCodec||B.audioCodec||"mp4a.40.2",H=this.transmuxer;H||(H=this.transmuxer=new I.default(this.hls,L.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var V=this.initPTS[f.cc],X=(m=f.initSegment)===null||m===void 0?void 0:m.data;if(V!==void 0){var $=!1,j=g?g.index:-1,J=j!==-1,ee=new _.ChunkMetadata(f.level,f.sn,f.stats.chunkCount,y.byteLength,j,J);H.push(y,X,F,"",f,g,N.totalduration,$,ee,V)}else{this.log("Unknown video PTS for cc "+f.cc+", waiting for video PTS before demuxing audio frag "+f.sn+" of ["+N.startSN+" ,"+N.endSN+"],track "+D);var te=this.waitingData=this.waitingData||{frag:f,part:g,cache:new x.default,complete:!1},se=te.cache;se.push(new Uint8Array(y)),this.waitingVideoCC=this.videoTrackCC,this.state=a.State.WAITING_INIT_PTS}},E._handleFragmentLoadComplete=function(c){if(this.waitingData){this.waitingData.complete=!0;return}o.prototype._handleFragmentLoadComplete.call(this,c)},E.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},E.onBufferCreated=function(c,m){var f=m.tracks.audio;f&&(this.mediaBuffer=f.buffer||null),m.tracks.video&&(this.videoBuffer=m.tracks.video.buffer||null)},E.onFragBuffered=function(c,m){var f=m.frag,g=m.part;if(f.type===L.PlaylistLevelType.AUDIO){if(this.fragContextChanged(f)){this.warn("Fragment "+f.sn+(g?" p: "+g.index:"")+" of level "+f.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}f.sn!=="initSegment"&&(this.fragPrevious=f,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(u.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(f,g)}},E.onError=function(c,m){switch(m.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(L.PlaylistLevelType.AUDIO,m);break;case v.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case v.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==a.State.ERROR&&this.state!==a.State.STOPPED&&(this.state=m.fatal?a.State.ERROR:a.State.IDLE,this.warn(m.details+" while loading frag, switching to "+this.state+" state"));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if(m.parent==="audio"&&(this.state===a.State.PARSING||this.state===a.State.PARSED)){var f=!0,g=this.getFwdBufferInfo(this.mediaBuffer,L.PlaylistLevelType.AUDIO);g&&g.len>.5&&(f=!this.reduceMaxBufferLength(g.len)),f&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,o.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},E.onBufferFlushed=function(c,m){var f=m.type;f===b.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},E._handleTransmuxComplete=function(c){var m,f="audio",g=this.hls,y=c.remuxResult,M=c.chunkMeta,D=this.getCurrentContext(M);if(!D){this.warn("The loading context changed while buffering fragment "+M.sn+" of level "+M.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(M.level);return}var P=D.frag,B=D.part,N=D.level.details,F=y.audio,H=y.text,V=y.id3,X=y.initSegment;if(!(this.fragContextChanged(P)||!N)){if(this.state=a.State.PARSING,this.audioSwitch&&F&&this.completeAudioSwitch(),X!=null&&X.tracks&&(this._bufferInitSegment(X.tracks,P,M),g.trigger(u.Events.FRAG_PARSING_INIT_SEGMENT,{frag:P,id:f,tracks:X.tracks})),F){var $=F.startPTS,j=F.endPTS,J=F.startDTS,ee=F.endDTS;B&&(B.elementaryStreams[b.ElementaryStreamTypes.AUDIO]={startPTS:$,endPTS:j,startDTS:J,endDTS:ee}),P.setElementaryStreamInfo(b.ElementaryStreamTypes.AUDIO,$,j,J,ee),this.bufferFragmentData(F,P,B,M)}if(V!=null&&(m=V.samples)!==null&&m!==void 0&&m.length){var te=i({id:f,frag:P,details:N},V);g.trigger(u.Events.FRAG_PARSING_METADATA,te)}if(H){var se=i({id:f,frag:P,details:N},H);g.trigger(u.Events.FRAG_PARSING_USERDATA,se)}}},E._bufferInitSegment=function(c,m,f){if(this.state===a.State.PARSING){c.video&&delete c.video;var g=c.audio;if(!!g){g.levelCodec=g.codec,g.id="audio",this.log("Init audio buffer, container:"+g.container+", codecs[parsed]=["+g.codec+"]"),this.hls.trigger(u.Events.BUFFER_CODECS,c);var y=g.initSegment;if(y!=null&&y.byteLength){var M={type:"audio",frag:m,part:null,chunkMeta:f,parent:m.type,data:y};this.hls.trigger(u.Events.BUFFER_APPENDING,M)}this.tick()}}},E.loadFragment=function(c,m,f){var g=this.fragmentTracker.getState(c);this.fragCurrent=c,(this.audioSwitch||g===C.FragmentState.NOT_LOADED||g===C.FragmentState.PARTIAL)&&(c.sn==="initSegment"?this._loadInitSegment(c):m.live&&!Object(s.isFiniteNumber)(this.initPTS[c.cc])?(this.log("Waiting for video PTS in continuity counter "+c.cc+" of live stream before loading audio fragment "+c.sn+" of level "+this.trackId),this.state=a.State.WAITING_INIT_PTS):(this.startFragRequested=!0,o.prototype.loadFragment.call(this,c,m,f)))},E.completeAudioSwitch=function(){var c=this.hls,m=this.media,f=this.trackId;m&&(this.log("Switching audio track : flushing all audio"),o.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,c.trigger(u.Events.AUDIO_TRACK_SWITCHED,{id:f})},h}(a.default);t.default=l},"./src/controller/audio-track-controller.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/events.ts"),a=e("./src/errors.ts"),u=e("./src/controller/base-playlist-controller.ts"),R=e("./src/types/loader.ts");function C(I,_){for(var A=0;A<_.length;A++){var S=_[A];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(I,S.key,S)}}function O(I,_,A){return _&&C(I.prototype,_),A&&C(I,A),Object.defineProperty(I,"prototype",{writable:!1}),I}function L(I,_){I.prototype=Object.create(_.prototype),I.prototype.constructor=I,b(I,_)}function b(I,_){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(S,v){return S.__proto__=v,S},b(I,_)}var x=function(I){L(_,I);function _(S){var v;return v=I.call(this,S,"[audio-track-controller]")||this,v.tracks=[],v.groupId=null,v.tracksInGroup=[],v.trackId=-1,v.trackName="",v.selectDefaultTrack=!0,v.registerListeners(),v}var A=_.prototype;return A.registerListeners=function(){var v=this.hls;v.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.on(s.Events.LEVEL_LOADING,this.onLevelLoading,this),v.on(s.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),v.on(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),v.on(s.Events.ERROR,this.onError,this)},A.unregisterListeners=function(){var v=this.hls;v.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.off(s.Events.LEVEL_LOADING,this.onLevelLoading,this),v.off(s.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),v.off(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),v.off(s.Events.ERROR,this.onError,this)},A.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,I.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(v,i){this.tracks=i.audioTracks||[]},A.onAudioTrackLoaded=function(v,i){var d=i.id,p=i.details,T=this.tracksInGroup[d];if(!T){this.warn("Invalid audio track id "+d);return}var l=T.details;T.details=i.details,this.log("audioTrack "+d+" loaded ["+p.startSN+"-"+p.endSN+"]"),d===this.trackId&&(this.retryCount=0,this.playlistLoaded(d,i,l))},A.onLevelLoading=function(v,i){this.switchLevel(i.level)},A.onLevelSwitching=function(v,i){this.switchLevel(i.level)},A.switchLevel=function(v){var i=this.hls.levels[v];if(!!(i!=null&&i.audioGroupIds)){var d=i.audioGroupIds[i.urlId];if(this.groupId!==d){this.groupId=d;var p=this.tracks.filter(function(l){return!d||l.groupId===d});this.selectDefaultTrack&&!p.some(function(l){return l.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=p;var T={audioTracks:p};this.log("Updating audio tracks, "+p.length+' track(s) found in "'+d+'" group-id'),this.hls.trigger(s.Events.AUDIO_TRACKS_UPDATED,T),this.selectInitialTrack()}}},A.onError=function(v,i){I.prototype.onError.call(this,v,i),!(i.fatal||!i.context)&&i.context.type===R.PlaylistContextType.AUDIO_TRACK&&i.context.id===this.trackId&&i.context.groupId===this.groupId&&this.retryLoadingOrFail(i)},A.setAudioTrack=function(v){var i=this.tracksInGroup;if(v<0||v>=i.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var d=i[this.trackId];this.log("Now switching to audio-track index "+v);var p=i[v],T=p.id,l=p.groupId,o=l===void 0?"":l,h=p.name,E=p.type,n=p.url;if(this.trackId=v,this.trackName=h,this.selectDefaultTrack=!1,this.hls.trigger(s.Events.AUDIO_TRACK_SWITCHING,{id:T,groupId:o,name:h,type:E,url:n}),!(p.details&&!p.details.live)){var c=this.switchParams(p.url,d==null?void 0:d.details);this.loadPlaylist(c)}},A.selectInitialTrack=function(){var v=this.tracksInGroup;console.assert(v.length,"Initial audio track should be selected when tracks are known");var i=this.trackName,d=this.findTrackId(i)||this.findTrackId();d!==-1?this.setAudioTrack(d):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},A.findTrackId=function(v){for(var i=this.tracksInGroup,d=0;d<i.length;d++){var p=i[d];if((!this.selectDefaultTrack||p.default)&&(!v||v===p.name))return p.id}return-1},A.loadPlaylist=function(v){var i=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(i)){var d=i.id,p=i.groupId,T=i.url;if(v)try{T=v.addDirectives(T)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("loading audio-track playlist for id: "+d),this.clearTimer(),this.hls.trigger(s.Events.AUDIO_TRACK_LOADING,{url:T,id:d,groupId:p,deliveryDirectives:v||null})}},O(_,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(v){this.selectDefaultTrack=!1,this.setAudioTrack(v)}}]),_}(u.default);t.default=x},"./src/controller/base-playlist-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return O});var s=e("./src/polyfills/number.ts"),a=e("./src/types/level.ts"),u=e("./src/controller/level-helper.ts"),R=e("./src/utils/logger.ts"),C=e("./src/errors.ts"),O=function(){function L(x,I){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=R.logger.log.bind(R.logger,I+":"),this.warn=R.logger.warn.bind(R.logger,I+":"),this.hls=x}var b=L.prototype;return b.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},b.onError=function(I,_){_.fatal&&_.type===C.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},b.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},b.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},b.stopLoad=function(){this.canLoad=!1,this.clearTimer()},b.switchParams=function(I,_){var A=_==null?void 0:_.renditionReports;if(A)for(var S=0;S<A.length;S++){var v=A[S],i=""+v.URI;if(i===I.slice(-i.length)){var d=parseInt(v["LAST-MSN"]),p=parseInt(v["LAST-PART"]);if(_&&this.hls.config.lowLatencyMode){var T=Math.min(_.age-_.partTarget,_.targetduration);p!==void 0&&T>_.partTarget&&(p+=1)}if(Object(s.isFiniteNumber)(d))return new a.HlsUrlParameters(d,Object(s.isFiniteNumber)(p)?p:void 0,a.HlsSkip.No)}}},b.loadPlaylist=function(I){},b.shouldLoadTrack=function(I){return this.canLoad&&I&&!!I.url&&(!I.details||I.details.live)},b.playlistLoaded=function(I,_,A){var S=this,v=_.details,i=_.stats,d=i.loading.end?Math.max(0,self.performance.now()-i.loading.end):0;if(v.advancedDateTime=Date.now()-d,v.live||A!=null&&A.live){if(v.reloaded(A),A&&this.log("live playlist "+I+" "+(v.advanced?"REFRESHED "+v.lastPartSn+"-"+v.lastPartIndex:"MISSED")),A&&v.fragments.length>0&&Object(u.mergeDetails)(A,v),!this.canLoad||!v.live)return;var p,T=void 0,l=void 0;if(v.canBlockReload&&v.endSN&&v.advanced){var o=this.hls.config.lowLatencyMode,h=v.lastPartSn,E=v.endSN,n=v.lastPartIndex,c=n!==-1,m=h===E,f=o?0:n;c?(T=m?E+1:h,l=m?f:n+1):T=E+1;var g=v.age,y=g+v.ageHeader,M=Math.min(y-v.partTarget,v.targetduration*1.5);if(M>0){if(A&&M>A.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+A.tuneInGoal+" to: "+M+" with playlist age: "+v.age),M=0;else{var D=Math.floor(M/v.targetduration);if(T+=D,l!==void 0){var P=Math.round(M%v.targetduration/v.partTarget);l+=P}this.log("CDN Tune-in age: "+v.ageHeader+"s last advanced "+g.toFixed(2)+"s goal: "+M+" skip sn "+D+" to part "+l)}v.tuneInGoal=M}if(p=this.getDeliveryDirectives(v,_.deliveryDirectives,T,l),o||!m){this.loadPlaylist(p);return}}else p=this.getDeliveryDirectives(v,_.deliveryDirectives,T,l);var B=Object(u.computeReloadInterval)(v,i);T!==void 0&&v.canBlockReload&&(B-=v.partTarget||1),this.log("reload live playlist "+I+" in "+Math.round(B)+" ms"),this.timer=self.setTimeout(function(){return S.loadPlaylist(p)},B)}else this.clearTimer()},b.getDeliveryDirectives=function(I,_,A,S){var v=Object(a.getSkipValue)(I,A);return _!=null&&_.skip&&I.deltaUpdateFailed&&(A=_.msn,S=_.part,v=a.HlsSkip.No),new a.HlsUrlParameters(A,S,v)},b.retryLoadingOrFail=function(I){var _=this,A=this.hls.config,S=this.retryCount<A.levelLoadingMaxRetry;if(S){var v;if(this.retryCount++,I.details.indexOf("LoadTimeOut")>-1&&(v=I.context)!==null&&v!==void 0&&v.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+I.details+'"'),this.loadPlaylist();else{var i=Math.min(Math.pow(2,this.retryCount)*A.levelLoadingRetryDelay,A.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return _.loadPlaylist()},i),this.warn("retry playlist loading #"+this.retryCount+" in "+i+' ms after "'+I.details+'"')}}else this.warn('cannot recover from error "'+I.details+'"'),this.clearTimer(),I.fatal=!0;return S},L}()},"./src/controller/base-stream-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"State",function(){return E}),e.d(t,"default",function(){return n});var s=e("./src/polyfills/number.ts"),a=e("./src/task-loop.ts"),u=e("./src/controller/fragment-tracker.ts"),R=e("./src/utils/buffer-helper.ts"),C=e("./src/utils/logger.ts"),O=e("./src/events.ts"),L=e("./src/errors.ts"),b=e("./src/types/transmuxer.ts"),x=e("./src/utils/mp4-tools.ts"),I=e("./src/utils/discontinuities.ts"),_=e("./src/controller/fragment-finders.ts"),A=e("./src/controller/level-helper.ts"),S=e("./src/loader/fragment-loader.ts"),v=e("./src/crypt/decrypter.ts"),i=e("./src/utils/time-ranges.ts"),d=e("./src/types/loader.ts");function p(c,m){for(var f=0;f<m.length;f++){var g=m[f];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(c,g.key,g)}}function T(c,m,f){return m&&p(c.prototype,m),f&&p(c,f),Object.defineProperty(c,"prototype",{writable:!1}),c}function l(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function o(c,m){c.prototype=Object.create(m.prototype),c.prototype.constructor=c,h(c,m)}function h(c,m){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,y){return g.__proto__=y,g},h(c,m)}var E={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"},n=function(c){o(m,c);function m(g,y,M){var D;return D=c.call(this)||this,D.hls=void 0,D.fragPrevious=null,D.fragCurrent=null,D.fragmentTracker=void 0,D.transmuxer=null,D._state=E.STOPPED,D.media=null,D.mediaBuffer=null,D.config=void 0,D.bitrateTest=!1,D.lastCurrentTime=0,D.nextLoadPosition=0,D.startPosition=0,D.loadedmetadata=!1,D.fragLoadError=0,D.retryDate=0,D.levels=null,D.fragmentLoader=void 0,D.levelLastLoaded=null,D.startFragRequested=!1,D.decrypter=void 0,D.initPTS=[],D.onvseeking=null,D.onvended=null,D.logPrefix="",D.log=void 0,D.warn=void 0,D.logPrefix=M,D.log=C.logger.log.bind(C.logger,M+":"),D.warn=C.logger.warn.bind(C.logger,M+":"),D.hls=g,D.fragmentLoader=new S.default(g.config),D.fragmentTracker=y,D.config=g.config,D.decrypter=new v.default(g,g.config),g.on(O.Events.KEY_LOADED,D.onKeyLoaded,l(D)),g.on(O.Events.LEVEL_SWITCHING,D.onLevelSwitching,l(D)),D}var f=m.prototype;return f.doTick=function(){this.onTickEnd()},f.onTickEnd=function(){},f.startLoad=function(y){},f.stopLoad=function(){this.fragmentLoader.abort();var y=this.fragCurrent;y&&this.fragmentTracker.removeFragment(y),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=E.STOPPED},f._streamEnded=function(y,M){var D=this.fragCurrent,P=this.fragmentTracker;if(!M.live&&D&&this.media&&D.sn>=M.endSN&&!y.nextStart){var B=M.partList;if(B!=null&&B.length){var N=B[B.length-1],F=R.BufferHelper.isBuffered(this.media,N.start+N.duration/2);return F}var H=P.getState(D);return H===u.FragmentState.PARTIAL||H===u.FragmentState.OK}return!1},f.onMediaAttached=function(y,M){var D=this.media=this.mediaBuffer=M.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),D.addEventListener("seeking",this.onvseeking),D.addEventListener("ended",this.onvended);var P=this.config;this.levels&&P.autoStartLoad&&this.state===E.STOPPED&&this.startLoad(P.startPosition)},f.onMediaDetaching=function(){var y=this.media;y!=null&&y.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),y&&this.onvseeking&&this.onvended&&(y.removeEventListener("seeking",this.onvseeking),y.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},f.onMediaSeeking=function(){var y=this.config,M=this.fragCurrent,D=this.media,P=this.mediaBuffer,B=this.state,N=D?D.currentTime:0,F=R.BufferHelper.bufferInfo(P||D,N,y.maxBufferHole);if(this.log("media seeking to "+(Object(s.isFiniteNumber)(N)?N.toFixed(3):N)+", state: "+B),B===E.ENDED)this.resetLoadingState();else if(M&&!F.len){var H=y.maxFragLookUpTolerance,V=M.start-H,X=M.start+M.duration+H,$=N>X;(N<V||$)&&($&&M.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),M.loader.abort()),this.resetLoadingState())}D&&(this.lastCurrentTime=N),!this.loadedmetadata&&!F.len&&(this.nextLoadPosition=this.startPosition=N),this.tickImmediate()},f.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},f.onKeyLoaded=function(y,M){if(!(this.state!==E.KEY_LOADING||M.frag!==this.fragCurrent||!this.levels)){this.state=E.IDLE;var D=this.levels[M.frag.level].details;D&&this.loadFragment(M.frag,D,M.frag.start)}},f.onLevelSwitching=function(y,M){this.fragLoadError=0},f.onHandlerDestroying=function(){this.stopLoad(),c.prototype.onHandlerDestroying.call(this)},f.onHandlerDestroyed=function(){this.state=E.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,c.prototype.onHandlerDestroyed.call(this)},f.loadKey=function(y,M){this.log("Loading key for "+y.sn+" of ["+M.startSN+"-"+M.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+y.level),this.state=E.KEY_LOADING,this.fragCurrent=y,this.hls.trigger(O.Events.KEY_LOADING,{frag:y})},f.loadFragment=function(y,M,D){this._loadFragForPlayback(y,M,D)},f._loadFragForPlayback=function(y,M,D){var P=this,B=function(F){if(P.fragContextChanged(y)){P.warn("Fragment "+y.sn+(F.part?" p: "+F.part.index:"")+" of level "+y.level+" was dropped during download."),P.fragmentTracker.removeFragment(y);return}y.stats.chunkCount++,P._handleFragmentLoadProgress(F)};this._doFragLoad(y,M,D,B).then(function(N){if(!!N){P.fragLoadError=0;var F=P.state;if(P.fragContextChanged(y)){(F===E.FRAG_LOADING||!P.fragCurrent&&F===E.PARSING)&&(P.fragmentTracker.removeFragment(y),P.state=E.IDLE);return}"payload"in N&&(P.log("Loaded fragment "+y.sn+" of level "+y.level),P.hls.trigger(O.Events.FRAG_LOADED,N)),P._handleFragmentLoadComplete(N)}}).catch(function(N){P.state===E.STOPPED||P.state===E.ERROR||(P.warn(N),P.resetFragmentLoading(y))})},f.flushMainBuffer=function(y,M,D){if(D===void 0&&(D=null),!!(y-M)){var P={startOffset:y,endOffset:M,type:D};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,P)}},f._loadInitSegment=function(y){var M=this;this._doFragLoad(y).then(function(D){if(!D||M.fragContextChanged(y)||!M.levels)throw new Error("init load aborted");return D}).then(function(D){var P=M.hls,B=D.payload,N=y.decryptdata;if(B&&B.byteLength>0&&N&&N.key&&N.iv&&N.method==="AES-128"){var F=self.performance.now();return M.decrypter.webCryptoDecrypt(new Uint8Array(B),N.key.buffer,N.iv.buffer).then(function(H){var V=self.performance.now();return P.trigger(O.Events.FRAG_DECRYPTED,{frag:y,payload:H,stats:{tstart:F,tdecrypt:V}}),D.payload=H,D})}return D}).then(function(D){var P=M.fragCurrent,B=M.hls,N=M.levels;if(!N)throw new Error("init load aborted, missing levels");var F=N[y.level].details;console.assert(F,"Level details are defined when init segment is loaded");var H=y.stats;M.state=E.IDLE,M.fragLoadError=0,y.data=new Uint8Array(D.payload),H.parsing.start=H.buffering.start=self.performance.now(),H.parsing.end=H.buffering.end=self.performance.now(),D.frag===P&&B.trigger(O.Events.FRAG_BUFFERED,{stats:H,frag:P,part:null,id:y.type}),M.tick()}).catch(function(D){M.state===E.STOPPED||M.state===E.ERROR||(M.warn(D),M.resetFragmentLoading(y))})},f.fragContextChanged=function(y){var M=this.fragCurrent;return!y||!M||y.level!==M.level||y.sn!==M.sn||y.urlId!==M.urlId},f.fragBufferedComplete=function(y,M){var D=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+y.type+" sn: "+y.sn+(M?" part: "+M.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+y.level+" "+(D?i.default.toString(R.BufferHelper.getBuffered(D)):"(detached)")),this.state=E.IDLE,D&&(!this.loadedmetadata&&D.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},f.seekToStartPos=function(){},f._handleFragmentLoadComplete=function(y){var M=this.transmuxer;if(!!M){var D=y.frag,P=y.part,B=y.partsLoaded,N=!B||B.length===0||B.some(function(H){return!H}),F=new b.ChunkMetadata(D.level,D.sn,D.stats.chunkCount+1,0,P?P.index:-1,!N);M.flush(F)}},f._handleFragmentLoadProgress=function(y){},f._doFragLoad=function(y,M,D,P){var B=this;if(D===void 0&&(D=null),!this.levels)throw new Error("frag load aborted, missing levels");if(D=Math.max(y.start,D||0),this.config.lowLatencyMode&&M){var N=M.partList;if(N&&P){D>y.end&&M.fragmentHint&&(y=M.fragmentHint);var F=this.getNextPart(N,y,D);if(F>-1){var H=N[F];return this.log("Loading part sn: "+y.sn+" p: "+H.index+" cc: "+y.cc+" of playlist ["+M.startSN+"-"+M.endSN+"] parts [0-"+F+"-"+(N.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(D.toFixed(3))),this.nextLoadPosition=H.start+H.duration,this.state=E.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:y,part:N[F],targetBufferTime:D}),this.doFragPartsLoad(y,N,F,P).catch(function(V){return B.handleFragLoadError(V)})}else if(!y.url||this.loadedEndOfParts(N,D))return Promise.resolve(null)}}return this.log("Loading fragment "+y.sn+" cc: "+y.cc+" "+(M?"of ["+M.startSN+"-"+M.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(D.toFixed(3))),Object(s.isFiniteNumber)(y.sn)&&!this.bitrateTest&&(this.nextLoadPosition=y.start+y.duration),this.state=E.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:y,targetBufferTime:D}),this.fragmentLoader.load(y,P).catch(function(V){return B.handleFragLoadError(V)})},f.doFragPartsLoad=function(y,M,D,P){var B=this;return new Promise(function(N,F){var H=[],V=function X($){var j=M[$];B.fragmentLoader.loadPart(y,j,P).then(function(J){H[j.index]=J;var ee=J.part;B.hls.trigger(O.Events.FRAG_LOADED,J);var te=M[$+1];if(te&&te.fragment===y)X($+1);else return N({frag:y,part:ee,partsLoaded:H})}).catch(F)};V(D)})},f.handleFragLoadError=function(y){var M=y.data;return M&&M.details===L.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(M.frag,M.part):this.hls.trigger(O.Events.ERROR,M),null},f._handleTransmuxerFlush=function(y){var M=this.getCurrentContext(y);if(!M||this.state!==E.PARSING){this.fragCurrent||(this.state=E.IDLE);return}var D=M.frag,P=M.part,B=M.level,N=self.performance.now();D.stats.parsing.end=N,P&&(P.stats.parsing.end=N),this.updateLevelTiming(D,P,B,y.partial)},f.getCurrentContext=function(y){var M=this.levels,D=y.level,P=y.sn,B=y.part;if(!M||!M[D])return this.warn("Levels object was unset while buffering fragment "+P+" of level "+D+". The current chunk will not be buffered."),null;var N=M[D],F=B>-1?Object(A.getPartWith)(N,P,B):null,H=F?F.fragment:Object(A.getFragmentWithSN)(N,P,this.fragCurrent);return H?{frag:H,part:F,level:N}:null},f.bufferFragmentData=function(y,M,D,P){if(!(!y||this.state!==E.PARSING)){var B=y.data1,N=y.data2,F=B;if(B&&N&&(F=Object(x.appendUint8Array)(B,N)),!(!F||!F.length)){var H={type:y.type,frag:M,part:D,chunkMeta:P,parent:M.type,data:F};this.hls.trigger(O.Events.BUFFER_APPENDING,H),y.dropped&&y.independent&&!D&&this.flushBufferGap(M)}}},f.flushBufferGap=function(y){var M=this.media;if(!!M){if(!R.BufferHelper.isBuffered(M,M.currentTime)){this.flushMainBuffer(0,y.start);return}var D=M.currentTime,P=R.BufferHelper.bufferInfo(M,D,0),B=y.duration,N=Math.min(this.config.maxFragLookUpTolerance*2,B*.25),F=Math.max(Math.min(y.start-N,P.end-N),D+N);y.start-F>N&&this.flushMainBuffer(F,y.start)}},f.getFwdBufferInfo=function(y,M){var D=this.config,P=this.getLoadPosition();if(!Object(s.isFiniteNumber)(P))return null;var B=R.BufferHelper.bufferInfo(y,P,D.maxBufferHole);if(B.len===0&&B.nextStart!==void 0){var N=this.fragmentTracker.getBufferedFrag(P,M);if(N&&B.nextStart<N.end)return R.BufferHelper.bufferInfo(y,P,Math.max(B.nextStart,D.maxBufferHole))}return B},f.getMaxBufferLength=function(y){var M=this.config,D;return y?D=Math.max(8*M.maxBufferSize/y,M.maxBufferLength):D=M.maxBufferLength,Math.min(D,M.maxMaxBufferLength)},f.reduceMaxBufferLength=function(y){var M=this.config,D=y||M.maxBufferLength;return M.maxMaxBufferLength>=D?(M.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+M.maxMaxBufferLength+"s"),!0):!1},f.getNextFragment=function(y,M){var D=M.fragments,P=D.length;if(!P)return null;var B=this.config,N=D[0].start,F;if(M.live){var H=B.initialLiveManifestSize;if(P<H)return this.warn("Not enough fragments to start playback (have: "+P+", need: "+H+")"),null;!M.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(F=this.getInitialLiveFragment(M,D),this.startPosition=F?this.hls.liveSyncPosition||F.start:y)}else y<=N&&(F=D[0]);if(!F){var V=B.lowLatencyMode?M.partEnd:M.fragmentEnd;F=this.getFragmentAtPosition(y,V,M)}return this.mapToInitFragWhenRequired(F)},f.mapToInitFragWhenRequired=function(y){return y!=null&&y.initSegment&&!(y!=null&&y.initSegment.data)&&!this.bitrateTest?y.initSegment:y},f.getNextPart=function(y,M,D){for(var P=-1,B=!1,N=!0,F=0,H=y.length;F<H;F++){var V=y[F];if(N=N&&!V.independent,P>-1&&D<V.start)break;var X=V.loaded;!X&&(B||V.independent||N)&&V.fragment===M&&(P=F),B=X}return P},f.loadedEndOfParts=function(y,M){var D=y[y.length-1];return D&&M>D.start&&D.loaded},f.getInitialLiveFragment=function(y,M){var D=this.fragPrevious,P=null;if(D){if(y.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+D.programDateTime),P=Object(_.findFragmentByPDT)(M,D.endProgramDateTime,this.config.maxFragLookUpTolerance)),!P){var B=D.sn+1;if(B>=y.startSN&&B<=y.endSN){var N=M[B-y.startSN];D.cc===N.cc&&(P=N,this.log("Live playlist, switching playlist, load frag with next SN: "+P.sn))}P||(P=Object(_.findFragWithCC)(M,D.cc),P&&this.log("Live playlist, switching playlist, load frag with same CC: "+P.sn))}}else{var F=this.hls.liveSyncPosition;F!==null&&(P=this.getFragmentAtPosition(F,this.bitrateTest?y.fragmentEnd:y.edge,y))}return P},f.getFragmentAtPosition=function(y,M,D){var P=this.config,B=this.fragPrevious,N=D.fragments,F=D.endSN,H=D.fragmentHint,V=P.maxFragLookUpTolerance,X=!!(P.lowLatencyMode&&D.partList&&H);X&&H&&!this.bitrateTest&&(N=N.concat(H),F=H.sn);var $;if(y<M){var j=y>M-V?0:V;$=Object(_.findFragmentByPTS)(B,N,y,j)}else $=N[N.length-1];if($){var J=$.sn-D.startSN;if(B&&$.sn===B.sn&&!X){var ee=B&&$.level===B.level;if(ee){var te=N[J+1];$.sn<F&&this.fragmentTracker.getState(te)!==u.FragmentState.OK?(this.log("SN "+$.sn+" just loaded, load next one: "+te.sn),$=te):$=null}}}return $},f.synchronizeToLiveEdge=function(y){var M=this.config,D=this.media;if(!!D){var P=this.hls.liveSyncPosition,B=D.currentTime,N=y.fragments[0].start,F=y.edge,H=B>=N-M.maxFragLookUpTolerance&&B<=F;if(P!==null&&D.duration>P&&(B<P||!H)){var V=M.liveMaxLatencyDuration!==void 0?M.liveMaxLatencyDuration:M.liveMaxLatencyDurationCount*y.targetduration;(!H&&D.readyState<4||B<F-V)&&(this.loadedmetadata||(this.nextLoadPosition=P),D.readyState&&(this.warn("Playback: "+B.toFixed(3)+" is located too far from the end of live sliding playlist: "+F+", reset currentTime to : "+P.toFixed(3)),D.currentTime=P))}}},f.alignPlaylists=function(y,M){var D=this.levels,P=this.levelLastLoaded,B=this.fragPrevious,N=P!==null?D[P]:null,F=y.fragments.length;if(!F)return this.warn("No fragments in live playlist"),0;var H=y.fragments[0].start,V=!M,X=y.alignedSliding&&Object(s.isFiniteNumber)(H);if(V||!X&&!H){Object(I.alignStream)(B,N,y);var $=y.fragments[0].start;return this.log("Live playlist sliding: "+$.toFixed(2)+" start-sn: "+(M?M.startSN:"na")+"->"+y.startSN+" prev-sn: "+(B?B.sn:"na")+" fragments: "+F),$}return H},f.waitForCdnTuneIn=function(y){var M=3;return y.live&&y.canBlockReload&&y.partTarget&&y.tuneInGoal>Math.max(y.partHoldBack,y.partTarget*M)},f.setStartPosition=function(y,M){var D=this.startPosition;if(D<M&&(D=-1),D===-1||this.lastCurrentTime===-1){var P=y.startTimeOffset;Object(s.isFiniteNumber)(P)?(D=M+P,P<0&&(D+=y.totalduration),D=Math.min(Math.max(M,D),M+y.totalduration),this.log("Start time offset "+P+" found in playlist, adjust startPosition to "+D),this.startPosition=D):y.live?D=this.hls.liveSyncPosition||M:this.startPosition=D=0,this.lastCurrentTime=D}this.nextLoadPosition=D},f.getLoadPosition=function(){var y=this.media,M=0;return this.loadedmetadata&&y?M=y.currentTime:this.nextLoadPosition&&(M=this.nextLoadPosition),M},f.handleFragLoadAborted=function(y,M){this.transmuxer&&y.sn!=="initSegment"&&y.stats.aborted&&(this.warn("Fragment "+y.sn+(M?" part"+M.index:"")+" of level "+y.level+" was aborted"),this.resetFragmentLoading(y))},f.resetFragmentLoading=function(y){(!this.fragCurrent||!this.fragContextChanged(y)&&this.state!==E.FRAG_LOADING_WAITING_RETRY)&&(this.state=E.IDLE)},f.onFragmentOrKeyLoadError=function(y,M){if(!M.fatal){var D=M.frag;if(!(!D||D.type!==y)){var P=this.fragCurrent;console.assert(P&&D.sn===P.sn&&D.level===P.level&&D.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 N=Math.min(Math.pow(2,this.fragLoadError)*B.fragLoadingRetryDelay,B.fragLoadingMaxRetryTimeout);this.warn("Fragment "+D.sn+" of "+y+" "+D.level+" failed to load, retrying in "+N+"ms"),this.retryDate=self.performance.now()+N,this.fragLoadError++,this.state=E.FRAG_LOADING_WAITING_RETRY}else M.levelRetry?(y===d.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=E.IDLE):(C.logger.error(M.details+" reaches max retry, redispatch as fatal ..."),M.fatal=!0,this.hls.stopLoad(),this.state=E.ERROR)}}},f.afterBufferFlushed=function(y,M,D){if(!!y){var P=R.BufferHelper.getBuffered(y);this.fragmentTracker.detectEvictedFragments(M,P,D),this.state===E.ENDED&&this.resetLoadingState()}},f.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=E.IDLE},f.resetStartWhenNotLoaded=function(y){if(!this.loadedmetadata){this.startFragRequested=!1;var M=this.levels?this.levels[y].details:null;M!=null&&M.live?(this.startPosition=-1,this.setStartPosition(M,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},f.updateLevelTiming=function(y,M,D,P){var B=this,N=D.details;console.assert(!!N,"level.details must be defined");var F=Object.keys(y.elementaryStreams).reduce(function(H,V){var X=y.elementaryStreams[V];if(X){var $=X.endPTS-X.startPTS;if($<=0)return B.warn("Could not parse fragment "+y.sn+" "+V+" duration reliably ("+$+")"),H||!1;var j=P?0:Object(A.updateFragPTSDTS)(N,y,X.startPTS,X.endPTS,X.startDTS,X.endDTS);return B.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:N,level:D,drift:j,type:V,frag:y,start:X.startPTS,end:X.endPTS}),!0}return H},!1);F||(this.warn("Found no media in fragment "+y.sn+" of level "+D.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=E.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:y,part:M})},f.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},T(m,[{key:"state",get:function(){return this._state},set:function(y){var M=this._state;M!==y&&(this._state=y,this.log(M+"->"+y))}}]),m}(a.default)},"./src/controller/buffer-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return _});var s=e("./src/polyfills/number.ts"),a=e("./src/events.ts"),u=e("./src/utils/logger.ts"),R=e("./src/errors.ts"),C=e("./src/utils/buffer-helper.ts"),O=e("./src/utils/mediasource-helper.ts"),L=e("./src/loader/fragment.ts"),b=e("./src/controller/buffer-operation-queue.ts"),x=Object(O.getMediaSource)(),I=/([ha]vc.)(?:\.[^.,]+)+/,_=function(){function A(v){var i=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 d=i.hls,p=i.media,T=i.mediaSource;u.logger.log("[buffer-controller]: Media source opened"),p&&(i.updateMediaElementDuration(),d.trigger(a.Events.MEDIA_ATTACHED,{media:p})),T&&T.removeEventListener("sourceopen",i._onMediaSourceOpen),i.checkPendingTracks()},this._onMediaSourceClose=function(){u.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){u.logger.log("[buffer-controller]: Media source ended")},this.hls=v,this._initSourceBuffer(),this.registerListeners()}var S=A.prototype;return S.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},S.destroy=function(){this.unregisterListeners(),this.details=null},S.registerListeners=function(){var i=this.hls;i.on(a.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.on(a.Events.BUFFER_RESET,this.onBufferReset,this),i.on(a.Events.BUFFER_APPENDING,this.onBufferAppending,this),i.on(a.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.on(a.Events.BUFFER_EOS,this.onBufferEos,this),i.on(a.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),i.on(a.Events.LEVEL_UPDATED,this.onLevelUpdated,this),i.on(a.Events.FRAG_PARSED,this.onFragParsed,this),i.on(a.Events.FRAG_CHANGED,this.onFragChanged,this)},S.unregisterListeners=function(){var i=this.hls;i.off(a.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.off(a.Events.BUFFER_RESET,this.onBufferReset,this),i.off(a.Events.BUFFER_APPENDING,this.onBufferAppending,this),i.off(a.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.off(a.Events.BUFFER_EOS,this.onBufferEos,this),i.off(a.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),i.off(a.Events.LEVEL_UPDATED,this.onLevelUpdated,this),i.off(a.Events.FRAG_PARSED,this.onFragParsed,this),i.off(a.Events.FRAG_CHANGED,this.onFragChanged,this)},S._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new b.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},S.onManifestParsed=function(i,d){var p=2;(d.audio&&!d.video||!d.altAudio)&&(p=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=p,this.details=null,u.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},S.onMediaAttaching=function(i,d){var p=this.media=d.media;if(p&&x){var T=this.mediaSource=new x;T.addEventListener("sourceopen",this._onMediaSourceOpen),T.addEventListener("sourceended",this._onMediaSourceEnded),T.addEventListener("sourceclose",this._onMediaSourceClose),p.src=self.URL.createObjectURL(T),this._objectUrl=p.src}},S.onMediaDetaching=function(){var i=this.media,d=this.mediaSource,p=this._objectUrl;if(d){if(u.logger.log("[buffer-controller]: media source detaching"),d.readyState==="open")try{d.endOfStream()}catch(T){u.logger.warn("[buffer-controller]: onMediaDetaching: "+T.message+" while calling endOfStream")}this.onBufferReset(),d.removeEventListener("sourceopen",this._onMediaSourceOpen),d.removeEventListener("sourceended",this._onMediaSourceEnded),d.removeEventListener("sourceclose",this._onMediaSourceClose),i&&(p&&self.URL.revokeObjectURL(p),i.src===p?(i.removeAttribute("src"),i.load()):u.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(a.Events.MEDIA_DETACHED,void 0)},S.onBufferReset=function(){var i=this;this.getSourceBufferTypes().forEach(function(d){var p=i.sourceBuffer[d];try{p&&(i.removeBufferListeners(d),i.mediaSource&&i.mediaSource.removeSourceBuffer(p),i.sourceBuffer[d]=void 0)}catch(T){u.logger.warn("[buffer-controller]: Failed to reset the "+d+" buffer",T)}}),this._initSourceBuffer()},S.onBufferCodecs=function(i,d){var p=this,T=this.getSourceBufferTypes().length;Object.keys(d).forEach(function(l){if(T){var o=p.tracks[l];if(o&&typeof o.buffer.changeType=="function"){var h=d[l],E=h.id,n=h.codec,c=h.levelCodec,m=h.container,f=h.metadata,g=(o.levelCodec||o.codec).replace(I,"$1"),y=(c||n).replace(I,"$1");if(g!==y){var M=m+";codecs="+(c||n);p.appendChangeType(l,M),u.logger.log("[buffer-controller]: switching codec "+g+" to "+y),p.tracks[l]={buffer:o.buffer,codec:n,container:m,levelCodec:c,metadata:f,id:E}}}}else p.pendingTracks[l]=d[l]}),!T&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},S.appendChangeType=function(i,d){var p=this,T=this.operationQueue,l={execute:function(){var h=p.sourceBuffer[i];h&&(u.logger.log("[buffer-controller]: changing "+i+" sourceBuffer type to "+d),h.changeType(d)),T.shiftAndExecuteNext(i)},onStart:function(){},onComplete:function(){},onError:function(h){u.logger.warn("[buffer-controller]: Failed to change "+i+" SourceBuffer type",h)}};T.append(l,i)},S.onBufferAppending=function(i,d){var p=this,T=this.hls,l=this.operationQueue,o=this.tracks,h=d.data,E=d.type,n=d.frag,c=d.part,m=d.chunkMeta,f=m.buffering[E],g=self.performance.now();f.start=g;var y=n.stats.buffering,M=c?c.stats.buffering:null;y.start===0&&(y.start=g),M&&M.start===0&&(M.start=g);var D=o.audio,P=E==="audio"&&m.id===1&&(D==null?void 0:D.container)==="audio/mpeg",B={execute:function(){if(f.executeStart=self.performance.now(),P){var F=p.sourceBuffer[E];if(F){var H=n.start-F.timestampOffset;Math.abs(H)>=.1&&(u.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+n.start+" (delta: "+H+") sn: "+n.sn+")"),F.timestampOffset=n.start)}}p.appendExecutor(h,E)},onStart:function(){},onComplete:function(){var F=self.performance.now();f.executeEnd=f.end=F,y.first===0&&(y.first=F),M&&M.first===0&&(M.first=F);var H=p.sourceBuffer,V={};for(var X in H)V[X]=C.BufferHelper.getBuffered(H[X]);p.appendError=0,p.hls.trigger(a.Events.BUFFER_APPENDED,{type:E,frag:n,part:c,chunkMeta:m,parent:n.type,timeRanges:V})},onError:function(F){u.logger.error("[buffer-controller]: Error encountered while trying to append to the "+E+" SourceBuffer",F);var H={type:R.ErrorTypes.MEDIA_ERROR,parent:n.type,details:R.ErrorDetails.BUFFER_APPEND_ERROR,err:F,fatal:!1};F.code===DOMException.QUOTA_EXCEEDED_ERR?H.details=R.ErrorDetails.BUFFER_FULL_ERROR:(p.appendError++,H.details=R.ErrorDetails.BUFFER_APPEND_ERROR,p.appendError>T.config.appendErrorMaxRetry&&(u.logger.error("[buffer-controller]: Failed "+T.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),H.fatal=!0,T.stopLoad())),T.trigger(a.Events.ERROR,H)}};l.append(B,E)},S.onBufferFlushing=function(i,d){var p=this,T=this.operationQueue,l=function(h){return{execute:p.removeExecutor.bind(p,h,d.startOffset,d.endOffset),onStart:function(){},onComplete:function(){p.hls.trigger(a.Events.BUFFER_FLUSHED,{type:h})},onError:function(n){u.logger.warn("[buffer-controller]: Failed to remove from "+h+" SourceBuffer",n)}}};d.type?T.append(l(d.type),d.type):this.getSourceBufferTypes().forEach(function(o){T.append(l(o),o)})},S.onFragParsed=function(i,d){var p=this,T=d.frag,l=d.part,o=[],h=l?l.elementaryStreams:T.elementaryStreams;h[L.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(h[L.ElementaryStreamTypes.AUDIO]&&o.push("audio"),h[L.ElementaryStreamTypes.VIDEO]&&o.push("video"));var E=function(){var c=self.performance.now();T.stats.buffering.end=c,l&&(l.stats.buffering.end=c);var m=l?l.stats:T.stats;p.hls.trigger(a.Events.FRAG_BUFFERED,{frag:T,part:l,stats:m,id:T.type})};o.length===0&&u.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+T.type+" level: "+T.level+" sn: "+T.sn),this.blockBuffers(E,o)},S.onFragChanged=function(i,d){this.flushBackBuffer()},S.onBufferEos=function(i,d){var p=this,T=this.getSourceBufferTypes().reduce(function(l,o){var h=p.sourceBuffer[o];return(!d.type||d.type===o)&&h&&!h.ended&&(h.ended=!0,u.logger.log("[buffer-controller]: "+o+" sourceBuffer now EOS")),l&&!!(!h||h.ended)},!0);T&&this.blockBuffers(function(){var l=p.mediaSource;!l||l.readyState!=="open"||l.endOfStream()})},S.onLevelUpdated=function(i,d){var p=d.details;!p.fragments.length||(this.details=p,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},S.flushBackBuffer=function(){var i=this.hls,d=this.details,p=this.media,T=this.sourceBuffer;if(!(!p||d===null)){var l=this.getSourceBufferTypes();if(!!l.length){var o=d.live&&i.config.liveBackBufferLength!==null?i.config.liveBackBufferLength:i.config.backBufferLength;if(!(!Object(s.isFiniteNumber)(o)||o<0)){var h=p.currentTime,E=d.levelTargetDuration,n=Math.max(o,E),c=Math.floor(h/E)*E-n;l.forEach(function(m){var f=T[m];if(f){var g=C.BufferHelper.getBuffered(f);g.length>0&&c>g.start(0)&&(i.trigger(a.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),d.live&&i.trigger(a.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c}),i.trigger(a.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:m}))}})}}}},S.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var i=this.details,d=this.hls,p=this.media,T=this.mediaSource,l=i.fragments[0].start+i.totalduration,o=p.duration,h=Object(s.isFiniteNumber)(T.duration)?T.duration:0;i.live&&d.config.liveDurationInfinity?(u.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),T.duration=1/0,this.updateSeekableRange(i)):(l>h&&l>o||!Object(s.isFiniteNumber)(o))&&(u.logger.log("[buffer-controller]: Updating Media Source duration to "+l.toFixed(3)),T.duration=l)}},S.updateSeekableRange=function(i){var d=this.mediaSource,p=i.fragments,T=p.length;if(T&&i.live&&d!==null&&d!==void 0&&d.setLiveSeekableRange){var l=Math.max(0,p[0].start),o=Math.max(l,l+i.totalduration);d.setLiveSeekableRange(l,o)}},S.checkPendingTracks=function(){var i=this.bufferCodecEventsExpected,d=this.operationQueue,p=this.pendingTracks,T=Object.keys(p).length;if(T&&!i||T===2){this.createSourceBuffers(p),this.pendingTracks={};var l=this.getSourceBufferTypes();if(l.length===0){this.hls.trigger(a.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}l.forEach(function(o){d.executeNext(o)})}},S.createSourceBuffers=function(i){var d=this.sourceBuffer,p=this.mediaSource;if(!p)throw Error("createSourceBuffers called when mediaSource was null");var T=0;for(var l in i)if(!d[l]){var o=i[l];if(!o)throw Error("source buffer exists for track "+l+", however track does not");var h=o.levelCodec||o.codec,E=o.container+";codecs="+h;u.logger.log("[buffer-controller]: creating sourceBuffer("+E+")");try{var n=d[l]=p.addSourceBuffer(E),c=l;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[l]={buffer:n,codec:h,container:o.container,levelCodec:o.levelCodec,metadata:o.metadata,id:o.id},T++}catch(m){u.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+m.message),this.hls.trigger(a.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:m,mimeType:E})}}T&&this.hls.trigger(a.Events.BUFFER_CREATED,{tracks:this.tracks})},S._onSBUpdateStart=function(i){var d=this.operationQueue,p=d.current(i);p.onStart()},S._onSBUpdateEnd=function(i){var d=this.operationQueue,p=d.current(i);p.onComplete(),d.shiftAndExecuteNext(i)},S._onSBUpdateError=function(i,d){u.logger.error("[buffer-controller]: "+i+" SourceBuffer error",d),this.hls.trigger(a.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var p=this.operationQueue.current(i);p&&p.onError(d)},S.removeExecutor=function(i,d,p){var T=this.media,l=this.mediaSource,o=this.operationQueue,h=this.sourceBuffer,E=h[i];if(!T||!l||!E){u.logger.warn("[buffer-controller]: Attempting to remove from the "+i+" SourceBuffer, but it does not exist"),o.shiftAndExecuteNext(i);return}var n=Object(s.isFiniteNumber)(T.duration)?T.duration:1/0,c=Object(s.isFiniteNumber)(l.duration)?l.duration:1/0,m=Math.max(0,d),f=Math.min(p,n,c);f>m?(u.logger.log("[buffer-controller]: Removing ["+m+","+f+"] from the "+i+" SourceBuffer"),console.assert(!E.updating,i+" sourceBuffer must not be updating"),E.remove(m,f)):o.shiftAndExecuteNext(i)},S.appendExecutor=function(i,d){var p=this.operationQueue,T=this.sourceBuffer,l=T[d];if(!l){u.logger.warn("[buffer-controller]: Attempting to append to the "+d+" SourceBuffer, but it does not exist"),p.shiftAndExecuteNext(d);return}l.ended=!1,console.assert(!l.updating,d+" sourceBuffer must not be updating"),l.appendBuffer(i)},S.blockBuffers=function(i,d){var p=this;if(d===void 0&&(d=this.getSourceBufferTypes()),!d.length){u.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(i);return}var T=this.operationQueue,l=d.map(function(o){return T.appendBlocker(o)});Promise.all(l).then(function(){i(),d.forEach(function(o){var h=p.sourceBuffer[o];(!h||!h.updating)&&T.shiftAndExecuteNext(o)})})},S.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},S.addBufferListener=function(i,d,p){var T=this.sourceBuffer[i];if(!!T){var l=p.bind(this,i);this.listeners[i].push({event:d,listener:l}),T.addEventListener(d,l)}},S.removeBufferListeners=function(i){var d=this.sourceBuffer[i];!d||this.listeners[i].forEach(function(p){d.removeEventListener(p.event,p.listener)})},A}()},"./src/controller/buffer-operation-queue.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return a});var s=e("./src/utils/logger.ts"),a=function(){function u(C){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=C}var R=u.prototype;return R.append=function(O,L){var b=this.queues[L];b.push(O),b.length===1&&this.buffers[L]&&this.executeNext(L)},R.insertAbort=function(O,L){var b=this.queues[L];b.unshift(O),this.executeNext(L)},R.appendBlocker=function(O){var L,b=new Promise(function(I){L=I}),x={execute:L,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(x,O),b},R.executeNext=function(O){var L=this.buffers,b=this.queues,x=L[O],I=b[O];if(I.length){var _=I[0];try{_.execute()}catch(A){s.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),_.onError(A),(!x||!x.updating)&&(I.shift(),this.executeNext(O))}}},R.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},R.current=function(O){return this.queues[O][0]},u}()},"./src/controller/cap-level-controller.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/events.ts");function a(C,O){for(var L=0;L<O.length;L++){var b=O[L];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(C,b.key,b)}}function u(C,O,L){return O&&a(C.prototype,O),L&&a(C,L),Object.defineProperty(C,"prototype",{writable:!1}),C}var R=function(){function C(L){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=L,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var O=C.prototype;return O.setStreamController=function(b){this.streamController=b},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 b=this.hls;b.on(s.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),b.on(s.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),b.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),b.on(s.Events.BUFFER_CODECS,this.onBufferCodecs,this),b.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var b=this.hls;b.off(s.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),b.off(s.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),b.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),b.off(s.Events.BUFFER_CODECS,this.onBufferCodecs,this),b.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(b,x){C.isLevelAllowed(x.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(x.droppedLevel)},O.onMediaAttaching=function(b,x){this.media=x.media instanceof HTMLVideoElement?x.media:null},O.onManifestParsed=function(b,x){var I=this.hls;this.restrictedLevels=[],this.firstLevel=x.firstLevel,I.config.capLevelToPlayerSize&&x.video&&this.startCapping()},O.onBufferCodecs=function(b,x){var I=this.hls;I.config.capLevelToPlayerSize&&x.video&&this.startCapping()},O.onMediaDetaching=function(){this.stopCapping()},O.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var b=this.hls.levels;if(b.length){var x=this.hls;x.autoLevelCapping=this.getMaxLevel(b.length-1),x.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=x.autoLevelCapping}}},O.getMaxLevel=function(b){var x=this,I=this.hls.levels;if(!I.length)return-1;var _=I.filter(function(A,S){return C.isLevelAllowed(S,x.restrictedLevels)&&S<=b});return this.clientRect=null,C.getMaxLevelByMediaSize(_,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 b=this.media,x={width:0,height:0};if(b){var I=b.getBoundingClientRect();x.width=I.width,x.height=I.height,!x.width&&!x.height&&(x.width=I.right-I.left||b.width||0,x.height=I.bottom-I.top||b.height||0)}return this.clientRect=x,x},C.isLevelAllowed=function(b,x){return x===void 0&&(x=[]),x.indexOf(b)===-1},C.getMaxLevelByMediaSize=function(b,x,I){if(!b||!b.length)return-1;for(var _=function(d,p){return p?d.width!==p.width||d.height!==p.height:!0},A=b.length-1,S=0;S<b.length;S+=1){var v=b[S];if((v.width>=x||v.height>=I)&&_(v,b[S+1])){A=S;break}}return A},u(C,[{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 b=1;if(!this.hls.config.ignoreDevicePixelRatio)try{b=self.devicePixelRatio}catch{}return b}}]),C}();t.default=R},"./src/controller/cmcd-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return _});var s=e("./src/events.ts"),a=e("./src/types/cmcd.ts"),u=e("./src/utils/buffer-helper.ts"),R=e("./src/utils/logger.ts");function C(A,S){for(var v=0;v<S.length;v++){var i=S[v];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(A,i.key,i)}}function O(A,S,v){return S&&C(A.prototype,S),v&&C(A,v),Object.defineProperty(A,"prototype",{writable:!1}),A}function L(A,S){var v=typeof Symbol!="undefined"&&A[Symbol.iterator]||A["@@iterator"];if(v)return(v=v.call(A)).next.bind(v);if(Array.isArray(A)||(v=b(A))||S&&A&&typeof A.length=="number"){v&&(A=v);var i=0;return function(){return i>=A.length?{done:!0}:{done:!1,value:A[i++]}}}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 b(A,S){if(!!A){if(typeof A=="string")return x(A,S);var v=Object.prototype.toString.call(A).slice(8,-1);if(v==="Object"&&A.constructor&&(v=A.constructor.name),v==="Map"||v==="Set")return Array.from(A);if(v==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(v))return x(A,S)}}function x(A,S){(S==null||S>A.length)&&(S=A.length);for(var v=0,i=new Array(S);v<S;v++)i[v]=A[v];return i}function I(){return I=Object.assign?Object.assign.bind():function(A){for(var S=1;S<arguments.length;S++){var v=arguments[S];for(var i in v)Object.prototype.hasOwnProperty.call(v,i)&&(A[i]=v[i])}return A},I.apply(this,arguments)}var _=function(){function A(v){var i=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(){i.initialized&&(i.starved=!0),i.buffering=!0},this.onPlaying=function(){i.initialized||(i.initialized=!0),i.buffering=!1},this.applyPlaylistData=function(T){try{i.apply(T,{ot:a.CMCDObjectType.MANIFEST,su:!i.initialized})}catch(l){R.logger.warn("Could not generate manifest CMCD data.",l)}},this.applyFragmentData=function(T){try{var l=T.frag,o=i.hls.levels[l.level],h=i.getObjectType(l),E={d:l.duration*1e3,ot:h};(h===a.CMCDObjectType.VIDEO||h===a.CMCDObjectType.AUDIO||h==a.CMCDObjectType.MUXED)&&(E.br=o.bitrate/1e3,E.tb=i.getTopBandwidth(h)/1e3,E.bl=i.getBufferLength(h)),i.apply(T,E)}catch(n){R.logger.warn("Could not generate segment CMCD data.",n)}},this.hls=v;var d=this.config=v.config,p=d.cmcd;p!=null&&(d.pLoader=this.createPlaylistLoader(),d.fLoader=this.createFragmentLoader(),this.sid=p.sessionId||A.uuid(),this.cid=p.contentId,this.useHeaders=p.useHeaders===!0,this.registerListeners())}var S=A.prototype;return S.registerListeners=function(){var i=this.hls;i.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.on(s.Events.MEDIA_DETACHED,this.onMediaDetached,this),i.on(s.Events.BUFFER_CREATED,this.onBufferCreated,this)},S.unregisterListeners=function(){var i=this.hls;i.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.off(s.Events.MEDIA_DETACHED,this.onMediaDetached,this),i.off(s.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},S.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},S.onMediaAttached=function(i,d){this.media=d.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},S.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},S.onBufferCreated=function(i,d){var p,T;this.audioBuffer=(p=d.tracks.audio)===null||p===void 0?void 0:p.buffer,this.videoBuffer=(T=d.tracks.video)===null||T===void 0?void 0:T.buffer},S.createData=function(){var i;return{v:a.CMCDVersion,sf:a.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(i=this.media)===null||i===void 0?void 0:i.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},S.apply=function(i,d){d===void 0&&(d={}),I(d,this.createData());var p=d.ot===a.CMCDObjectType.INIT||d.ot===a.CMCDObjectType.VIDEO||d.ot===a.CMCDObjectType.MUXED;if(this.starved&&p&&(d.bs=!0,d.su=!0,this.starved=!1),d.su==null&&(d.su=this.buffering),this.useHeaders){var T=A.toHeaders(d);if(!Object.keys(T).length)return;i.headers||(i.headers={}),I(i.headers,T)}else{var l=A.toQuery(d);if(!l)return;i.url=A.appendQueryToUri(i.url,l)}},S.getObjectType=function(i){var d=i.type;if(d==="subtitle")return a.CMCDObjectType.TIMED_TEXT;if(i.sn==="initSegment")return a.CMCDObjectType.INIT;if(d==="audio")return a.CMCDObjectType.AUDIO;if(d==="main")return this.hls.audioTracks.length?a.CMCDObjectType.VIDEO:a.CMCDObjectType.MUXED},S.getTopBandwidth=function(i){var d=0,p,T=this.hls;if(i===a.CMCDObjectType.AUDIO)p=T.audioTracks;else{var l=T.maxAutoLevel,o=l>-1?l+1:T.levels.length;p=T.levels.slice(0,o)}for(var h=L(p),E;!(E=h()).done;){var n=E.value;n.bitrate>d&&(d=n.bitrate)}return d>0?d:NaN},S.getBufferLength=function(i){var d=this.hls.media,p=i===a.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!p||!d)return NaN;var T=u.BufferHelper.bufferInfo(p,d.currentTime,this.config.maxBufferHole);return T.len*1e3},S.createPlaylistLoader=function(){var i=this.config.pLoader,d=this.applyPlaylistData,p=i||this.config.loader;return function(){function T(o){this.loader=void 0,this.loader=new p(o)}var l=T.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(h,E,n){d(h),this.loader.load(h,E,n)},O(T,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),T}()},S.createFragmentLoader=function(){var i=this.config.fLoader,d=this.applyFragmentData,p=i||this.config.loader;return function(){function T(o){this.loader=void 0,this.loader=new p(o)}var l=T.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(h,E,n){d(h),this.loader.load(h,E,n)},O(T,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),T}()},A.uuid=function(){var i=URL.createObjectURL(new Blob),d=i.toString();return URL.revokeObjectURL(i),d.slice(d.lastIndexOf("/")+1)},A.serialize=function(i){for(var d=[],p=function(P){return!Number.isNaN(P)&&P!=null&&P!==""&&P!==!1},T=function(P){return Math.round(P)},l=function(P){return T(P/100)*100},o=function(P){return encodeURIComponent(P)},h={br:T,d:T,bl:l,dl:l,mtp:l,nor:o,rtp:l,tb:T},E=Object.keys(i||{}).sort(),n=L(E),c;!(c=n()).done;){var m=c.value,f=i[m];if(!!p(f)&&!(m==="v"&&f===1)&&!(m=="pr"&&f===1)){var g=h[m];g&&(f=g(f));var y=typeof f,M=void 0;m==="ot"||m==="sf"||m==="st"?M=m+"="+f:y==="boolean"?M=m:y==="number"?M=m+"="+f:M=m+"="+JSON.stringify(f),d.push(M)}}return d.join(",")},A.toHeaders=function(i){for(var d=Object.keys(i),p={},T=["Object","Request","Session","Status"],l=[{},{},{},{}],o={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},h=0,E=d;h<E.length;h++){var n=E[h],c=o[n]!=null?o[n]:1;l[c][n]=i[n]}for(var m=0;m<l.length;m++){var f=A.serialize(l[m]);f&&(p["CMCD-"+T[m]]=f)}return p},A.toQuery=function(i){return"CMCD="+encodeURIComponent(A.serialize(i))},A.appendQueryToUri=function(i,d){if(!d)return i;var p=i.includes("?")?"&":"?";return""+i+p+d},A}()},"./src/controller/eme-controller.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/events.ts"),a=e("./src/errors.ts"),u=e("./src/utils/logger.ts"),R=e("./src/utils/mediakeys-helper.ts");function C(_,A){for(var S=0;S<A.length;S++){var v=A[S];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(_,v.key,v)}}function O(_,A,S){return A&&C(_.prototype,A),S&&C(_,S),Object.defineProperty(_,"prototype",{writable:!1}),_}var L=3,b=function(A,S,v){var i={audioCapabilities:[],videoCapabilities:[]};return A.forEach(function(d){i.audioCapabilities.push({contentType:'audio/mp4; codecs="'+d+'"',robustness:v.audioRobustness||""})}),S.forEach(function(d){i.videoCapabilities.push({contentType:'video/mp4; codecs="'+d+'"',robustness:v.videoRobustness||""})}),[i]},x=function(A,S,v,i){switch(A){case R.KeySystems.WIDEVINE:return b(S,v,i);default:throw new Error("Unknown key-system: "+A)}},I=function(){function _(S){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=S,this._config=S.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var A=_.prototype;return A.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},A._registerListeners=function(){this.hls.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(s.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this)},A._unregisterListeners=function(){this.hls.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(s.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this)},A.getLicenseServerUrl=function(v){switch(v){case R.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+v+'"')},A._attemptKeySystemAccess=function(v,i,d){var p=this,T=x(v,i,d,this._drmSystemOptions);u.logger.log("Requesting encrypted media key-system access");var l=this.requestMediaKeySystemAccess(v,T);this.mediaKeysPromise=l.then(function(o){return p._onMediaKeySystemAccessObtained(v,o)}),l.catch(function(o){u.logger.error('Failed to obtain key-system "'+v+'" access:',o)})},A._onMediaKeySystemAccessObtained=function(v,i){var d=this;u.logger.log('Access for key-system "'+v+'" obtained');var p={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:i,mediaKeySystemDomain:v};this._mediaKeysList.push(p);var T=Promise.resolve().then(function(){return i.createMediaKeys()}).then(function(l){return p.mediaKeys=l,u.logger.log('Media-keys created for key-system "'+v+'"'),d._onMediaKeysCreated(),l});return T.catch(function(l){u.logger.error("Failed to create media-keys:",l)}),T},A._onMediaKeysCreated=function(){var v=this;this._mediaKeysList.forEach(function(i){i.mediaKeysSession||(i.mediaKeysSession=i.mediaKeys.createSession(),v._onNewMediaKeySession(i.mediaKeysSession))})},A._onNewMediaKeySession=function(v){var i=this;u.logger.log("New key-system session "+v.sessionId),v.addEventListener("message",function(d){i._onKeySessionMessage(v,d.message)},!1)},A._onKeySessionMessage=function(v,i){u.logger.log("Got EME message event, creating license request"),this._requestLicense(i,function(d){u.logger.log("Received license data (length: "+(d&&d.byteLength)+"), updating key-session"),v.update(d).catch(function(p){u.logger.warn("Updating key-session failed: "+p)})})},A.onMediaEncrypted=function(v){var i=this;if(u.logger.log('Media is encrypted using "'+v.initDataType+'" init data type'),!this.mediaKeysPromise){u.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.KEY_SYSTEM_ERROR,details:a.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var d=function(T){!i._media||(i._attemptSetMediaKeys(T),i._generateRequestWithPreferredKeySession(v.initDataType,v.initData))};this.mediaKeysPromise.then(d).catch(d)},A._attemptSetMediaKeys=function(v){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var i=this._mediaKeysList[0];if(!i||!i.mediaKeys){u.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.KEY_SYSTEM_ERROR,details:a.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}u.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(i.mediaKeys),this._hasSetMediaKeys=!0}},A._generateRequestWithPreferredKeySession=function(v,i){var d=this,p=this._mediaKeysList[0];if(!p){u.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.KEY_SYSTEM_ERROR,details:a.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(p.mediaKeysSessionInitialized){u.logger.warn("Key-Session already initialized but requested again");return}var T=p.mediaKeysSession;if(!T){u.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.KEY_SYSTEM_ERROR,details:a.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!i){u.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.KEY_SYSTEM_ERROR,details:a.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}u.logger.log('Generating key-session request for "'+v+'" init data type'),p.mediaKeysSessionInitialized=!0,T.generateRequest(v,i).then(function(){u.logger.debug("Key-session generation succeeded")}).catch(function(l){u.logger.error("Error generating key-session request:",l),d.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.KEY_SYSTEM_ERROR,details:a.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},A._createLicenseXhr=function(v,i,d){var p=new XMLHttpRequest;p.responseType="arraybuffer",p.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,p,v,i,d);var T=this._licenseXhrSetup;if(T)try{T.call(this.hls,p,v),T=void 0}catch(l){u.logger.error(l)}try{p.readyState||p.open("POST",v,!0),T&&T.call(this.hls,p,v)}catch(l){throw new Error("issue setting up KeySystem license XHR "+l)}return p},A._onLicenseRequestReadyStageChange=function(v,i,d,p){switch(v.readyState){case 4:if(v.status===200){this._requestLicenseFailureCount=0,u.logger.log("License request succeeded");var T=v.response,l=this._licenseResponseCallback;if(l)try{T=l.call(this.hls,v,i)}catch(h){u.logger.error(h)}p(T)}else{if(u.logger.error("License Request XHR failed ("+i+"). Status: "+v.status+" ("+v.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>L){this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.KEY_SYSTEM_ERROR,details:a.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var o=L-this._requestLicenseFailureCount+1;u.logger.warn("Retrying license request, "+o+" attempts left"),this._requestLicense(d,p)}break}},A._generateLicenseRequestChallenge=function(v,i){switch(v.mediaKeySystemDomain){case R.KeySystems.WIDEVINE:return i}throw new Error("unsupported key-system: "+v.mediaKeySystemDomain)},A._requestLicense=function(v,i){u.logger.log("Requesting content license for key-system");var d=this._mediaKeysList[0];if(!d){u.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.KEY_SYSTEM_ERROR,details:a.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var p=this.getLicenseServerUrl(d.mediaKeySystemDomain),T=this._createLicenseXhr(p,v,i);u.logger.log("Sending license request to URL: "+p);var l=this._generateLicenseRequestChallenge(d,v);T.send(l)}catch(o){u.logger.error("Failure requesting DRM license: "+o),this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.KEY_SYSTEM_ERROR,details:a.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},A.onMediaAttached=function(v,i){if(!!this._emeEnabled){var d=i.media;this._media=d,d.addEventListener("encrypted",this._onMediaEncrypted)}},A.onMediaDetached=function(){var v=this._media,i=this._mediaKeysList;!v||(v.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(i.map(function(d){if(d.mediaKeysSession)return d.mediaKeysSession.close().catch(function(){})})).then(function(){return v.setMediaKeys(null)}).catch(function(){}))},A.onManifestParsed=function(v,i){if(!!this._emeEnabled){var d=i.levels.map(function(T){return T.audioCodec}).filter(function(T){return!!T}),p=i.levels.map(function(T){return T.videoCodec}).filter(function(T){return!!T});this._attemptKeySystemAccess(R.KeySystems.WIDEVINE,d,p)}},O(_,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),_}();t.default=I},"./src/controller/fps-controller.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/events.ts"),a=e("./src/utils/logger.ts"),u=function(){function R(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 C=R.prototype;return C.setStreamController=function(L){this.streamController=L},C.registerListeners=function(){this.hls.on(s.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},C.unregisterListeners=function(){this.hls.off(s.Events.MEDIA_ATTACHING,this.onMediaAttaching)},C.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},C.onMediaAttaching=function(L,b){var x=this.hls.config;if(x.capLevelOnFPSDrop){var I=b.media instanceof self.HTMLVideoElement?b.media:null;this.media=I,I&&typeof I.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),x.fpsDroppedMonitoringPeriod)}},C.checkFPS=function(L,b,x){var I=performance.now();if(b){if(this.lastTime){var _=I-this.lastTime,A=x-this.lastDroppedFrames,S=b-this.lastDecodedFrames,v=1e3*A/_,i=this.hls;if(i.trigger(s.Events.FPS_DROP,{currentDropped:A,currentDecoded:S,totalDroppedFrames:x}),v>0&&A>i.config.fpsDroppedMonitoringThreshold*S){var d=i.currentLevel;a.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(i.autoLevelCapping===-1||i.autoLevelCapping>=d)&&(d=d-1,i.trigger(s.Events.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:i.currentLevel}),i.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=I,this.lastDroppedFrames=x,this.lastDecodedFrames=b}},C.checkFPSInterval=function(){var L=this.media;if(L)if(this.isVideoPlaybackQualityAvailable){var b=L.getVideoPlaybackQuality();this.checkFPS(L,b.totalVideoFrames,b.droppedVideoFrames)}else this.checkFPS(L,L.webkitDecodedFrameCount,L.webkitDroppedFrameCount)},R}();t.default=u},"./src/controller/fragment-finders.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"findFragmentByPDT",function(){return u}),e.d(t,"findFragmentByPTS",function(){return R}),e.d(t,"fragmentWithinToleranceTest",function(){return C}),e.d(t,"pdtWithinToleranceTest",function(){return O}),e.d(t,"findFragWithCC",function(){return L});var s=e("./src/polyfills/number.ts"),a=e("./src/utils/binary-search.ts");function u(b,x,I){if(x===null||!Array.isArray(b)||!b.length||!Object(s.isFiniteNumber)(x))return null;var _=b[0].programDateTime;if(x<(_||0))return null;var A=b[b.length-1].endProgramDateTime;if(x>=(A||0))return null;I=I||0;for(var S=0;S<b.length;++S){var v=b[S];if(O(x,I,v))return v}return null}function R(b,x,I,_){I===void 0&&(I=0),_===void 0&&(_=0);var A=null;if(b?A=x[b.sn-x[0].sn+1]||null:I===0&&x[0].start===0&&(A=x[0]),A&&C(I,_,A)===0)return A;var S=a.default.search(x,C.bind(null,I,_));return S||A}function C(b,x,I){b===void 0&&(b=0),x===void 0&&(x=0);var _=Math.min(x,I.duration+(I.deltaPTS?I.deltaPTS:0));return I.start+I.duration-_<=b?1:I.start-_>b&&I.start?-1:0}function O(b,x,I){var _=Math.min(x,I.duration+(I.deltaPTS?I.deltaPTS:0))*1e3,A=I.endProgramDateTime||0;return A-_>b}function L(b,x){return a.default.search(b,function(I){return I.cc<x?1:I.cc>x?-1:0})}},"./src/controller/fragment-tracker.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"FragmentState",function(){return u}),e.d(t,"FragmentTracker",function(){return R});var s=e("./src/events.ts"),a=e("./src/types/loader.ts"),u;(function(L){L.NOT_LOADED="NOT_LOADED",L.APPENDING="APPENDING",L.PARTIAL="PARTIAL",L.OK="OK"})(u||(u={}));var R=function(){function L(x){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=x,this._registerListeners()}var b=L.prototype;return b._registerListeners=function(){var I=this.hls;I.on(s.Events.BUFFER_APPENDED,this.onBufferAppended,this),I.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),I.on(s.Events.FRAG_LOADED,this.onFragLoaded,this)},b._unregisterListeners=function(){var I=this.hls;I.off(s.Events.BUFFER_APPENDED,this.onBufferAppended,this),I.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),I.off(s.Events.FRAG_LOADED,this.onFragLoaded,this)},b.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},b.getAppendedFrag=function(I,_){if(_===a.PlaylistLevelType.MAIN){var A=this.activeFragment,S=this.activeParts;if(!A)return null;if(S)for(var v=S.length;v--;){var i=S[v],d=i?i.end:A.appendedPTS;if(i.start<=I&&d!==void 0&&I<=d)return v>9&&(this.activeParts=S.slice(v-9)),i}else if(A.start<=I&&A.appendedPTS!==void 0&&I<=A.appendedPTS)return A}return this.getBufferedFrag(I,_)},b.getBufferedFrag=function(I,_){for(var A=this.fragments,S=Object.keys(A),v=S.length;v--;){var i=A[S[v]];if((i==null?void 0:i.body.type)===_&&i.buffered){var d=i.body;if(d.start<=I&&I<=d.end)return d}}return null},b.detectEvictedFragments=function(I,_,A){var S=this;Object.keys(this.fragments).forEach(function(v){var i=S.fragments[v];if(!!i){if(!i.buffered){i.body.type===A&&S.removeFragment(i.body);return}var d=i.range[I];!d||d.time.some(function(p){var T=!S.isTimeBuffered(p.startPTS,p.endPTS,_);return T&&S.removeFragment(i.body),T})}})},b.detectPartialFragments=function(I){var _=this,A=this.timeRanges,S=I.frag,v=I.part;if(!(!A||S.sn==="initSegment")){var i=O(S),d=this.fragments[i];!d||(Object.keys(A).forEach(function(p){var T=S.elementaryStreams[p];if(!!T){var l=A[p],o=v!==null||T.partial===!0;d.range[p]=_.getBufferedTimes(S,v,o,l)}}),d.loaded=null,Object.keys(d.range).length?d.buffered=!0:this.removeFragment(d.body))}},b.fragBuffered=function(I){var _=O(I),A=this.fragments[_];A&&(A.loaded=null,A.buffered=!0)},b.getBufferedTimes=function(I,_,A,S){for(var v={time:[],partial:A},i=_?_.start:I.start,d=_?_.end:I.end,p=I.minEndPTS||d,T=I.maxStartPTS||i,l=0;l<S.length;l++){var o=S.start(l)-this.bufferPadding,h=S.end(l)+this.bufferPadding;if(T>=o&&p<=h){v.time.push({startPTS:Math.max(i,S.start(l)),endPTS:Math.min(d,S.end(l))});break}else if(i<h&&d>o)v.partial=!0,v.time.push({startPTS:Math.max(i,S.start(l)),endPTS:Math.min(d,S.end(l))});else if(d<=o)break}return v},b.getPartialFragment=function(I){var _=null,A,S,v,i=0,d=this.bufferPadding,p=this.fragments;return Object.keys(p).forEach(function(T){var l=p[T];!l||C(l)&&(S=l.body.start-d,v=l.body.end+d,I>=S&&I<=v&&(A=Math.min(I-S,v-I),i<=A&&(_=l.body,i=A)))}),_},b.getState=function(I){var _=O(I),A=this.fragments[_];return A?A.buffered?C(A)?u.PARTIAL:u.OK:u.APPENDING:u.NOT_LOADED},b.isTimeBuffered=function(I,_,A){for(var S,v,i=0;i<A.length;i++){if(S=A.start(i)-this.bufferPadding,v=A.end(i)+this.bufferPadding,I>=S&&_<=v)return!0;if(_<=S)return!1}return!1},b.onFragLoaded=function(I,_){var A=_.frag,S=_.part;if(!(A.sn==="initSegment"||A.bitrateTest||S)){var v=O(A);this.fragments[v]={body:A,loaded:_,buffered:!1,range:Object.create(null)}}},b.onBufferAppended=function(I,_){var A=this,S=_.frag,v=_.part,i=_.timeRanges;if(S.type===a.PlaylistLevelType.MAIN)if(this.activeFragment=S,v){var d=this.activeParts;d||(this.activeParts=d=[]),d.push(v)}else this.activeParts=null;this.timeRanges=i,Object.keys(i).forEach(function(p){var T=i[p];if(A.detectEvictedFragments(p,T),!v)for(var l=0;l<T.length;l++)S.appendedPTS=Math.max(T.end(l),S.appendedPTS||0)})},b.onFragBuffered=function(I,_){this.detectPartialFragments(_)},b.hasFragment=function(I){var _=O(I);return!!this.fragments[_]},b.removeFragmentsInRange=function(I,_,A){var S=this;Object.keys(this.fragments).forEach(function(v){var i=S.fragments[v];if(!!i&&i.buffered){var d=i.body;d.type===A&&d.start<_&&d.end>I&&S.removeFragment(d)}})},b.removeFragment=function(I){var _=O(I);I.stats.loaded=0,I.clearElementaryStreamInfo(),delete this.fragments[_]},b.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},L}();function C(L){var b,x;return L.buffered&&(((b=L.range.video)===null||b===void 0?void 0:b.partial)||((x=L.range.audio)===null||x===void 0?void 0:x.partial))}function O(L){return L.type+"_"+L.level+"_"+L.urlId+"_"+L.sn}},"./src/controller/gap-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"STALL_MINIMUM_DURATION_MS",function(){return C}),e.d(t,"MAX_START_GAP_JUMP",function(){return O}),e.d(t,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return L}),e.d(t,"SKIP_BUFFER_RANGE_START",function(){return b}),e.d(t,"default",function(){return x});var s=e("./src/utils/buffer-helper.ts"),a=e("./src/errors.ts"),u=e("./src/events.ts"),R=e("./src/utils/logger.ts"),C=250,O=2,L=.1,b=.05,x=function(){function I(A,S,v,i){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=A,this.media=S,this.fragmentTracker=v,this.hls=i}var _=I.prototype;return _.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},_.poll=function(S,v){var i=this.config,d=this.media,p=this.stalled;if(d!==null){var T=d.currentTime,l=d.seeking,o=this.seeking&&!l,h=!this.seeking&&l;if(this.seeking=l,T!==S){if(this.moved=!0,p!==null){if(this.stallReported){var E=self.performance.now()-p;R.logger.warn("playback not stuck anymore @"+T+", after "+Math.round(E)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((h||o)&&(this.stalled=null),!(d.paused&&!l||d.ended||d.playbackRate===0||!s.BufferHelper.getBuffered(d).length)){var n=s.BufferHelper.bufferInfo(d,T,0),c=n.len>0,m=n.nextStart||0;if(!(!c&&!m)){if(l){var f=n.len>O,g=!m||v&&v.start<=T||m-T>O&&!this.fragmentTracker.getPartialFragment(T);if(f||g)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var y,M=Math.max(m,n.start||0)-T,D=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=D==null||(y=D.details)===null||y===void 0?void 0:y.live,B=P?D.details.targetduration*2:O;if(M>0&&M<=B){this._trySkipBufferHole(null);return}}var N=self.performance.now();if(p===null){this.stalled=N;return}var F=N-p;if(!(!l&&F>=C&&(this._reportStall(n),!this.media))){var H=s.BufferHelper.bufferInfo(d,T,i.maxBufferHole);this._tryFixBufferStall(H,F)}}}}},_._tryFixBufferStall=function(S,v){var i=this.config,d=this.fragmentTracker,p=this.media;if(p!==null){var T=p.currentTime,l=d.getPartialFragment(T);if(l){var o=this._trySkipBufferHole(l);if(o||!this.media)return}S.len>i.maxBufferHole&&v>i.highBufferWatchdogPeriod*1e3&&(R.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},_._reportStall=function(S){var v=this.hls,i=this.media,d=this.stallReported;!d&&i&&(this.stallReported=!0,R.logger.warn("Playback stalling at @"+i.currentTime+" due to low buffer ("+JSON.stringify(S)+")"),v.trigger(u.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:S.len}))},_._trySkipBufferHole=function(S){var v=this.config,i=this.hls,d=this.media;if(d===null)return 0;for(var p=d.currentTime,T=0,l=s.BufferHelper.getBuffered(d),o=0;o<l.length;o++){var h=l.start(o);if(p+v.maxBufferHole>=T&&p<h){var E=Math.max(h+b,d.currentTime+L);return R.logger.warn("skipping hole, adjusting currentTime from "+p+" to "+E),this.moved=!0,this.stalled=null,d.currentTime=E,S&&i.trigger(u.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+p+" to "+E,frag:S}),E}T=l.end(o)}return 0},_._tryNudgeBuffer=function(){var S=this.config,v=this.hls,i=this.media,d=this.nudgeRetry;if(i!==null){var p=i.currentTime;if(this.nudgeRetry++,d<S.nudgeMaxRetry){var T=p+(d+1)*S.nudgeOffset;R.logger.warn("Nudging 'currentTime' from "+p+" to "+T),i.currentTime=T,v.trigger(u.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else R.logger.error("Playhead still not moving while enough data buffered @"+p+" after "+S.nudgeMaxRetry+" nudges"),v.trigger(u.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},I}()},"./src/controller/id3-track-controller.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/polyfills/number.ts"),a=e("./src/events.ts"),u=e("./src/utils/texttrack-utils.ts"),R=e("./src/demux/id3.ts"),C=e("./src/loader/date-range.ts"),O=e("./src/types/demuxer.ts"),L=.25;function b(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function x(A,S){return A.getTime()/1e3-S}function I(A){return Uint8Array.from(A.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var _=function(){function A(v){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=v,this._registerListeners()}var S=A.prototype;return S.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},S._registerListeners=function(){var i=this.hls;i.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.on(a.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),i.on(a.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),i.on(a.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},S._unregisterListeners=function(){var i=this.hls;i.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.off(a.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),i.off(a.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),i.off(a.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},S.onMediaAttached=function(i,d){this.media=d.media},S.onMediaDetaching=function(){!this.id3Track||(Object(u.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},S.onManifestLoading=function(){this.dateRangeCuesAppended={}},S.createTrack=function(i){var d=this.getID3Track(i.textTracks);return d.mode="hidden",d},S.getID3Track=function(i){if(!!this.media){for(var d=0;d<i.length;d++){var p=i[d];if(p.kind==="metadata"&&p.label==="id3")return Object(u.sendAddTrackEvent)(p,this.media),p}return this.media.addTextTrack("metadata","id3")}},S.onFragParsingMetadata=function(i,d){if(!!this.media){var p=this.hls.config,T=p.enableEmsgMetadataCues,l=p.enableID3MetadataCues;if(!(!T&&!l)){var o=d.frag,h=d.samples,E=d.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var n=E.edge||o.end,c=b(),m=!1,f={},g=0;g<h.length;g++){var y=h[g].type;if(!(y===O.MetadataSchema.emsg&&!T||!l)){var M=R.getID3Frames(h[g].data);if(M){var D=h[g].pts,P=n,B=P-D;B<=0&&(P=D+L);for(var N=0;N<M.length;N++){var F=M[N];if(!R.isTimeStampFrame(F)){var H=new c(D,P,"");H.value=F,y&&(H.type=y),this.id3Track.addCue(H),f[F.key]=null,m=!0}}}}}m&&this.updateId3CueEnds(f)}}},S.updateId3CueEnds=function(i){var d,p=(d=this.id3Track)===null||d===void 0?void 0:d.cues;if(p)for(var T=p.length;T--;){var l,o=p[T],h=(l=o.value)===null||l===void 0?void 0:l.key;if(h&&h in i){var E=i[h];E&&o.endTime!==E&&(o.endTime=E),i[h]=o.startTime}}},S.onBufferFlushing=function(i,d){var p=d.startOffset,T=d.endOffset,l=d.type,o=this.id3Track,h=this.hls;if(!!h){var E=h.config,n=E.enableEmsgMetadataCues,c=E.enableID3MetadataCues;if(o&&(n||c)){var m;l==="audio"?m=function(g){return g.type===O.MetadataSchema.audioId3&&c}:l==="video"?m=function(g){return g.type===O.MetadataSchema.emsg&&n}:m=function(g){return g.type===O.MetadataSchema.audioId3&&c||g.type===O.MetadataSchema.emsg&&n},Object(u.removeCuesInRange)(o,p,T,m)}}},S.onLevelUpdated=function(i,d){var p=this,T=d.details;if(!(!this.media||!T.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var l=this.dateRangeCuesAppended,o=this.id3Track,h=T.dateRanges,E=Object.keys(h);if(o)for(var n=Object.keys(l).filter(function(B){return!E.includes(B)}),c=function(N){var F=n[N];Object.keys(l[F].cues).forEach(function(H){o.removeCue(l[F].cues[H])}),delete l[F]},m=n.length;m--;)c(m);var f=T.fragments[T.fragments.length-1];if(!(E.length===0||!Object(s.isFiniteNumber)(f==null?void 0:f.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var g=f.programDateTime/1e3-f.start,y=T.edge||f.end,M=b(),D=function(N){var F=E[N],H=h[F],V=l[F],X=(V==null?void 0:V.cues)||{},$=(V==null?void 0:V.durationKnown)||!1,j=x(H.startDate,g),J=y,ee=H.endDate;if(ee)J=x(ee,g),$=!0;else if(H.endOnNext&&!$){var te=E.reduce(function(ne,Re){var Le=h[Re];return Le.class===H.class&&Le.id!==Re&&Le.startDate>H.startDate&&ne.push(Le),ne},[]).sort(function(ne,Re){return ne.startDate.getTime()-Re.startDate.getTime()})[0];te&&(J=x(te.startDate,g),$=!0)}for(var se=Object.keys(H.attr),ue=0;ue<se.length;ue++){var ie=se[ue];if(!(ie===C.DateRangeAttribute.ID||ie===C.DateRangeAttribute.CLASS||ie===C.DateRangeAttribute.START_DATE||ie===C.DateRangeAttribute.DURATION||ie===C.DateRangeAttribute.END_DATE||ie===C.DateRangeAttribute.END_ON_NEXT)){var he=X[ie];if(he)$&&!V.durationKnown&&(he.endTime=J);else{var me=H.attr[ie];he=new M(j,J,""),(ie===C.DateRangeAttribute.SCTE35_OUT||ie===C.DateRangeAttribute.SCTE35_IN)&&(me=I(me)),he.value={key:ie,data:me},he.type=O.MetadataSchema.dateRange,p.id3Track.addCue(he),X[ie]=he}}}l[F]={cues:X,dateRange:H,durationKnown:$}},P=0;P<E.length;P++)D(P)}}},A}();t.default=_},"./src/controller/latency-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return O});var s=e("./src/errors.ts"),a=e("./src/events.ts"),u=e("./src/utils/logger.ts");function R(L,b){for(var x=0;x<b.length;x++){var I=b[x];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(L,I.key,I)}}function C(L,b,x){return b&&R(L.prototype,b),x&&R(L,x),Object.defineProperty(L,"prototype",{writable:!1}),L}var O=function(){function L(x){var I=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 I.timeupdate()},this.hls=x,this.config=x.config,this.registerListeners()}var b=L.prototype;return b.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},b.registerListeners=function(){this.hls.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(a.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(a.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){this.hls.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(a.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(a.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(a.Events.ERROR,this.onError)},b.onMediaAttached=function(I,_){this.media=_.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},b.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},b.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},b.onLevelUpdated=function(I,_){var A=_.details;this.levelDetails=A,A.advanced&&this.timeupdate(),!A.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},b.onError=function(I,_){_.details===s.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,u.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},b.timeupdate=function(){var I=this.media,_=this.levelDetails;if(!(!I||!_)){this.currentTime=I.currentTime;var A=this.computeLatency();if(A!==null){this._latency=A;var S=this.config,v=S.lowLatencyMode,i=S.maxLiveSyncPlaybackRate;if(!(!v||i===1)){var d=this.targetLatency;if(d!==null){var p=A-d,T=Math.min(this.maxLatency,d+_.targetduration),l=p<T;if(_.live&&l&&p>.05&&this.forwardBufferLength>1){var o=Math.min(2,Math.max(1,i)),h=Math.round(2/(1+Math.exp(-.75*p-this.edgeStalled))*20)/20;I.playbackRate=Math.min(o,Math.max(1,h))}else I.playbackRate!==1&&I.playbackRate!==0&&(I.playbackRate=1)}}}}},b.estimateLiveEdge=function(){var I=this.levelDetails;return I===null?null:I.edge+I.age},b.computeLatency=function(){var I=this.estimateLiveEdge();return I===null?null:I-this.currentTime},C(L,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var I=this.config,_=this.levelDetails;return I.liveMaxLatencyDuration!==void 0?I.liveMaxLatencyDuration:_?I.liveMaxLatencyDurationCount*_.targetduration:0}},{key:"targetLatency",get:function(){var I=this.levelDetails;if(I===null)return null;var _=I.holdBack,A=I.partHoldBack,S=I.targetduration,v=this.config,i=v.liveSyncDuration,d=v.liveSyncDurationCount,p=v.lowLatencyMode,T=this.hls.userConfig,l=p&&A||_;(T.liveSyncDuration||T.liveSyncDurationCount||l===0)&&(l=i!==void 0?i:d*S);var o=S,h=1;return l+Math.min(this.stallCount*h,o)}},{key:"liveSyncPosition",get:function(){var I=this.estimateLiveEdge(),_=this.targetLatency,A=this.levelDetails;if(I===null||_===null||A===null)return null;var S=A.edge,v=I-_-this.edgeStalled,i=S-A.totalduration,d=S-(this.config.lowLatencyMode&&A.partTarget||A.targetduration);return Math.min(Math.max(i,v),d)}},{key:"drift",get:function(){var I=this.levelDetails;return I===null?1:I.drift}},{key:"edgeStalled",get:function(){var I=this.levelDetails;if(I===null)return 0;var _=(this.config.lowLatencyMode&&I.partTarget||I.targetduration)*3;return Math.max(I.age-_,0)}},{key:"forwardBufferLength",get:function(){var I=this.media,_=this.levelDetails;if(!I||!_)return 0;var A=I.buffered.length;return(A?I.buffered.end(A-1):_.edge)-this.currentTime}}]),L}()},"./src/controller/level-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return v});var s=e("./src/types/level.ts"),a=e("./src/events.ts"),u=e("./src/errors.ts"),R=e("./src/utils/codecs.ts"),C=e("./src/controller/level-helper.ts"),O=e("./src/controller/base-playlist-controller.ts"),L=e("./src/types/loader.ts");function b(){return b=Object.assign?Object.assign.bind():function(i){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var T in p)Object.prototype.hasOwnProperty.call(p,T)&&(i[T]=p[T])}return i},b.apply(this,arguments)}function x(i,d){for(var p=0;p<d.length;p++){var T=d[p];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(i,T.key,T)}}function I(i,d,p){return d&&x(i.prototype,d),p&&x(i,p),Object.defineProperty(i,"prototype",{writable:!1}),i}function _(i,d){i.prototype=Object.create(d.prototype),i.prototype.constructor=i,A(i,d)}function A(i,d){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,l){return T.__proto__=l,T},A(i,d)}var S=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),v=function(i){_(d,i);function d(T){var l;return l=i.call(this,T,"[level-controller]")||this,l._levels=[],l._firstLevel=-1,l._startLevel=void 0,l.currentLevelIndex=-1,l.manualLevelIndex=-1,l.onParsedComplete=void 0,l._registerListeners(),l}var p=d.prototype;return p._registerListeners=function(){var l=this.hls;l.on(a.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),l.on(a.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(a.Events.ERROR,this.onError,this)},p._unregisterListeners=function(){var l=this.hls;l.off(a.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),l.off(a.Events.FRAG_LOADED,this.onFragLoaded,this),l.off(a.Events.ERROR,this.onError,this)},p.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,i.prototype.destroy.call(this)},p.startLoad=function(){var l=this._levels;l.forEach(function(o){o.loadError=0}),i.prototype.startLoad.call(this)},p.onManifestLoaded=function(l,o){var h=[],E=[],n=[],c,m={},f,g=!1,y=!1,M=!1;if(o.levels.forEach(function(N){var F=N.attrs;g=g||!!(N.width&&N.height),y=y||!!N.videoCodec,M=M||!!N.audioCodec,S&&N.audioCodec&&N.audioCodec.indexOf("mp4a.40.34")!==-1&&(N.audioCodec=void 0);var H=N.bitrate+"-"+N.attrs.RESOLUTION+"-"+N.attrs.CODECS;f=m[H],f?f.url.push(N.url):(f=new s.Level(N),m[H]=f,h.push(f)),F&&(F.AUDIO&&Object(C.addGroupId)(f,"audio",F.AUDIO),F.SUBTITLES&&Object(C.addGroupId)(f,"text",F.SUBTITLES))}),(g||y)&&M&&(h=h.filter(function(N){var F=N.videoCodec,H=N.width,V=N.height;return!!F||!!(H&&V)})),h=h.filter(function(N){var F=N.audioCodec,H=N.videoCodec;return(!F||Object(R.isCodecSupportedInMp4)(F,"audio"))&&(!H||Object(R.isCodecSupportedInMp4)(H,"video"))}),o.audioTracks&&(E=o.audioTracks.filter(function(N){return!N.audioCodec||Object(R.isCodecSupportedInMp4)(N.audioCodec,"audio")}),Object(C.assignTrackIdsByGroup)(E)),o.subtitles&&(n=o.subtitles,Object(C.assignTrackIdsByGroup)(n)),h.length>0){c=h[0].bitrate,h.sort(function(N,F){return N.bitrate-F.bitrate}),this._levels=h;for(var D=0;D<h.length;D++)if(h[D].bitrate===c){this._firstLevel=D,this.log("manifest loaded, "+h.length+" level(s) found, first bitrate: "+c);break}var P=M&&!y,B={levels:h,audioTracks:E,subtitleTracks:n,firstLevel:this._firstLevel,stats:o.stats,audio:M,video:y,altAudio:!P&&E.some(function(N){return!!N.url})};this.hls.trigger(a.Events.MANIFEST_PARSED,B),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(a.Events.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:o.url,reason:"no level with compatible codecs found in manifest"})},p.onError=function(l,o){var h;if(i.prototype.onError.call(this,l,o),!o.fatal){var E=o.context,n=this._levels[this.currentLevelIndex];if(E&&(E.type===L.PlaylistContextType.AUDIO_TRACK&&n.audioGroupIds&&E.groupId===n.audioGroupIds[n.urlId]||E.type===L.PlaylistContextType.SUBTITLE_TRACK&&n.textGroupIds&&E.groupId===n.textGroupIds[n.urlId])){this.redundantFailover(this.currentLevelIndex);return}var c=!1,m=!0,f;switch(o.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:if(o.frag){var g=o.frag.type===L.PlaylistLevelType.MAIN?o.frag.level:this.currentLevelIndex,y=this._levels[g];y?(y.fragmentError++,y.fragmentError>this.hls.config.fragLoadingMaxRetry&&(f=g)):f=g}break;case u.ErrorDetails.LEVEL_LOAD_ERROR:case u.ErrorDetails.LEVEL_LOAD_TIMEOUT:E&&(E.deliveryDirectives&&(m=!1),f=E.level),c=!0;break;case u.ErrorDetails.REMUX_ALLOC_ERROR:f=(h=o.level)!=null?h:this.currentLevelIndex,c=!0;break}f!==void 0&&this.recoverLevel(o,f,c,m)}},p.recoverLevel=function(l,o,h,E){var n=l.details,c=this._levels[o];if(c.loadError++,h){var m=this.retryLoadingOrFail(l);if(m)l.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(E){var f=c.url.length;if(f>1&&c.loadError<f)l.levelRetry=!0,this.redundantFailover(o);else if(this.manualLevelIndex===-1){for(var g=-1,y=this._levels,M=y.length;M--;){var D=(M+this.currentLevelIndex)%y.length;if(D!==this.currentLevelIndex&&y[D].loadError===0){g=D;break}}g>-1&&this.currentLevelIndex!==g&&(this.warn(n+": switch to "+g),l.levelRetry=!0,this.hls.nextAutoLevel=g)}}},p.redundantFailover=function(l){var o=this._levels[l],h=o.url.length;if(h>1){var E=(o.urlId+1)%h;this.warn("Switching to redundant URL-id "+E),this._levels.forEach(function(n){n.urlId=E}),this.level=l}},p.onFragLoaded=function(l,o){var h=o.frag;if(h!==void 0&&h.type===L.PlaylistLevelType.MAIN){var E=this._levels[h.level];E!==void 0&&(E.fragmentError=0,E.loadError=0)}},p.onLevelLoaded=function(l,o){var h,E=o.level,n=o.details,c=this._levels[E];if(!c){var m;this.warn("Invalid level index "+E),(m=o.deliveryDirectives)!==null&&m!==void 0&&m.skip&&(n.deltaUpdateFailed=!0);return}E===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(E,o,c.details)):(h=o.deliveryDirectives)!==null&&h!==void 0&&h.skip&&(n.deltaUpdateFailed=!0)},p.onAudioTrackSwitched=function(l,o){var h=this.hls.levels[this.currentLevelIndex];if(!!h&&h.audioGroupIds){for(var E=-1,n=this.hls.audioTracks[o.id].groupId,c=0;c<h.audioGroupIds.length;c++)if(h.audioGroupIds[c]===n){E=c;break}E!==h.urlId&&(h.urlId=E,this.startLoad())}},p.loadPlaylist=function(l){var o=this.currentLevelIndex,h=this._levels[o];if(this.canLoad&&h&&h.url.length>0){var E=h.urlId,n=h.url[E];if(l)try{n=l.addDirectives(n)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Attempt loading level index "+o+(l?" at sn "+l.msn+" part "+l.part:"")+" with URL-id "+E+" "+n),this.clearTimer(),this.hls.trigger(a.Events.LEVEL_LOADING,{url:n,level:o,id:E,deliveryDirectives:l||null})}},p.removeLevel=function(l,o){var h=function(c,m){return m!==o},E=this._levels.filter(function(n,c){return c!==l?!0:n.url.length>1&&o!==void 0?(n.url=n.url.filter(h),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(h)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(h)),n.urlId=0,!0):!1}).map(function(n,c){var m=n.details;return m!=null&&m.fragments&&m.fragments.forEach(function(f){f.level=c}),n});this._levels=E,this.hls.trigger(a.Events.LEVELS_UPDATED,{levels:E})},I(d,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(l){var o,h=this._levels;if(h.length!==0&&!(this.currentLevelIndex===l&&(o=h[l])!==null&&o!==void 0&&o.details)){if(l<0||l>=h.length){var E=l<0;if(this.hls.trigger(a.Events.ERROR,{type:u.ErrorTypes.OTHER_ERROR,details:u.ErrorDetails.LEVEL_SWITCH_ERROR,level:l,fatal:E,reason:"invalid level idx"}),E)return;l=Math.min(l,h.length-1)}this.clearTimer();var n=this.currentLevelIndex,c=h[n],m=h[l];this.log("switching to level "+l+" from "+n),this.currentLevelIndex=l;var f=b({},m,{level:l,maxBitrate:m.maxBitrate,uri:m.uri,urlId:m.urlId});delete f._urlId,this.hls.trigger(a.Events.LEVEL_SWITCHING,f);var g=m.details;if(!g||g.live){var y=this.switchParams(m.uri,c==null?void 0:c.details);this.loadPlaylist(y)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(l){this.manualLevelIndex=l,this._startLevel===void 0&&(this._startLevel=l),l!==-1&&(this.level=l)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(l){this._firstLevel=l}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var l=this.hls.config.startLevel;return l!==void 0?l:this._firstLevel}else return this._startLevel},set:function(l){this._startLevel=l}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(l){this.level=l,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=l)}}]),d}(O.default)},"./src/controller/level-helper.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"addGroupId",function(){return C}),e.d(t,"assignTrackIdsByGroup",function(){return O}),e.d(t,"updatePTS",function(){return L}),e.d(t,"updateFragPTSDTS",function(){return x}),e.d(t,"mergeDetails",function(){return I}),e.d(t,"mapPartIntersection",function(){return A}),e.d(t,"mapFragmentIntersection",function(){return S}),e.d(t,"adjustSliding",function(){return v}),e.d(t,"addSliding",function(){return i}),e.d(t,"computeReloadInterval",function(){return d}),e.d(t,"getFragmentWithSN",function(){return p}),e.d(t,"getPartWith",function(){return T});var s=e("./src/polyfills/number.ts"),a=e("./src/utils/logger.ts"),u=e("./src/loader/date-range.ts");function R(){return R=Object.assign?Object.assign.bind():function(l){for(var o=1;o<arguments.length;o++){var h=arguments[o];for(var E in h)Object.prototype.hasOwnProperty.call(h,E)&&(l[E]=h[E])}return l},R.apply(this,arguments)}function C(l,o,h){switch(o){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(h);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(h);break}}function O(l){var o={};l.forEach(function(h){var E=h.groupId||"";h.id=o[E]=o[E]||0,o[E]++})}function L(l,o,h){var E=l[o],n=l[h];b(E,n)}function b(l,o){var h=o.startPTS;if(Object(s.isFiniteNumber)(h)){var E=0,n;o.sn>l.sn?(E=h-l.start,n=l):(E=l.start-h,n=o),n.duration!==E&&(n.duration=E)}else if(o.sn>l.sn){var c=l.cc===o.cc;c&&l.minEndPTS?o.start=l.start+(l.minEndPTS-l.start):o.start=l.start+l.duration}else o.start=Math.max(l.start-o.duration,0)}function x(l,o,h,E,n,c){var m=E-h;m<=0&&(a.logger.warn("Fragment should have a positive duration",o),E=h+o.duration,c=n+o.duration);var f=h,g=E,y=o.startPTS,M=o.endPTS;if(Object(s.isFiniteNumber)(y)){var D=Math.abs(y-h);Object(s.isFiniteNumber)(o.deltaPTS)?o.deltaPTS=Math.max(D,o.deltaPTS):o.deltaPTS=D,f=Math.max(h,y),h=Math.min(h,y),n=Math.min(n,o.startDTS),g=Math.min(E,M),E=Math.max(E,M),c=Math.max(c,o.endDTS)}o.duration=E-h;var P=h-o.start;o.appendedPTS=E,o.start=o.startPTS=h,o.maxStartPTS=f,o.startDTS=n,o.endPTS=E,o.minEndPTS=g,o.endDTS=c;var B=o.sn;if(!l||B<l.startSN||B>l.endSN)return 0;var N,F=B-l.startSN,H=l.fragments;for(H[F]=o,N=F;N>0;N--)b(H[N],H[N-1]);for(N=F;N<H.length-1;N++)b(H[N],H[N+1]);return l.fragmentHint&&b(H[H.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,P}function I(l,o){for(var h=null,E=l.fragments,n=E.length-1;n>=0;n--){var c=E[n].initSegment;if(c){h=c;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var m=0,f;if(S(l,o,function(N,F){N.relurl&&(m=N.cc-F.cc),Object(s.isFiniteNumber)(N.startPTS)&&Object(s.isFiniteNumber)(N.endPTS)&&(F.start=F.startPTS=N.startPTS,F.startDTS=N.startDTS,F.appendedPTS=N.appendedPTS,F.maxStartPTS=N.maxStartPTS,F.endPTS=N.endPTS,F.endDTS=N.endDTS,F.minEndPTS=N.minEndPTS,F.duration=N.endPTS-N.startPTS,F.duration&&(f=F),o.PTSKnown=o.alignedSliding=!0),F.elementaryStreams=N.elementaryStreams,F.loader=N.loader,F.stats=N.stats,F.urlId=N.urlId,N.initSegment&&(F.initSegment=N.initSegment,h=N.initSegment)}),h){var g=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments;g.forEach(function(N){var F;(!N.initSegment||N.initSegment.relurl===((F=h)===null||F===void 0?void 0:F.relurl))&&(N.initSegment=h)})}if(o.skippedSegments)if(o.deltaUpdateFailed=o.fragments.some(function(N){return!N}),o.deltaUpdateFailed){a.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var y=o.skippedSegments;y--;)o.fragments.shift();o.startSN=o.fragments[0].sn,o.startCC=o.fragments[0].cc}else o.canSkipDateRanges&&(o.dateRanges=_(l.dateRanges,o.dateRanges,o.recentlyRemovedDateranges));var M=o.fragments;if(m){a.logger.warn("discontinuity sliding from playlist, take drift into account");for(var D=0;D<M.length;D++)M[D].cc+=m}o.skippedSegments&&(o.startCC=o.fragments[0].cc),A(l.partList,o.partList,function(N,F){F.elementaryStreams=N.elementaryStreams,F.stats=N.stats}),f?x(o,f,f.startPTS,f.endPTS,f.startDTS,f.endDTS):v(l,o),M.length&&(o.totalduration=o.edge-M[0].start),o.driftStartTime=l.driftStartTime,o.driftStart=l.driftStart;var P=o.advancedDateTime;if(o.advanced&&P){var B=o.edge;o.driftStart||(o.driftStartTime=P,o.driftStart=B),o.driftEndTime=P,o.driftEnd=B}else o.driftEndTime=l.driftEndTime,o.driftEnd=l.driftEnd,o.advancedDateTime=l.advancedDateTime}function _(l,o,h){var E=R({},l);return h&&h.forEach(function(n){delete E[n]}),Object.keys(o).forEach(function(n){var c=new u.DateRange(o[n].attr,E[n]);c.isValid?E[n]=c:a.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(o[n].attr)+'"')}),E}function A(l,o,h){if(l&&o)for(var E=0,n=0,c=l.length;n<=c;n++){var m=l[n],f=o[n+E];m&&f&&m.index===f.index&&m.fragment.sn===f.fragment.sn?h(m,f):E--}}function S(l,o,h){for(var E=o.skippedSegments,n=Math.max(l.startSN,o.startSN)-o.startSN,c=(l.fragmentHint?1:0)+(E?o.endSN:Math.min(l.endSN,o.endSN))-o.startSN,m=o.startSN-l.startSN,f=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments,g=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,y=n;y<=c;y++){var M=g[m+y],D=f[y];E&&!D&&y<E&&(D=o.fragments[y]=M),M&&D&&h(M,D)}}function v(l,o){var h=o.startSN+o.skippedSegments-l.startSN,E=l.fragments;h<0||h>=E.length||i(o,E[h].start)}function i(l,o){if(o){for(var h=l.fragments,E=l.skippedSegments;E<h.length;E++)h[E].start+=o;l.fragmentHint&&(l.fragmentHint.start+=o)}}function d(l,o){var h=1e3*l.levelTargetDuration,E=h/2,n=l.age,c=n>0&&n<h*3,m=o.loading.end-o.loading.start,f,g=l.availabilityDelay;if(l.updated===!1)if(c){var y=333*l.misses;f=Math.max(Math.min(E,m*2),y),l.availabilityDelay=(l.availabilityDelay||0)+f}else f=E;else c?(g=Math.min(g||h/2,n),l.availabilityDelay=g,f=g+h-n):f=h-m;return Math.round(f)}function p(l,o,h){if(!l||!l.details)return null;var E=l.details,n=E.fragments[o-E.startSN];return n||(n=E.fragmentHint,n&&n.sn===o)?n:o<E.startSN&&h&&h.sn===o?h:null}function T(l,o,h){if(!l||!l.details)return null;var E=l.details.partList;if(E)for(var n=E.length;n--;){var c=E[n];if(c.index===h&&c.fragment.sn===o)return c}return null}},"./src/controller/stream-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return T});var s=e("./src/polyfills/number.ts"),a=e("./src/controller/base-stream-controller.ts"),u=e("./src/is-supported.ts"),R=e("./src/events.ts"),C=e("./src/utils/buffer-helper.ts"),O=e("./src/controller/fragment-tracker.ts"),L=e("./src/types/loader.ts"),b=e("./src/loader/fragment.ts"),x=e("./src/demux/transmuxer-interface.ts"),I=e("./src/types/transmuxer.ts"),_=e("./src/controller/gap-controller.ts"),A=e("./src/errors.ts");function S(l,o){for(var h=0;h<o.length;h++){var E=o[h];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(l,E.key,E)}}function v(l,o,h){return o&&S(l.prototype,o),h&&S(l,h),Object.defineProperty(l,"prototype",{writable:!1}),l}function i(l,o){l.prototype=Object.create(o.prototype),l.prototype.constructor=l,d(l,o)}function d(l,o){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,n){return E.__proto__=n,E},d(l,o)}var p=100,T=function(l){i(o,l);function o(E,n){var c;return c=l.call(this,E,n,"[stream-controller]")||this,c.audioCodecSwap=!1,c.gapController=null,c.level=-1,c._forceStartLoad=!1,c.altAudio=!1,c.audioOnly=!1,c.fragPlaying=null,c.onvplaying=null,c.onvseeked=null,c.fragLastKbps=0,c.couldBacktrack=!1,c.backtrackFragment=null,c.audioCodecSwitch=!1,c.videoBuffer=null,c._registerListeners(),c}var h=o.prototype;return h._registerListeners=function(){var n=this.hls;n.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),n.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(R.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),n.on(R.Events.ERROR,this.onError,this),n.on(R.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(R.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),n.on(R.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(R.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(R.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),n.on(R.Events.FRAG_BUFFERED,this.onFragBuffered,this)},h._unregisterListeners=function(){var n=this.hls;n.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(R.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),n.off(R.Events.ERROR,this.onError,this),n.off(R.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(R.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),n.off(R.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(R.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(R.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),n.off(R.Events.FRAG_BUFFERED,this.onFragBuffered,this)},h.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},h.startLoad=function(n){if(this.levels){var c=this.lastCurrentTime,m=this.hls;if(this.stopLoad(),this.setInterval(p),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var f=m.startLevel;f===-1&&(m.config.testBandwidth&&this.levels.length>1?(f=0,this.bitrateTest=!0):f=m.nextAutoLevel),this.level=m.nextLoadLevel=f,this.loadedmetadata=!1}c>0&&n===-1&&(this.log("Override startPosition with lastCurrentTime @"+c.toFixed(3)),n=c),this.state=a.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()}else this._forceStartLoad=!0,this.state=a.State.STOPPED},h.stopLoad=function(){this._forceStartLoad=!1,l.prototype.stopLoad.call(this)},h.doTick=function(){switch(this.state){case a.State.IDLE:this.doTickIdle();break;case a.State.WAITING_LEVEL:{var n,c=this.levels,m=this.level,f=c==null||(n=c[m])===null||n===void 0?void 0:n.details;if(f&&(!f.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(f))break;this.state=a.State.IDLE;break}break}case a.State.FRAG_LOADING_WAITING_RETRY:{var g,y=self.performance.now(),M=this.retryDate;(!M||y>=M||(g=this.media)!==null&&g!==void 0&&g.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=a.State.IDLE)}break;default:break}this.onTickEnd()},h.onTickEnd=function(){l.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},h.doTickIdle=function(){var n,c,m=this.hls,f=this.levelLastLoaded,g=this.levels,y=this.media,M=m.config,D=m.nextLoadLevel;if(!(f===null||!y&&(this.startFragRequested||!M.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!g||!g[D])){var P=g[D];this.level=m.nextLoadLevel=D;var B=P.details;if(!B||this.state===a.State.WAITING_LEVEL||B.live&&this.levelLastLoaded!==D){this.state=a.State.WAITING_LEVEL;return}var N=this.getMainFwdBufferInfo();if(N!==null){var F=N.len,H=this.getMaxBufferLength(P.maxBitrate);if(!(F>=H)){if(this._streamEnded(N,B)){var V={};this.altAudio&&(V.type="video"),this.hls.trigger(R.Events.BUFFER_EOS,V),this.state=a.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>N.end&&(this.backtrackFragment=null);var X=this.backtrackFragment?this.backtrackFragment.start:N.end,$=this.getNextFragment(X,B);if(this.couldBacktrack&&!this.fragPrevious&&$&&$.sn!=="initSegment"&&this.fragmentTracker.getState($)!==O.FragmentState.OK){var j,J=((j=this.backtrackFragment)!=null?j:$).sn,ee=J-B.startSN,te=B.fragments[ee-1];te&&$.cc===te.cc&&($=te,this.fragmentTracker.removeFragment(te))}else this.backtrackFragment&&N.len&&(this.backtrackFragment=null);if($&&this.fragmentTracker.getState($)===O.FragmentState.OK&&this.nextLoadPosition>X){var se=this.audioOnly&&!this.altAudio?b.ElementaryStreamTypes.AUDIO:b.ElementaryStreamTypes.VIDEO;y&&this.afterBufferFlushed(y,se,L.PlaylistLevelType.MAIN),$=this.getNextFragment(this.nextLoadPosition,B)}!$||($.initSegment&&!$.initSegment.data&&!this.bitrateTest&&($=$.initSegment),((n=$.decryptdata)===null||n===void 0?void 0:n.keyFormat)==="identity"&&!((c=$.decryptdata)!==null&&c!==void 0&&c.key)?this.loadKey($,B):this.loadFragment($,B,X))}}}},h.loadFragment=function(n,c,m){var f,g=this.fragmentTracker.getState(n);this.fragCurrent=n,g===O.FragmentState.NOT_LOADED?n.sn==="initSegment"?this._loadInitSegment(n):this.bitrateTest?(this.log("Fragment "+n.sn+" of level "+n.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(n)):(this.startFragRequested=!0,l.prototype.loadFragment.call(this,n,c,m)):g===O.FragmentState.APPENDING?this.reduceMaxBufferLength(n.duration)&&this.fragmentTracker.removeFragment(n):((f=this.media)===null||f===void 0?void 0:f.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},h.getAppendedFrag=function(n){var c=this.fragmentTracker.getAppendedFrag(n,L.PlaylistLevelType.MAIN);return c&&"fragment"in c?c.fragment:c},h.getBufferedFrag=function(n){return this.fragmentTracker.getBufferedFrag(n,L.PlaylistLevelType.MAIN)},h.followingBufferedFrag=function(n){return n?this.getBufferedFrag(n.end+.5):null},h.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},h.nextLevelSwitch=function(){var n=this.levels,c=this.media;if(c!=null&&c.readyState){var m,f=this.getAppendedFrag(c.currentTime);if(f&&f.start>1&&this.flushMainBuffer(0,f.start-1),!c.paused&&n){var g=this.hls.nextLoadLevel,y=n[g],M=this.fragLastKbps;M&&this.fragCurrent?m=this.fragCurrent.duration*y.maxBitrate/(1e3*M)+1:m=0}else m=0;var D=this.getBufferedFrag(c.currentTime+m);if(D){var P=this.followingBufferedFrag(D);if(P){this.abortCurrentFrag();var B=P.maxStartPTS?P.maxStartPTS:P.start,N=P.duration,F=Math.max(D.end,B+Math.min(Math.max(N-this.config.maxFragLookUpTolerance,N*.5),N*.75));this.flushMainBuffer(F,Number.POSITIVE_INFINITY)}}}},h.abortCurrentFrag=function(){var n=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,n!=null&&n.loader&&n.loader.abort(),this.state){case a.State.KEY_LOADING:case a.State.FRAG_LOADING:case a.State.FRAG_LOADING_WAITING_RETRY:case a.State.PARSING:case a.State.PARSED:this.state=a.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},h.flushMainBuffer=function(n,c){l.prototype.flushMainBuffer.call(this,n,c,this.altAudio?"video":null)},h.onMediaAttached=function(n,c){l.prototype.onMediaAttached.call(this,n,c);var m=c.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),m.addEventListener("playing",this.onvplaying),m.addEventListener("seeked",this.onvseeked),this.gapController=new _.default(this.config,m,this.fragmentTracker,this.hls)},h.onMediaDetaching=function(){var n=this.media;n&&this.onvplaying&&this.onvseeked&&(n.removeEventListener("playing",this.onvplaying),n.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),l.prototype.onMediaDetaching.call(this)},h.onMediaPlaying=function(){this.tick()},h.onMediaSeeked=function(){var n=this.media,c=n?n.currentTime:null;Object(s.isFiniteNumber)(c)&&this.log("Media seeked to "+c.toFixed(3)),this.tick()},h.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(R.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},h.onManifestParsed=function(n,c){var m=!1,f=!1,g;c.levels.forEach(function(y){g=y.audioCodec,g&&(g.indexOf("mp4a.40.2")!==-1&&(m=!0),g.indexOf("mp4a.40.5")!==-1&&(f=!0))}),this.audioCodecSwitch=m&&f&&!Object(u.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=c.levels,this.startFragRequested=!1},h.onLevelLoading=function(n,c){var m=this.levels;if(!(!m||this.state!==a.State.IDLE)){var f=m[c.level];(!f.details||f.details.live&&this.levelLastLoaded!==c.level||this.waitForCdnTuneIn(f.details))&&(this.state=a.State.WAITING_LEVEL)}},h.onLevelLoaded=function(n,c){var m,f=this.levels,g=c.level,y=c.details,M=y.totalduration;if(!f){this.warn("Levels were reset while loading level "+g);return}this.log("Level "+g+" loaded ["+y.startSN+","+y.endSN+"], cc ["+y.startCC+", "+y.endCC+"] duration:"+M);var D=this.fragCurrent;D&&(this.state===a.State.FRAG_LOADING||this.state===a.State.FRAG_LOADING_WAITING_RETRY)&&D.level!==c.level&&D.loader&&(this.state=a.State.IDLE,this.backtrackFragment=null,D.loader.abort());var P=f[g],B=0;if(y.live||(m=P.details)!==null&&m!==void 0&&m.live){if(y.fragments[0]||(y.deltaUpdateFailed=!0),y.deltaUpdateFailed)return;B=this.alignPlaylists(y,P.details)}if(P.details=y,this.levelLastLoaded=g,this.hls.trigger(R.Events.LEVEL_UPDATED,{details:y,level:g}),this.state===a.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(y))return;this.state=a.State.IDLE}this.startFragRequested?y.live&&this.synchronizeToLiveEdge(y):this.setStartPosition(y,B),this.tick()},h._handleFragmentLoadProgress=function(n){var c,m=n.frag,f=n.part,g=n.payload,y=this.levels;if(!y){this.warn("Levels were reset while fragment load was in progress. Fragment "+m.sn+" of level "+m.level+" will not be buffered");return}var M=y[m.level],D=M.details;if(!D){this.warn("Dropping fragment "+m.sn+" of level "+m.level+" after level details were reset");return}var P=M.videoCodec,B=D.PTSKnown||!D.live,N=(c=m.initSegment)===null||c===void 0?void 0:c.data,F=this._getAudioCodec(M),H=this.transmuxer=this.transmuxer||new x.default(this.hls,L.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),V=f?f.index:-1,X=V!==-1,$=new I.ChunkMetadata(m.level,m.sn,m.stats.chunkCount,g.byteLength,V,X),j=this.initPTS[m.cc];H.push(g,N,F,P,m,f,D.totalduration,B,$,j)},h.onAudioTrackSwitching=function(n,c){var m=this.altAudio,f=!!c.url,g=c.id;if(!f){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var y=this.fragCurrent;y!=null&&y.loader&&(this.log("Switching to main audio track, cancel main fragment load"),y.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var M=this.hls;m&&M.trigger(R.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),M.trigger(R.Events.AUDIO_TRACK_SWITCHED,{id:g})}},h.onAudioTrackSwitched=function(n,c){var m=c.id,f=!!this.hls.audioTracks[m].url;if(f){var g=this.videoBuffer;g&&this.mediaBuffer!==g&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=g)}this.altAudio=f,this.tick()},h.onBufferCreated=function(n,c){var m=c.tracks,f,g,y=!1;for(var M in m){var D=m[M];if(D.id==="main"){if(g=M,f=D,M==="video"){var P=m[M];P&&(this.videoBuffer=P.buffer)}}else y=!0}y&&f?(this.log("Alternate track found, use "+g+".buffered to schedule main fragment loading"),this.mediaBuffer=f.buffer):this.mediaBuffer=this.media},h.onFragBuffered=function(n,c){var m=c.frag,f=c.part;if(!(m&&m.type!==L.PlaylistLevelType.MAIN)){if(this.fragContextChanged(m)){this.warn("Fragment "+m.sn+(f?" p: "+f.index:"")+" of level "+m.level+" finished buffering, but was aborted. state: "+this.state),this.state===a.State.PARSED&&(this.state=a.State.IDLE);return}var g=f?f.stats:m.stats;this.fragLastKbps=Math.round(8*g.total/(g.buffering.end-g.loading.first)),m.sn!=="initSegment"&&(this.fragPrevious=m),this.fragBufferedComplete(m,f)}},h.onError=function(n,c){switch(c.details){case A.ErrorDetails.FRAG_LOAD_ERROR:case A.ErrorDetails.FRAG_LOAD_TIMEOUT:case A.ErrorDetails.KEY_LOAD_ERROR:case A.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(L.PlaylistLevelType.MAIN,c);break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==a.State.ERROR&&(c.fatal?(this.warn(""+c.details),this.state=a.State.ERROR):!c.levelRetry&&this.state===a.State.WAITING_LEVEL&&(this.state=a.State.IDLE));break;case A.ErrorDetails.BUFFER_FULL_ERROR:if(c.parent==="main"&&(this.state===a.State.PARSING||this.state===a.State.PARSED)){var m=!0,f=this.getFwdBufferInfo(this.media,L.PlaylistLevelType.MAIN);f&&f.len>.5&&(m=!this.reduceMaxBufferLength(f.len)),m&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},h.checkBuffer=function(){var n=this.media,c=this.gapController;if(!(!n||!c||!n.readyState)){if(this.loadedmetadata||!C.BufferHelper.getBuffered(n).length){var m=this.state!==a.State.IDLE?this.fragCurrent:null;c.poll(this.lastCurrentTime,m)}this.lastCurrentTime=n.currentTime}},h.onFragLoadEmergencyAborted=function(){this.state=a.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},h.onBufferFlushed=function(n,c){var m=c.type;if(m!==b.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var f=(m===b.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(f,m,L.PlaylistLevelType.MAIN)}},h.onLevelsUpdated=function(n,c){this.levels=c.levels},h.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},h.seekToStartPos=function(){var n=this.media;if(!!n){var c=n.currentTime,m=this.startPosition;if(m>=0&&c<m){if(n.seeking){this.log("could not seek to "+m+", already seeking at "+c);return}var f=C.BufferHelper.getBuffered(n),g=f.length?f.start(0):0,y=g-m;y>0&&(y<this.config.maxBufferHole||y<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+y+" to match buffer start"),m+=y,this.startPosition=m),this.log("seek to target start position "+m+" from current time "+c),n.currentTime=m}}},h._getAudioCodec=function(n){var c=this.config.defaultAudioCodec||n.audioCodec;return this.audioCodecSwap&&c&&(this.log("Swapping audio codec"),c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5"),c},h._loadBitrateTestFrag=function(n){var c=this;n.bitrateTest=!0,this._doFragLoad(n).then(function(m){var f=c.hls;if(!(!m||f.nextLoadLevel||c.fragContextChanged(n))){c.fragLoadError=0,c.state=a.State.IDLE,c.startFragRequested=!1,c.bitrateTest=!1;var g=n.stats;g.parsing.start=g.parsing.end=g.buffering.start=g.buffering.end=self.performance.now(),f.trigger(R.Events.FRAG_LOADED,m),n.bitrateTest=!1}})},h._handleTransmuxComplete=function(n){var c,m="main",f=this.hls,g=n.remuxResult,y=n.chunkMeta,M=this.getCurrentContext(y);if(!M){this.warn("The loading context changed while buffering fragment "+y.sn+" of level "+y.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(y.level);return}var D=M.frag,P=M.part,B=M.level,N=g.video,F=g.text,H=g.id3,V=g.initSegment,X=B.details,$=this.altAudio?void 0:g.audio;if(!this.fragContextChanged(D)){if(this.state=a.State.PARSING,V){V.tracks&&(this._bufferInitSegment(B,V.tracks,D,y),f.trigger(R.Events.FRAG_PARSING_INIT_SEGMENT,{frag:D,id:m,tracks:V.tracks}));var j=V.initPTS,J=V.timescale;Object(s.isFiniteNumber)(j)&&(this.initPTS[D.cc]=j,f.trigger(R.Events.INIT_PTS_FOUND,{frag:D,id:m,initPTS:j,timescale:J}))}if(N&&g.independent!==!1){if(X){var ee=N.startPTS,te=N.endPTS,se=N.startDTS,ue=N.endDTS;if(P)P.elementaryStreams[N.type]={startPTS:ee,endPTS:te,startDTS:se,endDTS:ue};else if(N.firstKeyFrame&&N.independent&&(this.couldBacktrack=!0),N.dropped&&N.independent){var ie=this.getMainFwdBufferInfo(),he=(ie?ie.end:this.getLoadPosition())+this.config.maxBufferHole,me=N.firstKeyFramePTS?N.firstKeyFramePTS:ee;if(he<me-this.config.maxBufferHole){this.backtrack(D);return}D.setElementaryStreamInfo(N.type,D.start,te,D.start,ue,!0)}D.setElementaryStreamInfo(N.type,ee,te,se,ue),this.backtrackFragment&&(this.backtrackFragment=D),this.bufferFragmentData(N,D,P,y)}}else if(g.independent===!1){this.backtrack(D);return}if($){var ne=$.startPTS,Re=$.endPTS,Le=$.startDTS,De=$.endDTS;P&&(P.elementaryStreams[b.ElementaryStreamTypes.AUDIO]={startPTS:ne,endPTS:Re,startDTS:Le,endDTS:De}),D.setElementaryStreamInfo(b.ElementaryStreamTypes.AUDIO,ne,Re,Le,De),this.bufferFragmentData($,D,P,y)}if(X&&H!==null&&H!==void 0&&(c=H.samples)!==null&&c!==void 0&&c.length){var _e={id:m,frag:D,details:X,samples:H.samples};f.trigger(R.Events.FRAG_PARSING_METADATA,_e)}if(X&&F){var ke={id:m,frag:D,details:X,samples:F.samples};f.trigger(R.Events.FRAG_PARSING_USERDATA,ke)}}},h._bufferInitSegment=function(n,c,m,f){var g=this;if(this.state===a.State.PARSING){this.audioOnly=!!c.audio&&!c.video,this.altAudio&&!this.audioOnly&&delete c.audio;var y=c.audio,M=c.video,D=c.audiovideo;if(y){var P=n.audioCodec,B=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(P&&(P.indexOf("mp4a.40.5")!==-1?P="mp4a.40.2":P="mp4a.40.5"),y.metadata.channelCount!==1&&B.indexOf("firefox")===-1&&(P="mp4a.40.5")),B.indexOf("android")!==-1&&y.container!=="audio/mpeg"&&(P="mp4a.40.2",this.log("Android: force audio codec to "+P)),n.audioCodec&&n.audioCodec!==P&&this.log('Swapping manifest audio codec "'+n.audioCodec+'" for "'+P+'"'),y.levelCodec=P,y.id="main",this.log("Init audio buffer, container:"+y.container+", codecs[selected/level/parsed]=["+(P||"")+"/"+(n.audioCodec||"")+"/"+y.codec+"]")}M&&(M.levelCodec=n.videoCodec,M.id="main",this.log("Init video buffer, container:"+M.container+", codecs[level/parsed]=["+(n.videoCodec||"")+"/"+M.codec+"]")),D&&this.log("Init audiovideo buffer, container:"+D.container+", codecs[level/parsed]=["+(n.attrs.CODECS||"")+"/"+D.codec+"]"),this.hls.trigger(R.Events.BUFFER_CODECS,c),Object.keys(c).forEach(function(N){var F=c[N],H=F.initSegment;H!=null&&H.byteLength&&g.hls.trigger(R.Events.BUFFER_APPENDING,{type:N,data:H,frag:m,part:null,chunkMeta:f,parent:m.type})}),this.tick()}},h.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,L.PlaylistLevelType.MAIN)},h.backtrack=function(n){this.couldBacktrack=!0,this.backtrackFragment=n,this.resetTransmuxer(),this.flushBufferGap(n),this.fragmentTracker.removeFragment(n),this.fragPrevious=null,this.nextLoadPosition=n.start,this.state=a.State.IDLE},h.checkFragmentChanged=function(){var n=this.media,c=null;if(n&&n.readyState>1&&n.seeking===!1){var m=n.currentTime;if(C.BufferHelper.isBuffered(n,m)?c=this.getAppendedFrag(m):C.BufferHelper.isBuffered(n,m+.1)&&(c=this.getAppendedFrag(m+.1)),c){this.backtrackFragment=null;var f=this.fragPlaying,g=c.level;(!f||c.sn!==f.sn||f.level!==g||c.urlId!==f.urlId)&&(this.hls.trigger(R.Events.FRAG_CHANGED,{frag:c}),(!f||f.level!==g)&&this.hls.trigger(R.Events.LEVEL_SWITCHED,{level:g}),this.fragPlaying=c)}}},v(o,[{key:"nextLevel",get:function(){var n=this.nextBufferedFrag;return n?n.level:-1}},{key:"currentFrag",get:function(){var n=this.media;return n?this.fragPlaying||this.getAppendedFrag(n.currentTime):null}},{key:"currentProgramDateTime",get:function(){var n=this.media;if(n){var c=n.currentTime,m=this.currentFrag;if(m&&Object(s.isFiniteNumber)(c)&&Object(s.isFiniteNumber)(m.programDateTime)){var f=m.programDateTime+(c-m.start)*1e3;return new Date(f)}}return null}},{key:"currentLevel",get:function(){var n=this.currentFrag;return n?n.level:-1}},{key:"nextBufferedFrag",get:function(){var n=this.currentFrag;return n?this.followingBufferedFrag(n):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),o}(a.default)},"./src/controller/subtitle-stream-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"SubtitleStreamController",function(){return i});var s=e("./src/events.ts"),a=e("./src/utils/buffer-helper.ts"),u=e("./src/controller/fragment-finders.ts"),R=e("./src/utils/discontinuities.ts"),C=e("./src/controller/level-helper.ts"),O=e("./src/controller/fragment-tracker.ts"),L=e("./src/controller/base-stream-controller.ts"),b=e("./src/types/loader.ts"),x=e("./src/types/level.ts");function I(p,T){for(var l=0;l<T.length;l++){var o=T[l];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(p,o.key,o)}}function _(p,T,l){return T&&I(p.prototype,T),l&&I(p,l),Object.defineProperty(p,"prototype",{writable:!1}),p}function A(p,T){p.prototype=Object.create(T.prototype),p.prototype.constructor=p,S(p,T)}function S(p,T){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,h){return o.__proto__=h,o},S(p,T)}var v=500,i=function(p){A(T,p);function T(o,h){var E;return E=p.call(this,o,h,"[subtitle-stream-controller]")||this,E.levels=[],E.currentTrackId=-1,E.tracksBuffered=[],E.mainDetails=null,E._registerListeners(),E}var l=T.prototype;return l.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},l._registerListeners=function(){var h=this.hls;h.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(s.Events.ERROR,this.onError,this),h.on(s.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.on(s.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),h.on(s.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),h.on(s.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),h.on(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},l._unregisterListeners=function(){var h=this.hls;h.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(s.Events.ERROR,this.onError,this),h.off(s.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.off(s.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),h.off(s.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),h.off(s.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),h.off(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},l.startLoad=function(){this.stopLoad(),this.state=L.State.IDLE,this.setInterval(v),this.tick()},l.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},l.onLevelLoaded=function(h,E){this.mainDetails=E.details},l.onSubtitleFragProcessed=function(h,E){var n=E.frag,c=E.success;if(this.fragPrevious=n,this.state=L.State.IDLE,!!c){var m=this.tracksBuffered[this.currentTrackId];if(!!m){for(var f,g=n.start,y=0;y<m.length;y++)if(g>=m[y].start&&g<=m[y].end){f=m[y];break}var M=n.start+n.duration;f?f.end=M:(f={start:g,end:M},m.push(f)),this.fragmentTracker.fragBuffered(n)}}},l.onBufferFlushing=function(h,E){var n=E.startOffset,c=E.endOffset;if(n===0&&c!==Number.POSITIVE_INFINITY){var m=this.currentTrackId,f=this.levels;if(!f.length||!f[m]||!f[m].details)return;var g=f[m].details,y=g.targetduration,M=c-y;if(M<=0)return;E.endOffsetSubtitles=Math.max(0,M),this.tracksBuffered.forEach(function(D){for(var P=0;P<D.length;){if(D[P].end<=M){D.shift();continue}else if(D[P].start<M)D[P].start=M;else break;P++}}),this.fragmentTracker.removeFragmentsInRange(n,M,b.PlaylistLevelType.SUBTITLE)}},l.onError=function(h,E){var n,c=E.frag;!c||c.type!==b.PlaylistLevelType.SUBTITLE||((n=this.fragCurrent)!==null&&n!==void 0&&n.loader&&this.fragCurrent.loader.abort(),this.state=L.State.IDLE)},l.onSubtitleTracksUpdated=function(h,E){var n=this,c=E.subtitleTracks;this.tracksBuffered=[],this.levels=c.map(function(m){return new x.Level(m)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(m){n.tracksBuffered[m.id]=[]}),this.mediaBuffer=null},l.onSubtitleTrackSwitch=function(h,E){if(this.currentTrackId=E.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var n=this.levels[this.currentTrackId];n!=null&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.setInterval(v)},l.onSubtitleTrackLoaded=function(h,E){var n,c=E.details,m=E.id,f=this.currentTrackId,g=this.levels;if(!!g.length){var y=g[f];if(!(m>=g.length||m!==f||!y)){if(this.mediaBuffer=this.mediaBufferTimeRanges,c.live||(n=y.details)!==null&&n!==void 0&&n.live){var M=this.mainDetails;if(c.deltaUpdateFailed||!M)return;var D=M.fragments[0];if(!y.details)c.hasProgramDateTime&&M.hasProgramDateTime?Object(R.alignMediaPlaylistByPDT)(c,M):D&&Object(C.addSliding)(c,D.start);else{var P=this.alignPlaylists(c,y.details);P===0&&D&&Object(C.addSliding)(c,D.start)}}if(y.details=c,this.levelLastLoaded=m,this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===L.State.IDLE){var B=Object(u.findFragmentByPTS)(null,c.fragments,this.media.currentTime,0);B||(this.warn("Subtitle playlist not aligned with playback"),y.details=void 0)}}}},l._handleFragmentLoadComplete=function(h){var E=h.frag,n=h.payload,c=E.decryptdata,m=this.hls;if(!this.fragContextChanged(E)&&n&&n.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var f=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(n),c.key.buffer,c.iv.buffer).then(function(g){var y=performance.now();m.trigger(s.Events.FRAG_DECRYPTED,{frag:E,payload:g,stats:{tstart:f,tdecrypt:y}})})}},l.doTick=function(){if(!this.media){this.state=L.State.IDLE;return}if(this.state===L.State.IDLE){var h=this.currentTrackId,E=this.levels;if(!E.length||!E[h]||!E[h].details)return;var n=E[h].details,c=n.targetduration,m=this.config,f=this.media,g=a.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],f.currentTime-c,m.maxBufferHole),y=g.end,M=g.len,D=this.getMaxBufferLength()+c;if(M>D)return;console.assert(n,"Subtitle track details are defined on idle subtitle stream controller tick");var P=n.fragments,B=P.length,N=n.edge,F,H=this.fragPrevious;if(y<N){var V=m.maxFragLookUpTolerance;F=Object(u.findFragmentByPTS)(H,P,Math.max(P[0].start,y),V),!F&&H&&H.start<P[0].start&&(F=P[0])}else F=P[B-1];if(F=this.mapToInitFragWhenRequired(F),!F||this.fragmentTracker.getState(F)!==O.FragmentState.NOT_LOADED)return;F.encrypted?this.loadKey(F,n):this.loadFragment(F,n,y)}},l.loadFragment=function(h,E,n){this.fragCurrent=h,h.sn==="initSegment"?this._loadInitSegment(h):p.prototype.loadFragment.call(this,h,E,n)},_(T,[{key:"mediaBufferTimeRanges",get:function(){return new d(this.tracksBuffered[this.currentTrackId]||[])}}]),T}(L.default),d=function(T){this.buffered=void 0;var l=function(h,E,n){if(E=E>>>0,E>n-1)throw new DOMException("Failed to execute '"+h+"' on 'TimeRanges': The index provided ("+E+") is greater than the maximum bound ("+n+")");return T[E][h]};this.buffered={get length(){return T.length},end:function(h){return l("end",h,T.length)},start:function(h){return l("start",h,T.length)}}}},"./src/controller/subtitle-track-controller.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/events.ts"),a=e("./src/utils/texttrack-utils.ts"),u=e("./src/controller/base-playlist-controller.ts"),R=e("./src/types/loader.ts");function C(_,A){for(var S=0;S<A.length;S++){var v=A[S];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(_,v.key,v)}}function O(_,A,S){return A&&C(_.prototype,A),S&&C(_,S),Object.defineProperty(_,"prototype",{writable:!1}),_}function L(_,A){_.prototype=Object.create(A.prototype),_.prototype.constructor=_,b(_,A)}function b(_,A){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,i){return v.__proto__=i,v},b(_,A)}var x=function(_){L(A,_);function A(v){var i;return i=_.call(this,v,"[subtitle-track-controller]")||this,i.media=null,i.tracks=[],i.groupId=null,i.tracksInGroup=[],i.trackId=-1,i.selectDefaultTrack=!0,i.queuedDefaultTrack=-1,i.trackChangeListener=function(){return i.onTextTracksChanged()},i.asyncPollTrackChange=function(){return i.pollTrackChange(0)},i.useTextTrackPolling=!1,i.subtitlePollingInterval=-1,i._subtitleDisplay=!0,i.registerListeners(),i}var S=A.prototype;return S.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,_.prototype.destroy.call(this)},S.registerListeners=function(){var i=this.hls;i.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.on(s.Events.LEVEL_LOADING,this.onLevelLoading,this),i.on(s.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),i.on(s.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),i.on(s.Events.ERROR,this.onError,this)},S.unregisterListeners=function(){var i=this.hls;i.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.off(s.Events.LEVEL_LOADING,this.onLevelLoading,this),i.off(s.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),i.off(s.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),i.off(s.Events.ERROR,this.onError,this)},S.onMediaAttached=function(i,d){this.media=d.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(i){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,i)},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 i=I(this.media.textTracks);i.forEach(function(d){Object(a.clearCurrentCues)(d)}),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(i,d){this.tracks=d.subtitleTracks},S.onSubtitleTrackLoaded=function(i,d){var p=d.id,T=d.details,l=this.trackId,o=this.tracksInGroup[l];if(!o){this.warn("Invalid subtitle track id "+p);return}var h=o.details;o.details=d.details,this.log("subtitle track "+p+" loaded ["+T.startSN+"-"+T.endSN+"]"),p===this.trackId&&(this.retryCount=0,this.playlistLoaded(p,d,h))},S.onLevelLoading=function(i,d){this.switchLevel(d.level)},S.onLevelSwitching=function(i,d){this.switchLevel(d.level)},S.switchLevel=function(i){var d=this.hls.levels[i];if(!!(d!=null&&d.textGroupIds)){var p=d.textGroupIds[d.urlId];if(this.groupId!==p){var T=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,l=this.tracks.filter(function(E){return!p||E.groupId===p});this.tracksInGroup=l;var o=this.findTrackId(T==null?void 0:T.name)||this.findTrackId();this.groupId=p;var h={subtitleTracks:l};this.log("Updating subtitle tracks, "+l.length+' track(s) found in "'+p+'" group-id'),this.hls.trigger(s.Events.SUBTITLE_TRACKS_UPDATED,h),o!==-1&&this.setSubtitleTrack(o,T)}}},S.findTrackId=function(i){for(var d=this.tracksInGroup,p=0;p<d.length;p++){var T=d[p];if((!this.selectDefaultTrack||T.default)&&(!i||i===T.name))return T.id}return-1},S.onError=function(i,d){_.prototype.onError.call(this,i,d),!(d.fatal||!d.context)&&d.context.type===R.PlaylistContextType.SUBTITLE_TRACK&&d.context.id===this.trackId&&d.context.groupId===this.groupId&&this.retryLoadingOrFail(d)},S.loadPlaylist=function(i){var d=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(d)){var p=d.id,T=d.groupId,l=d.url;if(i)try{l=i.addDirectives(l)}catch(o){this.warn("Could not construct new URL with HLS Delivery Directives: "+o)}this.log("Loading subtitle playlist for id "+p),this.hls.trigger(s.Events.SUBTITLE_TRACK_LOADING,{url:l,id:p,groupId:T,deliveryDirectives:i||null})}},S.toggleTrackModes=function(i){var d=this,p=this.media,T=this.trackId;if(!!p){var l=I(p.textTracks),o=l.filter(function(n){return n.groupId===d.groupId});if(i===-1)[].slice.call(l).forEach(function(n){n.mode="disabled"});else{var h=o[T];h&&(h.mode="disabled")}var E=o[i];E&&(E.mode=this.subtitleDisplay?"showing":"hidden")}},S.setSubtitleTrack=function(i,d){var p,T=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=i;return}if(this.trackId!==i&&this.toggleTrackModes(i),!(this.trackId===i&&(i===-1||(p=T[i])!==null&&p!==void 0&&p.details)||i<-1||i>=T.length)){this.clearTimer();var l=T[i];if(this.log("Switching to subtitle track "+i),this.trackId=i,l){var o=l.id,h=l.groupId,E=h===void 0?"":h,n=l.name,c=l.type,m=l.url;this.hls.trigger(s.Events.SUBTITLE_TRACK_SWITCH,{id:o,groupId:E,name:n,type:c,url:m});var f=this.switchParams(l.url,d==null?void 0:d.details);this.loadPlaylist(f)}else this.hls.trigger(s.Events.SUBTITLE_TRACK_SWITCH,{id:i})}},S.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var i=-1,d=I(this.media.textTracks),p=0;p<d.length;p++)if(d[p].mode==="hidden")i=p;else if(d[p].mode==="showing"){i=p;break}this.subtitleTrack!==i&&(this.subtitleTrack=i)}},O(A,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(i){this._subtitleDisplay=i,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(i){this.selectDefaultTrack=!1;var d=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(i,d)}}]),A}(u.default);function I(_){for(var A=[],S=0;S<_.length;S++){var v=_[S];v.kind==="subtitles"&&v.label&&A.push(_[S])}return A}t.default=x},"./src/controller/timeline-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"TimelineController",function(){return _});var s=e("./src/polyfills/number.ts"),a=e("./src/events.ts"),u=e("./src/utils/cea-608-parser.ts"),R=e("./src/utils/output-filter.ts"),C=e("./src/utils/webvtt-parser.ts"),O=e("./src/utils/texttrack-utils.ts"),L=e("./src/utils/imsc1-ttml-parser.ts"),b=e("./src/utils/mp4-tools.ts"),x=e("./src/types/loader.ts"),I=e("./src/utils/logger.ts"),_=function(){function i(p){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=p,this.config=p.config,this.Cues=p.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 T=new R.default(this,"textTrack1"),l=new R.default(this,"textTrack2"),o=new R.default(this,"textTrack3"),h=new R.default(this,"textTrack4");this.cea608Parser1=new u.default(1,T,l),this.cea608Parser2=new u.default(3,o,h)}p.on(a.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),p.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.on(a.Events.MANIFEST_LOADED,this.onManifestLoaded,this),p.on(a.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),p.on(a.Events.FRAG_LOADING,this.onFragLoading,this),p.on(a.Events.FRAG_LOADED,this.onFragLoaded,this),p.on(a.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),p.on(a.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),p.on(a.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),p.on(a.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),p.on(a.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var d=i.prototype;return d.destroy=function(){var T=this.hls;T.off(a.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),T.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),T.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),T.off(a.Events.MANIFEST_LOADED,this.onManifestLoaded,this),T.off(a.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),T.off(a.Events.FRAG_LOADING,this.onFragLoading,this),T.off(a.Events.FRAG_LOADED,this.onFragLoaded,this),T.off(a.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),T.off(a.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),T.off(a.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),T.off(a.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),T.off(a.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},d.addCues=function(T,l,o,h,E){for(var n=!1,c=E.length;c--;){var m=E[c],f=S(m[0],m[1],l,o);if(f>=0&&(m[0]=Math.min(m[0],l),m[1]=Math.max(m[1],o),n=!0,f/(o-l)>.5))return}if(n||E.push([l,o]),this.config.renderTextTracksNatively){var g=this.captionsTracks[T];this.Cues.newCue(g,l,o,h)}else{var y=this.Cues.newCue(null,l,o,h);this.hls.trigger(a.Events.CUES_PARSED,{type:"captions",cues:y,track:T})}},d.onInitPtsFound=function(T,l){var o=this,h=l.frag,E=l.id,n=l.initPTS,c=l.timescale,m=this.unparsedVttFrags;E==="main"&&(this.initPTS[h.cc]=n,this.timescale[h.cc]=c),m.length&&(this.unparsedVttFrags=[],m.forEach(function(f){o.onFragLoaded(a.Events.FRAG_LOADED,f)}))},d.getExistingTrack=function(T){var l=this.media;if(l)for(var o=0;o<l.textTracks.length;o++){var h=l.textTracks[o];if(h[T])return h}return null},d.createCaptionsTrack=function(T){this.config.renderTextTracksNatively?this.createNativeTrack(T):this.createNonNativeTrack(T)},d.createNativeTrack=function(T){if(!this.captionsTracks[T]){var l=this.captionsProperties,o=this.captionsTracks,h=this.media,E=l[T],n=E.label,c=E.languageCode,m=this.getExistingTrack(T);if(m)o[T]=m,Object(O.clearCurrentCues)(o[T]),Object(O.sendAddTrackEvent)(o[T],h);else{var f=this.createTextTrack("captions",n,c);f&&(f[T]=!0,o[T]=f)}}},d.createNonNativeTrack=function(T){if(!this.nonNativeCaptionsTracks[T]){var l=this.captionsProperties[T];if(!!l){var o=l.label,h={_id:T,label:o,kind:"captions",default:l.media?!!l.media.default:!1,closedCaptions:l.media};this.nonNativeCaptionsTracks[T]=h,this.hls.trigger(a.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[h]})}}},d.createTextTrack=function(T,l,o){var h=this.media;if(!!h)return h.addTextTrack(T,l,o)},d.onMediaAttaching=function(T,l){this.media=l.media,this._cleanTracks()},d.onMediaDetaching=function(){var T=this.captionsTracks;Object.keys(T).forEach(function(l){Object(O.clearCurrentCues)(T[l]),delete T[l]}),this.nonNativeCaptionsTracks={}},d.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())},d._cleanTracks=function(){var T=this.media;if(!!T){var l=T.textTracks;if(l)for(var o=0;o<l.length;o++)Object(O.clearCurrentCues)(l[o])}},d.onSubtitleTracksUpdated=function(T,l){var o=this;this.textTracks=[];var h=l.subtitleTracks||[],E=h.some(function(f){return f.textCodec===L.IMSC1_CODEC});if(this.config.enableWebVTT||E&&this.config.enableIMSC1){var n=this.tracks&&h&&this.tracks.length===h.length;if(this.tracks=h||[],this.config.renderTextTracksNatively){var c=this.media?this.media.textTracks:[];this.tracks.forEach(function(f,g){var y;if(g<c.length){for(var M=null,D=0;D<c.length;D++)if(A(c[D],f)){M=c[D];break}M&&(y=M)}if(y)Object(O.clearCurrentCues)(y);else{var P=o._captionsOrSubtitlesFromCharacteristics(f);y=o.createTextTrack(P,f.name,f.lang),y&&(y.mode="disabled")}y&&(y.groupId=f.groupId,o.textTracks.push(y))})}else if(!n&&this.tracks&&this.tracks.length){var m=this.tracks.map(function(f){return{label:f.name,kind:f.type.toLowerCase(),default:f.default,subtitleTrack:f}});this.hls.trigger(a.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:m})}}},d._captionsOrSubtitlesFromCharacteristics=function(T){var l;if((l=T.attrs)!==null&&l!==void 0&&l.CHARACTERISTICS){var o=/transcribes-spoken-dialog/gi.test(T.attrs.CHARACTERISTICS),h=/describes-music-and-sound/gi.test(T.attrs.CHARACTERISTICS);if(o&&h)return"captions"}return"subtitles"},d.onManifestLoaded=function(T,l){var o=this;this.config.enableCEA708Captions&&l.captions&&l.captions.forEach(function(h){var E=/(?:CC|SERVICE)([1-4])/.exec(h.instreamId);if(!!E){var n="textTrack"+E[1],c=o.captionsProperties[n];!c||(c.label=h.name,h.lang&&(c.languageCode=h.lang),c.media=h)}})},d.onFragLoading=function(T,l){var o=this.cea608Parser1,h=this.cea608Parser2,E=this.lastSn,n=this.lastPartIndex;if(!(!this.enabled||!(o&&h))&&l.frag.type===x.PlaylistLevelType.MAIN){var c,m,f=l.frag.sn,g=(c=l==null||(m=l.part)===null||m===void 0?void 0:m.index)!=null?c:-1;f===E+1||f===E&&g===n+1||(o.reset(),h.reset()),this.lastSn=f,this.lastPartIndex=g}},d.onFragLoaded=function(T,l){var o=l.frag,h=l.payload,E=this.initPTS,n=this.unparsedVttFrags;if(o.type===x.PlaylistLevelType.SUBTITLE)if(h.byteLength){if(!Object(s.isFiniteNumber)(E[o.cc])){n.push(l),E.length&&this.hls.trigger(a.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:new Error("Missing initial subtitle PTS")});return}var c=o.decryptdata,m="stats"in l;if(c==null||c.key==null||c.method!=="AES-128"||m){var f=this.tracks[o.level],g=this.vttCCs;g[o.cc]||(g[o.cc]={start:o.start,prevCC:this.prevCC,new:!0},this.prevCC=o.cc),f&&f.textCodec===L.IMSC1_CODEC?this._parseIMSC1(o,h):this._parseVTTs(o,h,g)}}else this.hls.trigger(a.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:new Error("Empty subtitle payload")})},d._parseIMSC1=function(T,l){var o=this,h=this.hls;Object(L.parseIMSC1)(l,this.initPTS[T.cc],this.timescale[T.cc],function(E){o._appendCues(E,T.level),h.trigger(a.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:T})},function(E){I.logger.log("Failed to parse IMSC1: "+E),h.trigger(a.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:T,error:E})})},d._parseVTTs=function(T,l,o){var h,E=this,n=this.hls,c=(h=T.initSegment)!==null&&h!==void 0&&h.data?Object(b.appendUint8Array)(T.initSegment.data,new Uint8Array(l)):l;Object(C.parseWebVTT)(c,this.initPTS[T.cc],this.timescale[T.cc],o,T.cc,T.start,function(m){E._appendCues(m,T.level),n.trigger(a.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:T})},function(m){E._fallbackToIMSC1(T,l),I.logger.log("Failed to parse VTT cue: "+m),n.trigger(a.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:T,error:m})})},d._fallbackToIMSC1=function(T,l){var o=this,h=this.tracks[T.level];h.textCodec||Object(L.parseIMSC1)(l,this.initPTS[T.cc],this.timescale[T.cc],function(){h.textCodec=L.IMSC1_CODEC,o._parseIMSC1(T,l)},function(){h.textCodec="wvtt"})},d._appendCues=function(T,l){var o=this.hls;if(this.config.renderTextTracksNatively){var h=this.textTracks[l];if(!h||h.mode==="disabled")return;T.forEach(function(c){return Object(O.addCueToTrack)(h,c)})}else{var E=this.tracks[l];if(!E)return;var n=E.default?"default":"subtitles"+l;o.trigger(a.Events.CUES_PARSED,{type:"subtitles",cues:T,track:n})}},d.onFragDecrypted=function(T,l){var o=l.frag;if(o.type===x.PlaylistLevelType.SUBTITLE){if(!Object(s.isFiniteNumber)(this.initPTS[o.cc])){this.unparsedVttFrags.push(l);return}this.onFragLoaded(a.Events.FRAG_LOADED,l)}},d.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},d.onFragParsingUserdata=function(T,l){var o=this.cea608Parser1,h=this.cea608Parser2;if(!(!this.enabled||!(o&&h)))for(var E=0;E<l.samples.length;E++){var n=l.samples[E].bytes;if(n){var c=this.extractCea608Data(n);o.addData(l.samples[E].pts,c[0]),h.addData(l.samples[E].pts,c[1])}}},d.onBufferFlushing=function(T,l){var o=l.startOffset,h=l.endOffset,E=l.endOffsetSubtitles,n=l.type,c=this.media;if(!(!c||c.currentTime<h)){if(!n||n==="video"){var m=this.captionsTracks;Object.keys(m).forEach(function(g){return Object(O.removeCuesInRange)(m[g],o,h)})}if(this.config.renderTextTracksNatively&&o===0&&E!==void 0){var f=this.textTracks;Object.keys(f).forEach(function(g){return Object(O.removeCuesInRange)(f[g],o,E)})}}},d.extractCea608Data=function(T){for(var l=[[],[]],o=T[0]&31,h=2,E=0;E<o;E++){var n=T[h++],c=127&T[h++],m=127&T[h++];if(!(c===0&&m===0)){var f=(4&n)!==0;if(f){var g=3&n;(g===0||g===1)&&(l[g].push(c),l[g].push(m))}}}return l},i}();function A(i,d){return i&&i.label===d.name&&!(i.textTrack1||i.textTrack2)}function S(i,d,p,T){return Math.min(d,T)-Math.max(i,p)}function v(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return s});var s=function(){function a(R,C){this.subtle=void 0,this.aesIV=void 0,this.subtle=R,this.aesIV=C}var u=a.prototype;return u.decrypt=function(C,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,C)},a}()},"./src/crypt/aes-decryptor.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"removePadding",function(){return a}),e.d(t,"default",function(){return u});var s=e("./src/utils/typed-array.ts");function a(R){var C=R.byteLength,O=C&&new DataView(R.buffer).getUint8(C-1);return O?Object(s.sliceUint8)(R,0,C-O):R}var u=function(){function R(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var C=R.prototype;return C.uint8ArrayToUint32Array_=function(L){for(var b=new DataView(L),x=new Uint32Array(4),I=0;I<4;I++)x[I]=b.getUint32(I*4);return x},C.initTable=function(){var L=this.sBox,b=this.invSBox,x=this.subMix,I=x[0],_=x[1],A=x[2],S=x[3],v=this.invSubMix,i=v[0],d=v[1],p=v[2],T=v[3],l=new Uint32Array(256),o=0,h=0,E=0;for(E=0;E<256;E++)E<128?l[E]=E<<1:l[E]=E<<1^283;for(E=0;E<256;E++){var n=h^h<<1^h<<2^h<<3^h<<4;n=n>>>8^n&255^99,L[o]=n,b[n]=o;var c=l[o],m=l[c],f=l[m],g=l[n]*257^n*16843008;I[o]=g<<24|g>>>8,_[o]=g<<16|g>>>16,A[o]=g<<8|g>>>24,S[o]=g,g=f*16843009^m*65537^c*257^o*16843008,i[n]=g<<24|g>>>8,d[n]=g<<16|g>>>16,p[n]=g<<8|g>>>24,T[n]=g,o?(o=c^l[l[l[f^c]]],h^=l[l[h]]):o=h=1}},C.expandKey=function(L){for(var b=this.uint8ArrayToUint32Array_(L),x=!0,I=0;I<b.length&&x;)x=b[I]===this.key[I],I++;if(!x){this.key=b;var _=this.keySize=b.length;if(_!==4&&_!==6&&_!==8)throw new Error("Invalid aes key size="+_);var A=this.ksRows=(_+6+1)*4,S,v,i=this.keySchedule=new Uint32Array(A),d=this.invKeySchedule=new Uint32Array(A),p=this.sBox,T=this.rcon,l=this.invSubMix,o=l[0],h=l[1],E=l[2],n=l[3],c,m;for(S=0;S<A;S++){if(S<_){c=i[S]=b[S];continue}m=c,S%_===0?(m=m<<8|m>>>24,m=p[m>>>24]<<24|p[m>>>16&255]<<16|p[m>>>8&255]<<8|p[m&255],m^=T[S/_|0]<<24):_>6&&S%_===4&&(m=p[m>>>24]<<24|p[m>>>16&255]<<16|p[m>>>8&255]<<8|p[m&255]),i[S]=c=(i[S-_]^m)>>>0}for(v=0;v<A;v++)S=A-v,v&3?m=i[S]:m=i[S-4],v<4||S<=4?d[v]=m:d[v]=o[p[m>>>24]]^h[p[m>>>16&255]]^E[p[m>>>8&255]]^n[p[m&255]],d[v]=d[v]>>>0}},C.networkToHostOrderSwap=function(L){return L<<24|(L&65280)<<8|(L&16711680)>>8|L>>>24},C.decrypt=function(L,b,x){for(var I=this.keySize+6,_=this.invKeySchedule,A=this.invSBox,S=this.invSubMix,v=S[0],i=S[1],d=S[2],p=S[3],T=this.uint8ArrayToUint32Array_(x),l=T[0],o=T[1],h=T[2],E=T[3],n=new Int32Array(L),c=new Int32Array(n.length),m,f,g,y,M,D,P,B,N,F,H,V,X,$,j=this.networkToHostOrderSwap;b<n.length;){for(N=j(n[b]),F=j(n[b+1]),H=j(n[b+2]),V=j(n[b+3]),M=N^_[0],D=V^_[1],P=H^_[2],B=F^_[3],X=4,$=1;$<I;$++)m=v[M>>>24]^i[D>>16&255]^d[P>>8&255]^p[B&255]^_[X],f=v[D>>>24]^i[P>>16&255]^d[B>>8&255]^p[M&255]^_[X+1],g=v[P>>>24]^i[B>>16&255]^d[M>>8&255]^p[D&255]^_[X+2],y=v[B>>>24]^i[M>>16&255]^d[D>>8&255]^p[P&255]^_[X+3],M=m,D=f,P=g,B=y,X=X+4;m=A[M>>>24]<<24^A[D>>16&255]<<16^A[P>>8&255]<<8^A[B&255]^_[X],f=A[D>>>24]<<24^A[P>>16&255]<<16^A[B>>8&255]<<8^A[M&255]^_[X+1],g=A[P>>>24]<<24^A[B>>16&255]<<16^A[M>>8&255]<<8^A[D&255]^_[X+2],y=A[B>>>24]<<24^A[M>>16&255]<<16^A[D>>8&255]<<8^A[P&255]^_[X+3],c[b]=j(m^l),c[b+1]=j(y^o),c[b+2]=j(g^h),c[b+3]=j(f^E),l=N,o=F,h=H,E=V,b=b+4}return c.buffer},R}()},"./src/crypt/decrypter.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return b});var s=e("./src/crypt/aes-crypto.ts"),a=e("./src/crypt/fast-aes-key.ts"),u=e("./src/crypt/aes-decryptor.ts"),R=e("./src/utils/logger.ts"),C=e("./src/utils/mp4-tools.ts"),O=e("./src/utils/typed-array.ts"),L=16,b=function(){function x(_,A,S){var v=S===void 0?{}:S,i=v.removePKCS7Padding,d=i===void 0?!0:i;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=_,this.config=A,this.removePKCS7Padding=d,d)try{var p=self.crypto;p&&(this.subtle=p.subtle||p.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var I=x.prototype;return I.destroy=function(){this.observer=null},I.isSync=function(){return this.config.enableSoftwareAES},I.flush=function(){var A=this.currentResult;if(!A){this.reset();return}var S=new Uint8Array(A);return this.reset(),this.removePKCS7Padding?Object(u.removePadding)(S):S},I.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},I.decrypt=function(A,S,v,i){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(A),S,v);var d=this.flush();d&&i(d.buffer)}else this.webCryptoDecrypt(new Uint8Array(A),S,v).then(i)},I.softwareDecrypt=function(A,S,v){var i=this.currentIV,d=this.currentResult,p=this.remainderData;this.logOnce("JS AES decrypt"),p&&(A=Object(C.appendUint8Array)(p,A),this.remainderData=null);var T=this.getValidChunk(A);if(!T.length)return null;i&&(v=i);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new u.default),l.expandKey(S);var o=d;return this.currentResult=l.decrypt(T.buffer,0,v),this.currentIV=Object(O.sliceUint8)(T,-16).buffer,o||null},I.webCryptoDecrypt=function(A,S,v){var i=this,d=this.subtle;return(this.key!==S||!this.fastAesKey)&&(this.key=S,this.fastAesKey=new a.default(d,S)),this.fastAesKey.expandKey().then(function(p){if(!d)return Promise.reject(new Error("web crypto not initialized"));var T=new s.default(d,v);return T.decrypt(A.buffer,p)}).catch(function(p){return i.onWebCryptoError(p,A,S,v)})},I.onWebCryptoError=function(A,S,v,i){return R.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",A),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(S,v,i)},I.getValidChunk=function(A){var S=A,v=A.length-A.length%L;return v!==A.length&&(S=Object(O.sliceUint8)(A,0,v),this.remainderData=Object(O.sliceUint8)(A,v)),S},I.logOnce=function(A){!this.logEnabled||(R.logger.log("[decrypter.ts]: "+A),this.logEnabled=!1)},x}()},"./src/crypt/fast-aes-key.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return s});var s=function(){function a(R,C){this.subtle=void 0,this.key=void 0,this.subtle=R,this.key=C}var u=a.prototype;return u.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},a}()},"./src/demux/aacdemuxer.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/demux/base-audio-demuxer.ts"),a=e("./src/demux/adts.ts"),u=e("./src/utils/logger.ts"),R=e("./src/demux/id3.ts");function C(b,x){b.prototype=Object.create(x.prototype),b.prototype.constructor=b,O(b,x)}function O(b,x){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(_,A){return _.__proto__=A,_},O(b,x)}var L=function(b){C(x,b);function x(_,A){var S;return S=b.call(this)||this,S.observer=void 0,S.config=void 0,S.observer=_,S.config=A,S}var I=x.prototype;return I.resetInitSegment=function(A,S,v,i){b.prototype.resetInitSegment.call(this,A,S,v,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:S,duration:i,inputTimeScale:9e4,dropped:0}},x.probe=function(A){if(!A)return!1;for(var S=R.getID3Data(A,0)||[],v=S.length,i=A.length;v<i;v++)if(a.probe(A,v))return u.logger.log("ADTS sync word found !"),!0;return!1},I.canParse=function(A,S){return a.canParse(A,S)},I.appendFrame=function(A,S,v){a.initTrackConfig(A,this.observer,S,v,A.manifestCodec);var i=a.appendFrame(A,S,v,this.basePTS,this.frameIndex);if(i&&i.missing===0)return i},x}(s.default);t.default=L},"./src/demux/adts.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"getAudioConfig",function(){return R}),e.d(t,"isHeaderPattern",function(){return C}),e.d(t,"getHeaderLength",function(){return O}),e.d(t,"getFullFrameLength",function(){return L}),e.d(t,"canGetFrameLength",function(){return b}),e.d(t,"isHeader",function(){return x}),e.d(t,"canParse",function(){return I}),e.d(t,"probe",function(){return _}),e.d(t,"initTrackConfig",function(){return A}),e.d(t,"getFrameDuration",function(){return S}),e.d(t,"parseFrameHeader",function(){return v}),e.d(t,"appendFrame",function(){return i});var s=e("./src/utils/logger.ts"),a=e("./src/errors.ts"),u=e("./src/events.ts");function R(d,p,T,l){var o,h,E,n,c=navigator.userAgent.toLowerCase(),m=l,f=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=((p[T+2]&192)>>>6)+1;var g=(p[T+2]&60)>>>2;if(g>f.length-1){d.trigger(u.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+g});return}return E=(p[T+2]&1)<<2,E|=(p[T+3]&192)>>>6,s.logger.log("manifest codec:"+l+", ADTS type:"+o+", samplingIndex:"+g),/firefox/i.test(c)?g>=6?(o=5,n=new Array(4),h=g-3):(o=2,n=new Array(2),h=g):c.indexOf("android")!==-1?(o=2,n=new Array(2),h=g):(o=5,n=new Array(4),l&&(l.indexOf("mp4a.40.29")!==-1||l.indexOf("mp4a.40.5")!==-1)||!l&&g>=6?h=g-3:((l&&l.indexOf("mp4a.40.2")!==-1&&(g>=6&&E===1||/vivaldi/i.test(c))||!l&&E===1)&&(o=2,n=new Array(2)),h=g)),n[0]=o<<3,n[0]|=(g&14)>>1,n[1]|=(g&1)<<7,n[1]|=E<<3,o===5&&(n[1]|=(h&14)>>1,n[2]=(h&1)<<7,n[2]|=2<<2,n[3]=0),{config:n,samplerate:f[g],channelCount:E,codec:"mp4a.40."+o,manifestCodec:m}}function C(d,p){return d[p]===255&&(d[p+1]&246)===240}function O(d,p){return d[p+1]&1?7:9}function L(d,p){return(d[p+3]&3)<<11|d[p+4]<<3|(d[p+5]&224)>>>5}function b(d,p){return p+5<d.length}function x(d,p){return p+1<d.length&&C(d,p)}function I(d,p){return b(d,p)&&C(d,p)&&L(d,p)<=d.length-p}function _(d,p){if(x(d,p)){var T=O(d,p);if(p+T>=d.length)return!1;var l=L(d,p);if(l<=T)return!1;var o=p+l;return o===d.length||x(d,o)}return!1}function A(d,p,T,l,o){if(!d.samplerate){var h=R(p,T,l,o);if(!h)return;d.config=h.config,d.samplerate=h.samplerate,d.channelCount=h.channelCount,d.codec=h.codec,d.manifestCodec=h.manifestCodec,s.logger.log("parsed codec:"+d.codec+", rate:"+h.samplerate+", channels:"+h.channelCount)}}function S(d){return 1024*9e4/d}function v(d,p){var T=O(d,p);if(p+T<=d.length){var l=L(d,p)-T;if(l>0)return{headerLength:T,frameLength:l}}}function i(d,p,T,l,o){var h=S(d.samplerate),E=l+o*h,n=v(p,T),c;if(n){var m=n.frameLength,f=n.headerLength,g=f+m,y=Math.max(0,T+g-p.length);y?(c=new Uint8Array(g-f),c.set(p.subarray(T+f,p.length),0)):c=p.subarray(T+f,T+g);var M={unit:c,pts:E};return y||d.samples.push(M),{sample:M,length:g,missing:y}}var D=p.length-T;c=new Uint8Array(D),c.set(p.subarray(T,p.length),0);var P={unit:c,pts:E};return{sample:P,length:D,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"initPTSFn",function(){return b});var s=e("./src/polyfills/number.ts"),a=e("./src/demux/id3.ts"),u=e("./src/types/demuxer.ts"),R=e("./src/demux/dummy-demuxed-track.ts"),C=e("./src/utils/mp4-tools.ts"),O=e("./src/utils/typed-array.ts"),L=function(){function x(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var I=x.prototype;return I.resetInitSegment=function(A,S,v,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},I.resetTimeStamp=function(A){this.initPTS=A,this.resetContiguity()},I.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},I.canParse=function(A,S){return!1},I.appendFrame=function(A,S,v){},I.demux=function(A,S){this.cachedData&&(A=Object(C.appendUint8Array)(this.cachedData,A),this.cachedData=null);var v=a.getID3Data(A,0),i=v?v.length:0,d,p,T=this._audioTrack,l=this._id3Track,o=v?a.getTimeStamp(v):void 0,h=A.length;for((this.basePTS===null||this.frameIndex===0&&Object(s.isFiniteNumber)(o))&&(this.basePTS=b(o,S,this.initPTS)),v&&v.length>0&&l.samples.push({pts:this.basePTS,dts:this.basePTS,data:v,type:u.MetadataSchema.audioId3}),p=this.basePTS;i<h;){if(this.canParse(A,i)){var E=this.appendFrame(T,A,i);E?(this.frameIndex++,p=E.sample.pts,i+=E.length,d=i):i=h}else a.canParse(A,i)?(v=a.getID3Data(A,i),l.samples.push({pts:p,dts:p,data:v,type:u.MetadataSchema.audioId3}),i+=v.length,d=i):i++;if(i===h&&d!==h){var n=Object(O.sliceUint8)(A,d);this.cachedData?this.cachedData=Object(C.appendUint8Array)(this.cachedData,n):this.cachedData=n}}return{audioTrack:T,videoTrack:Object(R.dummyTrack)(),id3Track:l,textTrack:Object(R.dummyTrack)()}},I.demuxSampleAes=function(A,S,v){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},I.flush=function(A){var S=this.cachedData;return S&&(this.cachedData=null,this.demux(S,0)),{audioTrack:this._audioTrack,videoTrack:Object(R.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(R.dummyTrack)()}},I.destroy=function(){},x}(),b=function(I,_,A){return Object(s.isFiniteNumber)(I)?I*90:_*9e4+(A||0)};t.default=L},"./src/demux/chunk-cache.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return s});var s=function(){function u(){this.chunks=[],this.dataLength=0}var R=u.prototype;return R.push=function(O){this.chunks.push(O),this.dataLength+=O.length},R.flush=function(){var O=this.chunks,L=this.dataLength,b;if(O.length)O.length===1?b=O[0]:b=a(O,L);else return new Uint8Array(0);return this.reset(),b},R.reset=function(){this.chunks.length=0,this.dataLength=0},u}();function a(u,R){for(var C=new Uint8Array(R),O=0,L=0;L<u.length;L++){var b=u[L];C.set(b,O),O+=b.length}return C}},"./src/demux/dummy-demuxed-track.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"dummyTrack",function(){return s});function s(a,u){return a===void 0&&(a=""),u===void 0&&(u=9e4),{type:a,id:-1,pid:-1,inputTimeScale:u,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/utils/logger.ts"),a=function(){function u(C){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=C,this.bytesAvailable=C.byteLength,this.word=0,this.bitsAvailable=0}var R=u.prototype;return R.loadWord=function(){var O=this.data,L=this.bytesAvailable,b=O.byteLength-L,x=new Uint8Array(4),I=Math.min(4,L);if(I===0)throw new Error("no bytes available");x.set(O.subarray(b,b+I)),this.word=new DataView(x.buffer).getUint32(0),this.bitsAvailable=I*8,this.bytesAvailable-=I},R.skipBits=function(O){var L;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,L=O>>3,O-=L>>3,this.bytesAvailable-=L,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},R.readBits=function(O){var L=Math.min(this.bitsAvailable,O),b=this.word>>>32-L;return O>32&&s.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=L,this.bitsAvailable>0?this.word<<=L:this.bytesAvailable>0&&this.loadWord(),L=O-L,L>0&&this.bitsAvailable?b<<L|this.readBits(L):b},R.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()},R.skipUEG=function(){this.skipBits(1+this.skipLZ())},R.skipEG=function(){this.skipBits(1+this.skipLZ())},R.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},R.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},R.readBoolean=function(){return this.readBits(1)===1},R.readUByte=function(){return this.readBits(8)},R.readUShort=function(){return this.readBits(16)},R.readUInt=function(){return this.readBits(32)},R.skipScalingList=function(O){for(var L=8,b=8,x,I=0;I<O;I++)b!==0&&(x=this.readEG(),b=(L+x+256)%256),L=b===0?L:b},R.readSPS=function(){var O=0,L=0,b=0,x=0,I,_,A,S=this.readUByte.bind(this),v=this.readBits.bind(this),i=this.readUEG.bind(this),d=this.readBoolean.bind(this),p=this.skipBits.bind(this),T=this.skipEG.bind(this),l=this.skipUEG.bind(this),o=this.skipScalingList.bind(this);S();var h=S();if(v(5),p(3),S(),l(),h===100||h===110||h===122||h===244||h===44||h===83||h===86||h===118||h===128){var E=i();if(E===3&&p(1),l(),l(),p(1),d())for(_=E!==3?8:12,A=0;A<_;A++)d()&&(A<6?o(16):o(64))}l();var n=i();if(n===0)i();else if(n===1)for(p(1),T(),T(),I=i(),A=0;A<I;A++)T();l(),p(1);var c=i(),m=i(),f=v(1);f===0&&p(1),p(1),d()&&(O=i(),L=i(),b=i(),x=i());var g=[1,1];if(d()&&d()){var y=S();switch(y){case 1:g=[1,1];break;case 2:g=[12,11];break;case 3:g=[10,11];break;case 4:g=[16,11];break;case 5:g=[40,33];break;case 6:g=[24,11];break;case 7:g=[20,11];break;case 8:g=[32,11];break;case 9:g=[80,33];break;case 10:g=[18,11];break;case 11:g=[15,11];break;case 12:g=[64,33];break;case 13:g=[160,99];break;case 14:g=[4,3];break;case 15:g=[3,2];break;case 16:g=[2,1];break;case 255:{g=[S()<<8|S(),S()<<8|S()];break}}}return{width:Math.ceil((c+1)*16-O*2-L*2),height:(2-f)*(m+1)*16-(f?2:4)*(b+x),pixelRatio:g}},R.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},u}();t.default=a},"./src/demux/id3.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"isHeader",function(){return s}),e.d(t,"isFooter",function(){return a}),e.d(t,"getID3Data",function(){return u}),e.d(t,"canParse",function(){return C}),e.d(t,"getTimeStamp",function(){return O}),e.d(t,"isTimeStampFrame",function(){return L}),e.d(t,"getID3Frames",function(){return x}),e.d(t,"decodeFrame",function(){return I}),e.d(t,"utf8ArrayToStr",function(){return i}),e.d(t,"testables",function(){return d});var s=function(o,h){return h+10<=o.length&&o[h]===73&&o[h+1]===68&&o[h+2]===51&&o[h+3]<255&&o[h+4]<255&&o[h+6]<128&&o[h+7]<128&&o[h+8]<128&&o[h+9]<128},a=function(o,h){return h+10<=o.length&&o[h]===51&&o[h+1]===68&&o[h+2]===73&&o[h+3]<255&&o[h+4]<255&&o[h+6]<128&&o[h+7]<128&&o[h+8]<128&&o[h+9]<128},u=function(o,h){for(var E=h,n=0;s(o,h);){n+=10;var c=R(o,h+6);n+=c,a(o,h+10)&&(n+=10),h+=n}if(n>0)return o.subarray(E,E+n)},R=function(o,h){var E=0;return E=(o[h]&127)<<21,E|=(o[h+1]&127)<<14,E|=(o[h+2]&127)<<7,E|=o[h+3]&127,E},C=function(o,h){return s(o,h)&&R(o,h+6)+10<=o.length-h},O=function(o){for(var h=x(o),E=0;E<h.length;E++){var n=h[E];if(L(n))return v(n)}},L=function(o){return o&&o.key==="PRIV"&&o.info==="com.apple.streaming.transportStreamTimestamp"},b=function(o){var h=String.fromCharCode(o[0],o[1],o[2],o[3]),E=R(o,4),n=10;return{type:h,size:E,data:o.subarray(n,n+E)}},x=function(o){for(var h=0,E=[];s(o,h);){var n=R(o,h+6);h+=10;for(var c=h+n;h+8<c;){var m=b(o.subarray(h)),f=I(m);f&&E.push(f),h+=m.size+10}a(o,h)&&(h+=10)}return E},I=function(o){return o.type==="PRIV"?_(o):o.type[0]==="W"?S(o):A(o)},_=function(o){if(!(o.size<2)){var h=i(o.data,!0),E=new Uint8Array(o.data.subarray(h.length+1));return{key:o.type,info:h,data:E.buffer}}},A=function(o){if(!(o.size<2)){if(o.type==="TXXX"){var h=1,E=i(o.data.subarray(h),!0);h+=E.length+1;var n=i(o.data.subarray(h));return{key:o.type,info:E,data:n}}var c=i(o.data.subarray(1));return{key:o.type,data:c}}},S=function(o){if(o.type==="WXXX"){if(o.size<2)return;var h=1,E=i(o.data.subarray(h),!0);h+=E.length+1;var n=i(o.data.subarray(h));return{key:o.type,info:E,data:n}}var c=i(o.data);return{key:o.type,data:c}},v=function(o){if(o.data.byteLength===8){var h=new Uint8Array(o.data),E=h[3]&1,n=(h[4]<<23)+(h[5]<<15)+(h[6]<<7)+h[7];return n/=45,E&&(n+=4772185884e-2),Math.round(n)}},i=function(o,h){h===void 0&&(h=!1);var E=T();if(E){var n=E.decode(o);if(h){var c=n.indexOf("\0");return c!==-1?n.substring(0,c):n}return n.replace(/\0/g,"")}for(var m=o.length,f,g,y,M="",D=0;D<m;){if(f=o[D++],f===0&&h)return M;if(f===0||f===3)continue;switch(f>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:M+=String.fromCharCode(f);break;case 12:case 13:g=o[D++],M+=String.fromCharCode((f&31)<<6|g&63);break;case 14:g=o[D++],y=o[D++],M+=String.fromCharCode((f&15)<<12|(g&63)<<6|(y&63)<<0);break;default:}}return M},d={decodeTextFrame:A},p;function T(){return!p&&typeof self.TextDecoder!="undefined"&&(p=new self.TextDecoder("utf-8")),p}},"./src/demux/mp3demuxer.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/demux/base-audio-demuxer.ts"),a=e("./src/demux/id3.ts"),u=e("./src/utils/logger.ts"),R=e("./src/demux/mpegaudio.ts");function C(b,x){b.prototype=Object.create(x.prototype),b.prototype.constructor=b,O(b,x)}function O(b,x){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(_,A){return _.__proto__=A,_},O(b,x)}var L=function(b){C(x,b);function x(){return b.apply(this,arguments)||this}var I=x.prototype;return I.resetInitSegment=function(A,S,v,i){b.prototype.resetInitSegment.call(this,A,S,v,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:S,duration:i,inputTimeScale:9e4,dropped:0}},x.probe=function(A){if(!A)return!1;for(var S=a.getID3Data(A,0)||[],v=S.length,i=A.length;v<i;v++)if(R.probe(A,v))return u.logger.log("MPEG Audio sync word found !"),!0;return!1},I.canParse=function(A,S){return R.canParse(A,S)},I.appendFrame=function(A,S,v){if(this.basePTS!==null)return R.appendFrame(A,S,v,this.basePTS,this.frameIndex)},x}(s.default);t.default=L},"./src/demux/mp4demuxer.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/polyfills/number.ts"),a=e("./src/types/demuxer.ts"),u=e("./src/utils/mp4-tools.ts"),R=e("./src/demux/dummy-demuxed-track.ts"),C=/\/emsg[-/]ID3/i,O=function(){function L(x,I){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=I}var b=L.prototype;return b.resetTimeStamp=function(){},b.resetInitSegment=function(I,_,A,S){var v=Object(u.parseInitSegment)(I),i=this.videoTrack=Object(R.dummyTrack)("video",1),d=this.audioTrack=Object(R.dummyTrack)("audio",1),p=this.txtTrack=Object(R.dummyTrack)("text",1);if(this.id3Track=Object(R.dummyTrack)("id3",1),this.timeOffset=0,v.video){var T=v.video,l=T.id,o=T.timescale,h=T.codec;i.id=l,i.timescale=p.timescale=o,i.codec=h}if(v.audio){var E=v.audio,n=E.id,c=E.timescale,m=E.codec;d.id=n,d.timescale=c,d.codec=m}p.id=u.RemuxerTrackIdConfig.text,i.sampleDuration=0,i.duration=d.duration=S},b.resetContiguity=function(){},L.probe=function(I){return I=I.length>16384?I.subarray(0,16384):I,Object(u.findBox)(I,["moof"]).length>0},b.demux=function(I,_){this.timeOffset=_;var A=I,S=this.videoTrack,v=this.txtTrack;if(this.config.progressive){this.remainderData&&(A=Object(u.appendUint8Array)(this.remainderData,I));var i=Object(u.segmentValidRange)(A);this.remainderData=i.remainder,S.samples=i.valid||new Uint8Array}else S.samples=A;var d=this.extractID3Track(S,_);return v.samples=Object(u.parseSamples)(_,S),{videoTrack:S,audioTrack:this.audioTrack,id3Track:d,textTrack:this.txtTrack}},b.flush=function(){var I=this.timeOffset,_=this.videoTrack,A=this.txtTrack;_.samples=this.remainderData||new Uint8Array,this.remainderData=null;var S=this.extractID3Track(_,this.timeOffset);return A.samples=Object(u.parseSamples)(I,_),{videoTrack:_,audioTrack:Object(R.dummyTrack)(),id3Track:S,textTrack:Object(R.dummyTrack)()}},b.extractID3Track=function(I,_){var A=this.id3Track;if(I.samples.length){var S=Object(u.findBox)(I.samples,["emsg"]);S&&S.forEach(function(v){var i=Object(u.parseEmsg)(v);if(C.test(i.schemeIdUri)){var d=Object(s.isFiniteNumber)(i.presentationTime)?i.presentationTime/i.timeScale:_+i.presentationTimeDelta/i.timeScale,p=i.payload;A.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:a.MetadataSchema.emsg})}})}return A},b.demuxSampleAes=function(I,_,A){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},b.destroy=function(){},L}();t.default=O},"./src/demux/mpegaudio.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"appendFrame",function(){return O}),e.d(t,"parseHeader",function(){return L}),e.d(t,"isHeaderPattern",function(){return b}),e.d(t,"isHeader",function(){return x}),e.d(t,"canParse",function(){return I}),e.d(t,"probe",function(){return _});var s=null,a=[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],u=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],R=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],C=[0,1,1,4];function O(A,S,v,i,d){if(!(v+24>S.length)){var p=L(S,v);if(p&&v+p.frameLength<=S.length){var T=p.samplesPerFrame*9e4/p.sampleRate,l=i+d*T,o={unit:S.subarray(v,v+p.frameLength),pts:l,dts:l};return A.config=[],A.channelCount=p.channelCount,A.samplerate=p.sampleRate,A.samples.push(o),{sample:o,length:p.frameLength,missing:0}}}}function L(A,S){var v=A[S+1]>>3&3,i=A[S+1]>>1&3,d=A[S+2]>>4&15,p=A[S+2]>>2&3;if(v!==1&&d!==0&&d!==15&&p!==3){var T=A[S+2]>>1&1,l=A[S+3]>>6,o=v===3?3-i:i===3?3:4,h=a[o*14+d-1]*1e3,E=v===3?0:v===2?1:2,n=u[E*3+p],c=l===3?1:2,m=R[v][i],f=C[i],g=m*8*f,y=Math.floor(m*h/n+T)*f;if(s===null){var M=navigator.userAgent||"",D=M.match(/Chrome\/(\d+)/i);s=D?parseInt(D[1]):0}var P=!!s&&s<=87;return P&&i===2&&h>=224e3&&l===0&&(A[S+3]=A[S+3]|128),{sampleRate:n,channelCount:c,frameLength:y,samplesPerFrame:g}}}function b(A,S){return A[S]===255&&(A[S+1]&224)===224&&(A[S+1]&6)!==0}function x(A,S){return S+1<A.length&&b(A,S)}function I(A,S){var v=4;return b(A,S)&&v<=A.length-S}function _(A,S){if(S+1<A.length&&b(A,S)){var v=4,i=L(A,S),d=v;i!=null&&i.frameLength&&(d=i.frameLength);var p=S+d;return p===A.length||x(A,p)}return!1}},"./src/demux/sample-aes.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/crypt/decrypter.ts"),a=e("./src/demux/tsdemuxer.ts"),u=function(){function R(O,L,b){this.keyData=void 0,this.decrypter=void 0,this.keyData=b,this.decrypter=new s.default(O,L,{removePKCS7Padding:!1})}var C=R.prototype;return C.decryptBuffer=function(L,b){this.decrypter.decrypt(L,this.keyData.key.buffer,this.keyData.iv.buffer,b)},C.decryptAacSample=function(L,b,x,I){var _=L[b].unit;if(!(_.length<=16)){var A=_.subarray(16,_.length-_.length%16),S=A.buffer.slice(A.byteOffset,A.byteOffset+A.length),v=this;this.decryptBuffer(S,function(i){var d=new Uint8Array(i);_.set(d,16),I||v.decryptAacSamples(L,b+1,x)})}},C.decryptAacSamples=function(L,b,x){for(;;b++){if(b>=L.length){x();return}if(!(L[b].unit.length<32)){var I=this.decrypter.isSync();if(this.decryptAacSample(L,b,x,I),!I)return}}},C.getAvcEncryptedData=function(L){for(var b=Math.floor((L.length-48)/160)*16+16,x=new Int8Array(b),I=0,_=32;_<L.length-16;_+=160,I+=16)x.set(L.subarray(_,_+16),I);return x},C.getAvcDecryptedUnit=function(L,b){for(var x=new Uint8Array(b),I=0,_=32;_<L.length-16;_+=160,I+=16)L.set(x.subarray(I,I+16),_);return L},C.decryptAvcSample=function(L,b,x,I,_,A){var S=Object(a.discardEPB)(_.data),v=this.getAvcEncryptedData(S),i=this;this.decryptBuffer(v.buffer,function(d){_.data=i.getAvcDecryptedUnit(S,d),A||i.decryptAvcSamples(L,b,x+1,I)})},C.decryptAvcSamples=function(L,b,x,I){if(L instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;b++,x=0){if(b>=L.length){I();return}for(var _=L[b].units;!(x>=_.length);x++){var A=_[x];if(!(A.data.length<=48||A.type!==1&&A.type!==5)){var S=this.decrypter.isSync();if(this.decryptAvcSample(L,b,x,I,A,S),!S)return}}}},R}();t.default=u},"./src/demux/transmuxer-interface.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return _});var s=e("./node_modules/webworkify-webpack/index.js"),a=e.n(s),u=e("./src/events.ts"),R=e("./src/demux/transmuxer.ts"),C=e("./src/utils/logger.ts"),O=e("./src/errors.ts"),L=e("./src/utils/mediasource-helper.ts"),b=e("./node_modules/eventemitter3/index.js"),x=e.n(b),I=Object(L.getMediaSource)()||{isTypeSupported:function(){return!1}},_=function(){function A(v,i,d,p){var T=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=v,this.id=i,this.onTransmuxComplete=d,this.onFlush=p;var l=v.config,o=function(m,f){f=f||{},f.frag=T.frag,f.id=T.id,v.trigger(m,f)};this.observer=new b.EventEmitter,this.observer.on(u.Events.FRAG_DECRYPTED,o),this.observer.on(u.Events.ERROR,o);var h={mp4:I.isTypeSupported("video/mp4"),mpeg:I.isTypeSupported("audio/mpeg"),mp3:I.isTypeSupported('audio/mp4; codecs="mp3"')},E=navigator.vendor;if(l.enableWorker&&typeof Worker!="undefined"){C.logger.log("demuxing in webworker");var n;try{n=this.worker=s("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),n.addEventListener("message",this.onwmsg),n.onerror=function(c){v.trigger(u.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},n.postMessage({cmd:"init",typeSupported:h,vendor:E,id:i,config:JSON.stringify(l)})}catch(c){C.logger.warn("Error in worker:",c),C.logger.error("Error while initializing DemuxerWorker, fallback to inline"),n&&self.URL.revokeObjectURL(n.objectURL),this.transmuxer=new R.default(this.observer,h,l,E,i),this.worker=null}}else this.transmuxer=new R.default(this.observer,h,l,E,i)}var S=A.prototype;return S.destroy=function(){var i=this.worker;if(i)i.removeEventListener("message",this.onwmsg),i.terminate(),this.worker=null,this.onwmsg=void 0;else{var d=this.transmuxer;d&&(d.destroy(),this.transmuxer=null)}var p=this.observer;p&&p.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},S.push=function(i,d,p,T,l,o,h,E,n,c){var m,f,g=this;n.transmuxing.start=self.performance.now();var y=this.transmuxer,M=this.worker,D=o?o.start:l.start,P=l.decryptdata,B=this.frag,N=!(B&&l.cc===B.cc),F=!(B&&n.level===B.level),H=B?n.sn-B.sn:-1,V=this.part?n.part-this.part.index:-1,X=H===0&&n.id>1&&n.id===(B==null?void 0:B.stats.chunkCount),$=!F&&(H===1||H===0&&(V===1||X&&V<=0)),j=self.performance.now();(F||H||l.stats.parsing.start===0)&&(l.stats.parsing.start=j),o&&(V||!$)&&(o.stats.parsing.start=j);var J=!(B&&((m=l.initSegment)===null||m===void 0?void 0:m.url)===((f=B.initSegment)===null||f===void 0?void 0:f.url)),ee=new R.TransmuxState(N,$,E,F,D,J);if(!$||N||J){C.logger.log("[transmuxer-interface, "+l.type+"]: Starting new transmux session for sn: "+n.sn+" p: "+n.part+" level: "+n.level+" id: "+n.id+`
12
+ Time to underbuffer: `+P.toFixed(3)+" s"),d.nextLoadLevel=N,this.bwEstimator.sample(E,o.loaded),this.clearTimer(),m.loader&&(this.fragCurrent=this.partCurrent=null,m.loader.abort()),d.trigger(u.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:m,part:i,stats:o})}}}}}},A.onFragLoaded=function(m,i){var d=i.frag,p=i.part;if(d.type===O.PlaylistLevelType.MAIN&&Object(a.isFiniteNumber)(d.sn)){var T=p?p.stats:d.stats,l=p?p.duration:d.duration;if(this.clearTimer(),this.lastLoadedFragLevel=d.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var o=this.hls.levels[d.level],h=(o.loaded?o.loaded.bytes:0)+T.loaded,E=(o.loaded?o.loaded.duration:0)+l;o.loaded={bytes:h,duration:E},o.realBitrate=Math.round(8*h/E)}if(d.bitrateTest){var n={stats:T,frag:d,part:p,id:d.type};this.onFragBuffered(u.Events.FRAG_BUFFERED,n)}}},A.onFragBuffered=function(m,i){var d=i.frag,p=i.part,T=p?p.stats:d.stats;if(!T.aborted&&!(d.type!==O.PlaylistLevelType.MAIN||d.sn==="initSegment")){var l=T.parsing.end-T.loading.start;this.bwEstimator.sample(l,T.loaded),T.bwEstimate=this.bwEstimator.getEstimate(),d.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}},A.onError=function(m,i){switch(i.details){case C.ErrorDetails.FRAG_LOAD_ERROR:case C.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},A.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},A.getNextABRAutoLevel=function(){var m=this.fragCurrent,i=this.partCurrent,d=this.hls,p=d.maxAutoLevel,T=d.config,l=d.minAutoLevel,o=d.media,h=i?i.duration:m?m.duration:0,E=o?o.currentTime:0,n=o&&o.playbackRate!==0?Math.abs(o.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():T.abrEwmaDefaultEstimate,v=(R.BufferHelper.bufferInfo(o,E,T.maxBufferHole).end-E)/n,f=this.findBestLevel(c,l,p,v,T.abrBandWidthFactor,T.abrBandWidthUpFactor);if(f>=0)return f;L.logger.trace((v?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var g=h?Math.min(h,T.maxStarvationDelay):T.maxStarvationDelay,y=T.abrBandWidthFactor,M=T.abrBandWidthUpFactor;if(!v){var D=this.bitrateTestDelay;if(D){var P=h?Math.min(h,T.maxLoadingDelay):T.maxLoadingDelay;g=P-D,L.logger.trace("bitrate test took "+Math.round(1e3*D)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),y=M=1}}return f=this.findBestLevel(c,l,p,v+g,y,M),Math.max(f,0)},A.findBestLevel=function(m,i,d,p,T,l){for(var o,h=this.fragCurrent,E=this.partCurrent,n=this.lastLoadedFragLevel,c=this.hls.levels,v=c[n],f=!!(v!=null&&(o=v.details)!==null&&o!==void 0&&o.live),g=v==null?void 0:v.codecSet,y=E?E.duration:h?h.duration:0,M=d;M>=i;M--){var D=c[M];if(!(!D||g&&D.codecSet!==g)){var P=D.details,B=(E?P==null?void 0:P.partTarget:P==null?void 0:P.averagetargetduration)||y,N=void 0;M<=n?N=T*m:N=l*m;var F=c[M].maxBitrate,H=F*B/N;if(L.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+M+"/"+Math.round(N)+"/"+F+"/"+B+"/"+p+"/"+H),N>F&&(!H||f&&!this.bitrateTestDelay||H<p))return M}}return-1},x(_,[{key:"nextAutoLevel",get:function(){var m=this._nextAutoLevel,i=this.bwEstimator;if(m!==-1&&!i.canEstimate())return m;var d=this.getNextABRAutoLevel();return m!==-1&&this.hls.levels[d].loadError?m:(m!==-1&&(d=Math.min(m,d)),d)},set:function(m){this._nextAutoLevel=m}}]),_}();t.default=I},"./src/controller/audio-stream-controller.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/polyfills/number.ts"),s=e("./src/controller/base-stream-controller.ts"),u=e("./src/events.ts"),R=e("./src/utils/buffer-helper.ts"),C=e("./src/controller/fragment-tracker.ts"),O=e("./src/types/level.ts"),L=e("./src/types/loader.ts"),b=e("./src/loader/fragment.ts"),x=e("./src/demux/chunk-cache.ts"),I=e("./src/demux/transmuxer-interface.ts"),_=e("./src/types/transmuxer.ts"),A=e("./src/controller/fragment-finders.ts"),S=e("./src/utils/discontinuities.ts"),m=e("./src/errors.ts");function i(){return i=Object.assign?Object.assign.bind():function(o){for(var h=1;h<arguments.length;h++){var E=arguments[h];for(var n in E)Object.prototype.hasOwnProperty.call(E,n)&&(o[n]=E[n])}return o},i.apply(this,arguments)}function d(o,h){o.prototype=Object.create(h.prototype),o.prototype.constructor=o,p(o,h)}function p(o,h){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,c){return n.__proto__=c,n},p(o,h)}var T=100,l=function(o){d(h,o);function h(n,c){var v;return v=o.call(this,n,c,"[audio-stream-controller]")||this,v.videoBuffer=null,v.videoTrackCC=-1,v.waitingVideoCC=-1,v.audioSwitch=!1,v.trackId=-1,v.waitingData=null,v.mainDetails=null,v.bufferFlushed=!1,v.cachedTrackLoadedData=null,v._registerListeners(),v}var E=h.prototype;return E.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},E._registerListeners=function(){var c=this.hls;c.on(u.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(u.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(u.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(u.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(u.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),c.on(u.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.on(u.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),c.on(u.Events.ERROR,this.onError,this),c.on(u.Events.BUFFER_RESET,this.onBufferReset,this),c.on(u.Events.BUFFER_CREATED,this.onBufferCreated,this),c.on(u.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.on(u.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.on(u.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E._unregisterListeners=function(){var c=this.hls;c.off(u.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(u.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(u.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(u.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(u.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),c.off(u.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.off(u.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),c.off(u.Events.ERROR,this.onError,this),c.off(u.Events.BUFFER_RESET,this.onBufferReset,this),c.off(u.Events.BUFFER_CREATED,this.onBufferCreated,this),c.off(u.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.off(u.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.off(u.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E.onInitPtsFound=function(c,v){var f=v.frag,g=v.id,y=v.initPTS;if(g==="main"){var M=f.cc;this.initPTS[f.cc]=y,this.log("InitPTS for cc: "+M+" found from main: "+y),this.videoTrackCC=M,this.state===s.State.WAITING_INIT_PTS&&this.tick()}},E.startLoad=function(c){if(!this.levels){this.startPosition=c,this.state=s.State.STOPPED;return}var v=this.lastCurrentTime;this.stopLoad(),this.setInterval(T),this.fragLoadError=0,v>0&&c===-1?(this.log("Override startPosition with lastCurrentTime @"+v.toFixed(3)),c=v,this.state=s.State.IDLE):(this.loadedmetadata=!1,this.state=s.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()},E.doTick=function(){switch(this.state){case s.State.IDLE:this.doTickIdle();break;case s.State.WAITING_TRACK:{var c,v=this.levels,f=this.trackId,g=v==null||(c=v[f])===null||c===void 0?void 0:c.details;if(g){if(this.waitForCdnTuneIn(g))break;this.state=s.State.WAITING_INIT_PTS}break}case s.State.FRAG_LOADING_WAITING_RETRY:{var y,M=performance.now(),D=this.retryDate;(!D||M>=D||(y=this.media)!==null&&y!==void 0&&y.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=s.State.IDLE);break}case s.State.WAITING_INIT_PTS:{var P=this.waitingData;if(P){var B=P.frag,N=P.part,F=P.cache,H=P.complete;if(this.initPTS[B.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=s.State.FRAG_LOADING;var V=F.flush(),X={frag:B,part:N,payload:V,networkDetails:null};this._handleFragmentLoadProgress(X),H&&o.prototype._handleFragmentLoadComplete.call(this,X)}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 $=this.getLoadPosition(),j=R.BufferHelper.bufferInfo(this.mediaBuffer,$,this.config.maxBufferHole),J=Object(A.fragmentWithinToleranceTest)(j.end,this.config.maxFragLookUpTolerance,B);J<0&&(this.log("Waiting fragment cc ("+B.cc+") @ "+B.start+" cancelled because another fragment at "+j.end+" is needed"),this.clearWaitingFragment())}}else this.state=s.State.IDLE}}this.onTickEnd()},E.clearWaitingFragment=function(){var c=this.waitingData;c&&(this.fragmentTracker.removeFragment(c.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=s.State.IDLE)},E.resetLoadingState=function(){this.clearWaitingFragment(),o.prototype.resetLoadingState.call(this)},E.onTickEnd=function(){var c=this.media;if(!(!c||!c.readyState)){var v=this.mediaBuffer?this.mediaBuffer:c,f=v.buffered;!this.loadedmetadata&&f.length&&(this.loadedmetadata=!0),this.lastCurrentTime=c.currentTime}},E.doTickIdle=function(){var c,v,f=this.hls,g=this.levels,y=this.media,M=this.trackId,D=f.config;if(!(!g||!g[M])&&!(!y&&(this.startFragRequested||!D.startFragPrefetch))){var P=g[M],B=P.details;if(!B||B.live&&this.levelLastLoaded!==M||this.waitForCdnTuneIn(B)){this.state=s.State.WAITING_TRACK;return}var N=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&N&&(this.bufferFlushed=!1,this.afterBufferFlushed(N,b.ElementaryStreamTypes.AUDIO,L.PlaylistLevelType.AUDIO));var F=this.getFwdBufferInfo(N,L.PlaylistLevelType.AUDIO);if(F!==null){var H=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,L.PlaylistLevelType.MAIN),V=F.len,X=this.getMaxBufferLength(H==null?void 0:H.len),$=this.audioSwitch;if(!(V>=X&&!$)){if(!$&&this._streamEnded(F,B)){f.trigger(u.Events.BUFFER_EOS,{type:"audio"}),this.state=s.State.ENDED;return}var j=B.fragments,J=j[0].start,ee=F.end;if($&&y){var te=this.getLoadPosition();ee=te,B.PTSKnown&&te<J&&(F.end>J||F.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),y.currentTime=J+.05)}if(!(H&&ee>H.end+B.targetduration)&&!((!H||!H.len)&&F.len)){var le=this.getNextFragment(ee,B);if(!le){this.bufferFlushed=!0;return}((c=le.decryptdata)===null||c===void 0?void 0:c.keyFormat)==="identity"&&!((v=le.decryptdata)!==null&&v!==void 0&&v.key)?this.loadKey(le,B):this.loadFragment(le,B,ee)}}}}},E.getMaxBufferLength=function(c){var v=o.prototype.getMaxBufferLength.call(this);return c?Math.max(v,c):v},E.onMediaDetaching=function(){this.videoBuffer=null,o.prototype.onMediaDetaching.call(this)},E.onAudioTracksUpdated=function(c,v){var f=v.audioTracks;this.resetTransmuxer(),this.levels=f.map(function(g){return new O.Level(g)})},E.onAudioTrackSwitching=function(c,v){var f=!!v.url;this.trackId=v.id;var g=this.fragCurrent;g!=null&&g.loader&&g.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),f?this.setInterval(T):this.resetTransmuxer(),f?(this.audioSwitch=!0,this.state=s.State.IDLE):this.state=s.State.STOPPED,this.tick()},E.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},E.onLevelLoaded=function(c,v){this.mainDetails=v.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(u.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},E.onAudioTrackLoaded=function(c,v){var f;if(this.mainDetails==null){this.cachedTrackLoadedData=v;return}var g=this.levels,y=v.details,M=v.id;if(!g){this.warn("Audio tracks were reset while loading level "+M);return}this.log("Track "+M+" loaded ["+y.startSN+","+y.endSN+"],duration:"+y.totalduration);var D=g[M],P=0;if(y.live||(f=D.details)!==null&&f!==void 0&&f.live){var B=this.mainDetails;if(y.fragments[0]||(y.deltaUpdateFailed=!0),y.deltaUpdateFailed||!B)return;!D.details&&y.hasProgramDateTime&&B.hasProgramDateTime?(Object(S.alignMediaPlaylistByPDT)(y,B),P=y.fragments[0].start):P=this.alignPlaylists(y,D.details)}D.details=y,this.levelLastLoaded=M,!this.startFragRequested&&(this.mainDetails||!y.live)&&this.setStartPosition(D.details,P),this.state===s.State.WAITING_TRACK&&!this.waitForCdnTuneIn(y)&&(this.state=s.State.IDLE),this.tick()},E._handleFragmentLoadProgress=function(c){var v,f=c.frag,g=c.part,y=c.payload,M=this.config,D=this.trackId,P=this.levels;if(!P){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+f.sn+" of level "+f.level+" will not be buffered");return}var B=P[D];console.assert(B,"Audio track is defined on fragment load progress");var N=B.details;console.assert(N,"Audio track details are defined on fragment load progress");var F=M.defaultAudioCodec||B.audioCodec||"mp4a.40.2",H=this.transmuxer;H||(H=this.transmuxer=new I.default(this.hls,L.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var V=this.initPTS[f.cc],X=(v=f.initSegment)===null||v===void 0?void 0:v.data;if(V!==void 0){var $=!1,j=g?g.index:-1,J=j!==-1,ee=new _.ChunkMetadata(f.level,f.sn,f.stats.chunkCount,y.byteLength,j,J);H.push(y,X,F,"",f,g,N.totalduration,$,ee,V)}else{this.log("Unknown video PTS for cc "+f.cc+", waiting for video PTS before demuxing audio frag "+f.sn+" of ["+N.startSN+" ,"+N.endSN+"],track "+D);var te=this.waitingData=this.waitingData||{frag:f,part:g,cache:new x.default,complete:!1},le=te.cache;le.push(new Uint8Array(y)),this.waitingVideoCC=this.videoTrackCC,this.state=s.State.WAITING_INIT_PTS}},E._handleFragmentLoadComplete=function(c){if(this.waitingData){this.waitingData.complete=!0;return}o.prototype._handleFragmentLoadComplete.call(this,c)},E.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},E.onBufferCreated=function(c,v){var f=v.tracks.audio;f&&(this.mediaBuffer=f.buffer||null),v.tracks.video&&(this.videoBuffer=v.tracks.video.buffer||null)},E.onFragBuffered=function(c,v){var f=v.frag,g=v.part;if(f.type===L.PlaylistLevelType.AUDIO){if(this.fragContextChanged(f)){this.warn("Fragment "+f.sn+(g?" p: "+g.index:"")+" of level "+f.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}f.sn!=="initSegment"&&(this.fragPrevious=f,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(u.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(f,g)}},E.onError=function(c,v){switch(v.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(L.PlaylistLevelType.AUDIO,v);break;case m.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case m.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==s.State.ERROR&&this.state!==s.State.STOPPED&&(this.state=v.fatal?s.State.ERROR:s.State.IDLE,this.warn(v.details+" while loading frag, switching to "+this.state+" state"));break;case m.ErrorDetails.BUFFER_FULL_ERROR:if(v.parent==="audio"&&(this.state===s.State.PARSING||this.state===s.State.PARSED)){var f=!0,g=this.getFwdBufferInfo(this.mediaBuffer,L.PlaylistLevelType.AUDIO);g&&g.len>.5&&(f=!this.reduceMaxBufferLength(g.len)),f&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,o.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},E.onBufferFlushed=function(c,v){var f=v.type;f===b.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},E._handleTransmuxComplete=function(c){var v,f="audio",g=this.hls,y=c.remuxResult,M=c.chunkMeta,D=this.getCurrentContext(M);if(!D){this.warn("The loading context changed while buffering fragment "+M.sn+" of level "+M.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(M.level);return}var P=D.frag,B=D.part,N=D.level.details,F=y.audio,H=y.text,V=y.id3,X=y.initSegment;if(!(this.fragContextChanged(P)||!N)){if(this.state=s.State.PARSING,this.audioSwitch&&F&&this.completeAudioSwitch(),X!=null&&X.tracks&&(this._bufferInitSegment(X.tracks,P,M),g.trigger(u.Events.FRAG_PARSING_INIT_SEGMENT,{frag:P,id:f,tracks:X.tracks})),F){var $=F.startPTS,j=F.endPTS,J=F.startDTS,ee=F.endDTS;B&&(B.elementaryStreams[b.ElementaryStreamTypes.AUDIO]={startPTS:$,endPTS:j,startDTS:J,endDTS:ee}),P.setElementaryStreamInfo(b.ElementaryStreamTypes.AUDIO,$,j,J,ee),this.bufferFragmentData(F,P,B,M)}if(V!=null&&(v=V.samples)!==null&&v!==void 0&&v.length){var te=i({id:f,frag:P,details:N},V);g.trigger(u.Events.FRAG_PARSING_METADATA,te)}if(H){var le=i({id:f,frag:P,details:N},H);g.trigger(u.Events.FRAG_PARSING_USERDATA,le)}}},E._bufferInitSegment=function(c,v,f){if(this.state===s.State.PARSING){c.video&&delete c.video;var g=c.audio;if(!!g){g.levelCodec=g.codec,g.id="audio",this.log("Init audio buffer, container:"+g.container+", codecs[parsed]=["+g.codec+"]"),this.hls.trigger(u.Events.BUFFER_CODECS,c);var y=g.initSegment;if(y!=null&&y.byteLength){var M={type:"audio",frag:v,part:null,chunkMeta:f,parent:v.type,data:y};this.hls.trigger(u.Events.BUFFER_APPENDING,M)}this.tick()}}},E.loadFragment=function(c,v,f){var g=this.fragmentTracker.getState(c);this.fragCurrent=c,(this.audioSwitch||g===C.FragmentState.NOT_LOADED||g===C.FragmentState.PARTIAL)&&(c.sn==="initSegment"?this._loadInitSegment(c):v.live&&!Object(a.isFiniteNumber)(this.initPTS[c.cc])?(this.log("Waiting for video PTS in continuity counter "+c.cc+" of live stream before loading audio fragment "+c.sn+" of level "+this.trackId),this.state=s.State.WAITING_INIT_PTS):(this.startFragRequested=!0,o.prototype.loadFragment.call(this,c,v,f)))},E.completeAudioSwitch=function(){var c=this.hls,v=this.media,f=this.trackId;v&&(this.log("Switching audio track : flushing all audio"),o.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,c.trigger(u.Events.AUDIO_TRACK_SWITCHED,{id:f})},h}(s.default);t.default=l},"./src/controller/audio-track-controller.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/events.ts"),s=e("./src/errors.ts"),u=e("./src/controller/base-playlist-controller.ts"),R=e("./src/types/loader.ts");function C(I,_){for(var A=0;A<_.length;A++){var S=_[A];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(I,S.key,S)}}function O(I,_,A){return _&&C(I.prototype,_),A&&C(I,A),Object.defineProperty(I,"prototype",{writable:!1}),I}function L(I,_){I.prototype=Object.create(_.prototype),I.prototype.constructor=I,b(I,_)}function b(I,_){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(S,m){return S.__proto__=m,S},b(I,_)}var x=function(I){L(_,I);function _(S){var m;return m=I.call(this,S,"[audio-track-controller]")||this,m.tracks=[],m.groupId=null,m.tracksInGroup=[],m.trackId=-1,m.trackName="",m.selectDefaultTrack=!0,m.registerListeners(),m}var A=_.prototype;return A.registerListeners=function(){var m=this.hls;m.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),m.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),m.on(a.Events.LEVEL_LOADING,this.onLevelLoading,this),m.on(a.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),m.on(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),m.on(a.Events.ERROR,this.onError,this)},A.unregisterListeners=function(){var m=this.hls;m.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),m.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),m.off(a.Events.LEVEL_LOADING,this.onLevelLoading,this),m.off(a.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),m.off(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),m.off(a.Events.ERROR,this.onError,this)},A.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,I.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(m,i){this.tracks=i.audioTracks||[]},A.onAudioTrackLoaded=function(m,i){var d=i.id,p=i.details,T=this.tracksInGroup[d];if(!T){this.warn("Invalid audio track id "+d);return}var l=T.details;T.details=i.details,this.log("audioTrack "+d+" loaded ["+p.startSN+"-"+p.endSN+"]"),d===this.trackId&&(this.retryCount=0,this.playlistLoaded(d,i,l))},A.onLevelLoading=function(m,i){this.switchLevel(i.level)},A.onLevelSwitching=function(m,i){this.switchLevel(i.level)},A.switchLevel=function(m){var i=this.hls.levels[m];if(!!(i!=null&&i.audioGroupIds)){var d=i.audioGroupIds[i.urlId];if(this.groupId!==d){this.groupId=d;var p=this.tracks.filter(function(l){return!d||l.groupId===d});this.selectDefaultTrack&&!p.some(function(l){return l.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=p;var T={audioTracks:p};this.log("Updating audio tracks, "+p.length+' track(s) found in "'+d+'" group-id'),this.hls.trigger(a.Events.AUDIO_TRACKS_UPDATED,T),this.selectInitialTrack()}}},A.onError=function(m,i){I.prototype.onError.call(this,m,i),!(i.fatal||!i.context)&&i.context.type===R.PlaylistContextType.AUDIO_TRACK&&i.context.id===this.trackId&&i.context.groupId===this.groupId&&this.retryLoadingOrFail(i)},A.setAudioTrack=function(m){var i=this.tracksInGroup;if(m<0||m>=i.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var d=i[this.trackId];this.log("Now switching to audio-track index "+m);var p=i[m],T=p.id,l=p.groupId,o=l===void 0?"":l,h=p.name,E=p.type,n=p.url;if(this.trackId=m,this.trackName=h,this.selectDefaultTrack=!1,this.hls.trigger(a.Events.AUDIO_TRACK_SWITCHING,{id:T,groupId:o,name:h,type:E,url:n}),!(p.details&&!p.details.live)){var c=this.switchParams(p.url,d==null?void 0:d.details);this.loadPlaylist(c)}},A.selectInitialTrack=function(){var m=this.tracksInGroup;console.assert(m.length,"Initial audio track should be selected when tracks are known");var i=this.trackName,d=this.findTrackId(i)||this.findTrackId();d!==-1?this.setAudioTrack(d):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(a.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},A.findTrackId=function(m){for(var i=this.tracksInGroup,d=0;d<i.length;d++){var p=i[d];if((!this.selectDefaultTrack||p.default)&&(!m||m===p.name))return p.id}return-1},A.loadPlaylist=function(m){var i=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(i)){var d=i.id,p=i.groupId,T=i.url;if(m)try{T=m.addDirectives(T)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("loading audio-track playlist for id: "+d),this.clearTimer(),this.hls.trigger(a.Events.AUDIO_TRACK_LOADING,{url:T,id:d,groupId:p,deliveryDirectives:m||null})}},O(_,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(m){this.selectDefaultTrack=!1,this.setAudioTrack(m)}}]),_}(u.default);t.default=x},"./src/controller/base-playlist-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return O});var a=e("./src/polyfills/number.ts"),s=e("./src/types/level.ts"),u=e("./src/controller/level-helper.ts"),R=e("./src/utils/logger.ts"),C=e("./src/errors.ts"),O=function(){function L(x,I){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=R.logger.log.bind(R.logger,I+":"),this.warn=R.logger.warn.bind(R.logger,I+":"),this.hls=x}var b=L.prototype;return b.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},b.onError=function(I,_){_.fatal&&_.type===C.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},b.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},b.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},b.stopLoad=function(){this.canLoad=!1,this.clearTimer()},b.switchParams=function(I,_){var A=_==null?void 0:_.renditionReports;if(A)for(var S=0;S<A.length;S++){var m=A[S],i=""+m.URI;if(i===I.slice(-i.length)){var d=parseInt(m["LAST-MSN"]),p=parseInt(m["LAST-PART"]);if(_&&this.hls.config.lowLatencyMode){var T=Math.min(_.age-_.partTarget,_.targetduration);p!==void 0&&T>_.partTarget&&(p+=1)}if(Object(a.isFiniteNumber)(d))return new s.HlsUrlParameters(d,Object(a.isFiniteNumber)(p)?p:void 0,s.HlsSkip.No)}}},b.loadPlaylist=function(I){},b.shouldLoadTrack=function(I){return this.canLoad&&I&&!!I.url&&(!I.details||I.details.live)},b.playlistLoaded=function(I,_,A){var S=this,m=_.details,i=_.stats,d=i.loading.end?Math.max(0,self.performance.now()-i.loading.end):0;if(m.advancedDateTime=Date.now()-d,m.live||A!=null&&A.live){if(m.reloaded(A),A&&this.log("live playlist "+I+" "+(m.advanced?"REFRESHED "+m.lastPartSn+"-"+m.lastPartIndex:"MISSED")),A&&m.fragments.length>0&&Object(u.mergeDetails)(A,m),!this.canLoad||!m.live)return;var p,T=void 0,l=void 0;if(m.canBlockReload&&m.endSN&&m.advanced){var o=this.hls.config.lowLatencyMode,h=m.lastPartSn,E=m.endSN,n=m.lastPartIndex,c=n!==-1,v=h===E,f=o?0:n;c?(T=v?E+1:h,l=v?f:n+1):T=E+1;var g=m.age,y=g+m.ageHeader,M=Math.min(y-m.partTarget,m.targetduration*1.5);if(M>0){if(A&&M>A.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+A.tuneInGoal+" to: "+M+" with playlist age: "+m.age),M=0;else{var D=Math.floor(M/m.targetduration);if(T+=D,l!==void 0){var P=Math.round(M%m.targetduration/m.partTarget);l+=P}this.log("CDN Tune-in age: "+m.ageHeader+"s last advanced "+g.toFixed(2)+"s goal: "+M+" skip sn "+D+" to part "+l)}m.tuneInGoal=M}if(p=this.getDeliveryDirectives(m,_.deliveryDirectives,T,l),o||!v){this.loadPlaylist(p);return}}else p=this.getDeliveryDirectives(m,_.deliveryDirectives,T,l);var B=Object(u.computeReloadInterval)(m,i);T!==void 0&&m.canBlockReload&&(B-=m.partTarget||1),this.log("reload live playlist "+I+" in "+Math.round(B)+" ms"),this.timer=self.setTimeout(function(){return S.loadPlaylist(p)},B)}else this.clearTimer()},b.getDeliveryDirectives=function(I,_,A,S){var m=Object(s.getSkipValue)(I,A);return _!=null&&_.skip&&I.deltaUpdateFailed&&(A=_.msn,S=_.part,m=s.HlsSkip.No),new s.HlsUrlParameters(A,S,m)},b.retryLoadingOrFail=function(I){var _=this,A=this.hls.config,S=this.retryCount<A.levelLoadingMaxRetry;if(S){var m;if(this.retryCount++,I.details.indexOf("LoadTimeOut")>-1&&(m=I.context)!==null&&m!==void 0&&m.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+I.details+'"'),this.loadPlaylist();else{var i=Math.min(Math.pow(2,this.retryCount)*A.levelLoadingRetryDelay,A.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return _.loadPlaylist()},i),this.warn("retry playlist loading #"+this.retryCount+" in "+i+' ms after "'+I.details+'"')}}else this.warn('cannot recover from error "'+I.details+'"'),this.clearTimer(),I.fatal=!0;return S},L}()},"./src/controller/base-stream-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"State",function(){return E}),e.d(t,"default",function(){return n});var a=e("./src/polyfills/number.ts"),s=e("./src/task-loop.ts"),u=e("./src/controller/fragment-tracker.ts"),R=e("./src/utils/buffer-helper.ts"),C=e("./src/utils/logger.ts"),O=e("./src/events.ts"),L=e("./src/errors.ts"),b=e("./src/types/transmuxer.ts"),x=e("./src/utils/mp4-tools.ts"),I=e("./src/utils/discontinuities.ts"),_=e("./src/controller/fragment-finders.ts"),A=e("./src/controller/level-helper.ts"),S=e("./src/loader/fragment-loader.ts"),m=e("./src/crypt/decrypter.ts"),i=e("./src/utils/time-ranges.ts"),d=e("./src/types/loader.ts");function p(c,v){for(var f=0;f<v.length;f++){var g=v[f];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(c,g.key,g)}}function T(c,v,f){return v&&p(c.prototype,v),f&&p(c,f),Object.defineProperty(c,"prototype",{writable:!1}),c}function l(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function o(c,v){c.prototype=Object.create(v.prototype),c.prototype.constructor=c,h(c,v)}function h(c,v){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,y){return g.__proto__=y,g},h(c,v)}var E={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"},n=function(c){o(v,c);function v(g,y,M){var D;return D=c.call(this)||this,D.hls=void 0,D.fragPrevious=null,D.fragCurrent=null,D.fragmentTracker=void 0,D.transmuxer=null,D._state=E.STOPPED,D.media=null,D.mediaBuffer=null,D.config=void 0,D.bitrateTest=!1,D.lastCurrentTime=0,D.nextLoadPosition=0,D.startPosition=0,D.loadedmetadata=!1,D.fragLoadError=0,D.retryDate=0,D.levels=null,D.fragmentLoader=void 0,D.levelLastLoaded=null,D.startFragRequested=!1,D.decrypter=void 0,D.initPTS=[],D.onvseeking=null,D.onvended=null,D.logPrefix="",D.log=void 0,D.warn=void 0,D.logPrefix=M,D.log=C.logger.log.bind(C.logger,M+":"),D.warn=C.logger.warn.bind(C.logger,M+":"),D.hls=g,D.fragmentLoader=new S.default(g.config),D.fragmentTracker=y,D.config=g.config,D.decrypter=new m.default(g,g.config),g.on(O.Events.KEY_LOADED,D.onKeyLoaded,l(D)),g.on(O.Events.LEVEL_SWITCHING,D.onLevelSwitching,l(D)),D}var f=v.prototype;return f.doTick=function(){this.onTickEnd()},f.onTickEnd=function(){},f.startLoad=function(y){},f.stopLoad=function(){this.fragmentLoader.abort();var y=this.fragCurrent;y&&this.fragmentTracker.removeFragment(y),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=E.STOPPED},f._streamEnded=function(y,M){var D=this.fragCurrent,P=this.fragmentTracker;if(!M.live&&D&&this.media&&D.sn>=M.endSN&&!y.nextStart){var B=M.partList;if(B!=null&&B.length){var N=B[B.length-1],F=R.BufferHelper.isBuffered(this.media,N.start+N.duration/2);return F}var H=P.getState(D);return H===u.FragmentState.PARTIAL||H===u.FragmentState.OK}return!1},f.onMediaAttached=function(y,M){var D=this.media=this.mediaBuffer=M.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),D.addEventListener("seeking",this.onvseeking),D.addEventListener("ended",this.onvended);var P=this.config;this.levels&&P.autoStartLoad&&this.state===E.STOPPED&&this.startLoad(P.startPosition)},f.onMediaDetaching=function(){var y=this.media;y!=null&&y.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),y&&this.onvseeking&&this.onvended&&(y.removeEventListener("seeking",this.onvseeking),y.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},f.onMediaSeeking=function(){var y=this.config,M=this.fragCurrent,D=this.media,P=this.mediaBuffer,B=this.state,N=D?D.currentTime:0,F=R.BufferHelper.bufferInfo(P||D,N,y.maxBufferHole);if(this.log("media seeking to "+(Object(a.isFiniteNumber)(N)?N.toFixed(3):N)+", state: "+B),B===E.ENDED)this.resetLoadingState();else if(M&&!F.len){var H=y.maxFragLookUpTolerance,V=M.start-H,X=M.start+M.duration+H,$=N>X;(N<V||$)&&($&&M.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),M.loader.abort()),this.resetLoadingState())}D&&(this.lastCurrentTime=N),!this.loadedmetadata&&!F.len&&(this.nextLoadPosition=this.startPosition=N),this.tickImmediate()},f.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},f.onKeyLoaded=function(y,M){if(!(this.state!==E.KEY_LOADING||M.frag!==this.fragCurrent||!this.levels)){this.state=E.IDLE;var D=this.levels[M.frag.level].details;D&&this.loadFragment(M.frag,D,M.frag.start)}},f.onLevelSwitching=function(y,M){this.fragLoadError=0},f.onHandlerDestroying=function(){this.stopLoad(),c.prototype.onHandlerDestroying.call(this)},f.onHandlerDestroyed=function(){this.state=E.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,c.prototype.onHandlerDestroyed.call(this)},f.loadKey=function(y,M){this.log("Loading key for "+y.sn+" of ["+M.startSN+"-"+M.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+y.level),this.state=E.KEY_LOADING,this.fragCurrent=y,this.hls.trigger(O.Events.KEY_LOADING,{frag:y})},f.loadFragment=function(y,M,D){this._loadFragForPlayback(y,M,D)},f._loadFragForPlayback=function(y,M,D){var P=this,B=function(F){if(P.fragContextChanged(y)){P.warn("Fragment "+y.sn+(F.part?" p: "+F.part.index:"")+" of level "+y.level+" was dropped during download."),P.fragmentTracker.removeFragment(y);return}y.stats.chunkCount++,P._handleFragmentLoadProgress(F)};this._doFragLoad(y,M,D,B).then(function(N){if(!!N){P.fragLoadError=0;var F=P.state;if(P.fragContextChanged(y)){(F===E.FRAG_LOADING||!P.fragCurrent&&F===E.PARSING)&&(P.fragmentTracker.removeFragment(y),P.state=E.IDLE);return}"payload"in N&&(P.log("Loaded fragment "+y.sn+" of level "+y.level),P.hls.trigger(O.Events.FRAG_LOADED,N)),P._handleFragmentLoadComplete(N)}}).catch(function(N){P.state===E.STOPPED||P.state===E.ERROR||(P.warn(N),P.resetFragmentLoading(y))})},f.flushMainBuffer=function(y,M,D){if(D===void 0&&(D=null),!!(y-M)){var P={startOffset:y,endOffset:M,type:D};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,P)}},f._loadInitSegment=function(y){var M=this;this._doFragLoad(y).then(function(D){if(!D||M.fragContextChanged(y)||!M.levels)throw new Error("init load aborted");return D}).then(function(D){var P=M.hls,B=D.payload,N=y.decryptdata;if(B&&B.byteLength>0&&N&&N.key&&N.iv&&N.method==="AES-128"){var F=self.performance.now();return M.decrypter.webCryptoDecrypt(new Uint8Array(B),N.key.buffer,N.iv.buffer).then(function(H){var V=self.performance.now();return P.trigger(O.Events.FRAG_DECRYPTED,{frag:y,payload:H,stats:{tstart:F,tdecrypt:V}}),D.payload=H,D})}return D}).then(function(D){var P=M.fragCurrent,B=M.hls,N=M.levels;if(!N)throw new Error("init load aborted, missing levels");var F=N[y.level].details;console.assert(F,"Level details are defined when init segment is loaded");var H=y.stats;M.state=E.IDLE,M.fragLoadError=0,y.data=new Uint8Array(D.payload),H.parsing.start=H.buffering.start=self.performance.now(),H.parsing.end=H.buffering.end=self.performance.now(),D.frag===P&&B.trigger(O.Events.FRAG_BUFFERED,{stats:H,frag:P,part:null,id:y.type}),M.tick()}).catch(function(D){M.state===E.STOPPED||M.state===E.ERROR||(M.warn(D),M.resetFragmentLoading(y))})},f.fragContextChanged=function(y){var M=this.fragCurrent;return!y||!M||y.level!==M.level||y.sn!==M.sn||y.urlId!==M.urlId},f.fragBufferedComplete=function(y,M){var D=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+y.type+" sn: "+y.sn+(M?" part: "+M.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+y.level+" "+(D?i.default.toString(R.BufferHelper.getBuffered(D)):"(detached)")),this.state=E.IDLE,D&&(!this.loadedmetadata&&D.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},f.seekToStartPos=function(){},f._handleFragmentLoadComplete=function(y){var M=this.transmuxer;if(!!M){var D=y.frag,P=y.part,B=y.partsLoaded,N=!B||B.length===0||B.some(function(H){return!H}),F=new b.ChunkMetadata(D.level,D.sn,D.stats.chunkCount+1,0,P?P.index:-1,!N);M.flush(F)}},f._handleFragmentLoadProgress=function(y){},f._doFragLoad=function(y,M,D,P){var B=this;if(D===void 0&&(D=null),!this.levels)throw new Error("frag load aborted, missing levels");if(D=Math.max(y.start,D||0),this.config.lowLatencyMode&&M){var N=M.partList;if(N&&P){D>y.end&&M.fragmentHint&&(y=M.fragmentHint);var F=this.getNextPart(N,y,D);if(F>-1){var H=N[F];return this.log("Loading part sn: "+y.sn+" p: "+H.index+" cc: "+y.cc+" of playlist ["+M.startSN+"-"+M.endSN+"] parts [0-"+F+"-"+(N.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(D.toFixed(3))),this.nextLoadPosition=H.start+H.duration,this.state=E.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:y,part:N[F],targetBufferTime:D}),this.doFragPartsLoad(y,N,F,P).catch(function(V){return B.handleFragLoadError(V)})}else if(!y.url||this.loadedEndOfParts(N,D))return Promise.resolve(null)}}return this.log("Loading fragment "+y.sn+" cc: "+y.cc+" "+(M?"of ["+M.startSN+"-"+M.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(D.toFixed(3))),Object(a.isFiniteNumber)(y.sn)&&!this.bitrateTest&&(this.nextLoadPosition=y.start+y.duration),this.state=E.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:y,targetBufferTime:D}),this.fragmentLoader.load(y,P).catch(function(V){return B.handleFragLoadError(V)})},f.doFragPartsLoad=function(y,M,D,P){var B=this;return new Promise(function(N,F){var H=[],V=function X($){var j=M[$];B.fragmentLoader.loadPart(y,j,P).then(function(J){H[j.index]=J;var ee=J.part;B.hls.trigger(O.Events.FRAG_LOADED,J);var te=M[$+1];if(te&&te.fragment===y)X($+1);else return N({frag:y,part:ee,partsLoaded:H})}).catch(F)};V(D)})},f.handleFragLoadError=function(y){var M=y.data;return M&&M.details===L.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(M.frag,M.part):this.hls.trigger(O.Events.ERROR,M),null},f._handleTransmuxerFlush=function(y){var M=this.getCurrentContext(y);if(!M||this.state!==E.PARSING){this.fragCurrent||(this.state=E.IDLE);return}var D=M.frag,P=M.part,B=M.level,N=self.performance.now();D.stats.parsing.end=N,P&&(P.stats.parsing.end=N),this.updateLevelTiming(D,P,B,y.partial)},f.getCurrentContext=function(y){var M=this.levels,D=y.level,P=y.sn,B=y.part;if(!M||!M[D])return this.warn("Levels object was unset while buffering fragment "+P+" of level "+D+". The current chunk will not be buffered."),null;var N=M[D],F=B>-1?Object(A.getPartWith)(N,P,B):null,H=F?F.fragment:Object(A.getFragmentWithSN)(N,P,this.fragCurrent);return H?{frag:H,part:F,level:N}:null},f.bufferFragmentData=function(y,M,D,P){if(!(!y||this.state!==E.PARSING)){var B=y.data1,N=y.data2,F=B;if(B&&N&&(F=Object(x.appendUint8Array)(B,N)),!(!F||!F.length)){var H={type:y.type,frag:M,part:D,chunkMeta:P,parent:M.type,data:F};this.hls.trigger(O.Events.BUFFER_APPENDING,H),y.dropped&&y.independent&&!D&&this.flushBufferGap(M)}}},f.flushBufferGap=function(y){var M=this.media;if(!!M){if(!R.BufferHelper.isBuffered(M,M.currentTime)){this.flushMainBuffer(0,y.start);return}var D=M.currentTime,P=R.BufferHelper.bufferInfo(M,D,0),B=y.duration,N=Math.min(this.config.maxFragLookUpTolerance*2,B*.25),F=Math.max(Math.min(y.start-N,P.end-N),D+N);y.start-F>N&&this.flushMainBuffer(F,y.start)}},f.getFwdBufferInfo=function(y,M){var D=this.config,P=this.getLoadPosition();if(!Object(a.isFiniteNumber)(P))return null;var B=R.BufferHelper.bufferInfo(y,P,D.maxBufferHole);if(B.len===0&&B.nextStart!==void 0){var N=this.fragmentTracker.getBufferedFrag(P,M);if(N&&B.nextStart<N.end)return R.BufferHelper.bufferInfo(y,P,Math.max(B.nextStart,D.maxBufferHole))}return B},f.getMaxBufferLength=function(y){var M=this.config,D;return y?D=Math.max(8*M.maxBufferSize/y,M.maxBufferLength):D=M.maxBufferLength,Math.min(D,M.maxMaxBufferLength)},f.reduceMaxBufferLength=function(y){var M=this.config,D=y||M.maxBufferLength;return M.maxMaxBufferLength>=D?(M.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+M.maxMaxBufferLength+"s"),!0):!1},f.getNextFragment=function(y,M){var D=M.fragments,P=D.length;if(!P)return null;var B=this.config,N=D[0].start,F;if(M.live){var H=B.initialLiveManifestSize;if(P<H)return this.warn("Not enough fragments to start playback (have: "+P+", need: "+H+")"),null;!M.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(F=this.getInitialLiveFragment(M,D),this.startPosition=F?this.hls.liveSyncPosition||F.start:y)}else y<=N&&(F=D[0]);if(!F){var V=B.lowLatencyMode?M.partEnd:M.fragmentEnd;F=this.getFragmentAtPosition(y,V,M)}return this.mapToInitFragWhenRequired(F)},f.mapToInitFragWhenRequired=function(y){return y!=null&&y.initSegment&&!(y!=null&&y.initSegment.data)&&!this.bitrateTest?y.initSegment:y},f.getNextPart=function(y,M,D){for(var P=-1,B=!1,N=!0,F=0,H=y.length;F<H;F++){var V=y[F];if(N=N&&!V.independent,P>-1&&D<V.start)break;var X=V.loaded;!X&&(B||V.independent||N)&&V.fragment===M&&(P=F),B=X}return P},f.loadedEndOfParts=function(y,M){var D=y[y.length-1];return D&&M>D.start&&D.loaded},f.getInitialLiveFragment=function(y,M){var D=this.fragPrevious,P=null;if(D){if(y.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+D.programDateTime),P=Object(_.findFragmentByPDT)(M,D.endProgramDateTime,this.config.maxFragLookUpTolerance)),!P){var B=D.sn+1;if(B>=y.startSN&&B<=y.endSN){var N=M[B-y.startSN];D.cc===N.cc&&(P=N,this.log("Live playlist, switching playlist, load frag with next SN: "+P.sn))}P||(P=Object(_.findFragWithCC)(M,D.cc),P&&this.log("Live playlist, switching playlist, load frag with same CC: "+P.sn))}}else{var F=this.hls.liveSyncPosition;F!==null&&(P=this.getFragmentAtPosition(F,this.bitrateTest?y.fragmentEnd:y.edge,y))}return P},f.getFragmentAtPosition=function(y,M,D){var P=this.config,B=this.fragPrevious,N=D.fragments,F=D.endSN,H=D.fragmentHint,V=P.maxFragLookUpTolerance,X=!!(P.lowLatencyMode&&D.partList&&H);X&&H&&!this.bitrateTest&&(N=N.concat(H),F=H.sn);var $;if(y<M){var j=y>M-V?0:V;$=Object(_.findFragmentByPTS)(B,N,y,j)}else $=N[N.length-1];if($){var J=$.sn-D.startSN;if(B&&$.sn===B.sn&&!X){var ee=B&&$.level===B.level;if(ee){var te=N[J+1];$.sn<F&&this.fragmentTracker.getState(te)!==u.FragmentState.OK?(this.log("SN "+$.sn+" just loaded, load next one: "+te.sn),$=te):$=null}}}return $},f.synchronizeToLiveEdge=function(y){var M=this.config,D=this.media;if(!!D){var P=this.hls.liveSyncPosition,B=D.currentTime,N=y.fragments[0].start,F=y.edge,H=B>=N-M.maxFragLookUpTolerance&&B<=F;if(P!==null&&D.duration>P&&(B<P||!H)){var V=M.liveMaxLatencyDuration!==void 0?M.liveMaxLatencyDuration:M.liveMaxLatencyDurationCount*y.targetduration;(!H&&D.readyState<4||B<F-V)&&(this.loadedmetadata||(this.nextLoadPosition=P),D.readyState&&(this.warn("Playback: "+B.toFixed(3)+" is located too far from the end of live sliding playlist: "+F+", reset currentTime to : "+P.toFixed(3)),D.currentTime=P))}}},f.alignPlaylists=function(y,M){var D=this.levels,P=this.levelLastLoaded,B=this.fragPrevious,N=P!==null?D[P]:null,F=y.fragments.length;if(!F)return this.warn("No fragments in live playlist"),0;var H=y.fragments[0].start,V=!M,X=y.alignedSliding&&Object(a.isFiniteNumber)(H);if(V||!X&&!H){Object(I.alignStream)(B,N,y);var $=y.fragments[0].start;return this.log("Live playlist sliding: "+$.toFixed(2)+" start-sn: "+(M?M.startSN:"na")+"->"+y.startSN+" prev-sn: "+(B?B.sn:"na")+" fragments: "+F),$}return H},f.waitForCdnTuneIn=function(y){var M=3;return y.live&&y.canBlockReload&&y.partTarget&&y.tuneInGoal>Math.max(y.partHoldBack,y.partTarget*M)},f.setStartPosition=function(y,M){var D=this.startPosition;if(D<M&&(D=-1),D===-1||this.lastCurrentTime===-1){var P=y.startTimeOffset;Object(a.isFiniteNumber)(P)?(D=M+P,P<0&&(D+=y.totalduration),D=Math.min(Math.max(M,D),M+y.totalduration),this.log("Start time offset "+P+" found in playlist, adjust startPosition to "+D),this.startPosition=D):y.live?D=this.hls.liveSyncPosition||M:this.startPosition=D=0,this.lastCurrentTime=D}this.nextLoadPosition=D},f.getLoadPosition=function(){var y=this.media,M=0;return this.loadedmetadata&&y?M=y.currentTime:this.nextLoadPosition&&(M=this.nextLoadPosition),M},f.handleFragLoadAborted=function(y,M){this.transmuxer&&y.sn!=="initSegment"&&y.stats.aborted&&(this.warn("Fragment "+y.sn+(M?" part"+M.index:"")+" of level "+y.level+" was aborted"),this.resetFragmentLoading(y))},f.resetFragmentLoading=function(y){(!this.fragCurrent||!this.fragContextChanged(y)&&this.state!==E.FRAG_LOADING_WAITING_RETRY)&&(this.state=E.IDLE)},f.onFragmentOrKeyLoadError=function(y,M){if(!M.fatal){var D=M.frag;if(!(!D||D.type!==y)){var P=this.fragCurrent;console.assert(P&&D.sn===P.sn&&D.level===P.level&&D.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 N=Math.min(Math.pow(2,this.fragLoadError)*B.fragLoadingRetryDelay,B.fragLoadingMaxRetryTimeout);this.warn("Fragment "+D.sn+" of "+y+" "+D.level+" failed to load, retrying in "+N+"ms"),this.retryDate=self.performance.now()+N,this.fragLoadError++,this.state=E.FRAG_LOADING_WAITING_RETRY}else M.levelRetry?(y===d.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=E.IDLE):(C.logger.error(M.details+" reaches max retry, redispatch as fatal ..."),M.fatal=!0,this.hls.stopLoad(),this.state=E.ERROR)}}},f.afterBufferFlushed=function(y,M,D){if(!!y){var P=R.BufferHelper.getBuffered(y);this.fragmentTracker.detectEvictedFragments(M,P,D),this.state===E.ENDED&&this.resetLoadingState()}},f.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=E.IDLE},f.resetStartWhenNotLoaded=function(y){if(!this.loadedmetadata){this.startFragRequested=!1;var M=this.levels?this.levels[y].details:null;M!=null&&M.live?(this.startPosition=-1,this.setStartPosition(M,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},f.updateLevelTiming=function(y,M,D,P){var B=this,N=D.details;console.assert(!!N,"level.details must be defined");var F=Object.keys(y.elementaryStreams).reduce(function(H,V){var X=y.elementaryStreams[V];if(X){var $=X.endPTS-X.startPTS;if($<=0)return B.warn("Could not parse fragment "+y.sn+" "+V+" duration reliably ("+$+")"),H||!1;var j=P?0:Object(A.updateFragPTSDTS)(N,y,X.startPTS,X.endPTS,X.startDTS,X.endDTS);return B.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:N,level:D,drift:j,type:V,frag:y,start:X.startPTS,end:X.endPTS}),!0}return H},!1);F||(this.warn("Found no media in fragment "+y.sn+" of level "+D.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=E.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:y,part:M})},f.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},T(v,[{key:"state",get:function(){return this._state},set:function(y){var M=this._state;M!==y&&(this._state=y,this.log(M+"->"+y))}}]),v}(s.default)},"./src/controller/buffer-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return _});var a=e("./src/polyfills/number.ts"),s=e("./src/events.ts"),u=e("./src/utils/logger.ts"),R=e("./src/errors.ts"),C=e("./src/utils/buffer-helper.ts"),O=e("./src/utils/mediasource-helper.ts"),L=e("./src/loader/fragment.ts"),b=e("./src/controller/buffer-operation-queue.ts"),x=Object(O.getMediaSource)(),I=/([ha]vc.)(?:\.[^.,]+)+/,_=function(){function A(m){var i=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 d=i.hls,p=i.media,T=i.mediaSource;u.logger.log("[buffer-controller]: Media source opened"),p&&(i.updateMediaElementDuration(),d.trigger(s.Events.MEDIA_ATTACHED,{media:p})),T&&T.removeEventListener("sourceopen",i._onMediaSourceOpen),i.checkPendingTracks()},this._onMediaSourceClose=function(){u.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){u.logger.log("[buffer-controller]: Media source ended")},this.hls=m,this._initSourceBuffer(),this.registerListeners()}var S=A.prototype;return S.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},S.destroy=function(){this.unregisterListeners(),this.details=null},S.registerListeners=function(){var i=this.hls;i.on(s.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.on(s.Events.BUFFER_RESET,this.onBufferReset,this),i.on(s.Events.BUFFER_APPENDING,this.onBufferAppending,this),i.on(s.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.on(s.Events.BUFFER_EOS,this.onBufferEos,this),i.on(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),i.on(s.Events.LEVEL_UPDATED,this.onLevelUpdated,this),i.on(s.Events.FRAG_PARSED,this.onFragParsed,this),i.on(s.Events.FRAG_CHANGED,this.onFragChanged,this)},S.unregisterListeners=function(){var i=this.hls;i.off(s.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.off(s.Events.BUFFER_RESET,this.onBufferReset,this),i.off(s.Events.BUFFER_APPENDING,this.onBufferAppending,this),i.off(s.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.off(s.Events.BUFFER_EOS,this.onBufferEos,this),i.off(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),i.off(s.Events.LEVEL_UPDATED,this.onLevelUpdated,this),i.off(s.Events.FRAG_PARSED,this.onFragParsed,this),i.off(s.Events.FRAG_CHANGED,this.onFragChanged,this)},S._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new b.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},S.onManifestParsed=function(i,d){var p=2;(d.audio&&!d.video||!d.altAudio)&&(p=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=p,this.details=null,u.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},S.onMediaAttaching=function(i,d){var p=this.media=d.media;if(p&&x){var T=this.mediaSource=new x;T.addEventListener("sourceopen",this._onMediaSourceOpen),T.addEventListener("sourceended",this._onMediaSourceEnded),T.addEventListener("sourceclose",this._onMediaSourceClose),p.src=self.URL.createObjectURL(T),this._objectUrl=p.src}},S.onMediaDetaching=function(){var i=this.media,d=this.mediaSource,p=this._objectUrl;if(d){if(u.logger.log("[buffer-controller]: media source detaching"),d.readyState==="open")try{d.endOfStream()}catch(T){u.logger.warn("[buffer-controller]: onMediaDetaching: "+T.message+" while calling endOfStream")}this.onBufferReset(),d.removeEventListener("sourceopen",this._onMediaSourceOpen),d.removeEventListener("sourceended",this._onMediaSourceEnded),d.removeEventListener("sourceclose",this._onMediaSourceClose),i&&(p&&self.URL.revokeObjectURL(p),i.src===p?(i.removeAttribute("src"),i.load()):u.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(s.Events.MEDIA_DETACHED,void 0)},S.onBufferReset=function(){var i=this;this.getSourceBufferTypes().forEach(function(d){var p=i.sourceBuffer[d];try{p&&(i.removeBufferListeners(d),i.mediaSource&&i.mediaSource.removeSourceBuffer(p),i.sourceBuffer[d]=void 0)}catch(T){u.logger.warn("[buffer-controller]: Failed to reset the "+d+" buffer",T)}}),this._initSourceBuffer()},S.onBufferCodecs=function(i,d){var p=this,T=this.getSourceBufferTypes().length;Object.keys(d).forEach(function(l){if(T){var o=p.tracks[l];if(o&&typeof o.buffer.changeType=="function"){var h=d[l],E=h.id,n=h.codec,c=h.levelCodec,v=h.container,f=h.metadata,g=(o.levelCodec||o.codec).replace(I,"$1"),y=(c||n).replace(I,"$1");if(g!==y){var M=v+";codecs="+(c||n);p.appendChangeType(l,M),u.logger.log("[buffer-controller]: switching codec "+g+" to "+y),p.tracks[l]={buffer:o.buffer,codec:n,container:v,levelCodec:c,metadata:f,id:E}}}}else p.pendingTracks[l]=d[l]}),!T&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},S.appendChangeType=function(i,d){var p=this,T=this.operationQueue,l={execute:function(){var h=p.sourceBuffer[i];h&&(u.logger.log("[buffer-controller]: changing "+i+" sourceBuffer type to "+d),h.changeType(d)),T.shiftAndExecuteNext(i)},onStart:function(){},onComplete:function(){},onError:function(h){u.logger.warn("[buffer-controller]: Failed to change "+i+" SourceBuffer type",h)}};T.append(l,i)},S.onBufferAppending=function(i,d){var p=this,T=this.hls,l=this.operationQueue,o=this.tracks,h=d.data,E=d.type,n=d.frag,c=d.part,v=d.chunkMeta,f=v.buffering[E],g=self.performance.now();f.start=g;var y=n.stats.buffering,M=c?c.stats.buffering:null;y.start===0&&(y.start=g),M&&M.start===0&&(M.start=g);var D=o.audio,P=E==="audio"&&v.id===1&&(D==null?void 0:D.container)==="audio/mpeg",B={execute:function(){if(f.executeStart=self.performance.now(),P){var F=p.sourceBuffer[E];if(F){var H=n.start-F.timestampOffset;Math.abs(H)>=.1&&(u.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+n.start+" (delta: "+H+") sn: "+n.sn+")"),F.timestampOffset=n.start)}}p.appendExecutor(h,E)},onStart:function(){},onComplete:function(){var F=self.performance.now();f.executeEnd=f.end=F,y.first===0&&(y.first=F),M&&M.first===0&&(M.first=F);var H=p.sourceBuffer,V={};for(var X in H)V[X]=C.BufferHelper.getBuffered(H[X]);p.appendError=0,p.hls.trigger(s.Events.BUFFER_APPENDED,{type:E,frag:n,part:c,chunkMeta:v,parent:n.type,timeRanges:V})},onError:function(F){u.logger.error("[buffer-controller]: Error encountered while trying to append to the "+E+" SourceBuffer",F);var H={type:R.ErrorTypes.MEDIA_ERROR,parent:n.type,details:R.ErrorDetails.BUFFER_APPEND_ERROR,err:F,fatal:!1};F.code===DOMException.QUOTA_EXCEEDED_ERR?H.details=R.ErrorDetails.BUFFER_FULL_ERROR:(p.appendError++,H.details=R.ErrorDetails.BUFFER_APPEND_ERROR,p.appendError>T.config.appendErrorMaxRetry&&(u.logger.error("[buffer-controller]: Failed "+T.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),H.fatal=!0,T.stopLoad())),T.trigger(s.Events.ERROR,H)}};l.append(B,E)},S.onBufferFlushing=function(i,d){var p=this,T=this.operationQueue,l=function(h){return{execute:p.removeExecutor.bind(p,h,d.startOffset,d.endOffset),onStart:function(){},onComplete:function(){p.hls.trigger(s.Events.BUFFER_FLUSHED,{type:h})},onError:function(n){u.logger.warn("[buffer-controller]: Failed to remove from "+h+" SourceBuffer",n)}}};d.type?T.append(l(d.type),d.type):this.getSourceBufferTypes().forEach(function(o){T.append(l(o),o)})},S.onFragParsed=function(i,d){var p=this,T=d.frag,l=d.part,o=[],h=l?l.elementaryStreams:T.elementaryStreams;h[L.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(h[L.ElementaryStreamTypes.AUDIO]&&o.push("audio"),h[L.ElementaryStreamTypes.VIDEO]&&o.push("video"));var E=function(){var c=self.performance.now();T.stats.buffering.end=c,l&&(l.stats.buffering.end=c);var v=l?l.stats:T.stats;p.hls.trigger(s.Events.FRAG_BUFFERED,{frag:T,part:l,stats:v,id:T.type})};o.length===0&&u.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+T.type+" level: "+T.level+" sn: "+T.sn),this.blockBuffers(E,o)},S.onFragChanged=function(i,d){this.flushBackBuffer()},S.onBufferEos=function(i,d){var p=this,T=this.getSourceBufferTypes().reduce(function(l,o){var h=p.sourceBuffer[o];return(!d.type||d.type===o)&&h&&!h.ended&&(h.ended=!0,u.logger.log("[buffer-controller]: "+o+" sourceBuffer now EOS")),l&&!!(!h||h.ended)},!0);T&&this.blockBuffers(function(){var l=p.mediaSource;!l||l.readyState!=="open"||l.endOfStream()})},S.onLevelUpdated=function(i,d){var p=d.details;!p.fragments.length||(this.details=p,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},S.flushBackBuffer=function(){var i=this.hls,d=this.details,p=this.media,T=this.sourceBuffer;if(!(!p||d===null)){var l=this.getSourceBufferTypes();if(!!l.length){var o=d.live&&i.config.liveBackBufferLength!==null?i.config.liveBackBufferLength:i.config.backBufferLength;if(!(!Object(a.isFiniteNumber)(o)||o<0)){var h=p.currentTime,E=d.levelTargetDuration,n=Math.max(o,E),c=Math.floor(h/E)*E-n;l.forEach(function(v){var f=T[v];if(f){var g=C.BufferHelper.getBuffered(f);g.length>0&&c>g.start(0)&&(i.trigger(s.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),d.live&&i.trigger(s.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c}),i.trigger(s.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:v}))}})}}}},S.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var i=this.details,d=this.hls,p=this.media,T=this.mediaSource,l=i.fragments[0].start+i.totalduration,o=p.duration,h=Object(a.isFiniteNumber)(T.duration)?T.duration:0;i.live&&d.config.liveDurationInfinity?(u.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),T.duration=1/0,this.updateSeekableRange(i)):(l>h&&l>o||!Object(a.isFiniteNumber)(o))&&(u.logger.log("[buffer-controller]: Updating Media Source duration to "+l.toFixed(3)),T.duration=l)}},S.updateSeekableRange=function(i){var d=this.mediaSource,p=i.fragments,T=p.length;if(T&&i.live&&d!==null&&d!==void 0&&d.setLiveSeekableRange){var l=Math.max(0,p[0].start),o=Math.max(l,l+i.totalduration);d.setLiveSeekableRange(l,o)}},S.checkPendingTracks=function(){var i=this.bufferCodecEventsExpected,d=this.operationQueue,p=this.pendingTracks,T=Object.keys(p).length;if(T&&!i||T===2){this.createSourceBuffers(p),this.pendingTracks={};var l=this.getSourceBufferTypes();if(l.length===0){this.hls.trigger(s.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}l.forEach(function(o){d.executeNext(o)})}},S.createSourceBuffers=function(i){var d=this.sourceBuffer,p=this.mediaSource;if(!p)throw Error("createSourceBuffers called when mediaSource was null");var T=0;for(var l in i)if(!d[l]){var o=i[l];if(!o)throw Error("source buffer exists for track "+l+", however track does not");var h=o.levelCodec||o.codec,E=o.container+";codecs="+h;u.logger.log("[buffer-controller]: creating sourceBuffer("+E+")");try{var n=d[l]=p.addSourceBuffer(E),c=l;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[l]={buffer:n,codec:h,container:o.container,levelCodec:o.levelCodec,metadata:o.metadata,id:o.id},T++}catch(v){u.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+v.message),this.hls.trigger(s.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:v,mimeType:E})}}T&&this.hls.trigger(s.Events.BUFFER_CREATED,{tracks:this.tracks})},S._onSBUpdateStart=function(i){var d=this.operationQueue,p=d.current(i);p.onStart()},S._onSBUpdateEnd=function(i){var d=this.operationQueue,p=d.current(i);p.onComplete(),d.shiftAndExecuteNext(i)},S._onSBUpdateError=function(i,d){u.logger.error("[buffer-controller]: "+i+" SourceBuffer error",d),this.hls.trigger(s.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var p=this.operationQueue.current(i);p&&p.onError(d)},S.removeExecutor=function(i,d,p){var T=this.media,l=this.mediaSource,o=this.operationQueue,h=this.sourceBuffer,E=h[i];if(!T||!l||!E){u.logger.warn("[buffer-controller]: Attempting to remove from the "+i+" SourceBuffer, but it does not exist"),o.shiftAndExecuteNext(i);return}var n=Object(a.isFiniteNumber)(T.duration)?T.duration:1/0,c=Object(a.isFiniteNumber)(l.duration)?l.duration:1/0,v=Math.max(0,d),f=Math.min(p,n,c);f>v?(u.logger.log("[buffer-controller]: Removing ["+v+","+f+"] from the "+i+" SourceBuffer"),console.assert(!E.updating,i+" sourceBuffer must not be updating"),E.remove(v,f)):o.shiftAndExecuteNext(i)},S.appendExecutor=function(i,d){var p=this.operationQueue,T=this.sourceBuffer,l=T[d];if(!l){u.logger.warn("[buffer-controller]: Attempting to append to the "+d+" SourceBuffer, but it does not exist"),p.shiftAndExecuteNext(d);return}l.ended=!1,console.assert(!l.updating,d+" sourceBuffer must not be updating"),l.appendBuffer(i)},S.blockBuffers=function(i,d){var p=this;if(d===void 0&&(d=this.getSourceBufferTypes()),!d.length){u.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(i);return}var T=this.operationQueue,l=d.map(function(o){return T.appendBlocker(o)});Promise.all(l).then(function(){i(),d.forEach(function(o){var h=p.sourceBuffer[o];(!h||!h.updating)&&T.shiftAndExecuteNext(o)})})},S.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},S.addBufferListener=function(i,d,p){var T=this.sourceBuffer[i];if(!!T){var l=p.bind(this,i);this.listeners[i].push({event:d,listener:l}),T.addEventListener(d,l)}},S.removeBufferListeners=function(i){var d=this.sourceBuffer[i];!d||this.listeners[i].forEach(function(p){d.removeEventListener(p.event,p.listener)})},A}()},"./src/controller/buffer-operation-queue.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return s});var a=e("./src/utils/logger.ts"),s=function(){function u(C){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=C}var R=u.prototype;return R.append=function(O,L){var b=this.queues[L];b.push(O),b.length===1&&this.buffers[L]&&this.executeNext(L)},R.insertAbort=function(O,L){var b=this.queues[L];b.unshift(O),this.executeNext(L)},R.appendBlocker=function(O){var L,b=new Promise(function(I){L=I}),x={execute:L,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(x,O),b},R.executeNext=function(O){var L=this.buffers,b=this.queues,x=L[O],I=b[O];if(I.length){var _=I[0];try{_.execute()}catch(A){a.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),_.onError(A),(!x||!x.updating)&&(I.shift(),this.executeNext(O))}}},R.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},R.current=function(O){return this.queues[O][0]},u}()},"./src/controller/cap-level-controller.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/events.ts");function s(C,O){for(var L=0;L<O.length;L++){var b=O[L];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(C,b.key,b)}}function u(C,O,L){return O&&s(C.prototype,O),L&&s(C,L),Object.defineProperty(C,"prototype",{writable:!1}),C}var R=function(){function C(L){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=L,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var O=C.prototype;return O.setStreamController=function(b){this.streamController=b},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 b=this.hls;b.on(a.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),b.on(a.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),b.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),b.on(a.Events.BUFFER_CODECS,this.onBufferCodecs,this),b.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var b=this.hls;b.off(a.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),b.off(a.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),b.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),b.off(a.Events.BUFFER_CODECS,this.onBufferCodecs,this),b.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(b,x){C.isLevelAllowed(x.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(x.droppedLevel)},O.onMediaAttaching=function(b,x){this.media=x.media instanceof HTMLVideoElement?x.media:null},O.onManifestParsed=function(b,x){var I=this.hls;this.restrictedLevels=[],this.firstLevel=x.firstLevel,I.config.capLevelToPlayerSize&&x.video&&this.startCapping()},O.onBufferCodecs=function(b,x){var I=this.hls;I.config.capLevelToPlayerSize&&x.video&&this.startCapping()},O.onMediaDetaching=function(){this.stopCapping()},O.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var b=this.hls.levels;if(b.length){var x=this.hls;x.autoLevelCapping=this.getMaxLevel(b.length-1),x.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=x.autoLevelCapping}}},O.getMaxLevel=function(b){var x=this,I=this.hls.levels;if(!I.length)return-1;var _=I.filter(function(A,S){return C.isLevelAllowed(S,x.restrictedLevels)&&S<=b});return this.clientRect=null,C.getMaxLevelByMediaSize(_,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 b=this.media,x={width:0,height:0};if(b){var I=b.getBoundingClientRect();x.width=I.width,x.height=I.height,!x.width&&!x.height&&(x.width=I.right-I.left||b.width||0,x.height=I.bottom-I.top||b.height||0)}return this.clientRect=x,x},C.isLevelAllowed=function(b,x){return x===void 0&&(x=[]),x.indexOf(b)===-1},C.getMaxLevelByMediaSize=function(b,x,I){if(!b||!b.length)return-1;for(var _=function(d,p){return p?d.width!==p.width||d.height!==p.height:!0},A=b.length-1,S=0;S<b.length;S+=1){var m=b[S];if((m.width>=x||m.height>=I)&&_(m,b[S+1])){A=S;break}}return A},u(C,[{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 b=1;if(!this.hls.config.ignoreDevicePixelRatio)try{b=self.devicePixelRatio}catch{}return b}}]),C}();t.default=R},"./src/controller/cmcd-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return _});var a=e("./src/events.ts"),s=e("./src/types/cmcd.ts"),u=e("./src/utils/buffer-helper.ts"),R=e("./src/utils/logger.ts");function C(A,S){for(var m=0;m<S.length;m++){var i=S[m];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(A,i.key,i)}}function O(A,S,m){return S&&C(A.prototype,S),m&&C(A,m),Object.defineProperty(A,"prototype",{writable:!1}),A}function L(A,S){var m=typeof Symbol!="undefined"&&A[Symbol.iterator]||A["@@iterator"];if(m)return(m=m.call(A)).next.bind(m);if(Array.isArray(A)||(m=b(A))||S&&A&&typeof A.length=="number"){m&&(A=m);var i=0;return function(){return i>=A.length?{done:!0}:{done:!1,value:A[i++]}}}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 b(A,S){if(!!A){if(typeof A=="string")return x(A,S);var m=Object.prototype.toString.call(A).slice(8,-1);if(m==="Object"&&A.constructor&&(m=A.constructor.name),m==="Map"||m==="Set")return Array.from(A);if(m==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m))return x(A,S)}}function x(A,S){(S==null||S>A.length)&&(S=A.length);for(var m=0,i=new Array(S);m<S;m++)i[m]=A[m];return i}function I(){return I=Object.assign?Object.assign.bind():function(A){for(var S=1;S<arguments.length;S++){var m=arguments[S];for(var i in m)Object.prototype.hasOwnProperty.call(m,i)&&(A[i]=m[i])}return A},I.apply(this,arguments)}var _=function(){function A(m){var i=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(){i.initialized&&(i.starved=!0),i.buffering=!0},this.onPlaying=function(){i.initialized||(i.initialized=!0),i.buffering=!1},this.applyPlaylistData=function(T){try{i.apply(T,{ot:s.CMCDObjectType.MANIFEST,su:!i.initialized})}catch(l){R.logger.warn("Could not generate manifest CMCD data.",l)}},this.applyFragmentData=function(T){try{var l=T.frag,o=i.hls.levels[l.level],h=i.getObjectType(l),E={d:l.duration*1e3,ot:h};(h===s.CMCDObjectType.VIDEO||h===s.CMCDObjectType.AUDIO||h==s.CMCDObjectType.MUXED)&&(E.br=o.bitrate/1e3,E.tb=i.getTopBandwidth(h)/1e3,E.bl=i.getBufferLength(h)),i.apply(T,E)}catch(n){R.logger.warn("Could not generate segment CMCD data.",n)}},this.hls=m;var d=this.config=m.config,p=d.cmcd;p!=null&&(d.pLoader=this.createPlaylistLoader(),d.fLoader=this.createFragmentLoader(),this.sid=p.sessionId||A.uuid(),this.cid=p.contentId,this.useHeaders=p.useHeaders===!0,this.registerListeners())}var S=A.prototype;return S.registerListeners=function(){var i=this.hls;i.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.on(a.Events.MEDIA_DETACHED,this.onMediaDetached,this),i.on(a.Events.BUFFER_CREATED,this.onBufferCreated,this)},S.unregisterListeners=function(){var i=this.hls;i.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.off(a.Events.MEDIA_DETACHED,this.onMediaDetached,this),i.off(a.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},S.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},S.onMediaAttached=function(i,d){this.media=d.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},S.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},S.onBufferCreated=function(i,d){var p,T;this.audioBuffer=(p=d.tracks.audio)===null||p===void 0?void 0:p.buffer,this.videoBuffer=(T=d.tracks.video)===null||T===void 0?void 0:T.buffer},S.createData=function(){var i;return{v:s.CMCDVersion,sf:s.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(i=this.media)===null||i===void 0?void 0:i.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},S.apply=function(i,d){d===void 0&&(d={}),I(d,this.createData());var p=d.ot===s.CMCDObjectType.INIT||d.ot===s.CMCDObjectType.VIDEO||d.ot===s.CMCDObjectType.MUXED;if(this.starved&&p&&(d.bs=!0,d.su=!0,this.starved=!1),d.su==null&&(d.su=this.buffering),this.useHeaders){var T=A.toHeaders(d);if(!Object.keys(T).length)return;i.headers||(i.headers={}),I(i.headers,T)}else{var l=A.toQuery(d);if(!l)return;i.url=A.appendQueryToUri(i.url,l)}},S.getObjectType=function(i){var d=i.type;if(d==="subtitle")return s.CMCDObjectType.TIMED_TEXT;if(i.sn==="initSegment")return s.CMCDObjectType.INIT;if(d==="audio")return s.CMCDObjectType.AUDIO;if(d==="main")return this.hls.audioTracks.length?s.CMCDObjectType.VIDEO:s.CMCDObjectType.MUXED},S.getTopBandwidth=function(i){var d=0,p,T=this.hls;if(i===s.CMCDObjectType.AUDIO)p=T.audioTracks;else{var l=T.maxAutoLevel,o=l>-1?l+1:T.levels.length;p=T.levels.slice(0,o)}for(var h=L(p),E;!(E=h()).done;){var n=E.value;n.bitrate>d&&(d=n.bitrate)}return d>0?d:NaN},S.getBufferLength=function(i){var d=this.hls.media,p=i===s.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!p||!d)return NaN;var T=u.BufferHelper.bufferInfo(p,d.currentTime,this.config.maxBufferHole);return T.len*1e3},S.createPlaylistLoader=function(){var i=this.config.pLoader,d=this.applyPlaylistData,p=i||this.config.loader;return function(){function T(o){this.loader=void 0,this.loader=new p(o)}var l=T.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(h,E,n){d(h),this.loader.load(h,E,n)},O(T,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),T}()},S.createFragmentLoader=function(){var i=this.config.fLoader,d=this.applyFragmentData,p=i||this.config.loader;return function(){function T(o){this.loader=void 0,this.loader=new p(o)}var l=T.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(h,E,n){d(h),this.loader.load(h,E,n)},O(T,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),T}()},A.uuid=function(){var i=URL.createObjectURL(new Blob),d=i.toString();return URL.revokeObjectURL(i),d.slice(d.lastIndexOf("/")+1)},A.serialize=function(i){for(var d=[],p=function(P){return!Number.isNaN(P)&&P!=null&&P!==""&&P!==!1},T=function(P){return Math.round(P)},l=function(P){return T(P/100)*100},o=function(P){return encodeURIComponent(P)},h={br:T,d:T,bl:l,dl:l,mtp:l,nor:o,rtp:l,tb:T},E=Object.keys(i||{}).sort(),n=L(E),c;!(c=n()).done;){var v=c.value,f=i[v];if(!!p(f)&&!(v==="v"&&f===1)&&!(v=="pr"&&f===1)){var g=h[v];g&&(f=g(f));var y=typeof f,M=void 0;v==="ot"||v==="sf"||v==="st"?M=v+"="+f:y==="boolean"?M=v:y==="number"?M=v+"="+f:M=v+"="+JSON.stringify(f),d.push(M)}}return d.join(",")},A.toHeaders=function(i){for(var d=Object.keys(i),p={},T=["Object","Request","Session","Status"],l=[{},{},{},{}],o={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},h=0,E=d;h<E.length;h++){var n=E[h],c=o[n]!=null?o[n]:1;l[c][n]=i[n]}for(var v=0;v<l.length;v++){var f=A.serialize(l[v]);f&&(p["CMCD-"+T[v]]=f)}return p},A.toQuery=function(i){return"CMCD="+encodeURIComponent(A.serialize(i))},A.appendQueryToUri=function(i,d){if(!d)return i;var p=i.includes("?")?"&":"?";return""+i+p+d},A}()},"./src/controller/eme-controller.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/events.ts"),s=e("./src/errors.ts"),u=e("./src/utils/logger.ts"),R=e("./src/utils/mediakeys-helper.ts");function C(_,A){for(var S=0;S<A.length;S++){var m=A[S];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(_,m.key,m)}}function O(_,A,S){return A&&C(_.prototype,A),S&&C(_,S),Object.defineProperty(_,"prototype",{writable:!1}),_}var L=3,b=function(A,S,m){var i={audioCapabilities:[],videoCapabilities:[]};return A.forEach(function(d){i.audioCapabilities.push({contentType:'audio/mp4; codecs="'+d+'"',robustness:m.audioRobustness||""})}),S.forEach(function(d){i.videoCapabilities.push({contentType:'video/mp4; codecs="'+d+'"',robustness:m.videoRobustness||""})}),[i]},x=function(A,S,m,i){switch(A){case R.KeySystems.WIDEVINE:return b(S,m,i);default:throw new Error("Unknown key-system: "+A)}},I=function(){function _(S){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=S,this._config=S.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var A=_.prototype;return A.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},A._registerListeners=function(){this.hls.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(a.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this)},A._unregisterListeners=function(){this.hls.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(a.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this)},A.getLicenseServerUrl=function(m){switch(m){case R.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+m+'"')},A._attemptKeySystemAccess=function(m,i,d){var p=this,T=x(m,i,d,this._drmSystemOptions);u.logger.log("Requesting encrypted media key-system access");var l=this.requestMediaKeySystemAccess(m,T);this.mediaKeysPromise=l.then(function(o){return p._onMediaKeySystemAccessObtained(m,o)}),l.catch(function(o){u.logger.error('Failed to obtain key-system "'+m+'" access:',o)})},A._onMediaKeySystemAccessObtained=function(m,i){var d=this;u.logger.log('Access for key-system "'+m+'" obtained');var p={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:i,mediaKeySystemDomain:m};this._mediaKeysList.push(p);var T=Promise.resolve().then(function(){return i.createMediaKeys()}).then(function(l){return p.mediaKeys=l,u.logger.log('Media-keys created for key-system "'+m+'"'),d._onMediaKeysCreated(),l});return T.catch(function(l){u.logger.error("Failed to create media-keys:",l)}),T},A._onMediaKeysCreated=function(){var m=this;this._mediaKeysList.forEach(function(i){i.mediaKeysSession||(i.mediaKeysSession=i.mediaKeys.createSession(),m._onNewMediaKeySession(i.mediaKeysSession))})},A._onNewMediaKeySession=function(m){var i=this;u.logger.log("New key-system session "+m.sessionId),m.addEventListener("message",function(d){i._onKeySessionMessage(m,d.message)},!1)},A._onKeySessionMessage=function(m,i){u.logger.log("Got EME message event, creating license request"),this._requestLicense(i,function(d){u.logger.log("Received license data (length: "+(d&&d.byteLength)+"), updating key-session"),m.update(d).catch(function(p){u.logger.warn("Updating key-session failed: "+p)})})},A.onMediaEncrypted=function(m){var i=this;if(u.logger.log('Media is encrypted using "'+m.initDataType+'" init data type'),!this.mediaKeysPromise){u.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(a.Events.ERROR,{type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var d=function(T){!i._media||(i._attemptSetMediaKeys(T),i._generateRequestWithPreferredKeySession(m.initDataType,m.initData))};this.mediaKeysPromise.then(d).catch(d)},A._attemptSetMediaKeys=function(m){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var i=this._mediaKeysList[0];if(!i||!i.mediaKeys){u.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(a.Events.ERROR,{type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}u.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(i.mediaKeys),this._hasSetMediaKeys=!0}},A._generateRequestWithPreferredKeySession=function(m,i){var d=this,p=this._mediaKeysList[0];if(!p){u.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(a.Events.ERROR,{type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(p.mediaKeysSessionInitialized){u.logger.warn("Key-Session already initialized but requested again");return}var T=p.mediaKeysSession;if(!T){u.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(a.Events.ERROR,{type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!i){u.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(a.Events.ERROR,{type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}u.logger.log('Generating key-session request for "'+m+'" init data type'),p.mediaKeysSessionInitialized=!0,T.generateRequest(m,i).then(function(){u.logger.debug("Key-session generation succeeded")}).catch(function(l){u.logger.error("Error generating key-session request:",l),d.hls.trigger(a.Events.ERROR,{type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},A._createLicenseXhr=function(m,i,d){var p=new XMLHttpRequest;p.responseType="arraybuffer",p.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,p,m,i,d);var T=this._licenseXhrSetup;if(T)try{T.call(this.hls,p,m),T=void 0}catch(l){u.logger.error(l)}try{p.readyState||p.open("POST",m,!0),T&&T.call(this.hls,p,m)}catch(l){throw new Error("issue setting up KeySystem license XHR "+l)}return p},A._onLicenseRequestReadyStageChange=function(m,i,d,p){switch(m.readyState){case 4:if(m.status===200){this._requestLicenseFailureCount=0,u.logger.log("License request succeeded");var T=m.response,l=this._licenseResponseCallback;if(l)try{T=l.call(this.hls,m,i)}catch(h){u.logger.error(h)}p(T)}else{if(u.logger.error("License Request XHR failed ("+i+"). Status: "+m.status+" ("+m.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>L){this.hls.trigger(a.Events.ERROR,{type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var o=L-this._requestLicenseFailureCount+1;u.logger.warn("Retrying license request, "+o+" attempts left"),this._requestLicense(d,p)}break}},A._generateLicenseRequestChallenge=function(m,i){switch(m.mediaKeySystemDomain){case R.KeySystems.WIDEVINE:return i}throw new Error("unsupported key-system: "+m.mediaKeySystemDomain)},A._requestLicense=function(m,i){u.logger.log("Requesting content license for key-system");var d=this._mediaKeysList[0];if(!d){u.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(a.Events.ERROR,{type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var p=this.getLicenseServerUrl(d.mediaKeySystemDomain),T=this._createLicenseXhr(p,m,i);u.logger.log("Sending license request to URL: "+p);var l=this._generateLicenseRequestChallenge(d,m);T.send(l)}catch(o){u.logger.error("Failure requesting DRM license: "+o),this.hls.trigger(a.Events.ERROR,{type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},A.onMediaAttached=function(m,i){if(!!this._emeEnabled){var d=i.media;this._media=d,d.addEventListener("encrypted",this._onMediaEncrypted)}},A.onMediaDetached=function(){var m=this._media,i=this._mediaKeysList;!m||(m.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(i.map(function(d){if(d.mediaKeysSession)return d.mediaKeysSession.close().catch(function(){})})).then(function(){return m.setMediaKeys(null)}).catch(function(){}))},A.onManifestParsed=function(m,i){if(!!this._emeEnabled){var d=i.levels.map(function(T){return T.audioCodec}).filter(function(T){return!!T}),p=i.levels.map(function(T){return T.videoCodec}).filter(function(T){return!!T});this._attemptKeySystemAccess(R.KeySystems.WIDEVINE,d,p)}},O(_,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),_}();t.default=I},"./src/controller/fps-controller.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/events.ts"),s=e("./src/utils/logger.ts"),u=function(){function R(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 C=R.prototype;return C.setStreamController=function(L){this.streamController=L},C.registerListeners=function(){this.hls.on(a.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},C.unregisterListeners=function(){this.hls.off(a.Events.MEDIA_ATTACHING,this.onMediaAttaching)},C.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},C.onMediaAttaching=function(L,b){var x=this.hls.config;if(x.capLevelOnFPSDrop){var I=b.media instanceof self.HTMLVideoElement?b.media:null;this.media=I,I&&typeof I.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),x.fpsDroppedMonitoringPeriod)}},C.checkFPS=function(L,b,x){var I=performance.now();if(b){if(this.lastTime){var _=I-this.lastTime,A=x-this.lastDroppedFrames,S=b-this.lastDecodedFrames,m=1e3*A/_,i=this.hls;if(i.trigger(a.Events.FPS_DROP,{currentDropped:A,currentDecoded:S,totalDroppedFrames:x}),m>0&&A>i.config.fpsDroppedMonitoringThreshold*S){var d=i.currentLevel;s.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(i.autoLevelCapping===-1||i.autoLevelCapping>=d)&&(d=d-1,i.trigger(a.Events.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:i.currentLevel}),i.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=I,this.lastDroppedFrames=x,this.lastDecodedFrames=b}},C.checkFPSInterval=function(){var L=this.media;if(L)if(this.isVideoPlaybackQualityAvailable){var b=L.getVideoPlaybackQuality();this.checkFPS(L,b.totalVideoFrames,b.droppedVideoFrames)}else this.checkFPS(L,L.webkitDecodedFrameCount,L.webkitDroppedFrameCount)},R}();t.default=u},"./src/controller/fragment-finders.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"findFragmentByPDT",function(){return u}),e.d(t,"findFragmentByPTS",function(){return R}),e.d(t,"fragmentWithinToleranceTest",function(){return C}),e.d(t,"pdtWithinToleranceTest",function(){return O}),e.d(t,"findFragWithCC",function(){return L});var a=e("./src/polyfills/number.ts"),s=e("./src/utils/binary-search.ts");function u(b,x,I){if(x===null||!Array.isArray(b)||!b.length||!Object(a.isFiniteNumber)(x))return null;var _=b[0].programDateTime;if(x<(_||0))return null;var A=b[b.length-1].endProgramDateTime;if(x>=(A||0))return null;I=I||0;for(var S=0;S<b.length;++S){var m=b[S];if(O(x,I,m))return m}return null}function R(b,x,I,_){I===void 0&&(I=0),_===void 0&&(_=0);var A=null;if(b?A=x[b.sn-x[0].sn+1]||null:I===0&&x[0].start===0&&(A=x[0]),A&&C(I,_,A)===0)return A;var S=s.default.search(x,C.bind(null,I,_));return S||A}function C(b,x,I){b===void 0&&(b=0),x===void 0&&(x=0);var _=Math.min(x,I.duration+(I.deltaPTS?I.deltaPTS:0));return I.start+I.duration-_<=b?1:I.start-_>b&&I.start?-1:0}function O(b,x,I){var _=Math.min(x,I.duration+(I.deltaPTS?I.deltaPTS:0))*1e3,A=I.endProgramDateTime||0;return A-_>b}function L(b,x){return s.default.search(b,function(I){return I.cc<x?1:I.cc>x?-1:0})}},"./src/controller/fragment-tracker.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"FragmentState",function(){return u}),e.d(t,"FragmentTracker",function(){return R});var a=e("./src/events.ts"),s=e("./src/types/loader.ts"),u;(function(L){L.NOT_LOADED="NOT_LOADED",L.APPENDING="APPENDING",L.PARTIAL="PARTIAL",L.OK="OK"})(u||(u={}));var R=function(){function L(x){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=x,this._registerListeners()}var b=L.prototype;return b._registerListeners=function(){var I=this.hls;I.on(a.Events.BUFFER_APPENDED,this.onBufferAppended,this),I.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),I.on(a.Events.FRAG_LOADED,this.onFragLoaded,this)},b._unregisterListeners=function(){var I=this.hls;I.off(a.Events.BUFFER_APPENDED,this.onBufferAppended,this),I.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),I.off(a.Events.FRAG_LOADED,this.onFragLoaded,this)},b.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},b.getAppendedFrag=function(I,_){if(_===s.PlaylistLevelType.MAIN){var A=this.activeFragment,S=this.activeParts;if(!A)return null;if(S)for(var m=S.length;m--;){var i=S[m],d=i?i.end:A.appendedPTS;if(i.start<=I&&d!==void 0&&I<=d)return m>9&&(this.activeParts=S.slice(m-9)),i}else if(A.start<=I&&A.appendedPTS!==void 0&&I<=A.appendedPTS)return A}return this.getBufferedFrag(I,_)},b.getBufferedFrag=function(I,_){for(var A=this.fragments,S=Object.keys(A),m=S.length;m--;){var i=A[S[m]];if((i==null?void 0:i.body.type)===_&&i.buffered){var d=i.body;if(d.start<=I&&I<=d.end)return d}}return null},b.detectEvictedFragments=function(I,_,A){var S=this;Object.keys(this.fragments).forEach(function(m){var i=S.fragments[m];if(!!i){if(!i.buffered){i.body.type===A&&S.removeFragment(i.body);return}var d=i.range[I];!d||d.time.some(function(p){var T=!S.isTimeBuffered(p.startPTS,p.endPTS,_);return T&&S.removeFragment(i.body),T})}})},b.detectPartialFragments=function(I){var _=this,A=this.timeRanges,S=I.frag,m=I.part;if(!(!A||S.sn==="initSegment")){var i=O(S),d=this.fragments[i];!d||(Object.keys(A).forEach(function(p){var T=S.elementaryStreams[p];if(!!T){var l=A[p],o=m!==null||T.partial===!0;d.range[p]=_.getBufferedTimes(S,m,o,l)}}),d.loaded=null,Object.keys(d.range).length?d.buffered=!0:this.removeFragment(d.body))}},b.fragBuffered=function(I){var _=O(I),A=this.fragments[_];A&&(A.loaded=null,A.buffered=!0)},b.getBufferedTimes=function(I,_,A,S){for(var m={time:[],partial:A},i=_?_.start:I.start,d=_?_.end:I.end,p=I.minEndPTS||d,T=I.maxStartPTS||i,l=0;l<S.length;l++){var o=S.start(l)-this.bufferPadding,h=S.end(l)+this.bufferPadding;if(T>=o&&p<=h){m.time.push({startPTS:Math.max(i,S.start(l)),endPTS:Math.min(d,S.end(l))});break}else if(i<h&&d>o)m.partial=!0,m.time.push({startPTS:Math.max(i,S.start(l)),endPTS:Math.min(d,S.end(l))});else if(d<=o)break}return m},b.getPartialFragment=function(I){var _=null,A,S,m,i=0,d=this.bufferPadding,p=this.fragments;return Object.keys(p).forEach(function(T){var l=p[T];!l||C(l)&&(S=l.body.start-d,m=l.body.end+d,I>=S&&I<=m&&(A=Math.min(I-S,m-I),i<=A&&(_=l.body,i=A)))}),_},b.getState=function(I){var _=O(I),A=this.fragments[_];return A?A.buffered?C(A)?u.PARTIAL:u.OK:u.APPENDING:u.NOT_LOADED},b.isTimeBuffered=function(I,_,A){for(var S,m,i=0;i<A.length;i++){if(S=A.start(i)-this.bufferPadding,m=A.end(i)+this.bufferPadding,I>=S&&_<=m)return!0;if(_<=S)return!1}return!1},b.onFragLoaded=function(I,_){var A=_.frag,S=_.part;if(!(A.sn==="initSegment"||A.bitrateTest||S)){var m=O(A);this.fragments[m]={body:A,loaded:_,buffered:!1,range:Object.create(null)}}},b.onBufferAppended=function(I,_){var A=this,S=_.frag,m=_.part,i=_.timeRanges;if(S.type===s.PlaylistLevelType.MAIN)if(this.activeFragment=S,m){var d=this.activeParts;d||(this.activeParts=d=[]),d.push(m)}else this.activeParts=null;this.timeRanges=i,Object.keys(i).forEach(function(p){var T=i[p];if(A.detectEvictedFragments(p,T),!m)for(var l=0;l<T.length;l++)S.appendedPTS=Math.max(T.end(l),S.appendedPTS||0)})},b.onFragBuffered=function(I,_){this.detectPartialFragments(_)},b.hasFragment=function(I){var _=O(I);return!!this.fragments[_]},b.removeFragmentsInRange=function(I,_,A){var S=this;Object.keys(this.fragments).forEach(function(m){var i=S.fragments[m];if(!!i&&i.buffered){var d=i.body;d.type===A&&d.start<_&&d.end>I&&S.removeFragment(d)}})},b.removeFragment=function(I){var _=O(I);I.stats.loaded=0,I.clearElementaryStreamInfo(),delete this.fragments[_]},b.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},L}();function C(L){var b,x;return L.buffered&&(((b=L.range.video)===null||b===void 0?void 0:b.partial)||((x=L.range.audio)===null||x===void 0?void 0:x.partial))}function O(L){return L.type+"_"+L.level+"_"+L.urlId+"_"+L.sn}},"./src/controller/gap-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"STALL_MINIMUM_DURATION_MS",function(){return C}),e.d(t,"MAX_START_GAP_JUMP",function(){return O}),e.d(t,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return L}),e.d(t,"SKIP_BUFFER_RANGE_START",function(){return b}),e.d(t,"default",function(){return x});var a=e("./src/utils/buffer-helper.ts"),s=e("./src/errors.ts"),u=e("./src/events.ts"),R=e("./src/utils/logger.ts"),C=250,O=2,L=.1,b=.05,x=function(){function I(A,S,m,i){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=A,this.media=S,this.fragmentTracker=m,this.hls=i}var _=I.prototype;return _.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},_.poll=function(S,m){var i=this.config,d=this.media,p=this.stalled;if(d!==null){var T=d.currentTime,l=d.seeking,o=this.seeking&&!l,h=!this.seeking&&l;if(this.seeking=l,T!==S){if(this.moved=!0,p!==null){if(this.stallReported){var E=self.performance.now()-p;R.logger.warn("playback not stuck anymore @"+T+", after "+Math.round(E)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((h||o)&&(this.stalled=null),!(d.paused&&!l||d.ended||d.playbackRate===0||!a.BufferHelper.getBuffered(d).length)){var n=a.BufferHelper.bufferInfo(d,T,0),c=n.len>0,v=n.nextStart||0;if(!(!c&&!v)){if(l){var f=n.len>O,g=!v||m&&m.start<=T||v-T>O&&!this.fragmentTracker.getPartialFragment(T);if(f||g)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var y,M=Math.max(v,n.start||0)-T,D=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=D==null||(y=D.details)===null||y===void 0?void 0:y.live,B=P?D.details.targetduration*2:O;if(M>0&&M<=B){this._trySkipBufferHole(null);return}}var N=self.performance.now();if(p===null){this.stalled=N;return}var F=N-p;if(!(!l&&F>=C&&(this._reportStall(n),!this.media))){var H=a.BufferHelper.bufferInfo(d,T,i.maxBufferHole);this._tryFixBufferStall(H,F)}}}}},_._tryFixBufferStall=function(S,m){var i=this.config,d=this.fragmentTracker,p=this.media;if(p!==null){var T=p.currentTime,l=d.getPartialFragment(T);if(l){var o=this._trySkipBufferHole(l);if(o||!this.media)return}S.len>i.maxBufferHole&&m>i.highBufferWatchdogPeriod*1e3&&(R.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},_._reportStall=function(S){var m=this.hls,i=this.media,d=this.stallReported;!d&&i&&(this.stallReported=!0,R.logger.warn("Playback stalling at @"+i.currentTime+" due to low buffer ("+JSON.stringify(S)+")"),m.trigger(u.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:S.len}))},_._trySkipBufferHole=function(S){var m=this.config,i=this.hls,d=this.media;if(d===null)return 0;for(var p=d.currentTime,T=0,l=a.BufferHelper.getBuffered(d),o=0;o<l.length;o++){var h=l.start(o);if(p+m.maxBufferHole>=T&&p<h){var E=Math.max(h+b,d.currentTime+L);return R.logger.warn("skipping hole, adjusting currentTime from "+p+" to "+E),this.moved=!0,this.stalled=null,d.currentTime=E,S&&i.trigger(u.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+p+" to "+E,frag:S}),E}T=l.end(o)}return 0},_._tryNudgeBuffer=function(){var S=this.config,m=this.hls,i=this.media,d=this.nudgeRetry;if(i!==null){var p=i.currentTime;if(this.nudgeRetry++,d<S.nudgeMaxRetry){var T=p+(d+1)*S.nudgeOffset;R.logger.warn("Nudging 'currentTime' from "+p+" to "+T),i.currentTime=T,m.trigger(u.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else R.logger.error("Playhead still not moving while enough data buffered @"+p+" after "+S.nudgeMaxRetry+" nudges"),m.trigger(u.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},I}()},"./src/controller/id3-track-controller.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/polyfills/number.ts"),s=e("./src/events.ts"),u=e("./src/utils/texttrack-utils.ts"),R=e("./src/demux/id3.ts"),C=e("./src/loader/date-range.ts"),O=e("./src/types/demuxer.ts"),L=.25;function b(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function x(A,S){return A.getTime()/1e3-S}function I(A){return Uint8Array.from(A.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var _=function(){function A(m){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=m,this._registerListeners()}var S=A.prototype;return S.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},S._registerListeners=function(){var i=this.hls;i.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.on(s.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),i.on(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),i.on(s.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},S._unregisterListeners=function(){var i=this.hls;i.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.off(s.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),i.off(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),i.off(s.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},S.onMediaAttached=function(i,d){this.media=d.media},S.onMediaDetaching=function(){!this.id3Track||(Object(u.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},S.onManifestLoading=function(){this.dateRangeCuesAppended={}},S.createTrack=function(i){var d=this.getID3Track(i.textTracks);return d.mode="hidden",d},S.getID3Track=function(i){if(!!this.media){for(var d=0;d<i.length;d++){var p=i[d];if(p.kind==="metadata"&&p.label==="id3")return Object(u.sendAddTrackEvent)(p,this.media),p}return this.media.addTextTrack("metadata","id3")}},S.onFragParsingMetadata=function(i,d){if(!!this.media){var p=this.hls.config,T=p.enableEmsgMetadataCues,l=p.enableID3MetadataCues;if(!(!T&&!l)){var o=d.frag,h=d.samples,E=d.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var n=E.edge||o.end,c=b(),v=!1,f={},g=0;g<h.length;g++){var y=h[g].type;if(!(y===O.MetadataSchema.emsg&&!T||!l)){var M=R.getID3Frames(h[g].data);if(M){var D=h[g].pts,P=n,B=P-D;B<=0&&(P=D+L);for(var N=0;N<M.length;N++){var F=M[N];if(!R.isTimeStampFrame(F)){var H=new c(D,P,"");H.value=F,y&&(H.type=y),this.id3Track.addCue(H),f[F.key]=null,v=!0}}}}}v&&this.updateId3CueEnds(f)}}},S.updateId3CueEnds=function(i){var d,p=(d=this.id3Track)===null||d===void 0?void 0:d.cues;if(p)for(var T=p.length;T--;){var l,o=p[T],h=(l=o.value)===null||l===void 0?void 0:l.key;if(h&&h in i){var E=i[h];E&&o.endTime!==E&&(o.endTime=E),i[h]=o.startTime}}},S.onBufferFlushing=function(i,d){var p=d.startOffset,T=d.endOffset,l=d.type,o=this.id3Track,h=this.hls;if(!!h){var E=h.config,n=E.enableEmsgMetadataCues,c=E.enableID3MetadataCues;if(o&&(n||c)){var v;l==="audio"?v=function(g){return g.type===O.MetadataSchema.audioId3&&c}:l==="video"?v=function(g){return g.type===O.MetadataSchema.emsg&&n}:v=function(g){return g.type===O.MetadataSchema.audioId3&&c||g.type===O.MetadataSchema.emsg&&n},Object(u.removeCuesInRange)(o,p,T,v)}}},S.onLevelUpdated=function(i,d){var p=this,T=d.details;if(!(!this.media||!T.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var l=this.dateRangeCuesAppended,o=this.id3Track,h=T.dateRanges,E=Object.keys(h);if(o)for(var n=Object.keys(l).filter(function(B){return!E.includes(B)}),c=function(N){var F=n[N];Object.keys(l[F].cues).forEach(function(H){o.removeCue(l[F].cues[H])}),delete l[F]},v=n.length;v--;)c(v);var f=T.fragments[T.fragments.length-1];if(!(E.length===0||!Object(a.isFiniteNumber)(f==null?void 0:f.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var g=f.programDateTime/1e3-f.start,y=T.edge||f.end,M=b(),D=function(N){var F=E[N],H=h[F],V=l[F],X=(V==null?void 0:V.cues)||{},$=(V==null?void 0:V.durationKnown)||!1,j=x(H.startDate,g),J=y,ee=H.endDate;if(ee)J=x(ee,g),$=!0;else if(H.endOnNext&&!$){var te=E.reduce(function(ae,Re){var Le=h[Re];return Le.class===H.class&&Le.id!==Re&&Le.startDate>H.startDate&&ae.push(Le),ae},[]).sort(function(ae,Re){return ae.startDate.getTime()-Re.startDate.getTime()})[0];te&&(J=x(te.startDate,g),$=!0)}for(var le=Object.keys(H.attr),ue=0;ue<le.length;ue++){var ie=le[ue];if(!(ie===C.DateRangeAttribute.ID||ie===C.DateRangeAttribute.CLASS||ie===C.DateRangeAttribute.START_DATE||ie===C.DateRangeAttribute.DURATION||ie===C.DateRangeAttribute.END_DATE||ie===C.DateRangeAttribute.END_ON_NEXT)){var he=X[ie];if(he)$&&!V.durationKnown&&(he.endTime=J);else{var ve=H.attr[ie];he=new M(j,J,""),(ie===C.DateRangeAttribute.SCTE35_OUT||ie===C.DateRangeAttribute.SCTE35_IN)&&(ve=I(ve)),he.value={key:ie,data:ve},he.type=O.MetadataSchema.dateRange,p.id3Track.addCue(he),X[ie]=he}}}l[F]={cues:X,dateRange:H,durationKnown:$}},P=0;P<E.length;P++)D(P)}}},A}();t.default=_},"./src/controller/latency-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return O});var a=e("./src/errors.ts"),s=e("./src/events.ts"),u=e("./src/utils/logger.ts");function R(L,b){for(var x=0;x<b.length;x++){var I=b[x];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(L,I.key,I)}}function C(L,b,x){return b&&R(L.prototype,b),x&&R(L,x),Object.defineProperty(L,"prototype",{writable:!1}),L}var O=function(){function L(x){var I=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 I.timeupdate()},this.hls=x,this.config=x.config,this.registerListeners()}var b=L.prototype;return b.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},b.registerListeners=function(){this.hls.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(s.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(s.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){this.hls.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(s.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(s.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(s.Events.ERROR,this.onError)},b.onMediaAttached=function(I,_){this.media=_.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},b.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},b.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},b.onLevelUpdated=function(I,_){var A=_.details;this.levelDetails=A,A.advanced&&this.timeupdate(),!A.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},b.onError=function(I,_){_.details===a.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,u.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},b.timeupdate=function(){var I=this.media,_=this.levelDetails;if(!(!I||!_)){this.currentTime=I.currentTime;var A=this.computeLatency();if(A!==null){this._latency=A;var S=this.config,m=S.lowLatencyMode,i=S.maxLiveSyncPlaybackRate;if(!(!m||i===1)){var d=this.targetLatency;if(d!==null){var p=A-d,T=Math.min(this.maxLatency,d+_.targetduration),l=p<T;if(_.live&&l&&p>.05&&this.forwardBufferLength>1){var o=Math.min(2,Math.max(1,i)),h=Math.round(2/(1+Math.exp(-.75*p-this.edgeStalled))*20)/20;I.playbackRate=Math.min(o,Math.max(1,h))}else I.playbackRate!==1&&I.playbackRate!==0&&(I.playbackRate=1)}}}}},b.estimateLiveEdge=function(){var I=this.levelDetails;return I===null?null:I.edge+I.age},b.computeLatency=function(){var I=this.estimateLiveEdge();return I===null?null:I-this.currentTime},C(L,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var I=this.config,_=this.levelDetails;return I.liveMaxLatencyDuration!==void 0?I.liveMaxLatencyDuration:_?I.liveMaxLatencyDurationCount*_.targetduration:0}},{key:"targetLatency",get:function(){var I=this.levelDetails;if(I===null)return null;var _=I.holdBack,A=I.partHoldBack,S=I.targetduration,m=this.config,i=m.liveSyncDuration,d=m.liveSyncDurationCount,p=m.lowLatencyMode,T=this.hls.userConfig,l=p&&A||_;(T.liveSyncDuration||T.liveSyncDurationCount||l===0)&&(l=i!==void 0?i:d*S);var o=S,h=1;return l+Math.min(this.stallCount*h,o)}},{key:"liveSyncPosition",get:function(){var I=this.estimateLiveEdge(),_=this.targetLatency,A=this.levelDetails;if(I===null||_===null||A===null)return null;var S=A.edge,m=I-_-this.edgeStalled,i=S-A.totalduration,d=S-(this.config.lowLatencyMode&&A.partTarget||A.targetduration);return Math.min(Math.max(i,m),d)}},{key:"drift",get:function(){var I=this.levelDetails;return I===null?1:I.drift}},{key:"edgeStalled",get:function(){var I=this.levelDetails;if(I===null)return 0;var _=(this.config.lowLatencyMode&&I.partTarget||I.targetduration)*3;return Math.max(I.age-_,0)}},{key:"forwardBufferLength",get:function(){var I=this.media,_=this.levelDetails;if(!I||!_)return 0;var A=I.buffered.length;return(A?I.buffered.end(A-1):_.edge)-this.currentTime}}]),L}()},"./src/controller/level-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return m});var a=e("./src/types/level.ts"),s=e("./src/events.ts"),u=e("./src/errors.ts"),R=e("./src/utils/codecs.ts"),C=e("./src/controller/level-helper.ts"),O=e("./src/controller/base-playlist-controller.ts"),L=e("./src/types/loader.ts");function b(){return b=Object.assign?Object.assign.bind():function(i){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var T in p)Object.prototype.hasOwnProperty.call(p,T)&&(i[T]=p[T])}return i},b.apply(this,arguments)}function x(i,d){for(var p=0;p<d.length;p++){var T=d[p];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(i,T.key,T)}}function I(i,d,p){return d&&x(i.prototype,d),p&&x(i,p),Object.defineProperty(i,"prototype",{writable:!1}),i}function _(i,d){i.prototype=Object.create(d.prototype),i.prototype.constructor=i,A(i,d)}function A(i,d){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,l){return T.__proto__=l,T},A(i,d)}var S=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),m=function(i){_(d,i);function d(T){var l;return l=i.call(this,T,"[level-controller]")||this,l._levels=[],l._firstLevel=-1,l._startLevel=void 0,l.currentLevelIndex=-1,l.manualLevelIndex=-1,l.onParsedComplete=void 0,l._registerListeners(),l}var p=d.prototype;return p._registerListeners=function(){var l=this.hls;l.on(s.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),l.on(s.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(s.Events.ERROR,this.onError,this)},p._unregisterListeners=function(){var l=this.hls;l.off(s.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),l.off(s.Events.FRAG_LOADED,this.onFragLoaded,this),l.off(s.Events.ERROR,this.onError,this)},p.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,i.prototype.destroy.call(this)},p.startLoad=function(){var l=this._levels;l.forEach(function(o){o.loadError=0}),i.prototype.startLoad.call(this)},p.onManifestLoaded=function(l,o){var h=[],E=[],n=[],c,v={},f,g=!1,y=!1,M=!1;if(o.levels.forEach(function(N){var F=N.attrs;g=g||!!(N.width&&N.height),y=y||!!N.videoCodec,M=M||!!N.audioCodec,S&&N.audioCodec&&N.audioCodec.indexOf("mp4a.40.34")!==-1&&(N.audioCodec=void 0);var H=N.bitrate+"-"+N.attrs.RESOLUTION+"-"+N.attrs.CODECS;f=v[H],f?f.url.push(N.url):(f=new a.Level(N),v[H]=f,h.push(f)),F&&(F.AUDIO&&Object(C.addGroupId)(f,"audio",F.AUDIO),F.SUBTITLES&&Object(C.addGroupId)(f,"text",F.SUBTITLES))}),(g||y)&&M&&(h=h.filter(function(N){var F=N.videoCodec,H=N.width,V=N.height;return!!F||!!(H&&V)})),h=h.filter(function(N){var F=N.audioCodec,H=N.videoCodec;return(!F||Object(R.isCodecSupportedInMp4)(F,"audio"))&&(!H||Object(R.isCodecSupportedInMp4)(H,"video"))}),o.audioTracks&&(E=o.audioTracks.filter(function(N){return!N.audioCodec||Object(R.isCodecSupportedInMp4)(N.audioCodec,"audio")}),Object(C.assignTrackIdsByGroup)(E)),o.subtitles&&(n=o.subtitles,Object(C.assignTrackIdsByGroup)(n)),h.length>0){c=h[0].bitrate,h.sort(function(N,F){return N.bitrate-F.bitrate}),this._levels=h;for(var D=0;D<h.length;D++)if(h[D].bitrate===c){this._firstLevel=D,this.log("manifest loaded, "+h.length+" level(s) found, first bitrate: "+c);break}var P=M&&!y,B={levels:h,audioTracks:E,subtitleTracks:n,firstLevel:this._firstLevel,stats:o.stats,audio:M,video:y,altAudio:!P&&E.some(function(N){return!!N.url})};this.hls.trigger(s.Events.MANIFEST_PARSED,B),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(s.Events.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:o.url,reason:"no level with compatible codecs found in manifest"})},p.onError=function(l,o){var h;if(i.prototype.onError.call(this,l,o),!o.fatal){var E=o.context,n=this._levels[this.currentLevelIndex];if(E&&(E.type===L.PlaylistContextType.AUDIO_TRACK&&n.audioGroupIds&&E.groupId===n.audioGroupIds[n.urlId]||E.type===L.PlaylistContextType.SUBTITLE_TRACK&&n.textGroupIds&&E.groupId===n.textGroupIds[n.urlId])){this.redundantFailover(this.currentLevelIndex);return}var c=!1,v=!0,f;switch(o.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:if(o.frag){var g=o.frag.type===L.PlaylistLevelType.MAIN?o.frag.level:this.currentLevelIndex,y=this._levels[g];y?(y.fragmentError++,y.fragmentError>this.hls.config.fragLoadingMaxRetry&&(f=g)):f=g}break;case u.ErrorDetails.LEVEL_LOAD_ERROR:case u.ErrorDetails.LEVEL_LOAD_TIMEOUT:E&&(E.deliveryDirectives&&(v=!1),f=E.level),c=!0;break;case u.ErrorDetails.REMUX_ALLOC_ERROR:f=(h=o.level)!=null?h:this.currentLevelIndex,c=!0;break}f!==void 0&&this.recoverLevel(o,f,c,v)}},p.recoverLevel=function(l,o,h,E){var n=l.details,c=this._levels[o];if(c.loadError++,h){var v=this.retryLoadingOrFail(l);if(v)l.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(E){var f=c.url.length;if(f>1&&c.loadError<f)l.levelRetry=!0,this.redundantFailover(o);else if(this.manualLevelIndex===-1){for(var g=-1,y=this._levels,M=y.length;M--;){var D=(M+this.currentLevelIndex)%y.length;if(D!==this.currentLevelIndex&&y[D].loadError===0){g=D;break}}g>-1&&this.currentLevelIndex!==g&&(this.warn(n+": switch to "+g),l.levelRetry=!0,this.hls.nextAutoLevel=g)}}},p.redundantFailover=function(l){var o=this._levels[l],h=o.url.length;if(h>1){var E=(o.urlId+1)%h;this.warn("Switching to redundant URL-id "+E),this._levels.forEach(function(n){n.urlId=E}),this.level=l}},p.onFragLoaded=function(l,o){var h=o.frag;if(h!==void 0&&h.type===L.PlaylistLevelType.MAIN){var E=this._levels[h.level];E!==void 0&&(E.fragmentError=0,E.loadError=0)}},p.onLevelLoaded=function(l,o){var h,E=o.level,n=o.details,c=this._levels[E];if(!c){var v;this.warn("Invalid level index "+E),(v=o.deliveryDirectives)!==null&&v!==void 0&&v.skip&&(n.deltaUpdateFailed=!0);return}E===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(E,o,c.details)):(h=o.deliveryDirectives)!==null&&h!==void 0&&h.skip&&(n.deltaUpdateFailed=!0)},p.onAudioTrackSwitched=function(l,o){var h=this.hls.levels[this.currentLevelIndex];if(!!h&&h.audioGroupIds){for(var E=-1,n=this.hls.audioTracks[o.id].groupId,c=0;c<h.audioGroupIds.length;c++)if(h.audioGroupIds[c]===n){E=c;break}E!==h.urlId&&(h.urlId=E,this.startLoad())}},p.loadPlaylist=function(l){var o=this.currentLevelIndex,h=this._levels[o];if(this.canLoad&&h&&h.url.length>0){var E=h.urlId,n=h.url[E];if(l)try{n=l.addDirectives(n)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Attempt loading level index "+o+(l?" at sn "+l.msn+" part "+l.part:"")+" with URL-id "+E+" "+n),this.clearTimer(),this.hls.trigger(s.Events.LEVEL_LOADING,{url:n,level:o,id:E,deliveryDirectives:l||null})}},p.removeLevel=function(l,o){var h=function(c,v){return v!==o},E=this._levels.filter(function(n,c){return c!==l?!0:n.url.length>1&&o!==void 0?(n.url=n.url.filter(h),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(h)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(h)),n.urlId=0,!0):!1}).map(function(n,c){var v=n.details;return v!=null&&v.fragments&&v.fragments.forEach(function(f){f.level=c}),n});this._levels=E,this.hls.trigger(s.Events.LEVELS_UPDATED,{levels:E})},I(d,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(l){var o,h=this._levels;if(h.length!==0&&!(this.currentLevelIndex===l&&(o=h[l])!==null&&o!==void 0&&o.details)){if(l<0||l>=h.length){var E=l<0;if(this.hls.trigger(s.Events.ERROR,{type:u.ErrorTypes.OTHER_ERROR,details:u.ErrorDetails.LEVEL_SWITCH_ERROR,level:l,fatal:E,reason:"invalid level idx"}),E)return;l=Math.min(l,h.length-1)}this.clearTimer();var n=this.currentLevelIndex,c=h[n],v=h[l];this.log("switching to level "+l+" from "+n),this.currentLevelIndex=l;var f=b({},v,{level:l,maxBitrate:v.maxBitrate,uri:v.uri,urlId:v.urlId});delete f._urlId,this.hls.trigger(s.Events.LEVEL_SWITCHING,f);var g=v.details;if(!g||g.live){var y=this.switchParams(v.uri,c==null?void 0:c.details);this.loadPlaylist(y)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(l){this.manualLevelIndex=l,this._startLevel===void 0&&(this._startLevel=l),l!==-1&&(this.level=l)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(l){this._firstLevel=l}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var l=this.hls.config.startLevel;return l!==void 0?l:this._firstLevel}else return this._startLevel},set:function(l){this._startLevel=l}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(l){this.level=l,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=l)}}]),d}(O.default)},"./src/controller/level-helper.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"addGroupId",function(){return C}),e.d(t,"assignTrackIdsByGroup",function(){return O}),e.d(t,"updatePTS",function(){return L}),e.d(t,"updateFragPTSDTS",function(){return x}),e.d(t,"mergeDetails",function(){return I}),e.d(t,"mapPartIntersection",function(){return A}),e.d(t,"mapFragmentIntersection",function(){return S}),e.d(t,"adjustSliding",function(){return m}),e.d(t,"addSliding",function(){return i}),e.d(t,"computeReloadInterval",function(){return d}),e.d(t,"getFragmentWithSN",function(){return p}),e.d(t,"getPartWith",function(){return T});var a=e("./src/polyfills/number.ts"),s=e("./src/utils/logger.ts"),u=e("./src/loader/date-range.ts");function R(){return R=Object.assign?Object.assign.bind():function(l){for(var o=1;o<arguments.length;o++){var h=arguments[o];for(var E in h)Object.prototype.hasOwnProperty.call(h,E)&&(l[E]=h[E])}return l},R.apply(this,arguments)}function C(l,o,h){switch(o){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(h);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(h);break}}function O(l){var o={};l.forEach(function(h){var E=h.groupId||"";h.id=o[E]=o[E]||0,o[E]++})}function L(l,o,h){var E=l[o],n=l[h];b(E,n)}function b(l,o){var h=o.startPTS;if(Object(a.isFiniteNumber)(h)){var E=0,n;o.sn>l.sn?(E=h-l.start,n=l):(E=l.start-h,n=o),n.duration!==E&&(n.duration=E)}else if(o.sn>l.sn){var c=l.cc===o.cc;c&&l.minEndPTS?o.start=l.start+(l.minEndPTS-l.start):o.start=l.start+l.duration}else o.start=Math.max(l.start-o.duration,0)}function x(l,o,h,E,n,c){var v=E-h;v<=0&&(s.logger.warn("Fragment should have a positive duration",o),E=h+o.duration,c=n+o.duration);var f=h,g=E,y=o.startPTS,M=o.endPTS;if(Object(a.isFiniteNumber)(y)){var D=Math.abs(y-h);Object(a.isFiniteNumber)(o.deltaPTS)?o.deltaPTS=Math.max(D,o.deltaPTS):o.deltaPTS=D,f=Math.max(h,y),h=Math.min(h,y),n=Math.min(n,o.startDTS),g=Math.min(E,M),E=Math.max(E,M),c=Math.max(c,o.endDTS)}o.duration=E-h;var P=h-o.start;o.appendedPTS=E,o.start=o.startPTS=h,o.maxStartPTS=f,o.startDTS=n,o.endPTS=E,o.minEndPTS=g,o.endDTS=c;var B=o.sn;if(!l||B<l.startSN||B>l.endSN)return 0;var N,F=B-l.startSN,H=l.fragments;for(H[F]=o,N=F;N>0;N--)b(H[N],H[N-1]);for(N=F;N<H.length-1;N++)b(H[N],H[N+1]);return l.fragmentHint&&b(H[H.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,P}function I(l,o){for(var h=null,E=l.fragments,n=E.length-1;n>=0;n--){var c=E[n].initSegment;if(c){h=c;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var v=0,f;if(S(l,o,function(N,F){N.relurl&&(v=N.cc-F.cc),Object(a.isFiniteNumber)(N.startPTS)&&Object(a.isFiniteNumber)(N.endPTS)&&(F.start=F.startPTS=N.startPTS,F.startDTS=N.startDTS,F.appendedPTS=N.appendedPTS,F.maxStartPTS=N.maxStartPTS,F.endPTS=N.endPTS,F.endDTS=N.endDTS,F.minEndPTS=N.minEndPTS,F.duration=N.endPTS-N.startPTS,F.duration&&(f=F),o.PTSKnown=o.alignedSliding=!0),F.elementaryStreams=N.elementaryStreams,F.loader=N.loader,F.stats=N.stats,F.urlId=N.urlId,N.initSegment&&(F.initSegment=N.initSegment,h=N.initSegment)}),h){var g=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments;g.forEach(function(N){var F;(!N.initSegment||N.initSegment.relurl===((F=h)===null||F===void 0?void 0:F.relurl))&&(N.initSegment=h)})}if(o.skippedSegments)if(o.deltaUpdateFailed=o.fragments.some(function(N){return!N}),o.deltaUpdateFailed){s.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var y=o.skippedSegments;y--;)o.fragments.shift();o.startSN=o.fragments[0].sn,o.startCC=o.fragments[0].cc}else o.canSkipDateRanges&&(o.dateRanges=_(l.dateRanges,o.dateRanges,o.recentlyRemovedDateranges));var M=o.fragments;if(v){s.logger.warn("discontinuity sliding from playlist, take drift into account");for(var D=0;D<M.length;D++)M[D].cc+=v}o.skippedSegments&&(o.startCC=o.fragments[0].cc),A(l.partList,o.partList,function(N,F){F.elementaryStreams=N.elementaryStreams,F.stats=N.stats}),f?x(o,f,f.startPTS,f.endPTS,f.startDTS,f.endDTS):m(l,o),M.length&&(o.totalduration=o.edge-M[0].start),o.driftStartTime=l.driftStartTime,o.driftStart=l.driftStart;var P=o.advancedDateTime;if(o.advanced&&P){var B=o.edge;o.driftStart||(o.driftStartTime=P,o.driftStart=B),o.driftEndTime=P,o.driftEnd=B}else o.driftEndTime=l.driftEndTime,o.driftEnd=l.driftEnd,o.advancedDateTime=l.advancedDateTime}function _(l,o,h){var E=R({},l);return h&&h.forEach(function(n){delete E[n]}),Object.keys(o).forEach(function(n){var c=new u.DateRange(o[n].attr,E[n]);c.isValid?E[n]=c:s.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(o[n].attr)+'"')}),E}function A(l,o,h){if(l&&o)for(var E=0,n=0,c=l.length;n<=c;n++){var v=l[n],f=o[n+E];v&&f&&v.index===f.index&&v.fragment.sn===f.fragment.sn?h(v,f):E--}}function S(l,o,h){for(var E=o.skippedSegments,n=Math.max(l.startSN,o.startSN)-o.startSN,c=(l.fragmentHint?1:0)+(E?o.endSN:Math.min(l.endSN,o.endSN))-o.startSN,v=o.startSN-l.startSN,f=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments,g=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,y=n;y<=c;y++){var M=g[v+y],D=f[y];E&&!D&&y<E&&(D=o.fragments[y]=M),M&&D&&h(M,D)}}function m(l,o){var h=o.startSN+o.skippedSegments-l.startSN,E=l.fragments;h<0||h>=E.length||i(o,E[h].start)}function i(l,o){if(o){for(var h=l.fragments,E=l.skippedSegments;E<h.length;E++)h[E].start+=o;l.fragmentHint&&(l.fragmentHint.start+=o)}}function d(l,o){var h=1e3*l.levelTargetDuration,E=h/2,n=l.age,c=n>0&&n<h*3,v=o.loading.end-o.loading.start,f,g=l.availabilityDelay;if(l.updated===!1)if(c){var y=333*l.misses;f=Math.max(Math.min(E,v*2),y),l.availabilityDelay=(l.availabilityDelay||0)+f}else f=E;else c?(g=Math.min(g||h/2,n),l.availabilityDelay=g,f=g+h-n):f=h-v;return Math.round(f)}function p(l,o,h){if(!l||!l.details)return null;var E=l.details,n=E.fragments[o-E.startSN];return n||(n=E.fragmentHint,n&&n.sn===o)?n:o<E.startSN&&h&&h.sn===o?h:null}function T(l,o,h){if(!l||!l.details)return null;var E=l.details.partList;if(E)for(var n=E.length;n--;){var c=E[n];if(c.index===h&&c.fragment.sn===o)return c}return null}},"./src/controller/stream-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return T});var a=e("./src/polyfills/number.ts"),s=e("./src/controller/base-stream-controller.ts"),u=e("./src/is-supported.ts"),R=e("./src/events.ts"),C=e("./src/utils/buffer-helper.ts"),O=e("./src/controller/fragment-tracker.ts"),L=e("./src/types/loader.ts"),b=e("./src/loader/fragment.ts"),x=e("./src/demux/transmuxer-interface.ts"),I=e("./src/types/transmuxer.ts"),_=e("./src/controller/gap-controller.ts"),A=e("./src/errors.ts");function S(l,o){for(var h=0;h<o.length;h++){var E=o[h];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(l,E.key,E)}}function m(l,o,h){return o&&S(l.prototype,o),h&&S(l,h),Object.defineProperty(l,"prototype",{writable:!1}),l}function i(l,o){l.prototype=Object.create(o.prototype),l.prototype.constructor=l,d(l,o)}function d(l,o){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,n){return E.__proto__=n,E},d(l,o)}var p=100,T=function(l){i(o,l);function o(E,n){var c;return c=l.call(this,E,n,"[stream-controller]")||this,c.audioCodecSwap=!1,c.gapController=null,c.level=-1,c._forceStartLoad=!1,c.altAudio=!1,c.audioOnly=!1,c.fragPlaying=null,c.onvplaying=null,c.onvseeked=null,c.fragLastKbps=0,c.couldBacktrack=!1,c.backtrackFragment=null,c.audioCodecSwitch=!1,c.videoBuffer=null,c._registerListeners(),c}var h=o.prototype;return h._registerListeners=function(){var n=this.hls;n.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),n.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(R.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),n.on(R.Events.ERROR,this.onError,this),n.on(R.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(R.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),n.on(R.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(R.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(R.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),n.on(R.Events.FRAG_BUFFERED,this.onFragBuffered,this)},h._unregisterListeners=function(){var n=this.hls;n.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(R.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),n.off(R.Events.ERROR,this.onError,this),n.off(R.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(R.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),n.off(R.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(R.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(R.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),n.off(R.Events.FRAG_BUFFERED,this.onFragBuffered,this)},h.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},h.startLoad=function(n){if(this.levels){var c=this.lastCurrentTime,v=this.hls;if(this.stopLoad(),this.setInterval(p),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var f=v.startLevel;f===-1&&(v.config.testBandwidth&&this.levels.length>1?(f=0,this.bitrateTest=!0):f=v.nextAutoLevel),this.level=v.nextLoadLevel=f,this.loadedmetadata=!1}c>0&&n===-1&&(this.log("Override startPosition with lastCurrentTime @"+c.toFixed(3)),n=c),this.state=s.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()}else this._forceStartLoad=!0,this.state=s.State.STOPPED},h.stopLoad=function(){this._forceStartLoad=!1,l.prototype.stopLoad.call(this)},h.doTick=function(){switch(this.state){case s.State.IDLE:this.doTickIdle();break;case s.State.WAITING_LEVEL:{var n,c=this.levels,v=this.level,f=c==null||(n=c[v])===null||n===void 0?void 0:n.details;if(f&&(!f.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(f))break;this.state=s.State.IDLE;break}break}case s.State.FRAG_LOADING_WAITING_RETRY:{var g,y=self.performance.now(),M=this.retryDate;(!M||y>=M||(g=this.media)!==null&&g!==void 0&&g.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=s.State.IDLE)}break;default:break}this.onTickEnd()},h.onTickEnd=function(){l.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},h.doTickIdle=function(){var n,c,v=this.hls,f=this.levelLastLoaded,g=this.levels,y=this.media,M=v.config,D=v.nextLoadLevel;if(!(f===null||!y&&(this.startFragRequested||!M.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!g||!g[D])){var P=g[D];this.level=v.nextLoadLevel=D;var B=P.details;if(!B||this.state===s.State.WAITING_LEVEL||B.live&&this.levelLastLoaded!==D){this.state=s.State.WAITING_LEVEL;return}var N=this.getMainFwdBufferInfo();if(N!==null){var F=N.len,H=this.getMaxBufferLength(P.maxBitrate);if(!(F>=H)){if(this._streamEnded(N,B)){var V={};this.altAudio&&(V.type="video"),this.hls.trigger(R.Events.BUFFER_EOS,V),this.state=s.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>N.end&&(this.backtrackFragment=null);var X=this.backtrackFragment?this.backtrackFragment.start:N.end,$=this.getNextFragment(X,B);if(this.couldBacktrack&&!this.fragPrevious&&$&&$.sn!=="initSegment"&&this.fragmentTracker.getState($)!==O.FragmentState.OK){var j,J=((j=this.backtrackFragment)!=null?j:$).sn,ee=J-B.startSN,te=B.fragments[ee-1];te&&$.cc===te.cc&&($=te,this.fragmentTracker.removeFragment(te))}else this.backtrackFragment&&N.len&&(this.backtrackFragment=null);if($&&this.fragmentTracker.getState($)===O.FragmentState.OK&&this.nextLoadPosition>X){var le=this.audioOnly&&!this.altAudio?b.ElementaryStreamTypes.AUDIO:b.ElementaryStreamTypes.VIDEO;y&&this.afterBufferFlushed(y,le,L.PlaylistLevelType.MAIN),$=this.getNextFragment(this.nextLoadPosition,B)}!$||($.initSegment&&!$.initSegment.data&&!this.bitrateTest&&($=$.initSegment),((n=$.decryptdata)===null||n===void 0?void 0:n.keyFormat)==="identity"&&!((c=$.decryptdata)!==null&&c!==void 0&&c.key)?this.loadKey($,B):this.loadFragment($,B,X))}}}},h.loadFragment=function(n,c,v){var f,g=this.fragmentTracker.getState(n);this.fragCurrent=n,g===O.FragmentState.NOT_LOADED?n.sn==="initSegment"?this._loadInitSegment(n):this.bitrateTest?(this.log("Fragment "+n.sn+" of level "+n.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(n)):(this.startFragRequested=!0,l.prototype.loadFragment.call(this,n,c,v)):g===O.FragmentState.APPENDING?this.reduceMaxBufferLength(n.duration)&&this.fragmentTracker.removeFragment(n):((f=this.media)===null||f===void 0?void 0:f.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},h.getAppendedFrag=function(n){var c=this.fragmentTracker.getAppendedFrag(n,L.PlaylistLevelType.MAIN);return c&&"fragment"in c?c.fragment:c},h.getBufferedFrag=function(n){return this.fragmentTracker.getBufferedFrag(n,L.PlaylistLevelType.MAIN)},h.followingBufferedFrag=function(n){return n?this.getBufferedFrag(n.end+.5):null},h.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},h.nextLevelSwitch=function(){var n=this.levels,c=this.media;if(c!=null&&c.readyState){var v,f=this.getAppendedFrag(c.currentTime);if(f&&f.start>1&&this.flushMainBuffer(0,f.start-1),!c.paused&&n){var g=this.hls.nextLoadLevel,y=n[g],M=this.fragLastKbps;M&&this.fragCurrent?v=this.fragCurrent.duration*y.maxBitrate/(1e3*M)+1:v=0}else v=0;var D=this.getBufferedFrag(c.currentTime+v);if(D){var P=this.followingBufferedFrag(D);if(P){this.abortCurrentFrag();var B=P.maxStartPTS?P.maxStartPTS:P.start,N=P.duration,F=Math.max(D.end,B+Math.min(Math.max(N-this.config.maxFragLookUpTolerance,N*.5),N*.75));this.flushMainBuffer(F,Number.POSITIVE_INFINITY)}}}},h.abortCurrentFrag=function(){var n=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,n!=null&&n.loader&&n.loader.abort(),this.state){case s.State.KEY_LOADING:case s.State.FRAG_LOADING:case s.State.FRAG_LOADING_WAITING_RETRY:case s.State.PARSING:case s.State.PARSED:this.state=s.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},h.flushMainBuffer=function(n,c){l.prototype.flushMainBuffer.call(this,n,c,this.altAudio?"video":null)},h.onMediaAttached=function(n,c){l.prototype.onMediaAttached.call(this,n,c);var v=c.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),v.addEventListener("playing",this.onvplaying),v.addEventListener("seeked",this.onvseeked),this.gapController=new _.default(this.config,v,this.fragmentTracker,this.hls)},h.onMediaDetaching=function(){var n=this.media;n&&this.onvplaying&&this.onvseeked&&(n.removeEventListener("playing",this.onvplaying),n.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),l.prototype.onMediaDetaching.call(this)},h.onMediaPlaying=function(){this.tick()},h.onMediaSeeked=function(){var n=this.media,c=n?n.currentTime:null;Object(a.isFiniteNumber)(c)&&this.log("Media seeked to "+c.toFixed(3)),this.tick()},h.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(R.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},h.onManifestParsed=function(n,c){var v=!1,f=!1,g;c.levels.forEach(function(y){g=y.audioCodec,g&&(g.indexOf("mp4a.40.2")!==-1&&(v=!0),g.indexOf("mp4a.40.5")!==-1&&(f=!0))}),this.audioCodecSwitch=v&&f&&!Object(u.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=c.levels,this.startFragRequested=!1},h.onLevelLoading=function(n,c){var v=this.levels;if(!(!v||this.state!==s.State.IDLE)){var f=v[c.level];(!f.details||f.details.live&&this.levelLastLoaded!==c.level||this.waitForCdnTuneIn(f.details))&&(this.state=s.State.WAITING_LEVEL)}},h.onLevelLoaded=function(n,c){var v,f=this.levels,g=c.level,y=c.details,M=y.totalduration;if(!f){this.warn("Levels were reset while loading level "+g);return}this.log("Level "+g+" loaded ["+y.startSN+","+y.endSN+"], cc ["+y.startCC+", "+y.endCC+"] duration:"+M);var D=this.fragCurrent;D&&(this.state===s.State.FRAG_LOADING||this.state===s.State.FRAG_LOADING_WAITING_RETRY)&&D.level!==c.level&&D.loader&&(this.state=s.State.IDLE,this.backtrackFragment=null,D.loader.abort());var P=f[g],B=0;if(y.live||(v=P.details)!==null&&v!==void 0&&v.live){if(y.fragments[0]||(y.deltaUpdateFailed=!0),y.deltaUpdateFailed)return;B=this.alignPlaylists(y,P.details)}if(P.details=y,this.levelLastLoaded=g,this.hls.trigger(R.Events.LEVEL_UPDATED,{details:y,level:g}),this.state===s.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(y))return;this.state=s.State.IDLE}this.startFragRequested?y.live&&this.synchronizeToLiveEdge(y):this.setStartPosition(y,B),this.tick()},h._handleFragmentLoadProgress=function(n){var c,v=n.frag,f=n.part,g=n.payload,y=this.levels;if(!y){this.warn("Levels were reset while fragment load was in progress. Fragment "+v.sn+" of level "+v.level+" will not be buffered");return}var M=y[v.level],D=M.details;if(!D){this.warn("Dropping fragment "+v.sn+" of level "+v.level+" after level details were reset");return}var P=M.videoCodec,B=D.PTSKnown||!D.live,N=(c=v.initSegment)===null||c===void 0?void 0:c.data,F=this._getAudioCodec(M),H=this.transmuxer=this.transmuxer||new x.default(this.hls,L.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),V=f?f.index:-1,X=V!==-1,$=new I.ChunkMetadata(v.level,v.sn,v.stats.chunkCount,g.byteLength,V,X),j=this.initPTS[v.cc];H.push(g,N,F,P,v,f,D.totalduration,B,$,j)},h.onAudioTrackSwitching=function(n,c){var v=this.altAudio,f=!!c.url,g=c.id;if(!f){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var y=this.fragCurrent;y!=null&&y.loader&&(this.log("Switching to main audio track, cancel main fragment load"),y.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var M=this.hls;v&&M.trigger(R.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),M.trigger(R.Events.AUDIO_TRACK_SWITCHED,{id:g})}},h.onAudioTrackSwitched=function(n,c){var v=c.id,f=!!this.hls.audioTracks[v].url;if(f){var g=this.videoBuffer;g&&this.mediaBuffer!==g&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=g)}this.altAudio=f,this.tick()},h.onBufferCreated=function(n,c){var v=c.tracks,f,g,y=!1;for(var M in v){var D=v[M];if(D.id==="main"){if(g=M,f=D,M==="video"){var P=v[M];P&&(this.videoBuffer=P.buffer)}}else y=!0}y&&f?(this.log("Alternate track found, use "+g+".buffered to schedule main fragment loading"),this.mediaBuffer=f.buffer):this.mediaBuffer=this.media},h.onFragBuffered=function(n,c){var v=c.frag,f=c.part;if(!(v&&v.type!==L.PlaylistLevelType.MAIN)){if(this.fragContextChanged(v)){this.warn("Fragment "+v.sn+(f?" p: "+f.index:"")+" of level "+v.level+" finished buffering, but was aborted. state: "+this.state),this.state===s.State.PARSED&&(this.state=s.State.IDLE);return}var g=f?f.stats:v.stats;this.fragLastKbps=Math.round(8*g.total/(g.buffering.end-g.loading.first)),v.sn!=="initSegment"&&(this.fragPrevious=v),this.fragBufferedComplete(v,f)}},h.onError=function(n,c){switch(c.details){case A.ErrorDetails.FRAG_LOAD_ERROR:case A.ErrorDetails.FRAG_LOAD_TIMEOUT:case A.ErrorDetails.KEY_LOAD_ERROR:case A.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(L.PlaylistLevelType.MAIN,c);break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==s.State.ERROR&&(c.fatal?(this.warn(""+c.details),this.state=s.State.ERROR):!c.levelRetry&&this.state===s.State.WAITING_LEVEL&&(this.state=s.State.IDLE));break;case A.ErrorDetails.BUFFER_FULL_ERROR:if(c.parent==="main"&&(this.state===s.State.PARSING||this.state===s.State.PARSED)){var v=!0,f=this.getFwdBufferInfo(this.media,L.PlaylistLevelType.MAIN);f&&f.len>.5&&(v=!this.reduceMaxBufferLength(f.len)),v&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},h.checkBuffer=function(){var n=this.media,c=this.gapController;if(!(!n||!c||!n.readyState)){if(this.loadedmetadata||!C.BufferHelper.getBuffered(n).length){var v=this.state!==s.State.IDLE?this.fragCurrent:null;c.poll(this.lastCurrentTime,v)}this.lastCurrentTime=n.currentTime}},h.onFragLoadEmergencyAborted=function(){this.state=s.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},h.onBufferFlushed=function(n,c){var v=c.type;if(v!==b.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var f=(v===b.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(f,v,L.PlaylistLevelType.MAIN)}},h.onLevelsUpdated=function(n,c){this.levels=c.levels},h.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},h.seekToStartPos=function(){var n=this.media;if(!!n){var c=n.currentTime,v=this.startPosition;if(v>=0&&c<v){if(n.seeking){this.log("could not seek to "+v+", already seeking at "+c);return}var f=C.BufferHelper.getBuffered(n),g=f.length?f.start(0):0,y=g-v;y>0&&(y<this.config.maxBufferHole||y<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+y+" to match buffer start"),v+=y,this.startPosition=v),this.log("seek to target start position "+v+" from current time "+c),n.currentTime=v}}},h._getAudioCodec=function(n){var c=this.config.defaultAudioCodec||n.audioCodec;return this.audioCodecSwap&&c&&(this.log("Swapping audio codec"),c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5"),c},h._loadBitrateTestFrag=function(n){var c=this;n.bitrateTest=!0,this._doFragLoad(n).then(function(v){var f=c.hls;if(!(!v||f.nextLoadLevel||c.fragContextChanged(n))){c.fragLoadError=0,c.state=s.State.IDLE,c.startFragRequested=!1,c.bitrateTest=!1;var g=n.stats;g.parsing.start=g.parsing.end=g.buffering.start=g.buffering.end=self.performance.now(),f.trigger(R.Events.FRAG_LOADED,v),n.bitrateTest=!1}})},h._handleTransmuxComplete=function(n){var c,v="main",f=this.hls,g=n.remuxResult,y=n.chunkMeta,M=this.getCurrentContext(y);if(!M){this.warn("The loading context changed while buffering fragment "+y.sn+" of level "+y.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(y.level);return}var D=M.frag,P=M.part,B=M.level,N=g.video,F=g.text,H=g.id3,V=g.initSegment,X=B.details,$=this.altAudio?void 0:g.audio;if(!this.fragContextChanged(D)){if(this.state=s.State.PARSING,V){V.tracks&&(this._bufferInitSegment(B,V.tracks,D,y),f.trigger(R.Events.FRAG_PARSING_INIT_SEGMENT,{frag:D,id:v,tracks:V.tracks}));var j=V.initPTS,J=V.timescale;Object(a.isFiniteNumber)(j)&&(this.initPTS[D.cc]=j,f.trigger(R.Events.INIT_PTS_FOUND,{frag:D,id:v,initPTS:j,timescale:J}))}if(N&&g.independent!==!1){if(X){var ee=N.startPTS,te=N.endPTS,le=N.startDTS,ue=N.endDTS;if(P)P.elementaryStreams[N.type]={startPTS:ee,endPTS:te,startDTS:le,endDTS:ue};else if(N.firstKeyFrame&&N.independent&&(this.couldBacktrack=!0),N.dropped&&N.independent){var ie=this.getMainFwdBufferInfo(),he=(ie?ie.end:this.getLoadPosition())+this.config.maxBufferHole,ve=N.firstKeyFramePTS?N.firstKeyFramePTS:ee;if(he<ve-this.config.maxBufferHole){this.backtrack(D);return}D.setElementaryStreamInfo(N.type,D.start,te,D.start,ue,!0)}D.setElementaryStreamInfo(N.type,ee,te,le,ue),this.backtrackFragment&&(this.backtrackFragment=D),this.bufferFragmentData(N,D,P,y)}}else if(g.independent===!1){this.backtrack(D);return}if($){var ae=$.startPTS,Re=$.endPTS,Le=$.startDTS,De=$.endDTS;P&&(P.elementaryStreams[b.ElementaryStreamTypes.AUDIO]={startPTS:ae,endPTS:Re,startDTS:Le,endDTS:De}),D.setElementaryStreamInfo(b.ElementaryStreamTypes.AUDIO,ae,Re,Le,De),this.bufferFragmentData($,D,P,y)}if(X&&H!==null&&H!==void 0&&(c=H.samples)!==null&&c!==void 0&&c.length){var _e={id:v,frag:D,details:X,samples:H.samples};f.trigger(R.Events.FRAG_PARSING_METADATA,_e)}if(X&&F){var we={id:v,frag:D,details:X,samples:F.samples};f.trigger(R.Events.FRAG_PARSING_USERDATA,we)}}},h._bufferInitSegment=function(n,c,v,f){var g=this;if(this.state===s.State.PARSING){this.audioOnly=!!c.audio&&!c.video,this.altAudio&&!this.audioOnly&&delete c.audio;var y=c.audio,M=c.video,D=c.audiovideo;if(y){var P=n.audioCodec,B=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(P&&(P.indexOf("mp4a.40.5")!==-1?P="mp4a.40.2":P="mp4a.40.5"),y.metadata.channelCount!==1&&B.indexOf("firefox")===-1&&(P="mp4a.40.5")),B.indexOf("android")!==-1&&y.container!=="audio/mpeg"&&(P="mp4a.40.2",this.log("Android: force audio codec to "+P)),n.audioCodec&&n.audioCodec!==P&&this.log('Swapping manifest audio codec "'+n.audioCodec+'" for "'+P+'"'),y.levelCodec=P,y.id="main",this.log("Init audio buffer, container:"+y.container+", codecs[selected/level/parsed]=["+(P||"")+"/"+(n.audioCodec||"")+"/"+y.codec+"]")}M&&(M.levelCodec=n.videoCodec,M.id="main",this.log("Init video buffer, container:"+M.container+", codecs[level/parsed]=["+(n.videoCodec||"")+"/"+M.codec+"]")),D&&this.log("Init audiovideo buffer, container:"+D.container+", codecs[level/parsed]=["+(n.attrs.CODECS||"")+"/"+D.codec+"]"),this.hls.trigger(R.Events.BUFFER_CODECS,c),Object.keys(c).forEach(function(N){var F=c[N],H=F.initSegment;H!=null&&H.byteLength&&g.hls.trigger(R.Events.BUFFER_APPENDING,{type:N,data:H,frag:v,part:null,chunkMeta:f,parent:v.type})}),this.tick()}},h.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,L.PlaylistLevelType.MAIN)},h.backtrack=function(n){this.couldBacktrack=!0,this.backtrackFragment=n,this.resetTransmuxer(),this.flushBufferGap(n),this.fragmentTracker.removeFragment(n),this.fragPrevious=null,this.nextLoadPosition=n.start,this.state=s.State.IDLE},h.checkFragmentChanged=function(){var n=this.media,c=null;if(n&&n.readyState>1&&n.seeking===!1){var v=n.currentTime;if(C.BufferHelper.isBuffered(n,v)?c=this.getAppendedFrag(v):C.BufferHelper.isBuffered(n,v+.1)&&(c=this.getAppendedFrag(v+.1)),c){this.backtrackFragment=null;var f=this.fragPlaying,g=c.level;(!f||c.sn!==f.sn||f.level!==g||c.urlId!==f.urlId)&&(this.hls.trigger(R.Events.FRAG_CHANGED,{frag:c}),(!f||f.level!==g)&&this.hls.trigger(R.Events.LEVEL_SWITCHED,{level:g}),this.fragPlaying=c)}}},m(o,[{key:"nextLevel",get:function(){var n=this.nextBufferedFrag;return n?n.level:-1}},{key:"currentFrag",get:function(){var n=this.media;return n?this.fragPlaying||this.getAppendedFrag(n.currentTime):null}},{key:"currentProgramDateTime",get:function(){var n=this.media;if(n){var c=n.currentTime,v=this.currentFrag;if(v&&Object(a.isFiniteNumber)(c)&&Object(a.isFiniteNumber)(v.programDateTime)){var f=v.programDateTime+(c-v.start)*1e3;return new Date(f)}}return null}},{key:"currentLevel",get:function(){var n=this.currentFrag;return n?n.level:-1}},{key:"nextBufferedFrag",get:function(){var n=this.currentFrag;return n?this.followingBufferedFrag(n):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),o}(s.default)},"./src/controller/subtitle-stream-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"SubtitleStreamController",function(){return i});var a=e("./src/events.ts"),s=e("./src/utils/buffer-helper.ts"),u=e("./src/controller/fragment-finders.ts"),R=e("./src/utils/discontinuities.ts"),C=e("./src/controller/level-helper.ts"),O=e("./src/controller/fragment-tracker.ts"),L=e("./src/controller/base-stream-controller.ts"),b=e("./src/types/loader.ts"),x=e("./src/types/level.ts");function I(p,T){for(var l=0;l<T.length;l++){var o=T[l];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(p,o.key,o)}}function _(p,T,l){return T&&I(p.prototype,T),l&&I(p,l),Object.defineProperty(p,"prototype",{writable:!1}),p}function A(p,T){p.prototype=Object.create(T.prototype),p.prototype.constructor=p,S(p,T)}function S(p,T){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,h){return o.__proto__=h,o},S(p,T)}var m=500,i=function(p){A(T,p);function T(o,h){var E;return E=p.call(this,o,h,"[subtitle-stream-controller]")||this,E.levels=[],E.currentTrackId=-1,E.tracksBuffered=[],E.mainDetails=null,E._registerListeners(),E}var l=T.prototype;return l.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},l._registerListeners=function(){var h=this.hls;h.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(a.Events.ERROR,this.onError,this),h.on(a.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.on(a.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),h.on(a.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),h.on(a.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),h.on(a.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},l._unregisterListeners=function(){var h=this.hls;h.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(a.Events.ERROR,this.onError,this),h.off(a.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.off(a.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),h.off(a.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),h.off(a.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),h.off(a.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},l.startLoad=function(){this.stopLoad(),this.state=L.State.IDLE,this.setInterval(m),this.tick()},l.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},l.onLevelLoaded=function(h,E){this.mainDetails=E.details},l.onSubtitleFragProcessed=function(h,E){var n=E.frag,c=E.success;if(this.fragPrevious=n,this.state=L.State.IDLE,!!c){var v=this.tracksBuffered[this.currentTrackId];if(!!v){for(var f,g=n.start,y=0;y<v.length;y++)if(g>=v[y].start&&g<=v[y].end){f=v[y];break}var M=n.start+n.duration;f?f.end=M:(f={start:g,end:M},v.push(f)),this.fragmentTracker.fragBuffered(n)}}},l.onBufferFlushing=function(h,E){var n=E.startOffset,c=E.endOffset;if(n===0&&c!==Number.POSITIVE_INFINITY){var v=this.currentTrackId,f=this.levels;if(!f.length||!f[v]||!f[v].details)return;var g=f[v].details,y=g.targetduration,M=c-y;if(M<=0)return;E.endOffsetSubtitles=Math.max(0,M),this.tracksBuffered.forEach(function(D){for(var P=0;P<D.length;){if(D[P].end<=M){D.shift();continue}else if(D[P].start<M)D[P].start=M;else break;P++}}),this.fragmentTracker.removeFragmentsInRange(n,M,b.PlaylistLevelType.SUBTITLE)}},l.onError=function(h,E){var n,c=E.frag;!c||c.type!==b.PlaylistLevelType.SUBTITLE||((n=this.fragCurrent)!==null&&n!==void 0&&n.loader&&this.fragCurrent.loader.abort(),this.state=L.State.IDLE)},l.onSubtitleTracksUpdated=function(h,E){var n=this,c=E.subtitleTracks;this.tracksBuffered=[],this.levels=c.map(function(v){return new x.Level(v)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(v){n.tracksBuffered[v.id]=[]}),this.mediaBuffer=null},l.onSubtitleTrackSwitch=function(h,E){if(this.currentTrackId=E.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var n=this.levels[this.currentTrackId];n!=null&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.setInterval(m)},l.onSubtitleTrackLoaded=function(h,E){var n,c=E.details,v=E.id,f=this.currentTrackId,g=this.levels;if(!!g.length){var y=g[f];if(!(v>=g.length||v!==f||!y)){if(this.mediaBuffer=this.mediaBufferTimeRanges,c.live||(n=y.details)!==null&&n!==void 0&&n.live){var M=this.mainDetails;if(c.deltaUpdateFailed||!M)return;var D=M.fragments[0];if(!y.details)c.hasProgramDateTime&&M.hasProgramDateTime?Object(R.alignMediaPlaylistByPDT)(c,M):D&&Object(C.addSliding)(c,D.start);else{var P=this.alignPlaylists(c,y.details);P===0&&D&&Object(C.addSliding)(c,D.start)}}if(y.details=c,this.levelLastLoaded=v,this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===L.State.IDLE){var B=Object(u.findFragmentByPTS)(null,c.fragments,this.media.currentTime,0);B||(this.warn("Subtitle playlist not aligned with playback"),y.details=void 0)}}}},l._handleFragmentLoadComplete=function(h){var E=h.frag,n=h.payload,c=E.decryptdata,v=this.hls;if(!this.fragContextChanged(E)&&n&&n.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var f=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(n),c.key.buffer,c.iv.buffer).then(function(g){var y=performance.now();v.trigger(a.Events.FRAG_DECRYPTED,{frag:E,payload:g,stats:{tstart:f,tdecrypt:y}})})}},l.doTick=function(){if(!this.media){this.state=L.State.IDLE;return}if(this.state===L.State.IDLE){var h=this.currentTrackId,E=this.levels;if(!E.length||!E[h]||!E[h].details)return;var n=E[h].details,c=n.targetduration,v=this.config,f=this.media,g=s.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],f.currentTime-c,v.maxBufferHole),y=g.end,M=g.len,D=this.getMaxBufferLength()+c;if(M>D)return;console.assert(n,"Subtitle track details are defined on idle subtitle stream controller tick");var P=n.fragments,B=P.length,N=n.edge,F,H=this.fragPrevious;if(y<N){var V=v.maxFragLookUpTolerance;F=Object(u.findFragmentByPTS)(H,P,Math.max(P[0].start,y),V),!F&&H&&H.start<P[0].start&&(F=P[0])}else F=P[B-1];if(F=this.mapToInitFragWhenRequired(F),!F||this.fragmentTracker.getState(F)!==O.FragmentState.NOT_LOADED)return;F.encrypted?this.loadKey(F,n):this.loadFragment(F,n,y)}},l.loadFragment=function(h,E,n){this.fragCurrent=h,h.sn==="initSegment"?this._loadInitSegment(h):p.prototype.loadFragment.call(this,h,E,n)},_(T,[{key:"mediaBufferTimeRanges",get:function(){return new d(this.tracksBuffered[this.currentTrackId]||[])}}]),T}(L.default),d=function(T){this.buffered=void 0;var l=function(h,E,n){if(E=E>>>0,E>n-1)throw new DOMException("Failed to execute '"+h+"' on 'TimeRanges': The index provided ("+E+") is greater than the maximum bound ("+n+")");return T[E][h]};this.buffered={get length(){return T.length},end:function(h){return l("end",h,T.length)},start:function(h){return l("start",h,T.length)}}}},"./src/controller/subtitle-track-controller.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/events.ts"),s=e("./src/utils/texttrack-utils.ts"),u=e("./src/controller/base-playlist-controller.ts"),R=e("./src/types/loader.ts");function C(_,A){for(var S=0;S<A.length;S++){var m=A[S];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(_,m.key,m)}}function O(_,A,S){return A&&C(_.prototype,A),S&&C(_,S),Object.defineProperty(_,"prototype",{writable:!1}),_}function L(_,A){_.prototype=Object.create(A.prototype),_.prototype.constructor=_,b(_,A)}function b(_,A){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,i){return m.__proto__=i,m},b(_,A)}var x=function(_){L(A,_);function A(m){var i;return i=_.call(this,m,"[subtitle-track-controller]")||this,i.media=null,i.tracks=[],i.groupId=null,i.tracksInGroup=[],i.trackId=-1,i.selectDefaultTrack=!0,i.queuedDefaultTrack=-1,i.trackChangeListener=function(){return i.onTextTracksChanged()},i.asyncPollTrackChange=function(){return i.pollTrackChange(0)},i.useTextTrackPolling=!1,i.subtitlePollingInterval=-1,i._subtitleDisplay=!0,i.registerListeners(),i}var S=A.prototype;return S.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,_.prototype.destroy.call(this)},S.registerListeners=function(){var i=this.hls;i.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.on(a.Events.LEVEL_LOADING,this.onLevelLoading,this),i.on(a.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),i.on(a.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),i.on(a.Events.ERROR,this.onError,this)},S.unregisterListeners=function(){var i=this.hls;i.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),i.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.off(a.Events.LEVEL_LOADING,this.onLevelLoading,this),i.off(a.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),i.off(a.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),i.off(a.Events.ERROR,this.onError,this)},S.onMediaAttached=function(i,d){this.media=d.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(i){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,i)},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 i=I(this.media.textTracks);i.forEach(function(d){Object(s.clearCurrentCues)(d)}),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(i,d){this.tracks=d.subtitleTracks},S.onSubtitleTrackLoaded=function(i,d){var p=d.id,T=d.details,l=this.trackId,o=this.tracksInGroup[l];if(!o){this.warn("Invalid subtitle track id "+p);return}var h=o.details;o.details=d.details,this.log("subtitle track "+p+" loaded ["+T.startSN+"-"+T.endSN+"]"),p===this.trackId&&(this.retryCount=0,this.playlistLoaded(p,d,h))},S.onLevelLoading=function(i,d){this.switchLevel(d.level)},S.onLevelSwitching=function(i,d){this.switchLevel(d.level)},S.switchLevel=function(i){var d=this.hls.levels[i];if(!!(d!=null&&d.textGroupIds)){var p=d.textGroupIds[d.urlId];if(this.groupId!==p){var T=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,l=this.tracks.filter(function(E){return!p||E.groupId===p});this.tracksInGroup=l;var o=this.findTrackId(T==null?void 0:T.name)||this.findTrackId();this.groupId=p;var h={subtitleTracks:l};this.log("Updating subtitle tracks, "+l.length+' track(s) found in "'+p+'" group-id'),this.hls.trigger(a.Events.SUBTITLE_TRACKS_UPDATED,h),o!==-1&&this.setSubtitleTrack(o,T)}}},S.findTrackId=function(i){for(var d=this.tracksInGroup,p=0;p<d.length;p++){var T=d[p];if((!this.selectDefaultTrack||T.default)&&(!i||i===T.name))return T.id}return-1},S.onError=function(i,d){_.prototype.onError.call(this,i,d),!(d.fatal||!d.context)&&d.context.type===R.PlaylistContextType.SUBTITLE_TRACK&&d.context.id===this.trackId&&d.context.groupId===this.groupId&&this.retryLoadingOrFail(d)},S.loadPlaylist=function(i){var d=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(d)){var p=d.id,T=d.groupId,l=d.url;if(i)try{l=i.addDirectives(l)}catch(o){this.warn("Could not construct new URL with HLS Delivery Directives: "+o)}this.log("Loading subtitle playlist for id "+p),this.hls.trigger(a.Events.SUBTITLE_TRACK_LOADING,{url:l,id:p,groupId:T,deliveryDirectives:i||null})}},S.toggleTrackModes=function(i){var d=this,p=this.media,T=this.trackId;if(!!p){var l=I(p.textTracks),o=l.filter(function(n){return n.groupId===d.groupId});if(i===-1)[].slice.call(l).forEach(function(n){n.mode="disabled"});else{var h=o[T];h&&(h.mode="disabled")}var E=o[i];E&&(E.mode=this.subtitleDisplay?"showing":"hidden")}},S.setSubtitleTrack=function(i,d){var p,T=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=i;return}if(this.trackId!==i&&this.toggleTrackModes(i),!(this.trackId===i&&(i===-1||(p=T[i])!==null&&p!==void 0&&p.details)||i<-1||i>=T.length)){this.clearTimer();var l=T[i];if(this.log("Switching to subtitle track "+i),this.trackId=i,l){var o=l.id,h=l.groupId,E=h===void 0?"":h,n=l.name,c=l.type,v=l.url;this.hls.trigger(a.Events.SUBTITLE_TRACK_SWITCH,{id:o,groupId:E,name:n,type:c,url:v});var f=this.switchParams(l.url,d==null?void 0:d.details);this.loadPlaylist(f)}else this.hls.trigger(a.Events.SUBTITLE_TRACK_SWITCH,{id:i})}},S.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var i=-1,d=I(this.media.textTracks),p=0;p<d.length;p++)if(d[p].mode==="hidden")i=p;else if(d[p].mode==="showing"){i=p;break}this.subtitleTrack!==i&&(this.subtitleTrack=i)}},O(A,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(i){this._subtitleDisplay=i,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(i){this.selectDefaultTrack=!1;var d=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(i,d)}}]),A}(u.default);function I(_){for(var A=[],S=0;S<_.length;S++){var m=_[S];m.kind==="subtitles"&&m.label&&A.push(_[S])}return A}t.default=x},"./src/controller/timeline-controller.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"TimelineController",function(){return _});var a=e("./src/polyfills/number.ts"),s=e("./src/events.ts"),u=e("./src/utils/cea-608-parser.ts"),R=e("./src/utils/output-filter.ts"),C=e("./src/utils/webvtt-parser.ts"),O=e("./src/utils/texttrack-utils.ts"),L=e("./src/utils/imsc1-ttml-parser.ts"),b=e("./src/utils/mp4-tools.ts"),x=e("./src/types/loader.ts"),I=e("./src/utils/logger.ts"),_=function(){function i(p){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=m(),this.captionsProperties=void 0,this.hls=p,this.config=p.config,this.Cues=p.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 T=new R.default(this,"textTrack1"),l=new R.default(this,"textTrack2"),o=new R.default(this,"textTrack3"),h=new R.default(this,"textTrack4");this.cea608Parser1=new u.default(1,T,l),this.cea608Parser2=new u.default(3,o,h)}p.on(s.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),p.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.on(s.Events.MANIFEST_LOADED,this.onManifestLoaded,this),p.on(s.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),p.on(s.Events.FRAG_LOADING,this.onFragLoading,this),p.on(s.Events.FRAG_LOADED,this.onFragLoaded,this),p.on(s.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),p.on(s.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),p.on(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),p.on(s.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),p.on(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var d=i.prototype;return d.destroy=function(){var T=this.hls;T.off(s.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),T.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),T.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),T.off(s.Events.MANIFEST_LOADED,this.onManifestLoaded,this),T.off(s.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),T.off(s.Events.FRAG_LOADING,this.onFragLoading,this),T.off(s.Events.FRAG_LOADED,this.onFragLoaded,this),T.off(s.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),T.off(s.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),T.off(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),T.off(s.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),T.off(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},d.addCues=function(T,l,o,h,E){for(var n=!1,c=E.length;c--;){var v=E[c],f=S(v[0],v[1],l,o);if(f>=0&&(v[0]=Math.min(v[0],l),v[1]=Math.max(v[1],o),n=!0,f/(o-l)>.5))return}if(n||E.push([l,o]),this.config.renderTextTracksNatively){var g=this.captionsTracks[T];this.Cues.newCue(g,l,o,h)}else{var y=this.Cues.newCue(null,l,o,h);this.hls.trigger(s.Events.CUES_PARSED,{type:"captions",cues:y,track:T})}},d.onInitPtsFound=function(T,l){var o=this,h=l.frag,E=l.id,n=l.initPTS,c=l.timescale,v=this.unparsedVttFrags;E==="main"&&(this.initPTS[h.cc]=n,this.timescale[h.cc]=c),v.length&&(this.unparsedVttFrags=[],v.forEach(function(f){o.onFragLoaded(s.Events.FRAG_LOADED,f)}))},d.getExistingTrack=function(T){var l=this.media;if(l)for(var o=0;o<l.textTracks.length;o++){var h=l.textTracks[o];if(h[T])return h}return null},d.createCaptionsTrack=function(T){this.config.renderTextTracksNatively?this.createNativeTrack(T):this.createNonNativeTrack(T)},d.createNativeTrack=function(T){if(!this.captionsTracks[T]){var l=this.captionsProperties,o=this.captionsTracks,h=this.media,E=l[T],n=E.label,c=E.languageCode,v=this.getExistingTrack(T);if(v)o[T]=v,Object(O.clearCurrentCues)(o[T]),Object(O.sendAddTrackEvent)(o[T],h);else{var f=this.createTextTrack("captions",n,c);f&&(f[T]=!0,o[T]=f)}}},d.createNonNativeTrack=function(T){if(!this.nonNativeCaptionsTracks[T]){var l=this.captionsProperties[T];if(!!l){var o=l.label,h={_id:T,label:o,kind:"captions",default:l.media?!!l.media.default:!1,closedCaptions:l.media};this.nonNativeCaptionsTracks[T]=h,this.hls.trigger(s.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[h]})}}},d.createTextTrack=function(T,l,o){var h=this.media;if(!!h)return h.addTextTrack(T,l,o)},d.onMediaAttaching=function(T,l){this.media=l.media,this._cleanTracks()},d.onMediaDetaching=function(){var T=this.captionsTracks;Object.keys(T).forEach(function(l){Object(O.clearCurrentCues)(T[l]),delete T[l]}),this.nonNativeCaptionsTracks={}},d.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=m(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},d._cleanTracks=function(){var T=this.media;if(!!T){var l=T.textTracks;if(l)for(var o=0;o<l.length;o++)Object(O.clearCurrentCues)(l[o])}},d.onSubtitleTracksUpdated=function(T,l){var o=this;this.textTracks=[];var h=l.subtitleTracks||[],E=h.some(function(f){return f.textCodec===L.IMSC1_CODEC});if(this.config.enableWebVTT||E&&this.config.enableIMSC1){var n=this.tracks&&h&&this.tracks.length===h.length;if(this.tracks=h||[],this.config.renderTextTracksNatively){var c=this.media?this.media.textTracks:[];this.tracks.forEach(function(f,g){var y;if(g<c.length){for(var M=null,D=0;D<c.length;D++)if(A(c[D],f)){M=c[D];break}M&&(y=M)}if(y)Object(O.clearCurrentCues)(y);else{var P=o._captionsOrSubtitlesFromCharacteristics(f);y=o.createTextTrack(P,f.name,f.lang),y&&(y.mode="disabled")}y&&(y.groupId=f.groupId,o.textTracks.push(y))})}else if(!n&&this.tracks&&this.tracks.length){var v=this.tracks.map(function(f){return{label:f.name,kind:f.type.toLowerCase(),default:f.default,subtitleTrack:f}});this.hls.trigger(s.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:v})}}},d._captionsOrSubtitlesFromCharacteristics=function(T){var l;if((l=T.attrs)!==null&&l!==void 0&&l.CHARACTERISTICS){var o=/transcribes-spoken-dialog/gi.test(T.attrs.CHARACTERISTICS),h=/describes-music-and-sound/gi.test(T.attrs.CHARACTERISTICS);if(o&&h)return"captions"}return"subtitles"},d.onManifestLoaded=function(T,l){var o=this;this.config.enableCEA708Captions&&l.captions&&l.captions.forEach(function(h){var E=/(?:CC|SERVICE)([1-4])/.exec(h.instreamId);if(!!E){var n="textTrack"+E[1],c=o.captionsProperties[n];!c||(c.label=h.name,h.lang&&(c.languageCode=h.lang),c.media=h)}})},d.onFragLoading=function(T,l){var o=this.cea608Parser1,h=this.cea608Parser2,E=this.lastSn,n=this.lastPartIndex;if(!(!this.enabled||!(o&&h))&&l.frag.type===x.PlaylistLevelType.MAIN){var c,v,f=l.frag.sn,g=(c=l==null||(v=l.part)===null||v===void 0?void 0:v.index)!=null?c:-1;f===E+1||f===E&&g===n+1||(o.reset(),h.reset()),this.lastSn=f,this.lastPartIndex=g}},d.onFragLoaded=function(T,l){var o=l.frag,h=l.payload,E=this.initPTS,n=this.unparsedVttFrags;if(o.type===x.PlaylistLevelType.SUBTITLE)if(h.byteLength){if(!Object(a.isFiniteNumber)(E[o.cc])){n.push(l),E.length&&this.hls.trigger(s.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:new Error("Missing initial subtitle PTS")});return}var c=o.decryptdata,v="stats"in l;if(c==null||c.key==null||c.method!=="AES-128"||v){var f=this.tracks[o.level],g=this.vttCCs;g[o.cc]||(g[o.cc]={start:o.start,prevCC:this.prevCC,new:!0},this.prevCC=o.cc),f&&f.textCodec===L.IMSC1_CODEC?this._parseIMSC1(o,h):this._parseVTTs(o,h,g)}}else this.hls.trigger(s.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:new Error("Empty subtitle payload")})},d._parseIMSC1=function(T,l){var o=this,h=this.hls;Object(L.parseIMSC1)(l,this.initPTS[T.cc],this.timescale[T.cc],function(E){o._appendCues(E,T.level),h.trigger(s.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:T})},function(E){I.logger.log("Failed to parse IMSC1: "+E),h.trigger(s.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:T,error:E})})},d._parseVTTs=function(T,l,o){var h,E=this,n=this.hls,c=(h=T.initSegment)!==null&&h!==void 0&&h.data?Object(b.appendUint8Array)(T.initSegment.data,new Uint8Array(l)):l;Object(C.parseWebVTT)(c,this.initPTS[T.cc],this.timescale[T.cc],o,T.cc,T.start,function(v){E._appendCues(v,T.level),n.trigger(s.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:T})},function(v){E._fallbackToIMSC1(T,l),I.logger.log("Failed to parse VTT cue: "+v),n.trigger(s.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:T,error:v})})},d._fallbackToIMSC1=function(T,l){var o=this,h=this.tracks[T.level];h.textCodec||Object(L.parseIMSC1)(l,this.initPTS[T.cc],this.timescale[T.cc],function(){h.textCodec=L.IMSC1_CODEC,o._parseIMSC1(T,l)},function(){h.textCodec="wvtt"})},d._appendCues=function(T,l){var o=this.hls;if(this.config.renderTextTracksNatively){var h=this.textTracks[l];if(!h||h.mode==="disabled")return;T.forEach(function(c){return Object(O.addCueToTrack)(h,c)})}else{var E=this.tracks[l];if(!E)return;var n=E.default?"default":"subtitles"+l;o.trigger(s.Events.CUES_PARSED,{type:"subtitles",cues:T,track:n})}},d.onFragDecrypted=function(T,l){var o=l.frag;if(o.type===x.PlaylistLevelType.SUBTITLE){if(!Object(a.isFiniteNumber)(this.initPTS[o.cc])){this.unparsedVttFrags.push(l);return}this.onFragLoaded(s.Events.FRAG_LOADED,l)}},d.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},d.onFragParsingUserdata=function(T,l){var o=this.cea608Parser1,h=this.cea608Parser2;if(!(!this.enabled||!(o&&h)))for(var E=0;E<l.samples.length;E++){var n=l.samples[E].bytes;if(n){var c=this.extractCea608Data(n);o.addData(l.samples[E].pts,c[0]),h.addData(l.samples[E].pts,c[1])}}},d.onBufferFlushing=function(T,l){var o=l.startOffset,h=l.endOffset,E=l.endOffsetSubtitles,n=l.type,c=this.media;if(!(!c||c.currentTime<h)){if(!n||n==="video"){var v=this.captionsTracks;Object.keys(v).forEach(function(g){return Object(O.removeCuesInRange)(v[g],o,h)})}if(this.config.renderTextTracksNatively&&o===0&&E!==void 0){var f=this.textTracks;Object.keys(f).forEach(function(g){return Object(O.removeCuesInRange)(f[g],o,E)})}}},d.extractCea608Data=function(T){for(var l=[[],[]],o=T[0]&31,h=2,E=0;E<o;E++){var n=T[h++],c=127&T[h++],v=127&T[h++];if(!(c===0&&v===0)){var f=(4&n)!==0;if(f){var g=3&n;(g===0||g===1)&&(l[g].push(c),l[g].push(v))}}}return l},i}();function A(i,d){return i&&i.label===d.name&&!(i.textTrack1||i.textTrack2)}function S(i,d,p,T){return Math.min(d,T)-Math.max(i,p)}function m(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return a});var a=function(){function s(R,C){this.subtle=void 0,this.aesIV=void 0,this.subtle=R,this.aesIV=C}var u=s.prototype;return u.decrypt=function(C,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,C)},s}()},"./src/crypt/aes-decryptor.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"removePadding",function(){return s}),e.d(t,"default",function(){return u});var a=e("./src/utils/typed-array.ts");function s(R){var C=R.byteLength,O=C&&new DataView(R.buffer).getUint8(C-1);return O?Object(a.sliceUint8)(R,0,C-O):R}var u=function(){function R(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var C=R.prototype;return C.uint8ArrayToUint32Array_=function(L){for(var b=new DataView(L),x=new Uint32Array(4),I=0;I<4;I++)x[I]=b.getUint32(I*4);return x},C.initTable=function(){var L=this.sBox,b=this.invSBox,x=this.subMix,I=x[0],_=x[1],A=x[2],S=x[3],m=this.invSubMix,i=m[0],d=m[1],p=m[2],T=m[3],l=new Uint32Array(256),o=0,h=0,E=0;for(E=0;E<256;E++)E<128?l[E]=E<<1:l[E]=E<<1^283;for(E=0;E<256;E++){var n=h^h<<1^h<<2^h<<3^h<<4;n=n>>>8^n&255^99,L[o]=n,b[n]=o;var c=l[o],v=l[c],f=l[v],g=l[n]*257^n*16843008;I[o]=g<<24|g>>>8,_[o]=g<<16|g>>>16,A[o]=g<<8|g>>>24,S[o]=g,g=f*16843009^v*65537^c*257^o*16843008,i[n]=g<<24|g>>>8,d[n]=g<<16|g>>>16,p[n]=g<<8|g>>>24,T[n]=g,o?(o=c^l[l[l[f^c]]],h^=l[l[h]]):o=h=1}},C.expandKey=function(L){for(var b=this.uint8ArrayToUint32Array_(L),x=!0,I=0;I<b.length&&x;)x=b[I]===this.key[I],I++;if(!x){this.key=b;var _=this.keySize=b.length;if(_!==4&&_!==6&&_!==8)throw new Error("Invalid aes key size="+_);var A=this.ksRows=(_+6+1)*4,S,m,i=this.keySchedule=new Uint32Array(A),d=this.invKeySchedule=new Uint32Array(A),p=this.sBox,T=this.rcon,l=this.invSubMix,o=l[0],h=l[1],E=l[2],n=l[3],c,v;for(S=0;S<A;S++){if(S<_){c=i[S]=b[S];continue}v=c,S%_===0?(v=v<<8|v>>>24,v=p[v>>>24]<<24|p[v>>>16&255]<<16|p[v>>>8&255]<<8|p[v&255],v^=T[S/_|0]<<24):_>6&&S%_===4&&(v=p[v>>>24]<<24|p[v>>>16&255]<<16|p[v>>>8&255]<<8|p[v&255]),i[S]=c=(i[S-_]^v)>>>0}for(m=0;m<A;m++)S=A-m,m&3?v=i[S]:v=i[S-4],m<4||S<=4?d[m]=v:d[m]=o[p[v>>>24]]^h[p[v>>>16&255]]^E[p[v>>>8&255]]^n[p[v&255]],d[m]=d[m]>>>0}},C.networkToHostOrderSwap=function(L){return L<<24|(L&65280)<<8|(L&16711680)>>8|L>>>24},C.decrypt=function(L,b,x){for(var I=this.keySize+6,_=this.invKeySchedule,A=this.invSBox,S=this.invSubMix,m=S[0],i=S[1],d=S[2],p=S[3],T=this.uint8ArrayToUint32Array_(x),l=T[0],o=T[1],h=T[2],E=T[3],n=new Int32Array(L),c=new Int32Array(n.length),v,f,g,y,M,D,P,B,N,F,H,V,X,$,j=this.networkToHostOrderSwap;b<n.length;){for(N=j(n[b]),F=j(n[b+1]),H=j(n[b+2]),V=j(n[b+3]),M=N^_[0],D=V^_[1],P=H^_[2],B=F^_[3],X=4,$=1;$<I;$++)v=m[M>>>24]^i[D>>16&255]^d[P>>8&255]^p[B&255]^_[X],f=m[D>>>24]^i[P>>16&255]^d[B>>8&255]^p[M&255]^_[X+1],g=m[P>>>24]^i[B>>16&255]^d[M>>8&255]^p[D&255]^_[X+2],y=m[B>>>24]^i[M>>16&255]^d[D>>8&255]^p[P&255]^_[X+3],M=v,D=f,P=g,B=y,X=X+4;v=A[M>>>24]<<24^A[D>>16&255]<<16^A[P>>8&255]<<8^A[B&255]^_[X],f=A[D>>>24]<<24^A[P>>16&255]<<16^A[B>>8&255]<<8^A[M&255]^_[X+1],g=A[P>>>24]<<24^A[B>>16&255]<<16^A[M>>8&255]<<8^A[D&255]^_[X+2],y=A[B>>>24]<<24^A[M>>16&255]<<16^A[D>>8&255]<<8^A[P&255]^_[X+3],c[b]=j(v^l),c[b+1]=j(y^o),c[b+2]=j(g^h),c[b+3]=j(f^E),l=N,o=F,h=H,E=V,b=b+4}return c.buffer},R}()},"./src/crypt/decrypter.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return b});var a=e("./src/crypt/aes-crypto.ts"),s=e("./src/crypt/fast-aes-key.ts"),u=e("./src/crypt/aes-decryptor.ts"),R=e("./src/utils/logger.ts"),C=e("./src/utils/mp4-tools.ts"),O=e("./src/utils/typed-array.ts"),L=16,b=function(){function x(_,A,S){var m=S===void 0?{}:S,i=m.removePKCS7Padding,d=i===void 0?!0:i;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=_,this.config=A,this.removePKCS7Padding=d,d)try{var p=self.crypto;p&&(this.subtle=p.subtle||p.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var I=x.prototype;return I.destroy=function(){this.observer=null},I.isSync=function(){return this.config.enableSoftwareAES},I.flush=function(){var A=this.currentResult;if(!A){this.reset();return}var S=new Uint8Array(A);return this.reset(),this.removePKCS7Padding?Object(u.removePadding)(S):S},I.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},I.decrypt=function(A,S,m,i){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(A),S,m);var d=this.flush();d&&i(d.buffer)}else this.webCryptoDecrypt(new Uint8Array(A),S,m).then(i)},I.softwareDecrypt=function(A,S,m){var i=this.currentIV,d=this.currentResult,p=this.remainderData;this.logOnce("JS AES decrypt"),p&&(A=Object(C.appendUint8Array)(p,A),this.remainderData=null);var T=this.getValidChunk(A);if(!T.length)return null;i&&(m=i);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new u.default),l.expandKey(S);var o=d;return this.currentResult=l.decrypt(T.buffer,0,m),this.currentIV=Object(O.sliceUint8)(T,-16).buffer,o||null},I.webCryptoDecrypt=function(A,S,m){var i=this,d=this.subtle;return(this.key!==S||!this.fastAesKey)&&(this.key=S,this.fastAesKey=new s.default(d,S)),this.fastAesKey.expandKey().then(function(p){if(!d)return Promise.reject(new Error("web crypto not initialized"));var T=new a.default(d,m);return T.decrypt(A.buffer,p)}).catch(function(p){return i.onWebCryptoError(p,A,S,m)})},I.onWebCryptoError=function(A,S,m,i){return R.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",A),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(S,m,i)},I.getValidChunk=function(A){var S=A,m=A.length-A.length%L;return m!==A.length&&(S=Object(O.sliceUint8)(A,0,m),this.remainderData=Object(O.sliceUint8)(A,m)),S},I.logOnce=function(A){!this.logEnabled||(R.logger.log("[decrypter.ts]: "+A),this.logEnabled=!1)},x}()},"./src/crypt/fast-aes-key.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return a});var a=function(){function s(R,C){this.subtle=void 0,this.key=void 0,this.subtle=R,this.key=C}var u=s.prototype;return u.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},s}()},"./src/demux/aacdemuxer.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/demux/base-audio-demuxer.ts"),s=e("./src/demux/adts.ts"),u=e("./src/utils/logger.ts"),R=e("./src/demux/id3.ts");function C(b,x){b.prototype=Object.create(x.prototype),b.prototype.constructor=b,O(b,x)}function O(b,x){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(_,A){return _.__proto__=A,_},O(b,x)}var L=function(b){C(x,b);function x(_,A){var S;return S=b.call(this)||this,S.observer=void 0,S.config=void 0,S.observer=_,S.config=A,S}var I=x.prototype;return I.resetInitSegment=function(A,S,m,i){b.prototype.resetInitSegment.call(this,A,S,m,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:S,duration:i,inputTimeScale:9e4,dropped:0}},x.probe=function(A){if(!A)return!1;for(var S=R.getID3Data(A,0)||[],m=S.length,i=A.length;m<i;m++)if(s.probe(A,m))return u.logger.log("ADTS sync word found !"),!0;return!1},I.canParse=function(A,S){return s.canParse(A,S)},I.appendFrame=function(A,S,m){s.initTrackConfig(A,this.observer,S,m,A.manifestCodec);var i=s.appendFrame(A,S,m,this.basePTS,this.frameIndex);if(i&&i.missing===0)return i},x}(a.default);t.default=L},"./src/demux/adts.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"getAudioConfig",function(){return R}),e.d(t,"isHeaderPattern",function(){return C}),e.d(t,"getHeaderLength",function(){return O}),e.d(t,"getFullFrameLength",function(){return L}),e.d(t,"canGetFrameLength",function(){return b}),e.d(t,"isHeader",function(){return x}),e.d(t,"canParse",function(){return I}),e.d(t,"probe",function(){return _}),e.d(t,"initTrackConfig",function(){return A}),e.d(t,"getFrameDuration",function(){return S}),e.d(t,"parseFrameHeader",function(){return m}),e.d(t,"appendFrame",function(){return i});var a=e("./src/utils/logger.ts"),s=e("./src/errors.ts"),u=e("./src/events.ts");function R(d,p,T,l){var o,h,E,n,c=navigator.userAgent.toLowerCase(),v=l,f=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=((p[T+2]&192)>>>6)+1;var g=(p[T+2]&60)>>>2;if(g>f.length-1){d.trigger(u.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+g});return}return E=(p[T+2]&1)<<2,E|=(p[T+3]&192)>>>6,a.logger.log("manifest codec:"+l+", ADTS type:"+o+", samplingIndex:"+g),/firefox/i.test(c)?g>=6?(o=5,n=new Array(4),h=g-3):(o=2,n=new Array(2),h=g):c.indexOf("android")!==-1?(o=2,n=new Array(2),h=g):(o=5,n=new Array(4),l&&(l.indexOf("mp4a.40.29")!==-1||l.indexOf("mp4a.40.5")!==-1)||!l&&g>=6?h=g-3:((l&&l.indexOf("mp4a.40.2")!==-1&&(g>=6&&E===1||/vivaldi/i.test(c))||!l&&E===1)&&(o=2,n=new Array(2)),h=g)),n[0]=o<<3,n[0]|=(g&14)>>1,n[1]|=(g&1)<<7,n[1]|=E<<3,o===5&&(n[1]|=(h&14)>>1,n[2]=(h&1)<<7,n[2]|=2<<2,n[3]=0),{config:n,samplerate:f[g],channelCount:E,codec:"mp4a.40."+o,manifestCodec:v}}function C(d,p){return d[p]===255&&(d[p+1]&246)===240}function O(d,p){return d[p+1]&1?7:9}function L(d,p){return(d[p+3]&3)<<11|d[p+4]<<3|(d[p+5]&224)>>>5}function b(d,p){return p+5<d.length}function x(d,p){return p+1<d.length&&C(d,p)}function I(d,p){return b(d,p)&&C(d,p)&&L(d,p)<=d.length-p}function _(d,p){if(x(d,p)){var T=O(d,p);if(p+T>=d.length)return!1;var l=L(d,p);if(l<=T)return!1;var o=p+l;return o===d.length||x(d,o)}return!1}function A(d,p,T,l,o){if(!d.samplerate){var h=R(p,T,l,o);if(!h)return;d.config=h.config,d.samplerate=h.samplerate,d.channelCount=h.channelCount,d.codec=h.codec,d.manifestCodec=h.manifestCodec,a.logger.log("parsed codec:"+d.codec+", rate:"+h.samplerate+", channels:"+h.channelCount)}}function S(d){return 1024*9e4/d}function m(d,p){var T=O(d,p);if(p+T<=d.length){var l=L(d,p)-T;if(l>0)return{headerLength:T,frameLength:l}}}function i(d,p,T,l,o){var h=S(d.samplerate),E=l+o*h,n=m(p,T),c;if(n){var v=n.frameLength,f=n.headerLength,g=f+v,y=Math.max(0,T+g-p.length);y?(c=new Uint8Array(g-f),c.set(p.subarray(T+f,p.length),0)):c=p.subarray(T+f,T+g);var M={unit:c,pts:E};return y||d.samples.push(M),{sample:M,length:g,missing:y}}var D=p.length-T;c=new Uint8Array(D),c.set(p.subarray(T,p.length),0);var P={unit:c,pts:E};return{sample:P,length:D,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"initPTSFn",function(){return b});var a=e("./src/polyfills/number.ts"),s=e("./src/demux/id3.ts"),u=e("./src/types/demuxer.ts"),R=e("./src/demux/dummy-demuxed-track.ts"),C=e("./src/utils/mp4-tools.ts"),O=e("./src/utils/typed-array.ts"),L=function(){function x(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var I=x.prototype;return I.resetInitSegment=function(A,S,m,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},I.resetTimeStamp=function(A){this.initPTS=A,this.resetContiguity()},I.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},I.canParse=function(A,S){return!1},I.appendFrame=function(A,S,m){},I.demux=function(A,S){this.cachedData&&(A=Object(C.appendUint8Array)(this.cachedData,A),this.cachedData=null);var m=s.getID3Data(A,0),i=m?m.length:0,d,p,T=this._audioTrack,l=this._id3Track,o=m?s.getTimeStamp(m):void 0,h=A.length;for((this.basePTS===null||this.frameIndex===0&&Object(a.isFiniteNumber)(o))&&(this.basePTS=b(o,S,this.initPTS)),m&&m.length>0&&l.samples.push({pts:this.basePTS,dts:this.basePTS,data:m,type:u.MetadataSchema.audioId3}),p=this.basePTS;i<h;){if(this.canParse(A,i)){var E=this.appendFrame(T,A,i);E?(this.frameIndex++,p=E.sample.pts,i+=E.length,d=i):i=h}else s.canParse(A,i)?(m=s.getID3Data(A,i),l.samples.push({pts:p,dts:p,data:m,type:u.MetadataSchema.audioId3}),i+=m.length,d=i):i++;if(i===h&&d!==h){var n=Object(O.sliceUint8)(A,d);this.cachedData?this.cachedData=Object(C.appendUint8Array)(this.cachedData,n):this.cachedData=n}}return{audioTrack:T,videoTrack:Object(R.dummyTrack)(),id3Track:l,textTrack:Object(R.dummyTrack)()}},I.demuxSampleAes=function(A,S,m){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},I.flush=function(A){var S=this.cachedData;return S&&(this.cachedData=null,this.demux(S,0)),{audioTrack:this._audioTrack,videoTrack:Object(R.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(R.dummyTrack)()}},I.destroy=function(){},x}(),b=function(I,_,A){return Object(a.isFiniteNumber)(I)?I*90:_*9e4+(A||0)};t.default=L},"./src/demux/chunk-cache.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return a});var a=function(){function u(){this.chunks=[],this.dataLength=0}var R=u.prototype;return R.push=function(O){this.chunks.push(O),this.dataLength+=O.length},R.flush=function(){var O=this.chunks,L=this.dataLength,b;if(O.length)O.length===1?b=O[0]:b=s(O,L);else return new Uint8Array(0);return this.reset(),b},R.reset=function(){this.chunks.length=0,this.dataLength=0},u}();function s(u,R){for(var C=new Uint8Array(R),O=0,L=0;L<u.length;L++){var b=u[L];C.set(b,O),O+=b.length}return C}},"./src/demux/dummy-demuxed-track.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"dummyTrack",function(){return a});function a(s,u){return s===void 0&&(s=""),u===void 0&&(u=9e4),{type:s,id:-1,pid:-1,inputTimeScale:u,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/utils/logger.ts"),s=function(){function u(C){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=C,this.bytesAvailable=C.byteLength,this.word=0,this.bitsAvailable=0}var R=u.prototype;return R.loadWord=function(){var O=this.data,L=this.bytesAvailable,b=O.byteLength-L,x=new Uint8Array(4),I=Math.min(4,L);if(I===0)throw new Error("no bytes available");x.set(O.subarray(b,b+I)),this.word=new DataView(x.buffer).getUint32(0),this.bitsAvailable=I*8,this.bytesAvailable-=I},R.skipBits=function(O){var L;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,L=O>>3,O-=L>>3,this.bytesAvailable-=L,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},R.readBits=function(O){var L=Math.min(this.bitsAvailable,O),b=this.word>>>32-L;return O>32&&a.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=L,this.bitsAvailable>0?this.word<<=L:this.bytesAvailable>0&&this.loadWord(),L=O-L,L>0&&this.bitsAvailable?b<<L|this.readBits(L):b},R.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()},R.skipUEG=function(){this.skipBits(1+this.skipLZ())},R.skipEG=function(){this.skipBits(1+this.skipLZ())},R.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},R.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},R.readBoolean=function(){return this.readBits(1)===1},R.readUByte=function(){return this.readBits(8)},R.readUShort=function(){return this.readBits(16)},R.readUInt=function(){return this.readBits(32)},R.skipScalingList=function(O){for(var L=8,b=8,x,I=0;I<O;I++)b!==0&&(x=this.readEG(),b=(L+x+256)%256),L=b===0?L:b},R.readSPS=function(){var O=0,L=0,b=0,x=0,I,_,A,S=this.readUByte.bind(this),m=this.readBits.bind(this),i=this.readUEG.bind(this),d=this.readBoolean.bind(this),p=this.skipBits.bind(this),T=this.skipEG.bind(this),l=this.skipUEG.bind(this),o=this.skipScalingList.bind(this);S();var h=S();if(m(5),p(3),S(),l(),h===100||h===110||h===122||h===244||h===44||h===83||h===86||h===118||h===128){var E=i();if(E===3&&p(1),l(),l(),p(1),d())for(_=E!==3?8:12,A=0;A<_;A++)d()&&(A<6?o(16):o(64))}l();var n=i();if(n===0)i();else if(n===1)for(p(1),T(),T(),I=i(),A=0;A<I;A++)T();l(),p(1);var c=i(),v=i(),f=m(1);f===0&&p(1),p(1),d()&&(O=i(),L=i(),b=i(),x=i());var g=[1,1];if(d()&&d()){var y=S();switch(y){case 1:g=[1,1];break;case 2:g=[12,11];break;case 3:g=[10,11];break;case 4:g=[16,11];break;case 5:g=[40,33];break;case 6:g=[24,11];break;case 7:g=[20,11];break;case 8:g=[32,11];break;case 9:g=[80,33];break;case 10:g=[18,11];break;case 11:g=[15,11];break;case 12:g=[64,33];break;case 13:g=[160,99];break;case 14:g=[4,3];break;case 15:g=[3,2];break;case 16:g=[2,1];break;case 255:{g=[S()<<8|S(),S()<<8|S()];break}}}return{width:Math.ceil((c+1)*16-O*2-L*2),height:(2-f)*(v+1)*16-(f?2:4)*(b+x),pixelRatio:g}},R.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},u}();t.default=s},"./src/demux/id3.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"isHeader",function(){return a}),e.d(t,"isFooter",function(){return s}),e.d(t,"getID3Data",function(){return u}),e.d(t,"canParse",function(){return C}),e.d(t,"getTimeStamp",function(){return O}),e.d(t,"isTimeStampFrame",function(){return L}),e.d(t,"getID3Frames",function(){return x}),e.d(t,"decodeFrame",function(){return I}),e.d(t,"utf8ArrayToStr",function(){return i}),e.d(t,"testables",function(){return d});var a=function(o,h){return h+10<=o.length&&o[h]===73&&o[h+1]===68&&o[h+2]===51&&o[h+3]<255&&o[h+4]<255&&o[h+6]<128&&o[h+7]<128&&o[h+8]<128&&o[h+9]<128},s=function(o,h){return h+10<=o.length&&o[h]===51&&o[h+1]===68&&o[h+2]===73&&o[h+3]<255&&o[h+4]<255&&o[h+6]<128&&o[h+7]<128&&o[h+8]<128&&o[h+9]<128},u=function(o,h){for(var E=h,n=0;a(o,h);){n+=10;var c=R(o,h+6);n+=c,s(o,h+10)&&(n+=10),h+=n}if(n>0)return o.subarray(E,E+n)},R=function(o,h){var E=0;return E=(o[h]&127)<<21,E|=(o[h+1]&127)<<14,E|=(o[h+2]&127)<<7,E|=o[h+3]&127,E},C=function(o,h){return a(o,h)&&R(o,h+6)+10<=o.length-h},O=function(o){for(var h=x(o),E=0;E<h.length;E++){var n=h[E];if(L(n))return m(n)}},L=function(o){return o&&o.key==="PRIV"&&o.info==="com.apple.streaming.transportStreamTimestamp"},b=function(o){var h=String.fromCharCode(o[0],o[1],o[2],o[3]),E=R(o,4),n=10;return{type:h,size:E,data:o.subarray(n,n+E)}},x=function(o){for(var h=0,E=[];a(o,h);){var n=R(o,h+6);h+=10;for(var c=h+n;h+8<c;){var v=b(o.subarray(h)),f=I(v);f&&E.push(f),h+=v.size+10}s(o,h)&&(h+=10)}return E},I=function(o){return o.type==="PRIV"?_(o):o.type[0]==="W"?S(o):A(o)},_=function(o){if(!(o.size<2)){var h=i(o.data,!0),E=new Uint8Array(o.data.subarray(h.length+1));return{key:o.type,info:h,data:E.buffer}}},A=function(o){if(!(o.size<2)){if(o.type==="TXXX"){var h=1,E=i(o.data.subarray(h),!0);h+=E.length+1;var n=i(o.data.subarray(h));return{key:o.type,info:E,data:n}}var c=i(o.data.subarray(1));return{key:o.type,data:c}}},S=function(o){if(o.type==="WXXX"){if(o.size<2)return;var h=1,E=i(o.data.subarray(h),!0);h+=E.length+1;var n=i(o.data.subarray(h));return{key:o.type,info:E,data:n}}var c=i(o.data);return{key:o.type,data:c}},m=function(o){if(o.data.byteLength===8){var h=new Uint8Array(o.data),E=h[3]&1,n=(h[4]<<23)+(h[5]<<15)+(h[6]<<7)+h[7];return n/=45,E&&(n+=4772185884e-2),Math.round(n)}},i=function(o,h){h===void 0&&(h=!1);var E=T();if(E){var n=E.decode(o);if(h){var c=n.indexOf("\0");return c!==-1?n.substring(0,c):n}return n.replace(/\0/g,"")}for(var v=o.length,f,g,y,M="",D=0;D<v;){if(f=o[D++],f===0&&h)return M;if(f===0||f===3)continue;switch(f>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:M+=String.fromCharCode(f);break;case 12:case 13:g=o[D++],M+=String.fromCharCode((f&31)<<6|g&63);break;case 14:g=o[D++],y=o[D++],M+=String.fromCharCode((f&15)<<12|(g&63)<<6|(y&63)<<0);break;default:}}return M},d={decodeTextFrame:A},p;function T(){return!p&&typeof self.TextDecoder!="undefined"&&(p=new self.TextDecoder("utf-8")),p}},"./src/demux/mp3demuxer.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/demux/base-audio-demuxer.ts"),s=e("./src/demux/id3.ts"),u=e("./src/utils/logger.ts"),R=e("./src/demux/mpegaudio.ts");function C(b,x){b.prototype=Object.create(x.prototype),b.prototype.constructor=b,O(b,x)}function O(b,x){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(_,A){return _.__proto__=A,_},O(b,x)}var L=function(b){C(x,b);function x(){return b.apply(this,arguments)||this}var I=x.prototype;return I.resetInitSegment=function(A,S,m,i){b.prototype.resetInitSegment.call(this,A,S,m,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:S,duration:i,inputTimeScale:9e4,dropped:0}},x.probe=function(A){if(!A)return!1;for(var S=s.getID3Data(A,0)||[],m=S.length,i=A.length;m<i;m++)if(R.probe(A,m))return u.logger.log("MPEG Audio sync word found !"),!0;return!1},I.canParse=function(A,S){return R.canParse(A,S)},I.appendFrame=function(A,S,m){if(this.basePTS!==null)return R.appendFrame(A,S,m,this.basePTS,this.frameIndex)},x}(a.default);t.default=L},"./src/demux/mp4demuxer.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/polyfills/number.ts"),s=e("./src/types/demuxer.ts"),u=e("./src/utils/mp4-tools.ts"),R=e("./src/demux/dummy-demuxed-track.ts"),C=/\/emsg[-/]ID3/i,O=function(){function L(x,I){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=I}var b=L.prototype;return b.resetTimeStamp=function(){},b.resetInitSegment=function(I,_,A,S){var m=Object(u.parseInitSegment)(I),i=this.videoTrack=Object(R.dummyTrack)("video",1),d=this.audioTrack=Object(R.dummyTrack)("audio",1),p=this.txtTrack=Object(R.dummyTrack)("text",1);if(this.id3Track=Object(R.dummyTrack)("id3",1),this.timeOffset=0,m.video){var T=m.video,l=T.id,o=T.timescale,h=T.codec;i.id=l,i.timescale=p.timescale=o,i.codec=h}if(m.audio){var E=m.audio,n=E.id,c=E.timescale,v=E.codec;d.id=n,d.timescale=c,d.codec=v}p.id=u.RemuxerTrackIdConfig.text,i.sampleDuration=0,i.duration=d.duration=S},b.resetContiguity=function(){},L.probe=function(I){return I=I.length>16384?I.subarray(0,16384):I,Object(u.findBox)(I,["moof"]).length>0},b.demux=function(I,_){this.timeOffset=_;var A=I,S=this.videoTrack,m=this.txtTrack;if(this.config.progressive){this.remainderData&&(A=Object(u.appendUint8Array)(this.remainderData,I));var i=Object(u.segmentValidRange)(A);this.remainderData=i.remainder,S.samples=i.valid||new Uint8Array}else S.samples=A;var d=this.extractID3Track(S,_);return m.samples=Object(u.parseSamples)(_,S),{videoTrack:S,audioTrack:this.audioTrack,id3Track:d,textTrack:this.txtTrack}},b.flush=function(){var I=this.timeOffset,_=this.videoTrack,A=this.txtTrack;_.samples=this.remainderData||new Uint8Array,this.remainderData=null;var S=this.extractID3Track(_,this.timeOffset);return A.samples=Object(u.parseSamples)(I,_),{videoTrack:_,audioTrack:Object(R.dummyTrack)(),id3Track:S,textTrack:Object(R.dummyTrack)()}},b.extractID3Track=function(I,_){var A=this.id3Track;if(I.samples.length){var S=Object(u.findBox)(I.samples,["emsg"]);S&&S.forEach(function(m){var i=Object(u.parseEmsg)(m);if(C.test(i.schemeIdUri)){var d=Object(a.isFiniteNumber)(i.presentationTime)?i.presentationTime/i.timeScale:_+i.presentationTimeDelta/i.timeScale,p=i.payload;A.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:s.MetadataSchema.emsg})}})}return A},b.demuxSampleAes=function(I,_,A){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},b.destroy=function(){},L}();t.default=O},"./src/demux/mpegaudio.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"appendFrame",function(){return O}),e.d(t,"parseHeader",function(){return L}),e.d(t,"isHeaderPattern",function(){return b}),e.d(t,"isHeader",function(){return x}),e.d(t,"canParse",function(){return I}),e.d(t,"probe",function(){return _});var a=null,s=[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],u=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],R=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],C=[0,1,1,4];function O(A,S,m,i,d){if(!(m+24>S.length)){var p=L(S,m);if(p&&m+p.frameLength<=S.length){var T=p.samplesPerFrame*9e4/p.sampleRate,l=i+d*T,o={unit:S.subarray(m,m+p.frameLength),pts:l,dts:l};return A.config=[],A.channelCount=p.channelCount,A.samplerate=p.sampleRate,A.samples.push(o),{sample:o,length:p.frameLength,missing:0}}}}function L(A,S){var m=A[S+1]>>3&3,i=A[S+1]>>1&3,d=A[S+2]>>4&15,p=A[S+2]>>2&3;if(m!==1&&d!==0&&d!==15&&p!==3){var T=A[S+2]>>1&1,l=A[S+3]>>6,o=m===3?3-i:i===3?3:4,h=s[o*14+d-1]*1e3,E=m===3?0:m===2?1:2,n=u[E*3+p],c=l===3?1:2,v=R[m][i],f=C[i],g=v*8*f,y=Math.floor(v*h/n+T)*f;if(a===null){var M=navigator.userAgent||"",D=M.match(/Chrome\/(\d+)/i);a=D?parseInt(D[1]):0}var P=!!a&&a<=87;return P&&i===2&&h>=224e3&&l===0&&(A[S+3]=A[S+3]|128),{sampleRate:n,channelCount:c,frameLength:y,samplesPerFrame:g}}}function b(A,S){return A[S]===255&&(A[S+1]&224)===224&&(A[S+1]&6)!==0}function x(A,S){return S+1<A.length&&b(A,S)}function I(A,S){var m=4;return b(A,S)&&m<=A.length-S}function _(A,S){if(S+1<A.length&&b(A,S)){var m=4,i=L(A,S),d=m;i!=null&&i.frameLength&&(d=i.frameLength);var p=S+d;return p===A.length||x(A,p)}return!1}},"./src/demux/sample-aes.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/crypt/decrypter.ts"),s=e("./src/demux/tsdemuxer.ts"),u=function(){function R(O,L,b){this.keyData=void 0,this.decrypter=void 0,this.keyData=b,this.decrypter=new a.default(O,L,{removePKCS7Padding:!1})}var C=R.prototype;return C.decryptBuffer=function(L,b){this.decrypter.decrypt(L,this.keyData.key.buffer,this.keyData.iv.buffer,b)},C.decryptAacSample=function(L,b,x,I){var _=L[b].unit;if(!(_.length<=16)){var A=_.subarray(16,_.length-_.length%16),S=A.buffer.slice(A.byteOffset,A.byteOffset+A.length),m=this;this.decryptBuffer(S,function(i){var d=new Uint8Array(i);_.set(d,16),I||m.decryptAacSamples(L,b+1,x)})}},C.decryptAacSamples=function(L,b,x){for(;;b++){if(b>=L.length){x();return}if(!(L[b].unit.length<32)){var I=this.decrypter.isSync();if(this.decryptAacSample(L,b,x,I),!I)return}}},C.getAvcEncryptedData=function(L){for(var b=Math.floor((L.length-48)/160)*16+16,x=new Int8Array(b),I=0,_=32;_<L.length-16;_+=160,I+=16)x.set(L.subarray(_,_+16),I);return x},C.getAvcDecryptedUnit=function(L,b){for(var x=new Uint8Array(b),I=0,_=32;_<L.length-16;_+=160,I+=16)L.set(x.subarray(I,I+16),_);return L},C.decryptAvcSample=function(L,b,x,I,_,A){var S=Object(s.discardEPB)(_.data),m=this.getAvcEncryptedData(S),i=this;this.decryptBuffer(m.buffer,function(d){_.data=i.getAvcDecryptedUnit(S,d),A||i.decryptAvcSamples(L,b,x+1,I)})},C.decryptAvcSamples=function(L,b,x,I){if(L instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;b++,x=0){if(b>=L.length){I();return}for(var _=L[b].units;!(x>=_.length);x++){var A=_[x];if(!(A.data.length<=48||A.type!==1&&A.type!==5)){var S=this.decrypter.isSync();if(this.decryptAvcSample(L,b,x,I,A,S),!S)return}}}},R}();t.default=u},"./src/demux/transmuxer-interface.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return _});var a=e("./node_modules/webworkify-webpack/index.js"),s=e.n(a),u=e("./src/events.ts"),R=e("./src/demux/transmuxer.ts"),C=e("./src/utils/logger.ts"),O=e("./src/errors.ts"),L=e("./src/utils/mediasource-helper.ts"),b=e("./node_modules/eventemitter3/index.js"),x=e.n(b),I=Object(L.getMediaSource)()||{isTypeSupported:function(){return!1}},_=function(){function A(m,i,d,p){var T=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=m,this.id=i,this.onTransmuxComplete=d,this.onFlush=p;var l=m.config,o=function(v,f){f=f||{},f.frag=T.frag,f.id=T.id,m.trigger(v,f)};this.observer=new b.EventEmitter,this.observer.on(u.Events.FRAG_DECRYPTED,o),this.observer.on(u.Events.ERROR,o);var h={mp4:I.isTypeSupported("video/mp4"),mpeg:I.isTypeSupported("audio/mpeg"),mp3:I.isTypeSupported('audio/mp4; codecs="mp3"')},E=navigator.vendor;if(l.enableWorker&&typeof Worker!="undefined"){C.logger.log("demuxing in webworker");var n;try{n=this.worker=a("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),n.addEventListener("message",this.onwmsg),n.onerror=function(c){m.trigger(u.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},n.postMessage({cmd:"init",typeSupported:h,vendor:E,id:i,config:JSON.stringify(l)})}catch(c){C.logger.warn("Error in worker:",c),C.logger.error("Error while initializing DemuxerWorker, fallback to inline"),n&&self.URL.revokeObjectURL(n.objectURL),this.transmuxer=new R.default(this.observer,h,l,E,i),this.worker=null}}else this.transmuxer=new R.default(this.observer,h,l,E,i)}var S=A.prototype;return S.destroy=function(){var i=this.worker;if(i)i.removeEventListener("message",this.onwmsg),i.terminate(),this.worker=null,this.onwmsg=void 0;else{var d=this.transmuxer;d&&(d.destroy(),this.transmuxer=null)}var p=this.observer;p&&p.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},S.push=function(i,d,p,T,l,o,h,E,n,c){var v,f,g=this;n.transmuxing.start=self.performance.now();var y=this.transmuxer,M=this.worker,D=o?o.start:l.start,P=l.decryptdata,B=this.frag,N=!(B&&l.cc===B.cc),F=!(B&&n.level===B.level),H=B?n.sn-B.sn:-1,V=this.part?n.part-this.part.index:-1,X=H===0&&n.id>1&&n.id===(B==null?void 0:B.stats.chunkCount),$=!F&&(H===1||H===0&&(V===1||X&&V<=0)),j=self.performance.now();(F||H||l.stats.parsing.start===0)&&(l.stats.parsing.start=j),o&&(V||!$)&&(o.stats.parsing.start=j);var J=!(B&&((v=l.initSegment)===null||v===void 0?void 0:v.url)===((f=B.initSegment)===null||f===void 0?void 0:f.url)),ee=new R.TransmuxState(N,$,E,F,D,J);if(!$||N||J){C.logger.log("[transmuxer-interface, "+l.type+"]: Starting new transmux session for sn: "+n.sn+" p: "+n.part+" level: "+n.level+" id: "+n.id+`
14
14
  discontinuity: `+N+`
15
15
  trackSwitch: `+F+`
16
16
  contiguous: `+$+`
17
17
  accurateTimeOffset: `+E+`
18
18
  timeOffset: `+D+`
19
- initSegmentChange: `+J);var te=new R.TransmuxConfig(p,T,d,h,c);this.configureTransmuxer(te)}if(this.frag=l,this.part=o,M)M.postMessage({cmd:"demux",data:i,decryptdata:P,chunkMeta:n,state:ee},i instanceof ArrayBuffer?[i]:[]);else if(y){var se=y.push(i,P,n,ee);Object(R.isPromise)(se)?se.then(function(ue){g.handleTransmuxComplete(ue)}):this.handleTransmuxComplete(se)}},S.flush=function(i){var d=this;i.transmuxing.start=self.performance.now();var p=this.transmuxer,T=this.worker;if(T)T.postMessage({cmd:"flush",chunkMeta:i});else if(p){var l=p.flush(i);Object(R.isPromise)(l)?l.then(function(o){d.handleFlushResult(o,i)}):this.handleFlushResult(l,i)}},S.handleFlushResult=function(i,d){var p=this;i.forEach(function(T){p.handleTransmuxComplete(T)}),this.onFlush(d)},S.onWorkerMessage=function(i){var d=i.data,p=this.hls;switch(d.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(d.data);break}case"flush":{this.onFlush(d.data);break}case"workerLog":C.logger[d.data.logType]&&C.logger[d.data.logType](d.data.message);break;default:{d.data=d.data||{},d.data.frag=this.frag,d.data.id=this.id,p.trigger(d.event,d.data);break}}},S.configureTransmuxer=function(i){var d=this.worker,p=this.transmuxer;d?d.postMessage({cmd:"configure",config:i}):p&&p.configure(i)},S.handleTransmuxComplete=function(i){i.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(i)},A}()},"./src/demux/transmuxer-worker.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return O});var s=e("./src/demux/transmuxer.ts"),a=e("./src/events.ts"),u=e("./src/utils/logger.ts"),R=e("./node_modules/eventemitter3/index.js"),C=e.n(R);function O(_){var A=new R.EventEmitter,S=function(d,p){_.postMessage({event:d,data:p})};A.on(a.Events.FRAG_DECRYPTED,S),A.on(a.Events.ERROR,S);var v=function(){var d=function(l){var o=function(E){S("workerLog",{logType:l,message:E})};u.logger[l]=o};for(var p in u.logger)d(p)};_.addEventListener("message",function(i){var d=i.data;switch(d.cmd){case"init":{var p=JSON.parse(d.config);_.transmuxer=new s.default(A,d.typeSupported,p,d.vendor,d.id),Object(u.enableLogs)(p.debug),v(),S("init",null);break}case"configure":{_.transmuxer.configure(d.config);break}case"demux":{var T=_.transmuxer.push(d.data,d.decryptdata,d.chunkMeta,d.state);Object(s.isPromise)(T)?T.then(function(h){L(_,h)}):L(_,T);break}case"flush":{var l=d.chunkMeta,o=_.transmuxer.flush(l);Object(s.isPromise)(o)?o.then(function(h){x(_,h,l)}):x(_,o,l);break}default:break}})}function L(_,A){if(I(A.remuxResult))return!1;var S=[],v=A.remuxResult,i=v.audio,d=v.video;return i&&b(S,i),d&&b(S,d),_.postMessage({event:"transmuxComplete",data:A},S),!0}function b(_,A){A.data1&&_.push(A.data1.buffer),A.data2&&_.push(A.data2.buffer)}function x(_,A,S){var v=A.reduce(function(i,d){return L(_,d)||i},!1);v||_.postMessage({event:"transmuxComplete",data:A[0]}),_.postMessage({event:"flush",data:S})}function I(_){return!_.audio&&!_.video&&!_.text&&!_.id3&&!_.initSegment}},"./src/demux/transmuxer.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return S}),e.d(t,"isPromise",function(){return d}),e.d(t,"TransmuxConfig",function(){return p}),e.d(t,"TransmuxState",function(){return T});var s=e("./src/events.ts"),a=e("./src/errors.ts"),u=e("./src/crypt/decrypter.ts"),R=e("./src/demux/aacdemuxer.ts"),C=e("./src/demux/mp4demuxer.ts"),O=e("./src/demux/tsdemuxer.ts"),L=e("./src/demux/mp3demuxer.ts"),b=e("./src/remux/mp4-remuxer.ts"),x=e("./src/remux/passthrough-remuxer.ts"),I=e("./src/utils/logger.ts"),_;try{_=self.performance.now.bind(self.performance)}catch{I.logger.debug("Unable to use Performance API on this environment"),_=self.Date.now}var A=[{demux:O.default,remux:b.default},{demux:C.default,remux:x.default},{demux:R.default,remux:b.default},{demux:L.default,remux:b.default}],S=function(){function l(h,E,n,c,m){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=h,this.typeSupported=E,this.config=n,this.vendor=c,this.id=m}var o=l.prototype;return o.configure=function(E){this.transmuxConfig=E,this.decrypter&&this.decrypter.reset()},o.push=function(E,n,c,m){var f=this,g=c.transmuxing;g.executeStart=_();var y=new Uint8Array(E),M=this.config,D=this.currentTransmuxState,P=this.transmuxConfig;m&&(this.currentTransmuxState=m);var B=m||D,N=B.contiguous,F=B.discontinuity,H=B.trackSwitch,V=B.accurateTimeOffset,X=B.timeOffset,$=B.initSegmentChange,j=P.audioCodec,J=P.videoCodec,ee=P.defaultInitPts,te=P.duration,se=P.initSegmentData;(F||H||$)&&this.resetInitSegment(se,j,J,te),(F||$)&&this.resetInitialTimestamp(ee),N||this.resetContiguity();var ue=v(y,n);if(ue&&ue.method==="AES-128"){var ie=this.getDecrypter();if(M.enableSoftwareAES){var he=ie.softwareDecrypt(y,ue.key.buffer,ue.iv.buffer);if(!he)return g.executeEnd=_(),i(c);y=new Uint8Array(he)}else return this.decryptionPromise=ie.webCryptoDecrypt(y,ue.key.buffer,ue.iv.buffer).then(function(Re){var Le=f.push(Re,null,c);return f.decryptionPromise=null,Le}),this.decryptionPromise}this.needsProbing(y,F,H)&&this.configureTransmuxer(y,P);var me=this.transmux(y,ue,X,V,c),ne=this.currentTransmuxState;return ne.contiguous=!0,ne.discontinuity=!1,ne.trackSwitch=!1,g.executeEnd=_(),me},o.flush=function(E){var n=this,c=E.transmuxing;c.executeStart=_();var m=this.decrypter,f=this.currentTransmuxState,g=this.decryptionPromise;if(g)return g.then(function(){return n.flush(E)});var y=[],M=f.timeOffset;if(m){var D=m.flush();D&&y.push(this.push(D,null,E))}var P=this.demuxer,B=this.remuxer;if(!P||!B)return this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),c.executeEnd=_(),[i(E)];var N=P.flush(M);return d(N)?N.then(function(F){return n.flushRemux(y,F,E),y}):(this.flushRemux(y,N,E),y)},o.flushRemux=function(E,n,c){var m=n.audioTrack,f=n.videoTrack,g=n.id3Track,y=n.textTrack,M=this.currentTransmuxState,D=M.accurateTimeOffset,P=M.timeOffset;I.logger.log("[transmuxer.ts]: Flushed fragment "+c.sn+(c.part>-1?" p: "+c.part:"")+" of level "+c.level);var B=this.remuxer.remux(m,f,g,y,P,D,!0,this.id);E.push({remuxResult:B,chunkMeta:c}),c.transmuxing.executeEnd=_()},o.resetInitialTimestamp=function(E){var n=this.demuxer,c=this.remuxer;!n||!c||(n.resetTimeStamp(E),c.resetTimeStamp(E))},o.resetContiguity=function(){var E=this.demuxer,n=this.remuxer;!E||!n||(E.resetContiguity(),n.resetNextTimestamp())},o.resetInitSegment=function(E,n,c,m){var f=this.demuxer,g=this.remuxer;!f||!g||(f.resetInitSegment(E,n,c,m),g.resetInitSegment(E,n,c))},o.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},o.transmux=function(E,n,c,m,f){var g;return n&&n.method==="SAMPLE-AES"?g=this.transmuxSampleAes(E,n,c,m,f):g=this.transmuxUnencrypted(E,c,m,f),g},o.transmuxUnencrypted=function(E,n,c,m){var f=this.demuxer.demux(E,n,!1,!this.config.progressive),g=f.audioTrack,y=f.videoTrack,M=f.id3Track,D=f.textTrack,P=this.remuxer.remux(g,y,M,D,n,c,!1,this.id);return{remuxResult:P,chunkMeta:m}},o.transmuxSampleAes=function(E,n,c,m,f){var g=this;return this.demuxer.demuxSampleAes(E,n,c).then(function(y){var M=g.remuxer.remux(y.audioTrack,y.videoTrack,y.id3Track,y.textTrack,c,m,!1,g.id);return{remuxResult:M,chunkMeta:f}})},o.configureTransmuxer=function(E,n){for(var c=this.config,m=this.observer,f=this.typeSupported,g=this.vendor,y=n.audioCodec,M=n.defaultInitPts,D=n.duration,P=n.initSegmentData,B=n.videoCodec,N,F=0,H=A.length;F<H;F++)if(A[F].demux.probe(E)){N=A[F];break}N||(I.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),N={demux:C.default,remux:x.default});var V=this.demuxer,X=this.remuxer,$=N.remux,j=N.demux;(!X||!(X instanceof $))&&(this.remuxer=new $(m,c,f,g)),(!V||!(V instanceof j))&&(this.demuxer=new j(m,c,f),this.probe=j.probe),this.resetInitSegment(P,y,B,D),this.resetInitialTimestamp(M)},o.needsProbing=function(E,n,c){return!this.demuxer||!this.remuxer||n||c},o.getDecrypter=function(){var E=this.decrypter;return E||(E=this.decrypter=new u.default(this.observer,this.config)),E},l}();function v(l,o){var h=null;return l.byteLength>0&&o!=null&&o.key!=null&&o.iv!==null&&o.method!=null&&(h=o),h}var i=function(o){return{remuxResult:{},chunkMeta:o}};function d(l){return"then"in l&&l.then instanceof Function}var p=function(o,h,E,n,c){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=o,this.videoCodec=h,this.initSegmentData=E,this.duration=n,this.defaultInitPts=c},T=function(o,h,E,n,c,m){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=o,this.contiguous=h,this.accurateTimeOffset=E,this.trackSwitch=n,this.timeOffset=c,this.initSegmentChange=m}},"./src/demux/tsdemuxer.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"discardEPB",function(){return p});var s=e("./src/demux/adts.ts"),a=e("./src/demux/mpegaudio.ts"),u=e("./src/demux/exp-golomb.ts"),R=e("./src/demux/sample-aes.ts"),C=e("./src/events.ts"),O=e("./src/utils/mp4-tools.ts"),L=e("./src/utils/logger.ts"),b=e("./src/errors.ts"),x=e("./src/types/demuxer.ts");function I(){return I=Object.assign?Object.assign.bind():function(T){for(var l=1;l<arguments.length;l++){var o=arguments[l];for(var h in o)Object.prototype.hasOwnProperty.call(o,h)&&(T[h]=o[h])}return T},I.apply(this,arguments)}var _=function(){function T(o,h,E){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=o,this.config=h,this.typeSupported=E}T.probe=function(h){return h[0]===71&&h[188]===71},T.createTrack=function(h,E){return{container:h==="video"||h==="audio"?"video/mp2t":void 0,type:h,id:O.RemuxerTrackIdConfig[h],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:h==="audio"?E:void 0}};var l=T.prototype;return l.resetInitSegment=function(h,E,n,c){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=T.createTrack("video"),this._audioTrack=T.createTrack("audio",c),this._id3Track=T.createTrack("id3"),this._txtTrack=T.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=E,this.videoCodec=n,this._duration=c},l.resetTimeStamp=function(){},l.resetContiguity=function(){var h=this._audioTrack,E=this._avcTrack,n=this._id3Track;h&&(h.pesData=null),E&&(E.pesData=null),n&&(n.pesData=null),this.aacOverFlow=null},l.demux=function(h,E,n,c){n===void 0&&(n=!1),c===void 0&&(c=!1),n||(this.sampleAes=null);var m,f=this._avcTrack,g=this._audioTrack,y=this._id3Track,M=this._txtTrack,D=f.pid,P=f.pesData,B=g.pid,N=y.pid,F=g.pesData,H=y.pesData,V=null,X=this.pmtParsed,$=this._pmtId,j=h.length;if(this.remainderData&&(h=Object(O.appendUint8Array)(this.remainderData,h),j=h.length,this.remainderData=null),j<188&&!c)return this.remainderData=h,{audioTrack:g,videoTrack:f,id3Track:y,textTrack:M};j-=j%188,j<h.byteLength&&!c&&(this.remainderData=new Uint8Array(h.buffer,j,h.buffer.byteLength-j));for(var J=0,ee=0;ee<j;ee+=188)if(h[ee]===71){var te=!!(h[ee+1]&64),se=((h[ee+1]&31)<<8)+h[ee+2],ue=(h[ee+3]&48)>>4,ie=void 0;if(ue>1){if(ie=ee+5+h[ee+4],ie===ee+188)continue}else ie=ee+4;switch(se){case D:te&&(P&&(m=i(P))&&this.parseAVCPES(f,M,m,!1),P={data:[],size:0}),P&&(P.data.push(h.subarray(ie,ee+188)),P.size+=ee+188-ie);break;case B:if(te){if(F&&(m=i(F)))switch(g.segmentCodec){case"aac":this.parseAACPES(g,m);break;case"mp3":this.parseMPEGPES(g,m);break}F={data:[],size:0}}F&&(F.data.push(h.subarray(ie,ee+188)),F.size+=ee+188-ie);break;case N:te&&(H&&(m=i(H))&&this.parseID3PES(y,m),H={data:[],size:0}),H&&(H.data.push(h.subarray(ie,ee+188)),H.size+=ee+188-ie);break;case 0:te&&(ie+=h[ie]+1),$=this._pmtId=S(h,ie);break;case $:{te&&(ie+=h[ie]+1);var he=v(h,ie,this.typeSupported,n);D=he.avc,D>0&&(f.pid=D),B=he.audio,B>0&&(g.pid=B,g.segmentCodec=he.segmentCodec),N=he.id3,N>0&&(y.pid=N),V!==null&&!X&&(L.logger.log("unknown PID '"+V+"' in TS found"),V=null),X=this.pmtParsed=!0;break}case 17:case 8191:break;default:V=se;break}}else J++;J>0&&this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+J+" TS packet/s that do not start with 0x47"}),f.pesData=P,g.pesData=F,y.pesData=H;var me={audioTrack:g,videoTrack:f,id3Track:y,textTrack:M};return c&&this.extractRemainingSamples(me),me},l.flush=function(){var h=this.remainderData;this.remainderData=null;var E;return h?E=this.demux(h,-1,!1,!0):E={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(E),this.sampleAes?this.decrypt(E,this.sampleAes):E},l.extractRemainingSamples=function(h){var E=h.audioTrack,n=h.videoTrack,c=h.id3Track,m=h.textTrack,f=n.pesData,g=E.pesData,y=c.pesData,M;if(f&&(M=i(f))?(this.parseAVCPES(n,m,M,!0),n.pesData=null):n.pesData=f,g&&(M=i(g))){switch(E.segmentCodec){case"aac":this.parseAACPES(E,M);break;case"mp3":this.parseMPEGPES(E,M);break}E.pesData=null}else g!=null&&g.size&&L.logger.log("last AAC PES packet truncated,might overlap between fragments"),E.pesData=g;y&&(M=i(y))?(this.parseID3PES(c,M),c.pesData=null):c.pesData=y},l.demuxSampleAes=function(h,E,n){var c=this.demux(h,n,!0,!this.config.progressive),m=this.sampleAes=new R.default(this.observer,this.config,E);return this.decrypt(c,m)},l.decrypt=function(h,E){return new Promise(function(n){var c=h.audioTrack,m=h.videoTrack;c.samples&&c.segmentCodec==="aac"?E.decryptAacSamples(c.samples,0,function(){m.samples?E.decryptAvcSamples(m.samples,0,0,function(){n(h)}):n(h)}):m.samples&&E.decryptAvcSamples(m.samples,0,0,function(){n(h)})})},l.destroy=function(){this._duration=0},l.parseAVCPES=function(h,E,n,c){var m=this,f=this.parseAVCNALu(h,n.data),g=!1,y=this.avcSample,M,D=!1;n.data=null,y&&f.length&&!h.audFound&&(d(y,h),y=this.avcSample=A(!1,n.pts,n.dts,"")),f.forEach(function(P){switch(P.type){case 1:{M=!0,y||(y=m.avcSample=A(!0,n.pts,n.dts,"")),g&&(y.debug+="NDR "),y.frame=!0;var B=P.data;if(D&&B.length>4){var N=new u.default(B).readSliceType();(N===2||N===4||N===7||N===9)&&(y.key=!0)}break}case 5:M=!0,y||(y=m.avcSample=A(!0,n.pts,n.dts,"")),g&&(y.debug+="IDR "),y.key=!0,y.frame=!0;break;case 6:{M=!0,g&&y&&(y.debug+="SEI "),Object(O.parseSEIMessageFromNALu)(p(P.data),n.pts,E.samples);break}case 7:if(M=!0,D=!0,g&&y&&(y.debug+="SPS "),!h.sps){var F=new u.default(P.data),H=F.readSPS();h.width=H.width,h.height=H.height,h.pixelRatio=H.pixelRatio,h.sps=[P.data],h.duration=m._duration;for(var V=P.data.subarray(1,4),X="avc1.",$=0;$<3;$++){var j=V[$].toString(16);j.length<2&&(j="0"+j),X+=j}h.codec=X}break;case 8:M=!0,g&&y&&(y.debug+="PPS "),h.pps||(h.pps=[P.data]);break;case 9:M=!1,h.audFound=!0,y&&d(y,h),y=m.avcSample=A(!1,n.pts,n.dts,g?"AUD ":"");break;case 12:M=!0;break;default:M=!1,y&&(y.debug+="unknown NAL "+P.type+" ");break}if(y&&M){var J=y.units;J.push(P)}}),c&&y&&(d(y,h),this.avcSample=null)},l.getLastNalUnit=function(h){var E,n=this.avcSample,c;if((!n||n.units.length===0)&&(n=h[h.length-1]),(E=n)!==null&&E!==void 0&&E.units){var m=n.units;c=m[m.length-1]}return c},l.parseAVCNALu=function(h,E){var n=E.byteLength,c=h.naluState||0,m=c,f=[],g=0,y,M,D,P=-1,B=0;for(c===-1&&(P=0,B=E[0]&31,c=0,g=1);g<n;){if(y=E[g++],!c){c=y?0:1;continue}if(c===1){c=y?0:2;continue}if(!y)c=3;else if(y===1){if(P>=0){var N={data:E.subarray(P,g-c-1),type:B};f.push(N)}else{var F=this.getLastNalUnit(h.samples);if(F&&(m&&g<=4-m&&F.state&&(F.data=F.data.subarray(0,F.data.byteLength-m)),M=g-c-1,M>0)){var H=new Uint8Array(F.data.byteLength+M);H.set(F.data,0),H.set(E.subarray(0,M),F.data.byteLength),F.data=H,F.state=0}}g<n?(D=E[g]&31,P=g,B=D,c=0):c=-1}else c=0}if(P>=0&&c>=0){var V={data:E.subarray(P,n),type:B,state:c};f.push(V)}if(f.length===0){var X=this.getLastNalUnit(h.samples);if(X){var $=new Uint8Array(X.data.byteLength+E.byteLength);$.set(X.data,0),$.set(E,X.data.byteLength),X.data=$}}return h.naluState=c,f},l.parseAACPES=function(h,E){var n=0,c=this.aacOverFlow,m=E.data;if(c){this.aacOverFlow=null;var f=c.missing,g=c.sample.unit.byteLength;if(f===-1){var y=new Uint8Array(g+m.byteLength);y.set(c.sample.unit,0),y.set(m,g),m=y}else{var M=g-f;c.sample.unit.set(m.subarray(0,f),M),h.samples.push(c.sample),n=c.missing}}var D,P;for(D=n,P=m.length;D<P-1&&!s.isHeader(m,D);D++);if(D!==n){var B,N;if(D<P-1?(B="AAC PES did not start with ADTS header,offset:"+D,N=!1):(B="no ADTS header found in AAC PES",N=!0),L.logger.warn("parsing error:"+B),this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.FRAG_PARSING_ERROR,fatal:N,reason:B}),N)return}s.initTrackConfig(h,this.observer,m,D,this.audioCodec);var F;if(E.pts!==void 0)F=E.pts;else if(c){var H=s.getFrameDuration(h.samplerate);F=c.sample.pts+H}else{L.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var V=0,X;D<P;)if(X=s.appendFrame(h,m,D,F,V),D+=X.length,X.missing){this.aacOverFlow=X;break}else for(V++;D<P-1&&!s.isHeader(m,D);D++);},l.parseMPEGPES=function(h,E){var n=E.data,c=n.length,m=0,f=0,g=E.pts;if(g===void 0){L.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;f<c;)if(a.isHeader(n,f)){var y=a.appendFrame(h,n,f,g,m);if(y)f+=y.length,m++;else break}else f++},l.parseID3PES=function(h,E){if(E.pts===void 0){L.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var n=I({},E,{type:this._avcTrack?x.MetadataSchema.emsg:x.MetadataSchema.audioId3});h.samples.push(n)},T}();function A(T,l,o,h){return{key:T,frame:!1,pts:l,dts:o,units:[],debug:h,length:0}}function S(T,l){return(T[l+10]&31)<<8|T[l+11]}function v(T,l,o,h){var E={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=(T[l+1]&15)<<8|T[l+2],c=l+3+n-4,m=(T[l+10]&15)<<8|T[l+11];for(l+=12+m;l<c;){var f=(T[l+1]&31)<<8|T[l+2];switch(T[l]){case 207:if(!h){L.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:E.audio===-1&&(E.audio=f);break;case 21:E.id3===-1&&(E.id3=f);break;case 219:if(!h){L.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:E.avc===-1&&(E.avc=f);break;case 3:case 4:o.mpeg!==!0&&o.mp3!==!0?L.logger.log("MPEG audio found, not supported in this browser"):E.audio===-1&&(E.audio=f,E.segmentCodec="mp3");break;case 36:L.logger.warn("Unsupported HEVC stream type found");break;default:break}l+=((T[l+3]&15)<<8|T[l+4])+5}return E}function i(T){var l=0,o,h,E,n,c,m=T.data;if(!T||T.size===0)return null;for(;m[0].length<19&&m.length>1;){var f=new Uint8Array(m[0].length+m[1].length);f.set(m[0]),f.set(m[1],m[0].length),m[0]=f,m.splice(1,1)}o=m[0];var g=(o[0]<<16)+(o[1]<<8)+o[2];if(g===1){if(h=(o[4]<<8)+o[5],h&&h>T.size-6)return null;var y=o[7];y&192&&(n=(o[9]&14)*536870912+(o[10]&255)*4194304+(o[11]&254)*16384+(o[12]&255)*128+(o[13]&254)/2,y&64?(c=(o[14]&14)*536870912+(o[15]&255)*4194304+(o[16]&254)*16384+(o[17]&255)*128+(o[18]&254)/2,n-c>60*9e4&&(L.logger.warn(Math.round((n-c)/9e4)+"s delta between PTS and DTS, align them"),n=c)):c=n),E=o[8];var M=E+9;if(T.size<=M)return null;T.size-=M;for(var D=new Uint8Array(T.size),P=0,B=m.length;P<B;P++){o=m[P];var N=o.byteLength;if(M)if(M>N){M-=N;continue}else o=o.subarray(M),N-=M,M=0;D.set(o,l),l+=N}return h&&(h-=E+3),{data:D,pts:n,dts:c,len:h}}return null}function d(T,l){if(T.units.length&&T.frame){if(T.pts===void 0){var o=l.samples,h=o.length;if(h){var E=o[h-1];T.pts=E.pts,T.dts=E.dts}else{l.dropped++;return}}l.samples.push(T)}T.debug.length&&L.logger.log(T.pts+"/"+T.dts+":"+T.debug)}function p(T){for(var l=T.byteLength,o=[],h=1;h<l-2;)T[h]===0&&T[h+1]===0&&T[h+2]===3?(o.push(h+2),h+=2):h++;if(o.length===0)return T;var E=l-o.length,n=new Uint8Array(E),c=0;for(h=0;h<E;c++,h++)c===o[0]&&(c++,o.shift()),n[h]=T[c];return n}t.default=_},"./src/errors.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"ErrorTypes",function(){return s}),e.d(t,"ErrorDetails",function(){return a});var s;(function(u){u.NETWORK_ERROR="networkError",u.MEDIA_ERROR="mediaError",u.KEY_SYSTEM_ERROR="keySystemError",u.MUX_ERROR="muxError",u.OTHER_ERROR="otherError"})(s||(s={}));var a;(function(u){u.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",u.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",u.KEY_SYSTEM_NO_SESSION="keySystemNoSession",u.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",u.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",u.MANIFEST_LOAD_ERROR="manifestLoadError",u.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",u.MANIFEST_PARSING_ERROR="manifestParsingError",u.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",u.LEVEL_EMPTY_ERROR="levelEmptyError",u.LEVEL_LOAD_ERROR="levelLoadError",u.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",u.LEVEL_SWITCH_ERROR="levelSwitchError",u.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",u.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",u.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",u.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",u.FRAG_LOAD_ERROR="fragLoadError",u.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",u.FRAG_DECRYPT_ERROR="fragDecryptError",u.FRAG_PARSING_ERROR="fragParsingError",u.REMUX_ALLOC_ERROR="remuxAllocError",u.KEY_LOAD_ERROR="keyLoadError",u.KEY_LOAD_TIMEOUT="keyLoadTimeOut",u.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",u.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",u.BUFFER_APPEND_ERROR="bufferAppendError",u.BUFFER_APPENDING_ERROR="bufferAppendingError",u.BUFFER_STALLED_ERROR="bufferStalledError",u.BUFFER_FULL_ERROR="bufferFullError",u.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",u.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",u.INTERNAL_EXCEPTION="internalException",u.INTERNAL_ABORTED="aborted",u.UNKNOWN="unknown"})(a||(a={}))},"./src/events.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"Events",function(){return s});var s;(function(a){a.MEDIA_ATTACHING="hlsMediaAttaching",a.MEDIA_ATTACHED="hlsMediaAttached",a.MEDIA_DETACHING="hlsMediaDetaching",a.MEDIA_DETACHED="hlsMediaDetached",a.BUFFER_RESET="hlsBufferReset",a.BUFFER_CODECS="hlsBufferCodecs",a.BUFFER_CREATED="hlsBufferCreated",a.BUFFER_APPENDING="hlsBufferAppending",a.BUFFER_APPENDED="hlsBufferAppended",a.BUFFER_EOS="hlsBufferEos",a.BUFFER_FLUSHING="hlsBufferFlushing",a.BUFFER_FLUSHED="hlsBufferFlushed",a.MANIFEST_LOADING="hlsManifestLoading",a.MANIFEST_LOADED="hlsManifestLoaded",a.MANIFEST_PARSED="hlsManifestParsed",a.LEVEL_SWITCHING="hlsLevelSwitching",a.LEVEL_SWITCHED="hlsLevelSwitched",a.LEVEL_LOADING="hlsLevelLoading",a.LEVEL_LOADED="hlsLevelLoaded",a.LEVEL_UPDATED="hlsLevelUpdated",a.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",a.LEVELS_UPDATED="hlsLevelsUpdated",a.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",a.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",a.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",a.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",a.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",a.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",a.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",a.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",a.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",a.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",a.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",a.CUES_PARSED="hlsCuesParsed",a.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",a.INIT_PTS_FOUND="hlsInitPtsFound",a.FRAG_LOADING="hlsFragLoading",a.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",a.FRAG_LOADED="hlsFragLoaded",a.FRAG_DECRYPTED="hlsFragDecrypted",a.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",a.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",a.FRAG_PARSING_METADATA="hlsFragParsingMetadata",a.FRAG_PARSED="hlsFragParsed",a.FRAG_BUFFERED="hlsFragBuffered",a.FRAG_CHANGED="hlsFragChanged",a.FPS_DROP="hlsFpsDrop",a.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",a.ERROR="hlsError",a.DESTROYING="hlsDestroying",a.KEY_LOADING="hlsKeyLoading",a.KEY_LOADED="hlsKeyLoaded",a.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",a.BACK_BUFFER_REACHED="hlsBackBufferReached"})(s||(s={}))},"./src/hls.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return l});var s=e("./node_modules/url-toolkit/src/url-toolkit.js"),a=e.n(s),u=e("./src/loader/playlist-loader.ts"),R=e("./src/loader/key-loader.ts"),C=e("./src/controller/id3-track-controller.ts"),O=e("./src/controller/latency-controller.ts"),L=e("./src/controller/level-controller.ts"),b=e("./src/controller/fragment-tracker.ts"),x=e("./src/controller/stream-controller.ts"),I=e("./src/is-supported.ts"),_=e("./src/utils/logger.ts"),A=e("./src/config.ts"),S=e("./node_modules/eventemitter3/index.js"),v=e.n(S),i=e("./src/events.ts"),d=e("./src/errors.ts");function p(o,h){for(var E=0;E<h.length;E++){var n=h[E];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(o,n.key,n)}}function T(o,h,E){return h&&p(o.prototype,h),E&&p(o,E),Object.defineProperty(o,"prototype",{writable:!1}),o}var l=function(){o.isSupported=function(){return Object(I.isSupported)()};function o(E){E===void 0&&(E={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new S.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 n=this.config=Object(A.mergeConfig)(o.DefaultConfig,E);this.userConfig=E,Object(_.enableLogs)(n.debug),this._autoLevelCapping=-1,n.progressive&&Object(A.enableStreamingMode)(n);var c=n.abrController,m=n.bufferController,f=n.capLevelController,g=n.fpsController,y=this.abrController=new c(this),M=this.bufferController=new m(this),D=this.capLevelController=new f(this),P=new g(this),B=new u.default(this),N=new R.default(this),F=new C.default(this),H=this.levelController=new L.default(this),V=new b.FragmentTracker(this),X=this.streamController=new x.default(this,V);D.setStreamController(X),P.setStreamController(X);var $=[B,N,H,X];this.networkControllers=$;var j=[y,M,D,P,F,V];this.audioTrackController=this.createController(n.audioTrackController,null,$),this.createController(n.audioStreamController,V,$),this.subtitleTrackController=this.createController(n.subtitleTrackController,null,$),this.createController(n.subtitleStreamController,V,$),this.createController(n.timelineController,null,j),this.emeController=this.createController(n.emeController,null,j),this.cmcdController=this.createController(n.cmcdController,null,j),this.latencyController=this.createController(O.default,null,j),this.coreComponents=j}var h=o.prototype;return h.createController=function(n,c,m){if(n){var f=c?new n(this,c):new n(this);return m&&m.push(f),f}return null},h.on=function(n,c,m){m===void 0&&(m=this),this._emitter.on(n,c,m)},h.once=function(n,c,m){m===void 0&&(m=this),this._emitter.once(n,c,m)},h.removeAllListeners=function(n){this._emitter.removeAllListeners(n)},h.off=function(n,c,m,f){m===void 0&&(m=this),this._emitter.off(n,c,m,f)},h.listeners=function(n){return this._emitter.listeners(n)},h.emit=function(n,c,m){return this._emitter.emit(n,c,m)},h.trigger=function(n,c){if(this.config.debug)return this.emit(n,n,c);try{return this.emit(n,n,c)}catch(m){_.logger.error("An internal error happened while handling event "+n+'. Error message: "'+m.message+'". Here is a stacktrace:',m),this.trigger(i.Events.ERROR,{type:d.ErrorTypes.OTHER_ERROR,details:d.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:n,error:m})}return!1},h.listenerCount=function(n){return this._emitter.listenerCount(n)},h.destroy=function(){_.logger.log("destroy"),this.trigger(i.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(n){return n.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(n){return n.destroy()}),this.coreComponents.length=0},h.attachMedia=function(n){_.logger.log("attachMedia"),this._media=n,this.trigger(i.Events.MEDIA_ATTACHING,{media:n})},h.detachMedia=function(){_.logger.log("detachMedia"),this.trigger(i.Events.MEDIA_DETACHING,void 0),this._media=null},h.loadSource=function(n){this.stopLoad();var c=this.media,m=this.url,f=this.url=s.buildAbsoluteURL(self.location.href,n,{alwaysNormalize:!0});_.logger.log("loadSource:"+f),c&&m&&m!==f&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(c)),this.trigger(i.Events.MANIFEST_LOADING,{url:n})},h.startLoad=function(n){n===void 0&&(n=-1),_.logger.log("startLoad("+n+")"),this.networkControllers.forEach(function(c){c.startLoad(n)})},h.stopLoad=function(){_.logger.log("stopLoad"),this.networkControllers.forEach(function(n){n.stopLoad()})},h.swapAudioCodec=function(){_.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},h.recoverMediaError=function(){_.logger.log("recoverMediaError");var n=this._media;this.detachMedia(),n&&this.attachMedia(n)},h.removeLevel=function(n,c){c===void 0&&(c=0),this.levelController.removeLevel(n,c)},T(o,[{key:"levels",get:function(){var n=this.levelController.levels;return n||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(n){_.logger.log("set currentLevel:"+n),this.loadLevel=n,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(n){_.logger.log("set nextLevel:"+n),this.levelController.manualLevel=n,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(n){_.logger.log("set loadLevel:"+n),this.levelController.manualLevel=n}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(n){this.levelController.nextLoadLevel=n}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(n){_.logger.log("set firstLevel:"+n),this.levelController.firstLevel=n}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(n){_.logger.log("set startLevel:"+n),n!==-1&&(n=Math.max(n,this.minAutoLevel)),this.levelController.startLevel=n}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(n){var c=!!n;c!==this.config.capLevelToPlayerSize&&(c?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=c)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(n){this._autoLevelCapping!==n&&(_.logger.log("set autoLevelCapping:"+n),this._autoLevelCapping=n)}},{key:"bandwidthEstimate",get:function(){var n=this.abrController.bwEstimator;return n?n.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var n=this.levels,c=this.config.minAutoBitrate;if(!n)return 0;for(var m=n.length,f=0;f<m;f++)if(n[f].maxBitrate>=c)return f;return 0}},{key:"maxAutoLevel",get:function(){var n=this.levels,c=this.autoLevelCapping,m;return c===-1&&n&&n.length?m=n.length-1:m=c,m}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(n){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,n)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"audioTracks",get:function(){var n=this.audioTrackController;return n?n.audioTracks:[]}},{key:"audioTrack",get:function(){var n=this.audioTrackController;return n?n.audioTrack:-1},set:function(n){var c=this.audioTrackController;c&&(c.audioTrack=n)}},{key:"subtitleTracks",get:function(){var n=this.subtitleTrackController;return n?n.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var n=this.subtitleTrackController;return n?n.subtitleTrack:-1},set:function(n){var c=this.subtitleTrackController;c&&(c.subtitleTrack=n)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var n=this.subtitleTrackController;return n?n.subtitleDisplay:!1},set:function(n){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=n)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(n){this.config.lowLatencyMode=n}},{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 i.Events}},{key:"ErrorTypes",get:function(){return d.ErrorTypes}},{key:"ErrorDetails",get:function(){return d.ErrorDetails}},{key:"DefaultConfig",get:function(){return o.defaultConfig?o.defaultConfig:A.hlsDefaultConfig},set:function(n){o.defaultConfig=n}}]),o}();l.defaultConfig=void 0},"./src/is-supported.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"isSupported",function(){return u}),e.d(t,"changeTypeSupported",function(){return R});var s=e("./src/utils/mediasource-helper.ts");function a(){return self.SourceBuffer||self.WebKitSourceBuffer}function u(){var C=Object(s.getMediaSource)();if(!C)return!1;var O=a(),L=C&&typeof C.isTypeSupported=="function"&&C.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),b=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!L&&!!b}function R(){var C,O=a();return typeof(O==null||(C=O.prototype)===null||C===void 0?void 0:C.changeType)=="function"}},"./src/loader/date-range.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"DateRangeAttribute",function(){return L}),e.d(t,"DateRange",function(){return b});var s=e("./src/polyfills/number.ts"),a=e("./src/utils/attr-list.ts"),u=e("./src/utils/logger.ts");function R(){return R=Object.assign?Object.assign.bind():function(x){for(var I=1;I<arguments.length;I++){var _=arguments[I];for(var A in _)Object.prototype.hasOwnProperty.call(_,A)&&(x[A]=_[A])}return x},R.apply(this,arguments)}function C(x,I){for(var _=0;_<I.length;_++){var A=I[_];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(x,A.key,A)}}function O(x,I,_){return I&&C(x.prototype,I),_&&C(x,_),Object.defineProperty(x,"prototype",{writable:!1}),x}var L;(function(x){x.ID="ID",x.CLASS="CLASS",x.START_DATE="START-DATE",x.DURATION="DURATION",x.END_DATE="END-DATE",x.END_ON_NEXT="END-ON-NEXT",x.PLANNED_DURATION="PLANNED-DURATION",x.SCTE35_OUT="SCTE35-OUT",x.SCTE35_IN="SCTE35-IN"})(L||(L={}));var b=function(){function x(I,_){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,_){var A=_.attr;for(var S in A)if(Object.prototype.hasOwnProperty.call(I,S)&&I[S]!==A[S]){u.logger.warn('DATERANGE tag attribute: "'+S+'" does not match for tags with ID: "'+I.ID+'"'),this._badValueForSameId=S;break}I=R(new a.AttrList({}),A,I)}if(this.attr=I,this._startDate=new Date(I[L.START_DATE]),L.END_DATE in this.attr){var v=new Date(this.attr[L.END_DATE]);Object(s.isFiniteNumber)(v.getTime())&&(this._endDate=v)}}return O(x,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var _=this.duration;return _!==null?new Date(this._startDate.getTime()+_*1e3):null}},{key:"duration",get:function(){if(L.DURATION in this.attr){var _=this.attr.decimalFloatingPoint(L.DURATION);if(Object(s.isFiniteNumber)(_))return _}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return L.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(L.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(L.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(s.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),x}()},"./src/loader/fragment-loader.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return _}),e.d(t,"LoadError",function(){return S});var s=e("./src/polyfills/number.ts"),a=e("./src/errors.ts");function u(v,i){v.prototype=Object.create(i.prototype),v.prototype.constructor=v,b(v,i)}function R(v){var i=typeof Map=="function"?new Map:void 0;return R=function(p){if(p===null||!L(p))return p;if(typeof p!="function")throw new TypeError("Super expression must either be null or a function");if(typeof i!="undefined"){if(i.has(p))return i.get(p);i.set(p,T)}function T(){return C(p,arguments,x(this).constructor)}return T.prototype=Object.create(p.prototype,{constructor:{value:T,enumerable:!1,writable:!0,configurable:!0}}),b(T,p)},R(v)}function C(v,i,d){return O()?C=Reflect.construct.bind():C=function(T,l,o){var h=[null];h.push.apply(h,l);var E=Function.bind.apply(T,h),n=new E;return o&&b(n,o.prototype),n},C.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 L(v){return Function.toString.call(v).indexOf("[native code]")!==-1}function b(v,i){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,T){return p.__proto__=T,p},b(v,i)}function x(v){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(d){return d.__proto__||Object.getPrototypeOf(d)},x(v)}var I=Math.pow(2,17),_=function(){function v(d){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=d}var i=v.prototype;return i.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},i.abort=function(){this.loader&&this.loader.abort()},i.load=function(p,T){var l=this,o=p.url;if(!o)return Promise.reject(new S({type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:p,networkDetails:null},"Fragment does not have a "+(o?"part list":"url")));this.abort();var h=this.config,E=h.fLoader,n=h.loader;return new Promise(function(c,m){l.loader&&l.loader.destroy();var f=l.loader=p.loader=E?new E(h):new n(h),g=A(p),y={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:p.sn==="initSegment"?1/0:I};p.stats=f.stats,f.load(g,y,{onSuccess:function(D,P,B,N){l.resetLoader(p,f),c({frag:p,part:null,payload:D.data,networkDetails:N})},onError:function(D,P,B){l.resetLoader(p,f),m(new S({type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:p,response:D,networkDetails:B}))},onAbort:function(D,P,B){l.resetLoader(p,f),m(new S({type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:p,networkDetails:B}))},onTimeout:function(D,P,B){l.resetLoader(p,f),m(new S({type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:p,networkDetails:B}))},onProgress:function(D,P,B,N){T&&T({frag:p,part:null,payload:B,networkDetails:N})}})})},i.loadPart=function(p,T,l){var o=this;this.abort();var h=this.config,E=h.fLoader,n=h.loader;return new Promise(function(c,m){o.loader&&o.loader.destroy();var f=o.loader=p.loader=E?new E(h):new n(h),g=A(p,T),y={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:I};T.stats=f.stats,f.load(g,y,{onSuccess:function(D,P,B,N){o.resetLoader(p,f),o.updateStatsFromPart(p,T);var F={frag:p,part:T,payload:D.data,networkDetails:N};l(F),c(F)},onError:function(D,P,B){o.resetLoader(p,f),m(new S({type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:p,part:T,response:D,networkDetails:B}))},onAbort:function(D,P,B){p.stats.aborted=T.stats.aborted,o.resetLoader(p,f),m(new S({type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:p,part:T,networkDetails:B}))},onTimeout:function(D,P,B){o.resetLoader(p,f),m(new S({type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:p,part:T,networkDetails:B}))}})})},i.updateStatsFromPart=function(p,T){var l=p.stats,o=T.stats,h=o.total;if(l.loaded+=o.loaded,h){var E=Math.round(p.duration/T.duration),n=Math.min(Math.round(l.loaded/h),E),c=E-n,m=c*Math.round(l.loaded/n);l.total=l.loaded+m}else l.total=Math.max(l.loaded,l.total);var f=l.loading,g=o.loading;f.start?f.first+=g.first-g.start:(f.start=g.start,f.first=g.first),f.end=g.end},i.resetLoader=function(p,T){p.loader=null,this.loader===T&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),T.destroy()},v}();function A(v,i){i===void 0&&(i=null);var d=i||v,p={frag:v,part:i,responseType:"arraybuffer",url:d.url,headers:{},rangeStart:0,rangeEnd:0},T=d.byteRangeStartOffset,l=d.byteRangeEndOffset;return Object(s.isFiniteNumber)(T)&&Object(s.isFiniteNumber)(l)&&(p.rangeStart=T,p.rangeEnd=l),p}var S=function(v){u(i,v);function i(d){for(var p,T=arguments.length,l=new Array(T>1?T-1:0),o=1;o<T;o++)l[o-1]=arguments[o];return p=v.call.apply(v,[this].concat(l))||this,p.data=void 0,p.data=d,p}return i}(R(Error))},"./src/loader/fragment.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"ElementaryStreamTypes",function(){return _}),e.d(t,"BaseSegment",function(){return A}),e.d(t,"Fragment",function(){return S}),e.d(t,"Part",function(){return v});var s=e("./src/polyfills/number.ts"),a=e("./node_modules/url-toolkit/src/url-toolkit.js"),u=e.n(a),R=e("./src/utils/logger.ts"),C=e("./src/loader/level-key.ts"),O=e("./src/loader/load-stats.ts");function L(i,d){i.prototype=Object.create(d.prototype),i.prototype.constructor=i,b(i,d)}function b(i,d){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,l){return T.__proto__=l,T},b(i,d)}function x(i,d){for(var p=0;p<d.length;p++){var T=d[p];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(i,T.key,T)}}function I(i,d,p){return d&&x(i.prototype,d),p&&x(i,p),Object.defineProperty(i,"prototype",{writable:!1}),i}var _;(function(i){i.AUDIO="audio",i.VIDEO="video",i.AUDIOVIDEO="audiovideo"})(_||(_={}));var A=function(){function i(p){var T;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(T={},T[_.AUDIO]=null,T[_.VIDEO]=null,T[_.AUDIOVIDEO]=null,T),this.baseurl=p}var d=i.prototype;return d.setByteRange=function(T,l){var o=T.split("@",2),h=[];o.length===1?h[0]=l?l.byteRangeEndOffset:0:h[0]=parseInt(o[1]),h[1]=parseInt(o[0])+h[0],this._byteRange=h},I(i,[{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(a.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(T){this._url=T}}]),i}(),S=function(i){L(d,i);function d(T,l){var o;return o=i.call(this,l)||this,o._decryptdata=null,o.rawProgramDateTime=null,o.programDateTime=null,o.tagList=[],o.duration=0,o.sn=0,o.levelkey=void 0,o.type=void 0,o.loader=null,o.level=-1,o.cc=0,o.startPTS=void 0,o.endPTS=void 0,o.appendedPTS=void 0,o.startDTS=void 0,o.endDTS=void 0,o.start=0,o.deltaPTS=void 0,o.maxStartPTS=void 0,o.minEndPTS=void 0,o.stats=new O.LoadStats,o.urlId=0,o.data=void 0,o.bitrateTest=!1,o.title=null,o.initSegment=null,o.type=T,o}var p=d.prototype;return p.createInitializationVector=function(l){for(var o=new Uint8Array(16),h=12;h<16;h++)o[h]=l>>8*(15-h)&255;return o},p.setDecryptDataFromLevelKey=function(l,o){var h=l;return(l==null?void 0:l.method)==="AES-128"&&l.uri&&!l.iv&&(h=C.LevelKey.fromURI(l.uri),h.method=l.method,h.iv=this.createInitializationVector(o),h.keyFormat="identity"),h},p.setElementaryStreamInfo=function(l,o,h,E,n,c){c===void 0&&(c=!1);var m=this.elementaryStreams,f=m[l];if(!f){m[l]={startPTS:o,endPTS:h,startDTS:E,endDTS:n,partial:c};return}f.startPTS=Math.min(f.startPTS,o),f.endPTS=Math.max(f.endPTS,h),f.startDTS=Math.min(f.startDTS,E),f.endDTS=Math.max(f.endDTS,n)},p.clearElementaryStreamInfo=function(){var l=this.elementaryStreams;l[_.AUDIO]=null,l[_.VIDEO]=null,l[_.AUDIOVIDEO]=null},I(d,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var l=this.sn;typeof l!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&R.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),l=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,l)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(s.isFiniteNumber)(this.programDateTime))return null;var l=Object(s.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+l*1e3}},{key:"encrypted",get:function(){var l;return!!((l=this.decryptdata)!==null&&l!==void 0&&l.keyFormat&&this.decryptdata.uri)}}]),d}(A),v=function(i){L(d,i);function d(p,T,l,o,h){var E;E=i.call(this,l)||this,E.fragOffset=0,E.duration=0,E.gap=!1,E.independent=!1,E.relurl=void 0,E.fragment=void 0,E.index=void 0,E.stats=new O.LoadStats,E.duration=p.decimalFloatingPoint("DURATION"),E.gap=p.bool("GAP"),E.independent=p.bool("INDEPENDENT"),E.relurl=p.enumeratedString("URI"),E.fragment=T,E.index=o;var n=p.enumeratedString("BYTERANGE");return n&&E.setByteRange(n,h),h&&(E.fragOffset=h.fragOffset+h.duration),E}return I(d,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var T=this.elementaryStreams;return!!(T.audio||T.video||T.audiovideo)}}]),d}(A)},"./src/loader/key-loader.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return R});var s=e("./src/events.ts"),a=e("./src/errors.ts"),u=e("./src/utils/logger.ts"),R=function(){function C(L){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=L,this.registerListeners()}var O=C.prototype;return O.startLoad=function(b){},O.stopLoad=function(){this.destroyInternalLoaders()},O.registerListeners=function(){this.hls.on(s.Events.KEY_LOADING,this.onKeyLoading,this)},O.unregisterListeners=function(){this.hls.off(s.Events.KEY_LOADING,this.onKeyLoading)},O.destroyInternalLoaders=function(){for(var b in this.loaders){var x=this.loaders[b];x&&x.destroy()}this.loaders={}},O.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},O.onKeyLoading=function(b,x){var I=x.frag,_=I.type,A=this.loaders[_];if(!I.decryptdata){u.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var S=I.decryptdata.uri;if(S!==this.decrypturl||this.decryptkey===null){var v=this.hls.config;if(A&&(u.logger.warn("abort previous key loader for type:"+_),A.abort()),!S){u.logger.warn("key uri is falsy");return}var i=v.loader,d=I.loader=this.loaders[_]=new i(v);this.decrypturl=S,this.decryptkey=null;var p={url:S,frag:I,responseType:"arraybuffer"},T={timeout:v.fragLoadingTimeOut,maxRetry:0,retryDelay:v.fragLoadingRetryDelay,maxRetryDelay:v.fragLoadingMaxRetryTimeout,highWaterMark:0},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};d.load(p,T,l)}else this.decryptkey&&(I.decryptdata.key=this.decryptkey,this.hls.trigger(s.Events.KEY_LOADED,{frag:I}))},O.loadsuccess=function(b,x,I){var _=I.frag;if(!_.decryptdata){u.logger.error("after key load, decryptdata unset");return}this.decryptkey=_.decryptdata.key=new Uint8Array(b.data),_.loader=null,delete this.loaders[_.type],this.hls.trigger(s.Events.KEY_LOADED,{frag:_})},O.loaderror=function(b,x){var I=x.frag,_=I.loader;_&&_.abort(),delete this.loaders[I.type],this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:I,response:b})},O.loadtimeout=function(b,x){var I=x.frag,_=I.loader;_&&_.abort(),delete this.loaders[I.type],this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:I})},C}()},"./src/loader/level-details.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"LevelDetails",function(){return C});var s=e("./src/polyfills/number.ts");function a(O,L){for(var b=0;b<L.length;b++){var x=L[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(O,x.key,x)}}function u(O,L,b){return L&&a(O.prototype,L),b&&a(O,b),Object.defineProperty(O,"prototype",{writable:!1}),O}var R=10,C=function(){function O(b){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=b}var L=O.prototype;return L.reloaded=function(x){if(!x){this.advanced=!0,this.updated=!0;return}var I=this.lastPartSn-x.lastPartSn,_=this.lastPartIndex-x.lastPartIndex;this.updated=this.endSN!==x.endSN||!!_||!!I,this.advanced=this.endSN>x.endSN||I>0||I===0&&_>0,this.updated||this.advanced?this.misses=Math.floor(x.misses*.6):this.misses=x.misses+1,this.availabilityDelay=x.availabilityDelay},u(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(s.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||R}},{key:"drift",get:function(){var x=this.driftEndTime-this.driftStartTime;if(x>0){var I=this.driftEnd-this.driftStart;return I*1e3/x}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var x;return(x=this.fragments)!==null&&x!==void 0&&x.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),O}()},"./src/loader/level-key.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"LevelKey",function(){return C});var s=e("./node_modules/url-toolkit/src/url-toolkit.js"),a=e.n(s);function u(O,L){for(var b=0;b<L.length;b++){var x=L[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(O,x.key,x)}}function R(O,L,b){return L&&u(O.prototype,L),b&&u(O,b),Object.defineProperty(O,"prototype",{writable:!1}),O}var C=function(){O.fromURL=function(b,x){return new O(b,x)},O.fromURI=function(b){return new O(b)};function O(L,b){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,b?this._uri=Object(s.buildAbsoluteURL)(L,b,{alwaysNormalize:!0}):this._uri=L}return R(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"LoadStats",function(){return s});var s=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(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return p});var s=e("./src/polyfills/number.ts"),a=e("./node_modules/url-toolkit/src/url-toolkit.js"),u=e.n(a),R=e("./src/loader/date-range.ts"),C=e("./src/loader/fragment.ts"),O=e("./src/loader/level-details.ts"),L=e("./src/loader/level-key.ts"),b=e("./src/utils/attr-list.ts"),x=e("./src/utils/logger.ts"),I=e("./src/utils/codecs.ts"),_=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,A=/#EXT-X-MEDIA:(.*)/g,S=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),v=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("|")),i=/\.(mp4|m4s|m4v|m4a)$/i;function d(n){var c,m;return i.test((c=(m=a.parseURL(n))===null||m===void 0?void 0:m.path)!=null?c:"")}var p=function(){function n(){}return n.findGroup=function(m,f){for(var g=0;g<m.length;g++){var y=m[g];if(y.id===f)return y}},n.convertAVC1ToAVCOTI=function(m){var f=m.split(".");if(f.length>2){var g=f.shift()+".";return g+=parseInt(f.shift()).toString(16),g+=("000"+parseInt(f.shift()).toString(16)).slice(-4),g}return m},n.resolve=function(m,f){return a.buildAbsoluteURL(f,m,{alwaysNormalize:!0})},n.parseMasterPlaylist=function(m,f){var g=[],y={},M=!1;_.lastIndex=0;for(var D;(D=_.exec(m))!=null;)if(D[1]){var P=new b.AttrList(D[1]),B={attrs:P,bitrate:P.decimalInteger("AVERAGE-BANDWIDTH")||P.decimalInteger("BANDWIDTH"),name:P.NAME,url:n.resolve(D[2],f)},N=P.decimalResolution("RESOLUTION");N&&(B.width=N.width,B.height=N.height),T((P.CODECS||"").split(/[ ,]+/).filter(function(H){return H}),B),B.videoCodec&&B.videoCodec.indexOf("avc1")!==-1&&(B.videoCodec=n.convertAVC1ToAVCOTI(B.videoCodec)),g.push(B)}else if(D[3]){var F=new b.AttrList(D[3]);F["DATA-ID"]&&(M=!0,y[F["DATA-ID"]]=F)}return{levels:g,sessionData:M?y:null}},n.parseMasterPlaylistMedia=function(m,f,g,y){y===void 0&&(y=[]);var M,D=[],P=0;for(A.lastIndex=0;(M=A.exec(m))!==null;){var B=new b.AttrList(M[1]);if(B.TYPE===g){var N={attrs:B,bitrate:0,id:P++,groupId:B["GROUP-ID"],instreamId:B["INSTREAM-ID"],name:B.NAME||B.LANGUAGE||"",type:g,default:B.bool("DEFAULT"),autoselect:B.bool("AUTOSELECT"),forced:B.bool("FORCED"),lang:B.LANGUAGE,url:B.URI?n.resolve(B.URI,f):""};if(y.length){var F=n.findGroup(y,N.groupId)||y[0];l(N,F,"audioCodec"),l(N,F,"textCodec")}D.push(N)}}return D},n.parseLevelPlaylist=function(m,f,g,y,M){var D=new O.LevelDetails(f),P=D.fragments,B=null,N=0,F=0,H=0,V=0,X=null,$=new C.Fragment(y,f),j,J,ee,te=-1,se=!1;for(S.lastIndex=0,D.m3u8=m;(j=S.exec(m))!==null;){se&&(se=!1,$=new C.Fragment(y,f),$.start=H,$.sn=N,$.cc=V,$.level=g,B&&($.initSegment=B,$.rawProgramDateTime=B.rawProgramDateTime,B.rawProgramDateTime=null));var ue=j[1];if(ue){$.duration=parseFloat(ue);var ie=(" "+j[2]).slice(1);$.title=ie||null,$.tagList.push(ie?["INF",ue,ie]:["INF",ue])}else if(j[3])Object(s.isFiniteNumber)($.duration)&&($.start=H,ee&&($.levelkey=ee),$.sn=N,$.level=g,$.cc=V,$.urlId=M,P.push($),$.relurl=(" "+j[3]).slice(1),h($,X),X=$,H+=$.duration,N++,F=0,se=!0);else if(j[4]){var he=(" "+j[4]).slice(1);X?$.setByteRange(he,X):$.setByteRange(he)}else if(j[5])$.rawProgramDateTime=(" "+j[5]).slice(1),$.tagList.push(["PROGRAM-DATE-TIME",$.rawProgramDateTime]),te===-1&&(te=P.length);else{if(j=j[0].match(v),!j){x.logger.warn("No matches on slow regex match for level playlist!");continue}for(J=1;J<j.length&&typeof j[J]=="undefined";J++);var me=(" "+j[J]).slice(1),ne=(" "+j[J+1]).slice(1),Re=j[J+2]?(" "+j[J+2]).slice(1):"";switch(me){case"PLAYLIST-TYPE":D.type=ne.toUpperCase();break;case"MEDIA-SEQUENCE":N=D.startSN=parseInt(ne);break;case"SKIP":{var Le=new b.AttrList(ne),De=Le.decimalInteger("SKIPPED-SEGMENTS");if(Object(s.isFiniteNumber)(De)){D.skippedSegments=De;for(var _e=De;_e--;)P.unshift(null);N+=De}var ke=Le.enumeratedString("RECENTLY-REMOVED-DATERANGES");ke&&(D.recentlyRemovedDateranges=ke.split(" "));break}case"TARGETDURATION":D.targetduration=parseFloat(ne);break;case"VERSION":D.version=parseInt(ne);break;case"EXTM3U":break;case"ENDLIST":D.live=!1;break;case"#":(ne||Re)&&$.tagList.push(Re?[ne,Re]:[ne]);break;case"DISCONTINUITY":V++,$.tagList.push(["DIS"]);break;case"GAP":$.tagList.push([me]);break;case"BITRATE":$.tagList.push([me,ne]);break;case"DATERANGE":{var Qe=new b.AttrList(ne),He=new R.DateRange(Qe,D.dateRanges[Qe.ID]);He.isValid||D.skippedSegments?D.dateRanges[He.id]=He:x.logger.warn('Ignoring invalid DATERANGE tag: "'+ne+'"'),$.tagList.push(["EXT-X-DATERANGE",ne]);break}case"DISCONTINUITY-SEQUENCE":V=parseInt(ne);break;case"KEY":{var qe,Ke=new b.AttrList(ne),st=Ke.enumeratedString("METHOD"),dt=Ke.URI,ct=Ke.hexadecimalInteger("IV"),ot=Ke.enumeratedString("KEYFORMATVERSIONS"),Dt=Ke.enumeratedString("KEYID"),et=(qe=Ke.enumeratedString("KEYFORMAT"))!=null?qe:"identity",It=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(It.indexOf(et)>-1){x.logger.warn("Keyformat "+et+" is not supported from the manifest");continue}else if(et!=="identity")continue;st&&(ee=L.LevelKey.fromURL(f,dt),dt&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(st)>=0&&(ee.method=st,ee.keyFormat=et,Dt&&(ee.keyID=Dt),ot&&(ee.keyFormatVersions=ot),ee.iv=ct));break}case"START":{var $e=new b.AttrList(ne),Ze=$e.decimalFloatingPoint("TIME-OFFSET");Object(s.isFiniteNumber)(Ze)&&(D.startTimeOffset=Ze);break}case"MAP":{var Et=new b.AttrList(ne);if($.duration){var Je=new C.Fragment(y,f);E(Je,Et,g,ee),B=Je,$.initSegment=B,B.rawProgramDateTime&&!$.rawProgramDateTime&&($.rawProgramDateTime=B.rawProgramDateTime)}else E($,Et,g,ee),B=$,se=!0;break}case"SERVER-CONTROL":{var Ge=new b.AttrList(ne);D.canBlockReload=Ge.bool("CAN-BLOCK-RELOAD"),D.canSkipUntil=Ge.optionalFloat("CAN-SKIP-UNTIL",0),D.canSkipDateRanges=D.canSkipUntil>0&&Ge.bool("CAN-SKIP-DATERANGES"),D.partHoldBack=Ge.optionalFloat("PART-HOLD-BACK",0),D.holdBack=Ge.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Pt=new b.AttrList(ne);D.partTarget=Pt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var ft=D.partList;ft||(ft=D.partList=[]);var Wt=F>0?ft[ft.length-1]:void 0,pr=F++,At=new C.Part(new b.AttrList(ne),$,f,pr,Wt);ft.push(At),$.duration+=At.duration;break}case"PRELOAD-HINT":{var Br=new b.AttrList(ne);D.preloadHint=Br;break}case"RENDITION-REPORT":{var Er=new b.AttrList(ne);D.renditionReports=D.renditionReports||[],D.renditionReports.push(Er);break}default:x.logger.warn("line parsed but not handled: "+j);break}}}X&&!X.relurl?(P.pop(),H-=X.duration,D.partList&&(D.fragmentHint=X)):D.partList&&(h($,X),$.cc=V,D.fragmentHint=$);var kt=P.length,Ht=P[0],wt=P[kt-1];if(H+=D.skippedSegments*D.targetduration,H>0&&kt&&wt){D.averagetargetduration=H/kt;var yr=wt.sn;D.endSN=yr!=="initSegment"?yr:0,Ht&&(D.startCC=Ht.cc,Ht.initSegment||D.fragments.every(function(ur){return ur.relurl&&d(ur.relurl)})&&(x.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),$=new C.Fragment(y,f),$.relurl=wt.relurl,$.level=g,$.sn="initSegment",Ht.initSegment=$,D.needSidxRanges=!0))}else D.endSN=0,D.startCC=0;return D.fragmentHint&&(H+=D.fragmentHint.duration),D.totalduration=H,D.endCC=V,te>0&&o(P,te),D},n}();function T(n,c){["video","audio","text"].forEach(function(m){var f=n.filter(function(y){return Object(I.isCodecType)(y,m)});if(f.length){var g=f.filter(function(y){return y.lastIndexOf("avc1",0)===0||y.lastIndexOf("mp4a",0)===0});c[m+"Codec"]=g.length>0?g[0]:f[0],n=n.filter(function(y){return f.indexOf(y)===-1})}}),c.unknownCodecs=n}function l(n,c,m){var f=c[m];f&&(n[m]=f)}function o(n,c){for(var m=n[c],f=c;f--;){var g=n[f];if(!g)return;g.programDateTime=m.programDateTime-g.duration*1e3,m=g}}function h(n,c){n.rawProgramDateTime?n.programDateTime=Date.parse(n.rawProgramDateTime):c!=null&&c.programDateTime&&(n.programDateTime=c.endProgramDateTime),Object(s.isFiniteNumber)(n.programDateTime)||(n.programDateTime=null,n.rawProgramDateTime=null)}function E(n,c,m,f){n.relurl=c.URI,c.BYTERANGE&&n.setByteRange(c.BYTERANGE),n.level=m,n.sn="initSegment",f&&(n.levelkey=f),n.initSegment=null}},"./src/loader/playlist-loader.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/polyfills/number.ts"),a=e("./src/events.ts"),u=e("./src/errors.ts"),R=e("./src/utils/logger.ts"),C=e("./src/utils/mp4-tools.ts"),O=e("./src/loader/m3u8-parser.ts"),L=e("./src/types/loader.ts"),b=e("./src/utils/attr-list.ts");function x(A){var S=A.type;switch(S){case L.PlaylistContextType.AUDIO_TRACK:return L.PlaylistLevelType.AUDIO;case L.PlaylistContextType.SUBTITLE_TRACK:return L.PlaylistLevelType.SUBTITLE;default:return L.PlaylistLevelType.MAIN}}function I(A,S){var v=A.url;return(v===void 0||v.indexOf("data:")===0)&&(v=S.url),v}var _=function(){function A(v){this.hls=void 0,this.loaders=Object.create(null),this.hls=v,this.registerListeners()}var S=A.prototype;return S.startLoad=function(i){},S.stopLoad=function(){this.destroyInternalLoaders()},S.registerListeners=function(){var i=this.hls;i.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.on(a.Events.LEVEL_LOADING,this.onLevelLoading,this),i.on(a.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),i.on(a.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},S.unregisterListeners=function(){var i=this.hls;i.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.off(a.Events.LEVEL_LOADING,this.onLevelLoading,this),i.off(a.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),i.off(a.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},S.createInternalLoader=function(i){var d=this.hls.config,p=d.pLoader,T=d.loader,l=p||T,o=new l(d);return i.loader=o,this.loaders[i.type]=o,o},S.getInternalLoader=function(i){return this.loaders[i.type]},S.resetInternalLoader=function(i){this.loaders[i]&&delete this.loaders[i]},S.destroyInternalLoaders=function(){for(var i in this.loaders){var d=this.loaders[i];d&&d.destroy(),this.resetInternalLoader(i)}},S.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},S.onManifestLoading=function(i,d){var p=d.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:L.PlaylistContextType.MANIFEST,url:p,deliveryDirectives:null})},S.onLevelLoading=function(i,d){var p=d.id,T=d.level,l=d.url,o=d.deliveryDirectives;this.load({id:p,groupId:null,level:T,responseType:"text",type:L.PlaylistContextType.LEVEL,url:l,deliveryDirectives:o})},S.onAudioTrackLoading=function(i,d){var p=d.id,T=d.groupId,l=d.url,o=d.deliveryDirectives;this.load({id:p,groupId:T,level:null,responseType:"text",type:L.PlaylistContextType.AUDIO_TRACK,url:l,deliveryDirectives:o})},S.onSubtitleTrackLoading=function(i,d){var p=d.id,T=d.groupId,l=d.url,o=d.deliveryDirectives;this.load({id:p,groupId:T,level:null,responseType:"text",type:L.PlaylistContextType.SUBTITLE_TRACK,url:l,deliveryDirectives:o})},S.load=function(i){var d,p=this.hls.config,T=this.getInternalLoader(i);if(T){var l=T.context;if(l&&l.url===i.url){R.logger.trace("[playlist-loader]: playlist request ongoing");return}R.logger.log("[playlist-loader]: aborting previous loader for type: "+i.type),T.abort()}var o,h,E,n;switch(i.type){case L.PlaylistContextType.MANIFEST:o=p.manifestLoadingMaxRetry,h=p.manifestLoadingTimeOut,E=p.manifestLoadingRetryDelay,n=p.manifestLoadingMaxRetryTimeout;break;case L.PlaylistContextType.LEVEL:case L.PlaylistContextType.AUDIO_TRACK:case L.PlaylistContextType.SUBTITLE_TRACK:o=0,h=p.levelLoadingTimeOut;break;default:o=p.levelLoadingMaxRetry,h=p.levelLoadingTimeOut,E=p.levelLoadingRetryDelay,n=p.levelLoadingMaxRetryTimeout;break}if(T=this.createInternalLoader(i),(d=i.deliveryDirectives)!==null&&d!==void 0&&d.part){var c;if(i.type===L.PlaylistContextType.LEVEL&&i.level!==null?c=this.hls.levels[i.level].details:i.type===L.PlaylistContextType.AUDIO_TRACK&&i.id!==null?c=this.hls.audioTracks[i.id].details:i.type===L.PlaylistContextType.SUBTITLE_TRACK&&i.id!==null&&(c=this.hls.subtitleTracks[i.id].details),c){var m=c.partTarget,f=c.targetduration;m&&f&&(h=Math.min(Math.max(m*3,f*.8)*1e3,h))}}var g={timeout:h,maxRetry:o,retryDelay:E,maxRetryDelay:n,highWaterMark:0},y={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};T.load(i,g,y)},S.loadsuccess=function(i,d,p,T){if(T===void 0&&(T=null),p.isSidxRequest){this.handleSidxRequest(i,p),this.handlePlaylistLoaded(i,d,p,T);return}this.resetInternalLoader(p.type);var l=i.data;if(l.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(i,p,"no EXTM3U delimiter",T);return}d.parsing.start=performance.now(),l.indexOf("#EXTINF:")>0||l.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(i,d,p,T):this.handleMasterPlaylist(i,d,p,T)},S.loaderror=function(i,d,p){p===void 0&&(p=null),this.handleNetworkError(d,p,!1,i)},S.loadtimeout=function(i,d,p){p===void 0&&(p=null),this.handleNetworkError(d,p,!0)},S.handleMasterPlaylist=function(i,d,p,T){var l=this.hls,o=i.data,h=I(i,p),E=O.default.parseMasterPlaylist(o,h),n=E.levels,c=E.sessionData;if(!n.length){this.handleManifestParsingError(i,p,"no level found in manifest",T);return}var m=n.map(function(P){return{id:P.attrs.AUDIO,audioCodec:P.audioCodec}}),f=n.map(function(P){return{id:P.attrs.SUBTITLES,textCodec:P.textCodec}}),g=O.default.parseMasterPlaylistMedia(o,h,"AUDIO",m),y=O.default.parseMasterPlaylistMedia(o,h,"SUBTITLES",f),M=O.default.parseMasterPlaylistMedia(o,h,"CLOSED-CAPTIONS");if(g.length){var D=g.some(function(P){return!P.url});!D&&n[0].audioCodec&&!n[0].attrs.AUDIO&&(R.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new b.AttrList({}),bitrate:0,url:""}))}l.trigger(a.Events.MANIFEST_LOADED,{levels:n,audioTracks:g,subtitles:y,captions:M,url:h,stats:d,networkDetails:T,sessionData:c})},S.handleTrackOrLevelPlaylist=function(i,d,p,T){var l=this.hls,o=p.id,h=p.level,E=p.type,n=I(i,p),c=Object(s.isFiniteNumber)(o)?o:0,m=Object(s.isFiniteNumber)(h)?h:c,f=x(p),g=O.default.parseLevelPlaylist(i.data,n,m,f,c);if(!g.fragments.length){l.trigger(a.Events.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:u.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:n,reason:"no fragments found in level",level:typeof p.level=="number"?p.level:void 0});return}if(E===L.PlaylistContextType.MANIFEST){var y={attrs:new b.AttrList({}),bitrate:0,details:g,name:"",url:n};l.trigger(a.Events.MANIFEST_LOADED,{levels:[y],audioTracks:[],url:n,stats:d,networkDetails:T,sessionData:null})}if(d.parsing.end=performance.now(),g.needSidxRanges){var M,D=(M=g.fragments[0].initSegment)===null||M===void 0?void 0:M.url;this.load({url:D,isSidxRequest:!0,type:E,level:h,levelDetails:g,id:o,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}p.levelDetails=g,this.handlePlaylistLoaded(i,d,p,T)},S.handleSidxRequest=function(i,d){var p=new Uint8Array(i.data),T=Object(C.findBox)(p,["sidx"])[0];if(!!T){var l=Object(C.parseSegmentIndex)(T);if(!!l){var o=l.references,h=d.levelDetails;o.forEach(function(E,n){var c=E.info,m=h.fragments[n];if(m.byteRange.length===0&&m.setByteRange(String(1+c.end-c.start)+"@"+String(c.start)),m.initSegment){var f=Object(C.findBox)(p,["moov"])[0],g=f?f.length:null;m.initSegment.setByteRange(String(g)+"@0")}})}}},S.handleManifestParsingError=function(i,d,p,T){this.hls.trigger(a.Events.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:u.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:d.type===L.PlaylistContextType.MANIFEST,url:i.url,reason:p,response:i,context:d,networkDetails:T})},S.handleNetworkError=function(i,d,p,T){p===void 0&&(p=!1),R.logger.warn("[playlist-loader]: A network "+(p?"timeout":"error")+" occurred while loading "+i.type+" level: "+i.level+" id: "+i.id+' group-id: "'+i.groupId+'"');var l=u.ErrorDetails.UNKNOWN,o=!1,h=this.getInternalLoader(i);switch(i.type){case L.PlaylistContextType.MANIFEST:l=p?u.ErrorDetails.MANIFEST_LOAD_TIMEOUT:u.ErrorDetails.MANIFEST_LOAD_ERROR,o=!0;break;case L.PlaylistContextType.LEVEL:l=p?u.ErrorDetails.LEVEL_LOAD_TIMEOUT:u.ErrorDetails.LEVEL_LOAD_ERROR,o=!1;break;case L.PlaylistContextType.AUDIO_TRACK:l=p?u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,o=!1;break;case L.PlaylistContextType.SUBTITLE_TRACK:l=p?u.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:u.ErrorDetails.SUBTITLE_LOAD_ERROR,o=!1;break}h&&this.resetInternalLoader(i.type);var E={type:u.ErrorTypes.NETWORK_ERROR,details:l,fatal:o,url:i.url,loader:h,context:i,networkDetails:d};T&&(E.response=T),this.hls.trigger(a.Events.ERROR,E)},S.handlePlaylistLoaded=function(i,d,p,T){var l=p.type,o=p.level,h=p.id,E=p.groupId,n=p.loader,c=p.levelDetails,m=p.deliveryDirectives;if(!(c!=null&&c.targetduration)){this.handleManifestParsingError(i,p,"invalid target duration",T);return}if(!!n)switch(c.live&&(n.getCacheAge&&(c.ageHeader=n.getCacheAge()||0),(!n.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0)),l){case L.PlaylistContextType.MANIFEST:case L.PlaylistContextType.LEVEL:this.hls.trigger(a.Events.LEVEL_LOADED,{details:c,level:o||0,id:h||0,stats:d,networkDetails:T,deliveryDirectives:m});break;case L.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(a.Events.AUDIO_TRACK_LOADED,{details:c,id:h||0,groupId:E||"",stats:d,networkDetails:T,deliveryDirectives:m});break;case L.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(a.Events.SUBTITLE_TRACK_LOADED,{details:c,id:h||0,groupId:E||"",stats:d,networkDetails:T,deliveryDirectives:m});break}},A}();t.default=_},"./src/polyfills/number.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"isFiniteNumber",function(){return s}),e.d(t,"MAX_SAFE_INTEGER",function(){return a});var s=Number.isFinite||function(u){return typeof u=="number"&&isFinite(u)},a=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(r,t,e){"use strict";e.r(t);var s=function(){function a(){}return a.getSilentFrame=function(R,C){switch(R){case"mp4a.40.2":if(C===1)return new Uint8Array([0,200,0,128,35,128]);if(C===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(C===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(C===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(C===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(C===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(C===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(C===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(C===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}},a}();t.default=s},"./src/remux/mp4-generator.ts":function(r,t,e){"use strict";e.r(t);var s=Math.pow(2,32)-1,a=function(){function u(){}return u.init=function(){u.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 C;for(C in u.types)u.types.hasOwnProperty(C)&&(u.types[C]=[C.charCodeAt(0),C.charCodeAt(1),C.charCodeAt(2),C.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]),L=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]);u.HDLR_TYPES={video:O,audio:L};var b=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]);u.STTS=u.STSC=u.STCO=x,u.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),u.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),u.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),u.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var I=new Uint8Array([105,115,111,109]),_=new Uint8Array([97,118,99,49]),A=new Uint8Array([0,0,0,1]);u.FTYP=u.box(u.types.ftyp,I,A,I,_),u.DINF=u.box(u.types.dinf,u.box(u.types.dref,b))},u.box=function(C){for(var O=8,L=arguments.length,b=new Array(L>1?L-1:0),x=1;x<L;x++)b[x-1]=arguments[x];for(var I=b.length,_=I;I--;)O+=b[I].byteLength;var A=new Uint8Array(O);for(A[0]=O>>24&255,A[1]=O>>16&255,A[2]=O>>8&255,A[3]=O&255,A.set(C,4),I=0,O=8;I<_;I++)A.set(b[I],O),O+=b[I].byteLength;return A},u.hdlr=function(C){return u.box(u.types.hdlr,u.HDLR_TYPES[C])},u.mdat=function(C){return u.box(u.types.mdat,C)},u.mdhd=function(C,O){O*=C;var L=Math.floor(O/(s+1)),b=Math.floor(O%(s+1));return u.box(u.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,C>>24&255,C>>16&255,C>>8&255,C&255,L>>24,L>>16&255,L>>8&255,L&255,b>>24,b>>16&255,b>>8&255,b&255,85,196,0,0]))},u.mdia=function(C){return u.box(u.types.mdia,u.mdhd(C.timescale,C.duration),u.hdlr(C.type),u.minf(C))},u.mfhd=function(C){return u.box(u.types.mfhd,new Uint8Array([0,0,0,0,C>>24,C>>16&255,C>>8&255,C&255]))},u.minf=function(C){return C.type==="audio"?u.box(u.types.minf,u.box(u.types.smhd,u.SMHD),u.DINF,u.stbl(C)):u.box(u.types.minf,u.box(u.types.vmhd,u.VMHD),u.DINF,u.stbl(C))},u.moof=function(C,O,L){return u.box(u.types.moof,u.mfhd(C),u.traf(L,O))},u.moov=function(C){for(var O=C.length,L=[];O--;)L[O]=u.trak(C[O]);return u.box.apply(null,[u.types.moov,u.mvhd(C[0].timescale,C[0].duration)].concat(L).concat(u.mvex(C)))},u.mvex=function(C){for(var O=C.length,L=[];O--;)L[O]=u.trex(C[O]);return u.box.apply(null,[u.types.mvex].concat(L))},u.mvhd=function(C,O){O*=C;var L=Math.floor(O/(s+1)),b=Math.floor(O%(s+1)),x=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,C>>24&255,C>>16&255,C>>8&255,C&255,L>>24,L>>16&255,L>>8&255,L&255,b>>24,b>>16&255,b>>8&255,b&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 u.box(u.types.mvhd,x)},u.sdtp=function(C){var O=C.samples||[],L=new Uint8Array(4+O.length),b,x;for(b=0;b<O.length;b++)x=O[b].flags,L[b+4]=x.dependsOn<<4|x.isDependedOn<<2|x.hasRedundancy;return u.box(u.types.sdtp,L)},u.stbl=function(C){return u.box(u.types.stbl,u.stsd(C),u.box(u.types.stts,u.STTS),u.box(u.types.stsc,u.STSC),u.box(u.types.stsz,u.STSZ),u.box(u.types.stco,u.STCO))},u.avc1=function(C){var O=[],L=[],b,x,I;for(b=0;b<C.sps.length;b++)x=C.sps[b],I=x.byteLength,O.push(I>>>8&255),O.push(I&255),O=O.concat(Array.prototype.slice.call(x));for(b=0;b<C.pps.length;b++)x=C.pps[b],I=x.byteLength,L.push(I>>>8&255),L.push(I&255),L=L.concat(Array.prototype.slice.call(x));var _=u.box(u.types.avcC,new Uint8Array([1,O[3],O[4],O[5],255,224|C.sps.length].concat(O).concat([C.pps.length]).concat(L))),A=C.width,S=C.height,v=C.pixelRatio[0],i=C.pixelRatio[1];return u.box(u.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,A>>8&255,A&255,S>>8&255,S&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]),_,u.box(u.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),u.box(u.types.pasp,new Uint8Array([v>>24,v>>16&255,v>>8&255,v&255,i>>24,i>>16&255,i>>8&255,i&255])))},u.esds=function(C){var O=C.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(C.config).concat([6,1,2]))},u.mp4a=function(C){var O=C.samplerate;return u.box(u.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,C.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),u.box(u.types.esds,u.esds(C)))},u.mp3=function(C){var O=C.samplerate;return u.box(u.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,C.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},u.stsd=function(C){return C.type==="audio"?C.segmentCodec==="mp3"&&C.codec==="mp3"?u.box(u.types.stsd,u.STSD,u.mp3(C)):u.box(u.types.stsd,u.STSD,u.mp4a(C)):u.box(u.types.stsd,u.STSD,u.avc1(C))},u.tkhd=function(C){var O=C.id,L=C.duration*C.timescale,b=C.width,x=C.height,I=Math.floor(L/(s+1)),_=Math.floor(L%(s+1));return u.box(u.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,I>>24,I>>16&255,I>>8&255,I&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,b>>8&255,b&255,0,0,x>>8&255,x&255,0,0]))},u.traf=function(C,O){var L=u.sdtp(C),b=C.id,x=Math.floor(O/(s+1)),I=Math.floor(O%(s+1));return u.box(u.types.traf,u.box(u.types.tfhd,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255])),u.box(u.types.tfdt,new Uint8Array([1,0,0,0,x>>24,x>>16&255,x>>8&255,x&255,I>>24,I>>16&255,I>>8&255,I&255])),u.trun(C,L.length+16+20+8+16+8+8),L)},u.trak=function(C){return C.duration=C.duration||4294967295,u.box(u.types.trak,u.tkhd(C),u.mdia(C))},u.trex=function(C){var O=C.id;return u.box(u.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]))},u.trun=function(C,O){var L=C.samples||[],b=L.length,x=12+16*b,I=new Uint8Array(x),_,A,S,v,i,d;for(O+=8+x,I.set([C.type==="video"?1:0,0,15,1,b>>>24&255,b>>>16&255,b>>>8&255,b&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),_=0;_<b;_++)A=L[_],S=A.duration,v=A.size,i=A.flags,d=A.cts,I.set([S>>>24&255,S>>>16&255,S>>>8&255,S&255,v>>>24&255,v>>>16&255,v>>>8&255,v&255,i.isLeading<<2|i.dependsOn,i.isDependedOn<<6|i.hasRedundancy<<4|i.paddingValue<<1|i.isNonSync,i.degradPrio&240<<8,i.degradPrio&15,d>>>24&255,d>>>16&255,d>>>8&255,d&255],12+16*_);return u.box(u.types.trun,I)},u.initSegment=function(C){u.types||u.init();var O=u.moov(C),L=new Uint8Array(u.FTYP.byteLength+O.byteLength);return L.set(u.FTYP),L.set(O,u.FTYP.byteLength),L},u}();a.types=void 0,a.HDLR_TYPES=void 0,a.STTS=void 0,a.STSC=void 0,a.STCO=void 0,a.STSZ=void 0,a.VMHD=void 0,a.SMHD=void 0,a.STSD=void 0,a.FTYP=void 0,a.DINF=void 0,t.default=a},"./src/remux/mp4-remuxer.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return i}),e.d(t,"normalizePts",function(){return d}),e.d(t,"flushTextTrackMetadataCueSamples",function(){return T}),e.d(t,"flushTextTrackUserdataCueSamples",function(){return l});var s=e("./src/polyfills/number.ts"),a=e("./src/remux/aac-helper.ts"),u=e("./src/remux/mp4-generator.ts"),R=e("./src/events.ts"),C=e("./src/errors.ts"),O=e("./src/utils/logger.ts"),L=e("./src/types/loader.ts"),b=e("./src/utils/timescale-conversion.ts");function x(){return x=Object.assign?Object.assign.bind():function(E){for(var n=1;n<arguments.length;n++){var c=arguments[n];for(var m in c)Object.prototype.hasOwnProperty.call(c,m)&&(E[m]=c[m])}return E},x.apply(this,arguments)}var I=10*1e3,_=1024,A=1152,S=null,v=null,i=function(){function E(c,m,f,g){if(g===void 0&&(g=""),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=c,this.config=m,this.typeSupported=f,this.ISGenerated=!1,S===null){var y=navigator.userAgent||"",M=y.match(/Chrome\/(\d+)/i);S=M?parseInt(M[1]):0}if(v===null){var D=navigator.userAgent.match(/Safari\/(\d+)/i);v=D?parseInt(D[1]):0}}var n=E.prototype;return n.destroy=function(){},n.resetTimeStamp=function(m){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=m},n.resetNextTimestamp=function(){O.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},n.resetInitSegment=function(){O.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},n.getVideoStartPts=function(m){var f=!1,g=m.reduce(function(y,M){var D=M.pts-y;return D<-4294967296?(f=!0,d(y,M.pts)):D>0?y:M.pts},m[0].pts);return f&&O.logger.debug("PTS rollover detected"),g},n.remux=function(m,f,g,y,M,D,P,B){var N,F,H,V,X,$,j=M,J=M,ee=m.pid>-1,te=f.pid>-1,se=f.samples.length,ue=m.samples.length>0,ie=P&&se>0||se>1,he=(!ee||ue)&&(!te||ie)||this.ISGenerated||P;if(he){this.ISGenerated||(H=this.generateIS(m,f,M));var me=this.isVideoContiguous,ne=-1,Re;if(ie&&(ne=p(f.samples),!me&&this.config.forceKeyFrameOnDiscontinuity))if($=!0,ne>0){O.logger.warn("[mp4-remuxer]: Dropped "+ne+" out of "+se+" video samples due to a missing keyframe");var Le=this.getVideoStartPts(f.samples);f.samples=f.samples.slice(ne),f.dropped+=ne,J+=(f.samples[0].pts-Le)/f.inputTimeScale,Re=J}else ne===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+se+" video samples"),$=!1);if(this.ISGenerated){if(ue&&ie){var De=this.getVideoStartPts(f.samples),_e=d(m.samples[0].pts,De)-De,ke=_e/f.inputTimeScale;j+=Math.max(0,ke),J+=Math.max(0,-ke)}if(ue){if(m.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),H=this.generateIS(m,f,M)),F=this.remuxAudio(m,j,this.isAudioContiguous,D,te||ie||B===L.PlaylistLevelType.AUDIO?J:void 0),ie){var Qe=F?F.endPTS-F.startPTS:0;f.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),H=this.generateIS(m,f,M)),N=this.remuxVideo(f,J,me,Qe)}}else ie&&(N=this.remuxVideo(f,J,me,0));N&&(N.firstKeyFrame=ne,N.independent=ne!==-1,N.firstKeyFramePTS=Re)}}return this.ISGenerated&&(g.samples.length&&(X=T(g,M,this._initPTS,this._initDTS)),y.samples.length&&(V=l(y,M,this._initPTS))),{audio:F,video:N,initSegment:H,independent:$,text:V,id3:X}},n.generateIS=function(m,f,g){var y=m.samples,M=f.samples,D=this.typeSupported,P={},B=!Object(s.isFiniteNumber)(this._initPTS),N="audio/mp4",F,H,V;if(B&&(F=H=1/0),m.config&&y.length){switch(m.timescale=m.samplerate,m.segmentCodec){case"mp3":D.mpeg?(N="audio/mpeg",m.codec=""):D.mp3&&(m.codec="mp3");break}P.audio={id:"audio",container:N,codec:m.codec,initSegment:m.segmentCodec==="mp3"&&D.mpeg?new Uint8Array(0):u.default.initSegment([m]),metadata:{channelCount:m.channelCount}},B&&(V=m.inputTimeScale,F=H=y[0].pts-Math.round(V*g))}if(f.sps&&f.pps&&M.length&&(f.timescale=f.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:f.codec,initSegment:u.default.initSegment([f]),metadata:{width:f.width,height:f.height}},B)){V=f.inputTimeScale;var X=this.getVideoStartPts(M),$=Math.round(V*g);H=Math.min(H,d(M[0].dts,X)-$),F=Math.min(F,X-$)}if(Object.keys(P).length)return this.ISGenerated=!0,B&&(this._initPTS=F,this._initDTS=H),{tracks:P,initPTS:F,timescale:V}},n.remuxVideo=function(m,f,g,y){var M=m.inputTimeScale,D=m.samples,P=[],B=D.length,N=this._initPTS,F=this.nextAvcDts,H=8,V=this.videoSampleDuration,X,$,j=Number.POSITIVE_INFINITY,J=Number.NEGATIVE_INFINITY,ee=!1;if(!g||F===null){var te=f*M,se=D[0].pts-d(D[0].dts,D[0].pts);F=te-se}for(var ue=0;ue<B;ue++){var ie=D[ue];ie.pts=d(ie.pts-N,F),ie.dts=d(ie.dts-N,F),ie.dts<D[ue>0?ue-1:ue].dts&&(ee=!0)}ee&&D.sort(function(Kr,Zi){var Tr=Kr.dts-Zi.dts,oa=Kr.pts-Zi.pts;return Tr||oa}),X=D[0].dts,$=D[D.length-1].dts;var he=$-X,me=he?Math.round(he/(B-1)):V||m.inputTimeScale/30;if(g){var ne=X-F,Re=ne>me,Le=ne<-1;if(Re||Le){Re?O.logger.warn("AVC: "+Object(b.toMsFromMpegTsClock)(ne,!0)+" ms ("+ne+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(b.toMsFromMpegTsClock)(-ne,!0)+" ms ("+ne+"dts) overlapping between fragments detected"),X=F;var De=D[0].pts-ne;D[0].dts=X,D[0].pts=De,O.logger.log("Video: First PTS/DTS adjusted: "+Object(b.toMsFromMpegTsClock)(De,!0)+"/"+Object(b.toMsFromMpegTsClock)(X,!0)+", delta: "+Object(b.toMsFromMpegTsClock)(ne,!0)+" ms")}}X=Math.max(0,X);for(var _e=0,ke=0,Qe=0;Qe<B;Qe++){for(var He=D[Qe],qe=He.units,Ke=qe.length,st=0,dt=0;dt<Ke;dt++)st+=qe[dt].data.length;ke+=st,_e+=Ke,He.length=st,He.dts=Math.max(He.dts,X),j=Math.min(He.pts,j),J=Math.max(He.pts,J)}$=D[B-1].dts;var ct=ke+4*_e+8,ot;try{ot=new Uint8Array(ct)}catch{this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:C.ErrorTypes.MUX_ERROR,details:C.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ct,reason:"fail allocating video mdat "+ct});return}var Dt=new DataView(ot.buffer);Dt.setUint32(0,ct),ot.set(u.default.types.mdat,4);for(var et=!1,It=Number.POSITIVE_INFINITY,$e=Number.POSITIVE_INFINITY,Ze=Number.NEGATIVE_INFINITY,Et=Number.NEGATIVE_INFINITY,Je=0;Je<B;Je++){for(var Ge=D[Je],Pt=Ge.units,ft=0,Wt=0,pr=Pt.length;Wt<pr;Wt++){var At=Pt[Wt],Br=At.data,Er=At.data.byteLength;Dt.setUint32(H,Er),H+=4,ot.set(Br,H),H+=Er,ft+=4+Er}var kt=void 0;if(Je<B-1)V=D[Je+1].dts-Ge.dts,kt=D[Je+1].pts-Ge.pts;else{var Ht=this.config,wt=Je>0?Ge.dts-D[Je-1].dts:me;if(kt=Je>0?Ge.pts-D[Je-1].pts:me,Ht.stretchShortVideoTrack&&this.nextAudioPts!==null){var yr=Math.floor(Ht.maxBufferHole*M),ur=(y?j+y*M:this.nextAudioPts)-Ge.pts;ur>yr?(V=ur-wt,V<0?V=wt:et=!0,O.logger.log("[mp4-remuxer]: It is approximately "+ur/90+" ms to the next segment; using duration "+V/90+" ms for the last video frame.")):V=wt}else V=wt}var na=Math.round(Ge.pts-Ge.dts);It=Math.min(It,V),Ze=Math.max(Ze,V),$e=Math.min($e,kt),Et=Math.max(Et,kt),P.push(new o(Ge.key,V,ft,na))}if(P.length){if(S){if(S<70){var ci=P[0].flags;ci.dependsOn=2,ci.isNonSync=0}}else if(v&&Et-$e<Ze-It&&me/Ze<.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 Fr=X,_t=0,Xi=P.length;_t<Xi;_t++){var fi=Fr+P[_t].duration,Qi=Fr+P[_t].cts;if(_t<Xi-1){var hi=fi+P[_t+1].cts;P[_t].duration=hi-Qi}else P[_t].duration=_t?P[_t-1].duration:me;P[_t].cts=0,Fr=fi}}}console.assert(V!==null,"mp4SampleDuration must be computed"),V=et||!V?me:V,this.nextAvcDts=F=$+V,this.videoSampleDuration=V,this.isVideoContiguous=!0;var aa=u.default.moof(m.sequenceNumber++,X,x({},m,{samples:P})),sa="video",Ut={data1:aa,data2:ot,startPTS:j/M,endPTS:(J+V)/M,startDTS:X/M,endDTS:F/M,type:sa,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:m.dropped};return m.samples=[],m.dropped=0,console.assert(ot.length,"MDAT length must not be zero"),Ut},n.remuxAudio=function(m,f,g,y,M){var D=m.inputTimeScale,P=m.samplerate?m.samplerate:D,B=D/P,N=m.segmentCodec==="aac"?_:A,F=N*B,H=this._initPTS,V=m.segmentCodec==="mp3"&&this.typeSupported.mpeg,X=[],$=M!==void 0,j=m.samples,J=V?0:8,ee=this.nextAudioPts||-1,te=f*D;if(this.isAudioContiguous=g=g||j.length&&ee>0&&(y&&Math.abs(te-ee)<9e3||Math.abs(d(j[0].pts-H,te)-ee)<20*F),j.forEach(function(At){At.pts=d(At.pts-H,te)}),!g||ee<0){if(j=j.filter(function(At){return At.pts>=0}),!j.length)return;M===0?ee=0:y&&!$?ee=Math.max(0,te):ee=j[0].pts}if(m.segmentCodec==="aac")for(var se=this.config.maxAudioFramesDrift,ue=0,ie=ee;ue<j.length;ue++){var he=j[ue],me=he.pts,ne=me-ie,Re=Math.abs(1e3*ne/D);if(ne<=-se*F&&$)ue===0&&(O.logger.warn("Audio frame @ "+(me/D).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*ne/D)+" ms."),this.nextAudioPts=ee=ie=me);else if(ne>=se*F&&Re<I&&$){var Le=Math.round(ne/F);ie=me-Le*F,ie<0&&(Le--,ie+=F),ue===0&&(this.nextAudioPts=ee=ie),O.logger.warn("[mp4-remuxer]: Injecting "+Le+" audio frame @ "+(ie/D).toFixed(3)+"s due to "+Math.round(1e3*ne/D)+" ms gap.");for(var De=0;De<Le;De++){var _e=Math.max(ie,0),ke=a.default.getSilentFrame(m.manifestCodec||m.codec,m.channelCount);ke||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),ke=he.unit.subarray()),j.splice(ue,0,{unit:ke,pts:_e}),ie+=F,ue++}}he.pts=ie,ie+=F}for(var Qe=null,He=null,qe,Ke=0,st=j.length;st--;)Ke+=j[st].unit.byteLength;for(var dt=0,ct=j.length;dt<ct;dt++){var ot=j[dt],Dt=ot.unit,et=ot.pts;if(He!==null){var It=X[dt-1];It.duration=Math.round((et-He)/B)}else if(g&&m.segmentCodec==="aac"&&(et=ee),Qe=et,Ke>0){Ke+=J;try{qe=new Uint8Array(Ke)}catch{this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:C.ErrorTypes.MUX_ERROR,details:C.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ke,reason:"fail allocating audio mdat "+Ke});return}if(!V){var $e=new DataView(qe.buffer);$e.setUint32(0,Ke),qe.set(u.default.types.mdat,4)}}else return;qe.set(Dt,J);var Ze=Dt.byteLength;J+=Ze,X.push(new o(!0,N,Ze,0)),He=et}var Et=X.length;if(!!Et){var Je=X[X.length-1];this.nextAudioPts=ee=He+B*Je.duration;var Ge=V?new Uint8Array(0):u.default.moof(m.sequenceNumber++,Qe/B,x({},m,{samples:X}));m.samples=[];var Pt=Qe/D,ft=ee/D,Wt="audio",pr={data1:Ge,data2:qe,startPTS:Pt,endPTS:ft,startDTS:Pt,endDTS:ft,type:Wt,hasAudio:!0,hasVideo:!1,nb:Et};return this.isAudioContiguous=!0,console.assert(qe.length,"MDAT length must not be zero"),pr}},n.remuxEmptyAudio=function(m,f,g,y){var M=m.inputTimeScale,D=m.samplerate?m.samplerate:M,P=M/D,B=this.nextAudioPts,N=(B!==null?B:y.startDTS*M)+this._initDTS,F=y.endDTS*M+this._initDTS,H=P*_,V=Math.ceil((F-N)/H),X=a.default.getSilentFrame(m.manifestCodec||m.codec,m.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!X){O.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var $=[],j=0;j<V;j++){var J=N+j*H;$.push({unit:X,pts:J,dts:J})}return m.samples=$,this.remuxAudio(m,f,g,!1)},E}();function d(E,n){var c;if(n===null)return E;for(n<E?c=-8589934592:c=8589934592;Math.abs(E-n)>4294967296;)E+=c;return E}function p(E){for(var n=0;n<E.length;n++)if(E[n].key)return n;return-1}function T(E,n,c,m){var f=E.samples.length;if(!!f){for(var g=E.inputTimeScale,y=0;y<f;y++){var M=E.samples[y];M.pts=d(M.pts-c,n*g)/g,M.dts=d(M.dts-m,n*g)/g}var D=E.samples;return E.samples=[],{samples:D}}}function l(E,n,c){var m=E.samples.length;if(!!m){for(var f=E.inputTimeScale,g=0;g<m;g++){var y=E.samples[g];y.pts=d(y.pts-c,n*f)/f}E.samples.sort(function(D,P){return D.pts-P.pts});var M=E.samples;return E.samples=[],{samples:M}}}var o=function(n,c,m,f){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=c,this.size=m,this.cts=f,this.flags=new h(n)},h=function(n){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=n?2:1,this.isNonSync=n?0:1}},"./src/remux/passthrough-remuxer.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/polyfills/number.ts"),a=e("./src/remux/mp4-remuxer.ts"),u=e("./src/utils/mp4-tools.ts"),R=e("./src/loader/fragment.ts"),C=e("./src/utils/logger.ts"),O=function(){function b(){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=b.prototype;return x.destroy=function(){},x.resetTimeStamp=function(_){this.initPTS=_,this.lastEndTime=null},x.resetNextTimestamp=function(){this.lastEndTime=null},x.resetInitSegment=function(_,A,S){this.audioCodec=A,this.videoCodec=S,this.generateInitSegment(_),this.emitInitSegment=!0},x.generateInitSegment=function(_){var A=this.audioCodec,S=this.videoCodec;if(!_||!_.byteLength){this.initTracks=void 0,this.initData=void 0;return}var v=this.initData=Object(u.parseInitSegment)(_);A||(A=L(v.audio,R.ElementaryStreamTypes.AUDIO)),S||(S=L(v.video,R.ElementaryStreamTypes.VIDEO));var i={};v.audio&&v.video?i.audiovideo={container:"video/mp4",codec:A+","+S,initSegment:_,id:"main"}:v.audio?i.audio={container:"audio/mp4",codec:A,initSegment:_,id:"audio"}:v.video?i.video={container:"video/mp4",codec:S,initSegment:_,id:"main"}:C.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=i},x.remux=function(_,A,S,v,i){var d,p=this.initPTS,T=this.lastEndTime,l={audio:void 0,video:void 0,text:v,id3:S,initSegment:void 0};Object(s.isFiniteNumber)(T)||(T=this.lastEndTime=i||0);var o=A.samples;if(!o||!o.length)return l;var h={initPTS:void 0,timescale:1},E=this.initData;if((!E||!E.length)&&(this.generateInitSegment(o),E=this.initData),!E||!E.length)return C.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),l;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);var n=Object(u.getStartDTS)(E,o);Object(s.isFiniteNumber)(p)||(this.initPTS=h.initPTS=p=n-i);var c=Object(u.getDuration)(o,E),m=_?n-p:T,f=m+c;Object(u.offsetStartDTS)(E,o,p),c>0?this.lastEndTime=f:(C.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var g=!!E.audio,y=!!E.video,M="";g&&(M+="audio"),y&&(M+="video");var D={data1:o,startPTS:m,startDTS:m,endPTS:f,endDTS:f,type:M,hasAudio:g,hasVideo:y,nb:1,dropped:0};l.audio=D.type==="audio"?D:void 0,l.video=D.type!=="audio"?D:void 0,l.initSegment=h;var P=(d=this.initPTS)!=null?d:0;return l.id3=Object(a.flushTextTrackMetadataCueSamples)(S,i,P,P),v.samples.length&&(l.text=Object(a.flushTextTrackUserdataCueSamples)(v,i,P)),l},b}();function L(b,x){var I=b==null?void 0:b.codec;return I&&I.length>4?I:I==="hvc1"||I==="hev1"?"hvc1.1.c.L120.90":I==="av01"?"av01.0.04M.08":I==="avc1"||x===R.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}t.default=O},"./src/task-loop.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return s});var s=function(){function a(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var u=a.prototype;return u.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},u.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},u.onHandlerDestroyed=function(){},u.hasInterval=function(){return!!this._tickInterval},u.hasNextTick=function(){return!!this._tickTimer},u.setInterval=function(C){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,C),!0)},u.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},u.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},u.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},u.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},u.doTick=function(){},a}()},"./src/types/cmcd.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"CMCDVersion",function(){return s}),e.d(t,"CMCDObjectType",function(){return a}),e.d(t,"CMCDStreamingFormat",function(){return u}),e.d(t,"CMCDStreamType",function(){return R});var s=1,a;(function(C){C.MANIFEST="m",C.AUDIO="a",C.VIDEO="v",C.MUXED="av",C.INIT="i",C.CAPTION="c",C.TIMED_TEXT="tt",C.KEY="k",C.OTHER="o"})(a||(a={}));var u;(function(C){C.DASH="d",C.HLS="h",C.SMOOTH="s",C.OTHER="o"})(u||(u={}));var R;(function(C){C.VOD="v",C.LIVE="l"})(R||(R={}))},"./src/types/demuxer.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"MetadataSchema",function(){return s});var s;(function(a){a.audioId3="org.id3",a.dateRange="com.apple.quicktime.HLS",a.emsg="https://aomedia.org/emsg/ID3"})(s||(s={}))},"./src/types/level.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"HlsSkip",function(){return u}),e.d(t,"getSkipValue",function(){return R}),e.d(t,"HlsUrlParameters",function(){return C}),e.d(t,"Level",function(){return O});function s(L,b){for(var x=0;x<b.length;x++){var I=b[x];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(L,I.key,I)}}function a(L,b,x){return b&&s(L.prototype,b),x&&s(L,x),Object.defineProperty(L,"prototype",{writable:!1}),L}var u;(function(L){L.No="",L.Yes="YES",L.v2="v2"})(u||(u={}));function R(L,b){var x=L.canSkipUntil,I=L.canSkipDateRanges,_=L.endSN,A=b!==void 0?b-_:0;return x&&A<x?I?u.v2:u.Yes:u.No}var C=function(){function L(x,I,_){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=x,this.part=I,this.skip=_}var b=L.prototype;return b.addDirectives=function(I){var _=new self.URL(I);return this.msn!==void 0&&_.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&_.searchParams.set("_HLS_part",this.part.toString()),this.skip&&_.searchParams.set("_HLS_skip",this.skip),_.toString()},L}(),O=function(){function L(b){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=[b.url],this.attrs=b.attrs,this.bitrate=b.bitrate,b.details&&(this.details=b.details),this.id=b.id||0,this.name=b.name,this.width=b.width||0,this.height=b.height||0,this.audioCodec=b.audioCodec,this.videoCodec=b.videoCodec,this.unknownCodecs=b.unknownCodecs,this.codecSet=[b.videoCodec,b.audioCodec].filter(function(x){return x}).join(",").replace(/\.[^.,]+/g,"")}return a(L,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(x){var I=x%this.url.length;this._urlId!==I&&(this.details=void 0,this._urlId=I)}}]),L}()},"./src/types/loader.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"PlaylistContextType",function(){return s}),e.d(t,"PlaylistLevelType",function(){return a});var s;(function(u){u.MANIFEST="manifest",u.LEVEL="level",u.AUDIO_TRACK="audioTrack",u.SUBTITLE_TRACK="subtitleTrack"})(s||(s={}));var a;(function(u){u.MAIN="main",u.AUDIO="audio",u.SUBTITLE="subtitle"})(a||(a={}))},"./src/types/transmuxer.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"ChunkMetadata",function(){return s});var s=function(R,C,O,L,b,x){L===void 0&&(L=0),b===void 0&&(b=-1),x===void 0&&(x=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=a(),this.buffering={audio:a(),video:a(),audiovideo:a()},this.level=R,this.sn=C,this.id=O,this.size=L,this.part=b,this.partial=x};function a(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"AttrList",function(){return u});var s=/^(\d+)x(\d+)$/,a=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,u=function(){function R(O){typeof O=="string"&&(O=R.parseAttrList(O));for(var L in O)O.hasOwnProperty(L)&&(this[L]=O[L])}var C=R.prototype;return C.decimalInteger=function(L){var b=parseInt(this[L],10);return b>Number.MAX_SAFE_INTEGER?1/0:b},C.hexadecimalInteger=function(L){if(this[L]){var b=(this[L]||"0x").slice(2);b=(b.length&1?"0":"")+b;for(var x=new Uint8Array(b.length/2),I=0;I<b.length/2;I++)x[I]=parseInt(b.slice(I*2,I*2+2),16);return x}else return null},C.hexadecimalIntegerAsNumber=function(L){var b=parseInt(this[L],16);return b>Number.MAX_SAFE_INTEGER?1/0:b},C.decimalFloatingPoint=function(L){return parseFloat(this[L])},C.optionalFloat=function(L,b){var x=this[L];return x?parseFloat(x):b},C.enumeratedString=function(L){return this[L]},C.bool=function(L){return this[L]==="YES"},C.decimalResolution=function(L){var b=s.exec(this[L]);if(b!==null)return{width:parseInt(b[1],10),height:parseInt(b[2],10)}},R.parseAttrList=function(L){var b,x={},I='"';for(a.lastIndex=0;(b=a.exec(L))!==null;){var _=b[2];_.indexOf(I)===0&&_.lastIndexOf(I)===_.length-1&&(_=_.slice(1,-1)),x[b[1]]=_}return x},R}()},"./src/utils/binary-search.ts":function(r,t,e){"use strict";e.r(t);var s={search:function(u,R){for(var C=0,O=u.length-1,L=null,b=null;C<=O;){L=(C+O)/2|0,b=u[L];var x=R(b);if(x>0)C=L+1;else if(x<0)O=L-1;else return b}return null}};t.default=s},"./src/utils/buffer-helper.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"BufferHelper",function(){return u});var s=e("./src/utils/logger.ts"),a={length:0,start:function(){return 0},end:function(){return 0}},u=function(){function R(){}return R.isBuffered=function(O,L){try{if(O){for(var b=R.getBuffered(O),x=0;x<b.length;x++)if(L>=b.start(x)&&L<=b.end(x))return!0}}catch{}return!1},R.bufferInfo=function(O,L,b){try{if(O){var x=R.getBuffered(O),I=[],_;for(_=0;_<x.length;_++)I.push({start:x.start(_),end:x.end(_)});return this.bufferedInfo(I,L,b)}}catch{}return{len:0,start:L,end:L,nextStart:void 0}},R.bufferedInfo=function(O,L,b){L=Math.max(0,L),O.sort(function(o,h){var E=o.start-h.start;return E||h.end-o.end});var x=[];if(b)for(var I=0;I<O.length;I++){var _=x.length;if(_){var A=x[_-1].end;O[I].start-A<b?O[I].end>A&&(x[_-1].end=O[I].end):x.push(O[I])}else x.push(O[I])}else x=O;for(var S=0,v,i=L,d=L,p=0;p<x.length;p++){var T=x[p].start,l=x[p].end;if(L+b>=T&&L<l)i=T,d=l,S=d-L;else if(L+b<T){v=T;break}}return{len:S,start:i||0,end:d||0,nextStart:v}},R.getBuffered=function(O){try{return O.buffered}catch(L){return s.logger.log("failed to get media.buffered",L),a}},R}()},"./src/utils/cea-608-parser.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"Row",function(){return d}),e.d(t,"CaptionScreen",function(){return p});var s=e("./src/utils/logger.ts"),a={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},u=function(c){var m=c;return a.hasOwnProperty(c)&&(m=a[c]),String.fromCharCode(m)},R=15,C=100,O={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},L={17:2,18:4,21:6,22:8,23:10,19:13,20:15},b={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},x={25:2,26:4,29:6,30:8,31:10,27:13,28:15},I=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],_;(function(n){n[n.ERROR=0]="ERROR",n[n.TEXT=1]="TEXT",n[n.WARNING=2]="WARNING",n[n.INFO=2]="INFO",n[n.DEBUG=3]="DEBUG",n[n.DATA=3]="DATA"})(_||(_={}));var A=function(){function n(){this.time=null,this.verboseLevel=_.ERROR}var c=n.prototype;return c.log=function(f,g){this.verboseLevel>=f&&s.logger.log(this.time+" ["+f+"] "+g)},n}(),S=function(c){for(var m=[],f=0;f<c.length;f++)m.push(c[f].toString(16));return m},v=function(){function n(m,f,g,y,M){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=m||"white",this.underline=f||!1,this.italics=g||!1,this.background=y||"black",this.flash=M||!1}var c=n.prototype;return c.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},c.setStyles=function(f){for(var g=["foreground","underline","italics","background","flash"],y=0;y<g.length;y++){var M=g[y];f.hasOwnProperty(M)&&(this[M]=f[M])}},c.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},c.equals=function(f){return this.foreground===f.foreground&&this.underline===f.underline&&this.italics===f.italics&&this.background===f.background&&this.flash===f.flash},c.copy=function(f){this.foreground=f.foreground,this.underline=f.underline,this.italics=f.italics,this.background=f.background,this.flash=f.flash},c.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},n}(),i=function(){function n(m,f,g,y,M,D){this.uchar=void 0,this.penState=void 0,this.uchar=m||" ",this.penState=new v(f,g,y,M,D)}var c=n.prototype;return c.reset=function(){this.uchar=" ",this.penState.reset()},c.setChar=function(f,g){this.uchar=f,this.penState.copy(g)},c.setPenState=function(f){this.penState.copy(f)},c.equals=function(f){return this.uchar===f.uchar&&this.penState.equals(f.penState)},c.copy=function(f){this.uchar=f.uchar,this.penState.copy(f.penState)},c.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},n}(),d=function(){function n(m){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var f=0;f<C;f++)this.chars.push(new i);this.logger=m,this.pos=0,this.currPenState=new v}var c=n.prototype;return c.equals=function(f){for(var g=!0,y=0;y<C;y++)if(!this.chars[y].equals(f.chars[y])){g=!1;break}return g},c.copy=function(f){for(var g=0;g<C;g++)this.chars[g].copy(f.chars[g])},c.isEmpty=function(){for(var f=!0,g=0;g<C;g++)if(!this.chars[g].isEmpty()){f=!1;break}return f},c.setCursor=function(f){this.pos!==f&&(this.pos=f),this.pos<0?(this.logger.log(_.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>C&&(this.logger.log(_.DEBUG,"Too large cursor position "+this.pos),this.pos=C)},c.moveCursor=function(f){var g=this.pos+f;if(f>1)for(var y=this.pos+1;y<g+1;y++)this.chars[y].setPenState(this.currPenState);this.setCursor(g)},c.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},c.insertChar=function(f){f>=144&&this.backSpace();var g=u(f);if(this.pos>=C){this.logger.log(_.ERROR,"Cannot insert "+f.toString(16)+" ("+g+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(g,this.currPenState),this.moveCursor(1)},c.clearFromPos=function(f){var g;for(g=f;g<C;g++)this.chars[g].reset()},c.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},c.clearToEndOfRow=function(){this.clearFromPos(this.pos)},c.getTextString=function(){for(var f=[],g=!0,y=0;y<C;y++){var M=this.chars[y].uchar;M!==" "&&(g=!1),f.push(M)}return g?"":f.join("")},c.setPenStyles=function(f){this.currPenState.setStyles(f);var g=this.chars[this.pos];g.setPenState(this.currPenState)},n}(),p=function(){function n(m){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var f=0;f<R;f++)this.rows.push(new d(m));this.logger=m,this.currRow=R-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var c=n.prototype;return c.reset=function(){for(var f=0;f<R;f++)this.rows[f].clear();this.currRow=R-1},c.equals=function(f){for(var g=!0,y=0;y<R;y++)if(!this.rows[y].equals(f.rows[y])){g=!1;break}return g},c.copy=function(f){for(var g=0;g<R;g++)this.rows[g].copy(f.rows[g])},c.isEmpty=function(){for(var f=!0,g=0;g<R;g++)if(!this.rows[g].isEmpty()){f=!1;break}return f},c.backSpace=function(){var f=this.rows[this.currRow];f.backSpace()},c.clearToEndOfRow=function(){var f=this.rows[this.currRow];f.clearToEndOfRow()},c.insertChar=function(f){var g=this.rows[this.currRow];g.insertChar(f)},c.setPen=function(f){var g=this.rows[this.currRow];g.setPenStyles(f)},c.moveCursor=function(f){var g=this.rows[this.currRow];g.moveCursor(f)},c.setCursor=function(f){this.logger.log(_.INFO,"setCursor: "+f);var g=this.rows[this.currRow];g.setCursor(f)},c.setPAC=function(f){this.logger.log(_.INFO,"pacData = "+JSON.stringify(f));var g=f.row-1;if(this.nrRollUpRows&&g<this.nrRollUpRows-1&&(g=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==g){for(var y=0;y<R;y++)this.rows[y].clear();var M=this.currRow+1-this.nrRollUpRows,D=this.lastOutputScreen;if(D){var P=D.rows[M].cueStartTime,B=this.logger.time;if(P&&B!==null&&P<B)for(var N=0;N<this.nrRollUpRows;N++)this.rows[g-this.nrRollUpRows+N+1].copy(D.rows[M+N])}}this.currRow=g;var F=this.rows[this.currRow];if(f.indent!==null){var H=f.indent,V=Math.max(H-1,0);F.setCursor(f.indent),f.color=F.chars[V].penState.foreground}var X={foreground:f.color,underline:f.underline,italics:f.italics,background:"black",flash:!1};this.setPen(X)},c.setBkgData=function(f){this.logger.log(_.INFO,"bkgData = "+JSON.stringify(f)),this.backSpace(),this.setPen(f),this.insertChar(32)},c.setRollUpRows=function(f){this.nrRollUpRows=f},c.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(_.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(_.TEXT,this.getDisplayText());var f=this.currRow+1-this.nrRollUpRows,g=this.rows.splice(f,1)[0];g.clear(),this.rows.splice(this.currRow,0,g),this.logger.log(_.INFO,"Rolling up")},c.getDisplayText=function(f){f=f||!1;for(var g=[],y="",M=-1,D=0;D<R;D++){var P=this.rows[D].getTextString();P&&(M=D+1,f?g.push("Row "+M+": '"+P+"'"):g.push(P.trim()))}return g.length>0&&(f?y="["+g.join(" | ")+"]":y=g.join(`
20
- `)),y},c.getTextAndFormat=function(){return this.rows},n}(),T=function(){function n(m,f,g){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=m,this.outputFilter=f,this.mode=null,this.verbose=0,this.displayedMemory=new p(g),this.nonDisplayedMemory=new p(g),this.lastOutputScreen=new p(g),this.currRollUpRow=this.displayedMemory.rows[R-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=g}var c=n.prototype;return c.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[R-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},c.getHandler=function(){return this.outputFilter},c.setHandler=function(f){this.outputFilter=f},c.setPAC=function(f){this.writeScreen.setPAC(f)},c.setBkgData=function(f){this.writeScreen.setBkgData(f)},c.setMode=function(f){f!==this.mode&&(this.mode=f,this.logger.log(_.INFO,"MODE="+f),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=f)},c.insertChars=function(f){for(var g=0;g<f.length;g++)this.writeScreen.insertChar(f[g]);var y=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(_.INFO,y+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(_.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},c.ccRCL=function(){this.logger.log(_.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},c.ccBS=function(){this.logger.log(_.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},c.ccAOF=function(){},c.ccAON=function(){},c.ccDER=function(){this.logger.log(_.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},c.ccRU=function(f){this.logger.log(_.INFO,"RU("+f+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(f)},c.ccFON=function(){this.logger.log(_.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},c.ccRDC=function(){this.logger.log(_.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},c.ccTR=function(){this.logger.log(_.INFO,"TR"),this.setMode("MODE_TEXT")},c.ccRTD=function(){this.logger.log(_.INFO,"RTD"),this.setMode("MODE_TEXT")},c.ccEDM=function(){this.logger.log(_.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},c.ccCR=function(){this.logger.log(_.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},c.ccENM=function(){this.logger.log(_.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},c.ccEOC=function(){if(this.logger.log(_.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var f=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=f,this.writeScreen=this.nonDisplayedMemory,this.logger.log(_.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},c.ccTO=function(f){this.logger.log(_.INFO,"TO("+f+") - Tab Offset"),this.writeScreen.moveCursor(f)},c.ccMIDROW=function(f){var g={flash:!1};if(g.underline=f%2===1,g.italics=f>=46,g.italics)g.foreground="white";else{var y=Math.floor(f/2)-16,M=["white","green","blue","cyan","red","yellow","magenta"];g.foreground=M[y]}this.logger.log(_.INFO,"MIDROW: "+JSON.stringify(g)),this.writeScreen.setPen(g)},c.outputDataUpdate=function(f){f===void 0&&(f=!1);var g=this.logger.time;g!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=g:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,g,this.lastOutputScreen),f&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:g),this.lastOutputScreen.copy(this.displayedMemory))},c.cueSplitAtTime=function(f){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,f,this.displayedMemory),this.cueStartTime=f))},n}(),l=function(){function n(m,f,g){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var y=new A;this.channels=[null,new T(m,f,y),new T(m+1,g,y)],this.cmdHistory=E(),this.logger=y}var c=n.prototype;return c.getHandler=function(f){return this.channels[f].getHandler()},c.setHandler=function(f,g){this.channels[f].setHandler(g)},c.addData=function(f,g){var y,M,D,P=!1;this.logger.time=f;for(var B=0;B<g.length;B+=2)if(M=g[B]&127,D=g[B+1]&127,!(M===0&&D===0)){if(this.logger.log(_.DATA,"["+S([g[B],g[B+1]])+"] -> ("+S([M,D])+")"),y=this.parseCmd(M,D),y||(y=this.parseMidrow(M,D)),y||(y=this.parsePAC(M,D)),y||(y=this.parseBackgroundAttributes(M,D)),!y&&(P=this.parseChars(M,D),P)){var N=this.currentChannel;if(N&&N>0){var F=this.channels[N];F.insertChars(P)}else this.logger.log(_.WARNING,"No channel found yet. TEXT-MODE?")}!y&&!P&&this.logger.log(_.WARNING,"Couldn't parse cleaned data "+S([M,D])+" orig: "+S([g[B],g[B+1]]))}},c.parseCmd=function(f,g){var y=this.cmdHistory,M=(f===20||f===28||f===21||f===29)&&g>=32&&g<=47,D=(f===23||f===31)&&g>=33&&g<=35;if(!(M||D))return!1;if(h(f,g,y))return o(null,null,y),this.logger.log(_.DEBUG,"Repeated command ("+S([f,g])+") is dropped"),!0;var P=f===20||f===21||f===23?1:2,B=this.channels[P];return f===20||f===21||f===28||f===29?g===32?B.ccRCL():g===33?B.ccBS():g===34?B.ccAOF():g===35?B.ccAON():g===36?B.ccDER():g===37?B.ccRU(2):g===38?B.ccRU(3):g===39?B.ccRU(4):g===40?B.ccFON():g===41?B.ccRDC():g===42?B.ccTR():g===43?B.ccRTD():g===44?B.ccEDM():g===45?B.ccCR():g===46?B.ccENM():g===47&&B.ccEOC():B.ccTO(g-32),o(f,g,y),this.currentChannel=P,!0},c.parseMidrow=function(f,g){var y=0;if((f===17||f===25)&&g>=32&&g<=47){if(f===17?y=1:y=2,y!==this.currentChannel)return this.logger.log(_.ERROR,"Mismatch channel in midrow parsing"),!1;var M=this.channels[y];return M?(M.ccMIDROW(g),this.logger.log(_.DEBUG,"MIDROW ("+S([f,g])+")"),!0):!1}return!1},c.parsePAC=function(f,g){var y,M=this.cmdHistory,D=(f>=17&&f<=23||f>=25&&f<=31)&&g>=64&&g<=127,P=(f===16||f===24)&&g>=64&&g<=95;if(!(D||P))return!1;if(h(f,g,M))return o(null,null,M),!0;var B=f<=23?1:2;g>=64&&g<=95?y=B===1?O[f]:b[f]:y=B===1?L[f]:x[f];var N=this.channels[B];return N?(N.setPAC(this.interpretPAC(y,g)),o(f,g,M),this.currentChannel=B,!0):!1},c.interpretPAC=function(f,g){var y,M={color:null,italics:!1,indent:null,underline:!1,row:f};return g>95?y=g-96:y=g-64,M.underline=(y&1)===1,y<=13?M.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(y/2)]:y<=15?(M.italics=!0,M.color="white"):M.indent=Math.floor((y-16)/2)*4,M},c.parseChars=function(f,g){var y,M=null,D=null;if(f>=25?(y=2,D=f-8):(y=1,D=f),D>=17&&D<=19){var P;D===17?P=g+80:D===18?P=g+112:P=g+144,this.logger.log(_.INFO,"Special char '"+u(P)+"' in channel "+y),M=[P]}else f>=32&&f<=127&&(M=g===0?[f]:[f,g]);if(M){var B=S(M);this.logger.log(_.DEBUG,"Char codes = "+B.join(",")),o(f,g,this.cmdHistory)}return M},c.parseBackgroundAttributes=function(f,g){var y=(f===16||f===24)&&g>=32&&g<=47,M=(f===23||f===31)&&g>=45&&g<=47;if(!(y||M))return!1;var D,P={};f===16||f===24?(D=Math.floor((g-32)/2),P.background=I[D],g%2===1&&(P.background=P.background+"_semi")):g===45?P.background="transparent":(P.foreground="black",g===47&&(P.underline=!0));var B=f<=23?1:2,N=this.channels[B];return N.setBkgData(P),o(f,g,this.cmdHistory),!0},c.reset=function(){for(var f=0;f<Object.keys(this.channels).length;f++){var g=this.channels[f];g&&g.reset()}this.cmdHistory=E()},c.cueSplitAtTime=function(f){for(var g=0;g<this.channels.length;g++){var y=this.channels[g];y&&y.cueSplitAtTime(f)}},n}();function o(n,c,m){m.a=n,m.b=c}function h(n,c,m){return m.a===n&&m.b===c}function E(){return{a:null,b:null}}t.default=l},"./src/utils/codecs.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"isCodecType",function(){return a}),e.d(t,"isCodecSupportedInMp4",function(){return u});var s={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 a(R,C){var O=s[C];return!!O&&O[R.slice(0,4)]===!0}function u(R,C){return MediaSource.isTypeSupported((C||"video")+'/mp4;codecs="'+R+'"')}},"./src/utils/cues.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/utils/vttparser.ts"),a=e("./src/utils/webvtt-parser.ts"),u=e("./src/utils/texttrack-utils.ts"),R=/\s/,C={newCue:function(L,b,x,I){for(var _=[],A,S,v,i,d,p=self.VTTCue||self.TextTrackCue,T=0;T<I.rows.length;T++)if(A=I.rows[T],v=!0,i=0,d="",!A.isEmpty()){for(var l=0;l<A.chars.length;l++)R.test(A.chars[l].uchar)&&v?i++:(d+=A.chars[l].uchar,v=!1);A.cueStartTime=b,b===x&&(x+=1e-4),i>=16?i--:i++;var o=Object(s.fixLineBreaks)(d.trim()),h=Object(a.generateCueId)(b,x,o);(!L||!L.cues||!L.cues.getCueById(h))&&(S=new p(b,x,o),S.id=h,S.line=T+1,S.align="left",S.position=10+Math.min(80,Math.floor(i*8/32)*10),_.push(S))}return L&&_.length&&(_.sort(function(E,n){return E.line==="auto"||n.line==="auto"?0:E.line>8&&n.line>8?n.line-E.line:E.line-n.line}),_.forEach(function(E){return Object(u.addCueToTrack)(L,E)})),_}};t.default=C},"./src/utils/discontinuities.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"findFirstFragWithCC",function(){return R}),e.d(t,"shouldAlignOnDiscontinuities",function(){return C}),e.d(t,"findDiscontinuousReferenceFrag",function(){return O}),e.d(t,"adjustSlidingStart",function(){return b}),e.d(t,"alignStream",function(){return x}),e.d(t,"alignPDT",function(){return _}),e.d(t,"alignFragmentByPDTDelta",function(){return A}),e.d(t,"alignMediaPlaylistByPDT",function(){return S});var s=e("./src/polyfills/number.ts"),a=e("./src/utils/logger.ts"),u=e("./src/controller/level-helper.ts");function R(v,i){for(var d=null,p=0,T=v.length;p<T;p++){var l=v[p];if(l&&l.cc===i){d=l;break}}return d}function C(v,i,d){return!!(i.details&&(d.endCC>d.startCC||v&&v.cc<d.startCC))}function O(v,i){var d=v.fragments,p=i.fragments;if(!p.length||!d.length){a.logger.log("No fragments to align");return}var T=R(d,p[0].cc);if(!T||T&&!T.startPTS){a.logger.log("No frag in previous level to align on");return}return T}function L(v,i){if(v){var d=v.start+i;v.start=v.startPTS=d,v.endPTS=d+v.duration}}function b(v,i){for(var d=i.fragments,p=0,T=d.length;p<T;p++)L(d[p],v);i.fragmentHint&&L(i.fragmentHint,v),i.alignedSliding=!0}function x(v,i,d){!i||(I(v,d,i),!d.alignedSliding&&i.details&&_(d,i.details),!d.alignedSliding&&i.details&&!d.skippedSegments&&Object(u.adjustSliding)(i.details,d))}function I(v,i,d){if(C(v,d,i)){var p=O(d.details,i);p&&Object(s.isFiniteNumber)(p.start)&&(a.logger.log("Adjusting PTS using last level due to CC increase within current level "+i.url),b(p.start,i))}}function _(v,i){if(!(!i.fragments.length||!v.hasProgramDateTime||!i.hasProgramDateTime)){var d=i.fragments[0].programDateTime,p=v.fragments[0].programDateTime,T=(p-d)/1e3+i.fragments[0].start;T&&Object(s.isFiniteNumber)(T)&&(a.logger.log("Adjusting PTS using programDateTime delta "+(p-d)+"ms, sliding:"+T.toFixed(3)+" "+v.url+" "),b(T,v))}}function A(v,i){var d=v.programDateTime;if(!!d){var p=(d-i)/1e3;v.start=v.startPTS=p,v.endPTS=p+v.duration}}function S(v,i){if(!(!i.fragments.length||!v.hasProgramDateTime||!i.hasProgramDateTime)){var d=i.fragments[0].programDateTime,p=i.fragments[0].start,T=d-p*1e3;v.fragments.forEach(function(l){A(l,T)}),v.fragmentHint&&A(v.fragmentHint,T),v.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/utils/ewma.ts"),a=function(){function u(C,O,L){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=L,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new s.default(C),this.fast_=new s.default(O)}var R=u.prototype;return R.update=function(O,L){var b=this.slow_,x=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new s.default(O,b.getEstimate(),b.getTotalWeight())),this.fast_.halfLife!==L&&(this.fast_=new s.default(L,x.getEstimate(),x.getTotalWeight()))},R.sample=function(O,L){O=Math.max(O,this.minDelayMs_);var b=8*L,x=O/1e3,I=b/x;this.fast_.sample(x,I),this.slow_.sample(x,I)},R.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},R.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},R.destroy=function(){},u}();t.default=a},"./src/utils/ewma.ts":function(r,t,e){"use strict";e.r(t);var s=function(){function a(R,C,O){C===void 0&&(C=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=R,this.alpha_=R?Math.exp(Math.log(.5)/R):0,this.estimate_=C,this.totalWeight_=O}var u=a.prototype;return u.sample=function(C,O){var L=Math.pow(this.alpha_,C);this.estimate_=O*(1-L)+L*this.estimate_,this.totalWeight_+=C},u.getTotalWeight=function(){return this.totalWeight_},u.getEstimate=function(){if(this.alpha_){var C=1-Math.pow(this.alpha_,this.totalWeight_);if(C)return this.estimate_/C}return this.estimate_},a}();t.default=s},"./src/utils/fetch-loader.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"fetchSupported",function(){return A});var s=e("./src/polyfills/number.ts"),a=e("./src/loader/load-stats.ts"),u=e("./src/demux/chunk-cache.ts");function R(p,T){p.prototype=Object.create(T.prototype),p.prototype.constructor=p,x(p,T)}function C(p){var T=typeof Map=="function"?new Map:void 0;return C=function(o){if(o===null||!b(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(typeof T!="undefined"){if(T.has(o))return T.get(o);T.set(o,h)}function h(){return O(o,arguments,I(this).constructor)}return h.prototype=Object.create(o.prototype,{constructor:{value:h,enumerable:!1,writable:!0,configurable:!0}}),x(h,o)},C(p)}function O(p,T,l){return L()?O=Reflect.construct.bind():O=function(h,E,n){var c=[null];c.push.apply(c,E);var m=Function.bind.apply(h,c),f=new m;return n&&x(f,n.prototype),f},O.apply(null,arguments)}function L(){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 b(p){return Function.toString.call(p).indexOf("[native code]")!==-1}function x(p,T){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,h){return o.__proto__=h,o},x(p,T)}function I(p){return I=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},I(p)}function _(){return _=Object.assign?Object.assign.bind():function(p){for(var T=1;T<arguments.length;T++){var l=arguments[T];for(var o in l)Object.prototype.hasOwnProperty.call(l,o)&&(p[o]=l[o])}return p},_.apply(this,arguments)}function A(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var S=function(){function p(l){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=l.fetchSetup||i,this.controller=new self.AbortController,this.stats=new a.LoadStats}var T=p.prototype;return T.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},T.abortInternal=function(){var o=this.response;(!o||!o.ok)&&(this.stats.aborted=!0,this.controller.abort())},T.abort=function(){var o;this.abortInternal(),(o=this.callbacks)!==null&&o!==void 0&&o.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},T.load=function(o,h,E){var n=this,c=this.stats;if(c.loading.start)throw new Error("Loader can only be used once.");c.loading.start=self.performance.now();var m=v(o,this.controller.signal),f=E.onProgress,g=o.responseType==="arraybuffer",y=g?"byteLength":"length";this.context=o,this.config=h,this.callbacks=E,this.request=this.fetchSetup(o,m),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){n.abortInternal(),E.onTimeout(c,o,n.response)},h.timeout),self.fetch(this.request).then(function(M){if(n.response=n.loader=M,!M.ok){var D=M.status,P=M.statusText;throw new d(P||"fetch, bad network response",D,M)}return c.loading.first=Math.max(self.performance.now(),c.loading.start),c.total=parseInt(M.headers.get("Content-Length")||"0"),f&&Object(s.isFiniteNumber)(h.highWaterMark)?n.loadProgressively(M,c,o,h.highWaterMark,f):g?M.arrayBuffer():M.text()}).then(function(M){var D=n.response;self.clearTimeout(n.requestTimeout),c.loading.end=Math.max(self.performance.now(),c.loading.first),c.loaded=c.total=M[y];var P={url:D.url,data:M};f&&!Object(s.isFiniteNumber)(h.highWaterMark)&&f(c,o,M,D),E.onSuccess(P,c,o,D)}).catch(function(M){if(self.clearTimeout(n.requestTimeout),!c.aborted){var D=M&&M.code||0,P=M?M.message:null;E.onError({code:D,text:P},o,M?M.details:null)}})},T.getCacheAge=function(){var o=null;if(this.response){var h=this.response.headers.get("age");o=h?parseFloat(h):null}return o},T.loadProgressively=function(o,h,E,n,c){n===void 0&&(n=0);var m=new u.default,f=o.body.getReader(),g=function y(){return f.read().then(function(M){if(M.done)return m.dataLength&&c(h,E,m.flush(),o),Promise.resolve(new ArrayBuffer(0));var D=M.value,P=D.length;return h.loaded+=P,P<n||m.dataLength?(m.push(D),m.dataLength>=n&&c(h,E,m.flush(),o)):c(h,E,D,o),y()}).catch(function(){return Promise.reject()})};return g()},p}();function v(p,T){var l={method:"GET",mode:"cors",credentials:"same-origin",signal:T,headers:new self.Headers(_({},p.headers))};return p.rangeEnd&&l.headers.set("Range","bytes="+p.rangeStart+"-"+String(p.rangeEnd-1)),l}function i(p,T){return new self.Request(p.url,T)}var d=function(p){R(T,p);function T(l,o,h){var E;return E=p.call(this,l)||this,E.code=void 0,E.details=void 0,E.code=o,E.details=h,E}return T}(C(Error));t.default=S},"./src/utils/imsc1-ttml-parser.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"IMSC1_CODEC",function(){return b}),e.d(t,"parseIMSC1",function(){return A});var s=e("./src/utils/mp4-tools.ts"),a=e("./src/utils/vttparser.ts"),u=e("./src/utils/vttcue.ts"),R=e("./src/demux/id3.ts"),C=e("./src/utils/timescale-conversion.ts"),O=e("./src/utils/webvtt-parser.ts");function L(){return L=Object.assign?Object.assign.bind():function(n){for(var c=1;c<arguments.length;c++){var m=arguments[c];for(var f in m)Object.prototype.hasOwnProperty.call(m,f)&&(n[f]=m[f])}return n},L.apply(this,arguments)}var b="stpp.ttml.im1t",x=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,I=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,_={left:"start",center:"center",right:"end",start:"start",end:"end"};function A(n,c,m,f,g){var y=Object(s.findBox)(new Uint8Array(n),["mdat"]);if(y.length===0){g(new Error("Could not parse IMSC1 mdat"));return}var M=y.map(function(P){return Object(R.utf8ArrayToStr)(P)}),D=Object(C.toTimescaleFromScale)(c,1,m);try{M.forEach(function(P){return f(S(P,D))})}catch(P){g(P)}}function S(n,c){var m=new DOMParser,f=m.parseFromString(n,"text/xml"),g=f.getElementsByTagName("tt")[0];if(!g)throw new Error("Invalid ttml");var y={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},M=Object.keys(y).reduce(function(F,H){return F[H]=g.getAttribute("ttp:"+H)||y[H],F},{}),D=g.getAttribute("xml:space")!=="preserve",P=i(v(g,"styling","style")),B=i(v(g,"layout","region")),N=v(g,"body","[begin]");return[].map.call(N,function(F){var H=d(F,D);if(!H||!F.hasAttribute("begin"))return null;var V=o(F.getAttribute("begin"),M),X=o(F.getAttribute("dur"),M),$=o(F.getAttribute("end"),M);if(V===null)throw l(F);if($===null){if(X===null)throw l(F);$=V+X}var j=new u.default(V-c,$-c,H);j.id=Object(O.generateCueId)(j.startTime,j.endTime,j.text);var J=B[F.getAttribute("region")],ee=P[F.getAttribute("style")];j.position=10,j.size=80;var te=p(J,ee,P),se=te.textAlign;if(se){var ue=_[se];ue&&(j.lineAlign=ue),j.align=se}return L(j,te),j}).filter(function(F){return F!==null})}function v(n,c,m){var f=n.getElementsByTagName(c)[0];return f?[].slice.call(f.querySelectorAll(m)):[]}function i(n){return n.reduce(function(c,m){var f=m.getAttribute("xml:id");return f&&(c[f]=m),c},{})}function d(n,c){return[].slice.call(n.childNodes).reduce(function(m,f,g){var y;return f.nodeName==="br"&&g?m+`
21
- `:(y=f.childNodes)!==null&&y!==void 0&&y.length?d(f,c):c?m+f.textContent.trim().replace(/\s+/g," "):m+f.textContent},"")}function p(n,c,m){var f="http://www.w3.org/ns/ttml#styling",g=null,y=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],M=n!=null&&n.hasAttribute("style")?n.getAttribute("style"):null;return M&&m.hasOwnProperty(M)&&(g=m[M]),y.reduce(function(D,P){var B=T(c,f,P)||T(n,f,P)||T(g,f,P);return B&&(D[P]=B),D},{})}function T(n,c,m){return n&&n.hasAttributeNS(c,m)?n.getAttributeNS(c,m):null}function l(n){return new Error("Could not parse ttml timestamp "+n)}function o(n,c){if(!n)return null;var m=Object(a.parseTimeStamp)(n);return m===null&&(x.test(n)?m=h(n,c):I.test(n)&&(m=E(n,c))),m}function h(n,c){var m=x.exec(n),f=(m[4]|0)+(m[5]|0)/c.subFrameRate;return(m[1]|0)*3600+(m[2]|0)*60+(m[3]|0)+f/c.frameRate}function E(n,c){var m=I.exec(n),f=Number(m[1]),g=m[2];switch(g){case"h":return f*3600;case"m":return f*60;case"ms":return f*1e3;case"f":return f/c.frameRate;case"t":return f/c.tickRate}return f}},"./src/utils/logger.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"enableLogs",function(){return O}),e.d(t,"logger",function(){return L});var s=function(){},a={trace:s,debug:s,log:s,warn:s,info:s,error:s},u=a;function R(b){var x=self.console[b];return x?x.bind(self.console,"["+b+"] >"):s}function C(b){for(var x=arguments.length,I=new Array(x>1?x-1:0),_=1;_<x;_++)I[_-1]=arguments[_];I.forEach(function(A){u[A]=b[A]?b[A].bind(b):R(A)})}function O(b){if(self.console&&b===!0||typeof b=="object"){C(b,"debug","log","info","warn","error");try{u.log()}catch{u=a}}else u=a}var L=u},"./src/utils/mediakeys-helper.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"KeySystems",function(){return s}),e.d(t,"requestMediaKeySystemAccess",function(){return a});var s;(function(u){u.WIDEVINE="com.widevine.alpha",u.PLAYREADY="com.microsoft.playready"})(s||(s={}));var a=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"getMediaSource",function(){return s});function s(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"RemuxerTrackIdConfig",function(){return O}),e.d(t,"bin2str",function(){return L}),e.d(t,"readUint16",function(){return b}),e.d(t,"readUint32",function(){return x}),e.d(t,"readSint32",function(){return I}),e.d(t,"writeUint32",function(){return _}),e.d(t,"findBox",function(){return A}),e.d(t,"parseSegmentIndex",function(){return S}),e.d(t,"parseInitSegment",function(){return v}),e.d(t,"getStartDTS",function(){return i}),e.d(t,"getDuration",function(){return d}),e.d(t,"computeRawDurationFromSamples",function(){return p}),e.d(t,"offsetStartDTS",function(){return T}),e.d(t,"segmentValidRange",function(){return l}),e.d(t,"appendUint8Array",function(){return o}),e.d(t,"parseSamples",function(){return h}),e.d(t,"parseSEIMessageFromNALu",function(){return c}),e.d(t,"parseEmsg",function(){return f});var s=e("./src/utils/typed-array.ts"),a=e("./src/loader/fragment.ts"),u=e("./src/demux/id3.ts"),R=Math.pow(2,32)-1,C=[].push,O={video:1,audio:2,id3:3,text:4};function L(g){return String.fromCharCode.apply(null,g)}function b(g,y){var M=g[y]<<8|g[y+1];return M<0?65536+M:M}function x(g,y){var M=I(g,y);return M<0?4294967296+M:M}function I(g,y){return g[y]<<24|g[y+1]<<16|g[y+2]<<8|g[y+3]}function _(g,y,M){g[y]=M>>24,g[y+1]=M>>16&255,g[y+2]=M>>8&255,g[y+3]=M&255}function A(g,y){var M=[];if(!y.length)return M;for(var D=g.byteLength,P=0;P<D;){var B=x(g,P),N=L(g.subarray(P+4,P+8)),F=B>1?P+B:D;if(N===y[0])if(y.length===1)M.push(g.subarray(P+8,F));else{var H=A(g.subarray(P+8,F),y.slice(1));H.length&&C.apply(M,H)}P=F}return M}function S(g){var y=[],M=g[0],D=8,P=x(g,D);D+=4;var B=0,N=0;M===0?D+=8:D+=16,D+=2;var F=g.length+N,H=b(g,D);D+=2;for(var V=0;V<H;V++){var X=D,$=x(g,X);X+=4;var j=$&2147483647,J=($&2147483648)>>>31;if(J===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ee=x(g,X);X+=4,y.push({referenceSize:j,subsegmentDuration:ee,info:{duration:ee/P,start:F,end:F+j-1}}),F+=j,X+=4,D=X}return{earliestPresentationTime:B,timescale:P,version:M,referencesCount:H,references:y}}function v(g){for(var y=[],M=A(g,["moov","trak"]),D=0;D<M.length;D++){var P=M[D],B=A(P,["tkhd"])[0];if(B){var N=B[0],F=N===0?12:20,H=x(B,F),V=A(P,["mdia","mdhd"])[0];if(V){N=V[0],F=N===0?12:20;var X=x(V,F),$=A(P,["mdia","hdlr"])[0];if($){var j=L($.subarray(8,12)),J={soun:a.ElementaryStreamTypes.AUDIO,vide:a.ElementaryStreamTypes.VIDEO}[j];if(J){var ee=A(P,["mdia","minf","stbl","stsd"])[0],te=void 0;ee&&(te=L(ee.subarray(12,16))),y[H]={timescale:X,type:J},y[J]={timescale:X,id:H,codec:te}}}}}}var se=A(g,["moov","mvex","trex"]);return se.forEach(function(ue){var ie=x(ue,4),he=y[ie];he&&(he.default={duration:x(ue,12),flags:x(ue,20)})}),y}function i(g,y){return A(y,["moof","traf"]).reduce(function(M,D){var P=A(D,["tfdt"])[0],B=P[0],N=A(D,["tfhd"]).reduce(function(F,H){var V=x(H,4),X=g[V];if(X){var $=x(P,4);B===1&&($*=Math.pow(2,32),$+=x(P,8));var j=X.timescale||9e4,J=$/j;if(isFinite(J)&&(F===null||J<F))return J}return F},null);return N!==null&&isFinite(N)&&(M===null||N<M)?N:M},null)||0}function d(g,y){for(var M=0,D=0,P=0,B=A(g,["moof","traf"]),N=0;N<B.length;N++){var F=B[N],H=A(F,["tfhd"])[0],V=x(H,4),X=y[V];if(!!X){var $=X.default,j=x(H,0)|($==null?void 0:$.flags),J=$==null?void 0:$.duration;j&8&&(j&2?J=x(H,12):J=x(H,8));for(var ee=X.timescale||9e4,te=A(F,["trun"]),se=0;se<te.length;se++){if(M=p(te[se]),!M&&J){var ue=x(te[se],4);M=J*ue}X.type===a.ElementaryStreamTypes.VIDEO?D+=M/ee:X.type===a.ElementaryStreamTypes.AUDIO&&(P+=M/ee)}}}if(D===0&&P===0){for(var ie=0,he=A(g,["sidx"]),me=0;me<he.length;me++){var ne=S(he[me]);ne!=null&&ne.references&&(ie+=ne.references.reduce(function(Re,Le){return Re+Le.info.duration||0},0))}return ie}return D||P}function p(g){var y=x(g,0),M=8;y&1&&(M+=4),y&4&&(M+=4);for(var D=0,P=x(g,4),B=0;B<P;B++){if(y&256){var N=x(g,M);D+=N,M+=4}y&512&&(M+=4),y&1024&&(M+=4),y&2048&&(M+=4)}return D}function T(g,y,M){A(y,["moof","traf"]).forEach(function(D){A(D,["tfhd"]).forEach(function(P){var B=x(P,4),N=g[B];if(!!N){var F=N.timescale||9e4;A(D,["tfdt"]).forEach(function(H){var V=H[0],X=x(H,4);if(V===0)X-=M*F,X=Math.max(X,0),_(H,4,X);else{X*=Math.pow(2,32),X+=x(H,8),X-=M*F,X=Math.max(X,0);var $=Math.floor(X/(R+1)),j=Math.floor(X%(R+1));_(H,4,$),_(H,8,j)}})}})})}function l(g){var y={valid:null,remainder:null},M=A(g,["moof"]);if(M){if(M.length<2)return y.remainder=g,y}else return y;var D=M[M.length-1];return y.valid=Object(s.sliceUint8)(g,0,D.byteOffset-8),y.remainder=Object(s.sliceUint8)(g,D.byteOffset-8),y}function o(g,y){var M=new Uint8Array(g.length+y.length);return M.set(g),M.set(y,g.length),M}function h(g,y){var M=[],D=y.samples,P=y.timescale,B=y.id,N=!1,F=A(D,["moof"]);return F.map(function(H){var V=H.byteOffset-8,X=A(H,["traf"]);X.map(function($){var j=A($,["tfdt"]).map(function(J){var ee=J[0],te=x(J,4);return ee===1&&(te*=Math.pow(2,32),te+=x(J,8)),te/P})[0];return j!==void 0&&(g=j),A($,["tfhd"]).map(function(J){var ee=x(J,4),te=x(J,0)&16777215,se=(te&1)!==0,ue=(te&2)!==0,ie=(te&8)!==0,he=0,me=(te&16)!==0,ne=0,Re=(te&32)!==0,Le=8;ee===B&&(se&&(Le+=8),ue&&(Le+=4),ie&&(he=x(J,Le),Le+=4),me&&(ne=x(J,Le),Le+=4),Re&&(Le+=4),y.type==="video"&&(N=E(y.codec)),A($,["trun"]).map(function(De){var _e=De[0],ke=x(De,0)&16777215,Qe=(ke&1)!==0,He=0,qe=(ke&4)!==0,Ke=(ke&256)!==0,st=0,dt=(ke&512)!==0,ct=0,ot=(ke&1024)!==0,Dt=(ke&2048)!==0,et=0,It=x(De,4),$e=8;Qe&&(He=x(De,$e),$e+=4),qe&&($e+=4);for(var Ze=He+V,Et=0;Et<It;Et++){if(Ke?(st=x(De,$e),$e+=4):st=he,dt?(ct=x(De,$e),$e+=4):ct=ne,ot&&($e+=4),Dt&&(_e===0?et=x(De,$e):et=I(De,$e),$e+=4),y.type===a.ElementaryStreamTypes.VIDEO)for(var Je=0;Je<ct;){var Ge=x(D,Ze);Ze+=4;var Pt=D[Ze]&31;if(n(N,Pt)){var ft=D.subarray(Ze,Ze+Ge);c(ft,g+et/P,M)}Ze+=Ge,Je+=Ge+4}g+=st/P}}))})})}),M}function E(g){if(!g)return!1;var y=g.indexOf("."),M=y<0?g:g.substring(0,y);return M==="hvc1"||M==="hev1"||M==="dvh1"||M==="dvhe"}function n(g,y){return g?y===39||y===40:y===6}function c(g,y,M){var D=m(g),P=0;P++;for(var B=0,N=0,F=!1,H=0;P<D.length;){B=0;do{if(P>=D.length)break;H=D[P++],B+=H}while(H===255);N=0;do{if(P>=D.length)break;H=D[P++],N+=H}while(H===255);var V=D.length-P;if(!F&&B===4&&P<D.length){F=!0;var X=D[P++];if(X===181){var $=b(D,P);if(P+=2,$===49){var j=x(D,P);if(P+=4,j===1195456820){var J=D[P++];if(J===3){var ee=D[P++],te=31&ee,se=64&ee,ue=se?2+te*3:0,ie=new Uint8Array(ue);if(se){ie[0]=ee;for(var he=1;he<ue;he++)ie[he]=D[P++]}M.push({type:J,payloadType:B,pts:y,bytes:ie})}}}}}else if(B===5&&N<V){if(F=!0,N>16){for(var me=[],ne=0;ne<16;ne++){var Re=D[P++].toString(16);me.push(Re.length==1?"0"+Re:Re),(ne===3||ne===5||ne===7||ne===9)&&me.push("-")}for(var Le=N-16,De=new Uint8Array(Le),_e=0;_e<Le;_e++)De[_e]=D[P++];M.push({payloadType:B,pts:y,uuid:me.join(""),userData:Object(u.utf8ArrayToStr)(De),userDataBytes:De})}}else if(N<V)P+=N;else if(N>V)break}}function m(g){for(var y=g.byteLength,M=[],D=1;D<y-2;)g[D]===0&&g[D+1]===0&&g[D+2]===3?(M.push(D+2),D+=2):D++;if(M.length===0)return g;var P=y-M.length,B=new Uint8Array(P),N=0;for(D=0;D<P;N++,D++)N===M[0]&&(N++,M.shift()),B[D]=g[N];return B}function f(g){var y=g[0],M="",D="",P=0,B=0,N=0,F=0,H=0,V=0;if(y===0){for(;L(g.subarray(V,V+1))!=="\0";)M+=L(g.subarray(V,V+1)),V+=1;for(M+=L(g.subarray(V,V+1)),V+=1;L(g.subarray(V,V+1))!=="\0";)D+=L(g.subarray(V,V+1)),V+=1;D+=L(g.subarray(V,V+1)),V+=1,P=x(g,12),B=x(g,16),F=x(g,20),H=x(g,24),V=28}else if(y===1){V+=4,P=x(g,V),V+=4;var X=x(g,V);V+=4;var $=x(g,V);for(V+=4,N=Math.pow(2,32)*X+$,Number.isSafeInteger(N)||(N=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),F=x(g,V),V+=4,H=x(g,V),V+=4;L(g.subarray(V,V+1))!=="\0";)M+=L(g.subarray(V,V+1)),V+=1;for(M+=L(g.subarray(V,V+1)),V+=1;L(g.subarray(V,V+1))!=="\0";)D+=L(g.subarray(V,V+1)),V+=1;D+=L(g.subarray(V,V+1)),V+=1}var j=g.subarray(V,g.byteLength);return{schemeIdUri:M,value:D,timeScale:P,presentationTime:N,presentationTimeDelta:B,eventDuration:F,id:H,payload:j}}},"./src/utils/output-filter.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return s});var s=function(){function a(R,C){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=R,this.trackName=C}var u=a.prototype;return u.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},u.newCue=function(C,O,L){(this.startTime===null||this.startTime>C)&&(this.startTime=C),this.endTime=O,this.screen=L,this.timelineController.createCaptionsTrack(this.trackName)},u.reset=function(){this.cueRanges=[],this.startTime=null},a}()},"./src/utils/texttrack-utils.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"sendAddTrackEvent",function(){return a}),e.d(t,"addCueToTrack",function(){return u}),e.d(t,"clearCurrentCues",function(){return R}),e.d(t,"removeCuesInRange",function(){return C}),e.d(t,"getCuesInRange",function(){return L});var s=e("./src/utils/logger.ts");function a(b,x){var I;try{I=new Event("addtrack")}catch{I=document.createEvent("Event"),I.initEvent("addtrack",!1,!1)}I.track=b,x.dispatchEvent(I)}function u(b,x){var I=b.mode;if(I==="disabled"&&(b.mode="hidden"),b.cues&&!b.cues.getCueById(x.id))try{if(b.addCue(x),!b.cues.getCueById(x.id))throw new Error("addCue is failed for: "+x)}catch(A){s.logger.debug("[texttrack-utils]: "+A);var _=new self.TextTrackCue(x.startTime,x.endTime,x.text);_.id=x.id,b.addCue(_)}I==="disabled"&&(b.mode=I)}function R(b){var x=b.mode;if(x==="disabled"&&(b.mode="hidden"),b.cues)for(var I=b.cues.length;I--;)b.removeCue(b.cues[I]);x==="disabled"&&(b.mode=x)}function C(b,x,I,_){var A=b.mode;if(A==="disabled"&&(b.mode="hidden"),b.cues&&b.cues.length>0)for(var S=L(b.cues,x,I),v=0;v<S.length;v++)(!_||_(S[v]))&&b.removeCue(S[v]);A==="disabled"&&(b.mode=A)}function O(b,x){if(x<b[0].startTime)return 0;var I=b.length-1;if(x>b[I].endTime)return-1;for(var _=0,A=I;_<=A;){var S=Math.floor((A+_)/2);if(x<b[S].startTime)A=S-1;else if(x>b[S].startTime&&_<I)_=S+1;else return S}return b[_].startTime-x<x-b[A].startTime?_:A}function L(b,x,I){var _=[],A=O(b,x);if(A>-1)for(var S=A,v=b.length;S<v;S++){var i=b[S];if(i.startTime>=x&&i.endTime<=I)_.push(i);else if(i.startTime>I)return _}return _}},"./src/utils/time-ranges.ts":function(r,t,e){"use strict";e.r(t);var s={toString:function(u){for(var R="",C=u.length,O=0;O<C;O++)R+="["+u.start(O).toFixed(3)+","+u.end(O).toFixed(3)+"]";return R}};t.default=s},"./src/utils/timescale-conversion.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"toTimescaleFromBase",function(){return a}),e.d(t,"toTimescaleFromScale",function(){return u}),e.d(t,"toMsFromMpegTsClock",function(){return R}),e.d(t,"toMpegTsClockFromTimescale",function(){return C});var s=9e4;function a(O,L,b,x){b===void 0&&(b=1),x===void 0&&(x=!1);var I=O*L*b;return x?Math.round(I):I}function u(O,L,b,x){return b===void 0&&(b=1),x===void 0&&(x=!1),a(O,L,1/b,x)}function R(O,L){return L===void 0&&(L=!1),a(O,1e3,1/s,L)}function C(O,L){return L===void 0&&(L=1),a(O,s,1/L)}},"./src/utils/typed-array.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"sliceUint8",function(){return s});function s(a,u,R){return Uint8Array.prototype.slice?a.slice(u,R):new Uint8Array(Array.prototype.slice.call(a,u,R))}},"./src/utils/vttcue.ts":function(r,t,e){"use strict";e.r(t),t.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var s=["","lr","rl"],a=["start","middle","end","left","right"];function u(b,x){if(typeof x!="string"||!Array.isArray(b))return!1;var I=x.toLowerCase();return~b.indexOf(I)?I:!1}function R(b){return u(s,b)}function C(b){return u(a,b)}function O(b){for(var x=arguments.length,I=new Array(x>1?x-1:0),_=1;_<x;_++)I[_-1]=arguments[_];for(var A=1;A<arguments.length;A++){var S=arguments[A];for(var v in S)b[v]=S[v]}return b}function L(b,x,I){var _=this,A={enumerable:!0};_.hasBeenReset=!1;var S="",v=!1,i=b,d=x,p=I,T=null,l="",o=!0,h="auto",E="start",n=50,c="middle",m=50,f="middle";Object.defineProperty(_,"id",O({},A,{get:function(){return S},set:function(y){S=""+y}})),Object.defineProperty(_,"pauseOnExit",O({},A,{get:function(){return v},set:function(y){v=!!y}})),Object.defineProperty(_,"startTime",O({},A,{get:function(){return i},set:function(y){if(typeof y!="number")throw new TypeError("Start time must be set to a number.");i=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"endTime",O({},A,{get:function(){return d},set:function(y){if(typeof y!="number")throw new TypeError("End time must be set to a number.");d=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"text",O({},A,{get:function(){return p},set:function(y){p=""+y,this.hasBeenReset=!0}})),Object.defineProperty(_,"region",O({},A,{get:function(){return T},set:function(y){T=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"vertical",O({},A,{get:function(){return l},set:function(y){var M=R(y);if(M===!1)throw new SyntaxError("An invalid or illegal string was specified.");l=M,this.hasBeenReset=!0}})),Object.defineProperty(_,"snapToLines",O({},A,{get:function(){return o},set:function(y){o=!!y,this.hasBeenReset=!0}})),Object.defineProperty(_,"line",O({},A,{get:function(){return h},set:function(y){if(typeof y!="number"&&y!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");h=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"lineAlign",O({},A,{get:function(){return E},set:function(y){var M=C(y);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");E=M,this.hasBeenReset=!0}})),Object.defineProperty(_,"position",O({},A,{get:function(){return n},set:function(y){if(y<0||y>100)throw new Error("Position must be between 0 and 100.");n=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"positionAlign",O({},A,{get:function(){return c},set:function(y){var M=C(y);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");c=M,this.hasBeenReset=!0}})),Object.defineProperty(_,"size",O({},A,{get:function(){return m},set:function(y){if(y<0||y>100)throw new Error("Size must be between 0 and 100.");m=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"align",O({},A,{get:function(){return f},set:function(y){var M=C(y);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");f=M,this.hasBeenReset=!0}})),_.displayState=void 0}return L.prototype.getCueAsHTML=function(){var b=self.WebVTT;return b.convertCueToDOMTree(self,this.text)},L}()},"./src/utils/vttparser.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"parseTimeStamp",function(){return u}),e.d(t,"fixLineBreaks",function(){return x}),e.d(t,"VTTParser",function(){return I});var s=e("./src/utils/vttcue.ts"),a=function(){function _(){}var A=_.prototype;return A.decode=function(v,i){if(!v)return"";if(typeof v!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(v))},_}();function u(_){function A(v,i,d,p){return(v|0)*3600+(i|0)*60+(d|0)+parseFloat(p||0)}var S=_.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return S?parseFloat(S[2])>59?A(S[2],S[3],0,S[4]):A(S[1],S[2],S[3],S[4]):null}var R=function(){function _(){this.values=Object.create(null)}var A=_.prototype;return A.set=function(v,i){!this.get(v)&&i!==""&&(this.values[v]=i)},A.get=function(v,i,d){return d?this.has(v)?this.values[v]:i[d]:this.has(v)?this.values[v]:i},A.has=function(v){return v in this.values},A.alt=function(v,i,d){for(var p=0;p<d.length;++p)if(i===d[p]){this.set(v,i);break}},A.integer=function(v,i){/^-?\d+$/.test(i)&&this.set(v,parseInt(i,10))},A.percent=function(v,i){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(i)){var d=parseFloat(i);if(d>=0&&d<=100)return this.set(v,d),!0}return!1},_}();function C(_,A,S,v){var i=v?_.split(v):[_];for(var d in i)if(typeof i[d]=="string"){var p=i[d].split(S);if(p.length===2){var T=p[0],l=p[1];A(T,l)}}}var O=new s.default(0,0,""),L=O.align==="middle"?"middle":"center";function b(_,A,S){var v=_;function i(){var T=u(_);if(T===null)throw new Error("Malformed timestamp: "+v);return _=_.replace(/^[^\sa-zA-Z-]+/,""),T}function d(T,l){var o=new R;C(T,function(n,c){var m;switch(n){case"region":for(var f=S.length-1;f>=0;f--)if(S[f].id===c){o.set(n,S[f].region);break}break;case"vertical":o.alt(n,c,["rl","lr"]);break;case"line":m=c.split(","),o.integer(n,m[0]),o.percent(n,m[0])&&o.set("snapToLines",!1),o.alt(n,m[0],["auto"]),m.length===2&&o.alt("lineAlign",m[1],["start",L,"end"]);break;case"position":m=c.split(","),o.percent(n,m[0]),m.length===2&&o.alt("positionAlign",m[1],["start",L,"end","line-left","line-right","auto"]);break;case"size":o.percent(n,c);break;case"align":o.alt(n,c,["start",L,"end","left","right"]);break}},/:/,/\s/),l.region=o.get("region",null),l.vertical=o.get("vertical","");var h=o.get("line","auto");h==="auto"&&O.line===-1&&(h=-1),l.line=h,l.lineAlign=o.get("lineAlign","start"),l.snapToLines=o.get("snapToLines",!0),l.size=o.get("size",100),l.align=o.get("align",L);var E=o.get("position","auto");E==="auto"&&O.position===50&&(E=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=E}function p(){_=_.replace(/^\s+/,"")}if(p(),A.startTime=i(),p(),_.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+v);_=_.slice(3),p(),A.endTime=i(),p(),d(_,A)}function x(_){return _.replace(/<br(?: \/)?>/gi,`
22
- `)}var I=function(){function _(){this.state="INITIAL",this.buffer="",this.decoder=new a,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var A=_.prototype;return A.parse=function(v){var i=this;v&&(i.buffer+=i.decoder.decode(v,{stream:!0}));function d(){var E=i.buffer,n=0;for(E=x(E);n<E.length&&E[n]!=="\r"&&E[n]!==`
19
+ initSegmentChange: `+J);var te=new R.TransmuxConfig(p,T,d,h,c);this.configureTransmuxer(te)}if(this.frag=l,this.part=o,M)M.postMessage({cmd:"demux",data:i,decryptdata:P,chunkMeta:n,state:ee},i instanceof ArrayBuffer?[i]:[]);else if(y){var le=y.push(i,P,n,ee);Object(R.isPromise)(le)?le.then(function(ue){g.handleTransmuxComplete(ue)}):this.handleTransmuxComplete(le)}},S.flush=function(i){var d=this;i.transmuxing.start=self.performance.now();var p=this.transmuxer,T=this.worker;if(T)T.postMessage({cmd:"flush",chunkMeta:i});else if(p){var l=p.flush(i);Object(R.isPromise)(l)?l.then(function(o){d.handleFlushResult(o,i)}):this.handleFlushResult(l,i)}},S.handleFlushResult=function(i,d){var p=this;i.forEach(function(T){p.handleTransmuxComplete(T)}),this.onFlush(d)},S.onWorkerMessage=function(i){var d=i.data,p=this.hls;switch(d.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(d.data);break}case"flush":{this.onFlush(d.data);break}case"workerLog":C.logger[d.data.logType]&&C.logger[d.data.logType](d.data.message);break;default:{d.data=d.data||{},d.data.frag=this.frag,d.data.id=this.id,p.trigger(d.event,d.data);break}}},S.configureTransmuxer=function(i){var d=this.worker,p=this.transmuxer;d?d.postMessage({cmd:"configure",config:i}):p&&p.configure(i)},S.handleTransmuxComplete=function(i){i.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(i)},A}()},"./src/demux/transmuxer-worker.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return O});var a=e("./src/demux/transmuxer.ts"),s=e("./src/events.ts"),u=e("./src/utils/logger.ts"),R=e("./node_modules/eventemitter3/index.js"),C=e.n(R);function O(_){var A=new R.EventEmitter,S=function(d,p){_.postMessage({event:d,data:p})};A.on(s.Events.FRAG_DECRYPTED,S),A.on(s.Events.ERROR,S);var m=function(){var d=function(l){var o=function(E){S("workerLog",{logType:l,message:E})};u.logger[l]=o};for(var p in u.logger)d(p)};_.addEventListener("message",function(i){var d=i.data;switch(d.cmd){case"init":{var p=JSON.parse(d.config);_.transmuxer=new a.default(A,d.typeSupported,p,d.vendor,d.id),Object(u.enableLogs)(p.debug),m(),S("init",null);break}case"configure":{_.transmuxer.configure(d.config);break}case"demux":{var T=_.transmuxer.push(d.data,d.decryptdata,d.chunkMeta,d.state);Object(a.isPromise)(T)?T.then(function(h){L(_,h)}):L(_,T);break}case"flush":{var l=d.chunkMeta,o=_.transmuxer.flush(l);Object(a.isPromise)(o)?o.then(function(h){x(_,h,l)}):x(_,o,l);break}default:break}})}function L(_,A){if(I(A.remuxResult))return!1;var S=[],m=A.remuxResult,i=m.audio,d=m.video;return i&&b(S,i),d&&b(S,d),_.postMessage({event:"transmuxComplete",data:A},S),!0}function b(_,A){A.data1&&_.push(A.data1.buffer),A.data2&&_.push(A.data2.buffer)}function x(_,A,S){var m=A.reduce(function(i,d){return L(_,d)||i},!1);m||_.postMessage({event:"transmuxComplete",data:A[0]}),_.postMessage({event:"flush",data:S})}function I(_){return!_.audio&&!_.video&&!_.text&&!_.id3&&!_.initSegment}},"./src/demux/transmuxer.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return S}),e.d(t,"isPromise",function(){return d}),e.d(t,"TransmuxConfig",function(){return p}),e.d(t,"TransmuxState",function(){return T});var a=e("./src/events.ts"),s=e("./src/errors.ts"),u=e("./src/crypt/decrypter.ts"),R=e("./src/demux/aacdemuxer.ts"),C=e("./src/demux/mp4demuxer.ts"),O=e("./src/demux/tsdemuxer.ts"),L=e("./src/demux/mp3demuxer.ts"),b=e("./src/remux/mp4-remuxer.ts"),x=e("./src/remux/passthrough-remuxer.ts"),I=e("./src/utils/logger.ts"),_;try{_=self.performance.now.bind(self.performance)}catch{I.logger.debug("Unable to use Performance API on this environment"),_=self.Date.now}var A=[{demux:O.default,remux:b.default},{demux:C.default,remux:x.default},{demux:R.default,remux:b.default},{demux:L.default,remux:b.default}],S=function(){function l(h,E,n,c,v){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=h,this.typeSupported=E,this.config=n,this.vendor=c,this.id=v}var o=l.prototype;return o.configure=function(E){this.transmuxConfig=E,this.decrypter&&this.decrypter.reset()},o.push=function(E,n,c,v){var f=this,g=c.transmuxing;g.executeStart=_();var y=new Uint8Array(E),M=this.config,D=this.currentTransmuxState,P=this.transmuxConfig;v&&(this.currentTransmuxState=v);var B=v||D,N=B.contiguous,F=B.discontinuity,H=B.trackSwitch,V=B.accurateTimeOffset,X=B.timeOffset,$=B.initSegmentChange,j=P.audioCodec,J=P.videoCodec,ee=P.defaultInitPts,te=P.duration,le=P.initSegmentData;(F||H||$)&&this.resetInitSegment(le,j,J,te),(F||$)&&this.resetInitialTimestamp(ee),N||this.resetContiguity();var ue=m(y,n);if(ue&&ue.method==="AES-128"){var ie=this.getDecrypter();if(M.enableSoftwareAES){var he=ie.softwareDecrypt(y,ue.key.buffer,ue.iv.buffer);if(!he)return g.executeEnd=_(),i(c);y=new Uint8Array(he)}else return this.decryptionPromise=ie.webCryptoDecrypt(y,ue.key.buffer,ue.iv.buffer).then(function(Re){var Le=f.push(Re,null,c);return f.decryptionPromise=null,Le}),this.decryptionPromise}this.needsProbing(y,F,H)&&this.configureTransmuxer(y,P);var ve=this.transmux(y,ue,X,V,c),ae=this.currentTransmuxState;return ae.contiguous=!0,ae.discontinuity=!1,ae.trackSwitch=!1,g.executeEnd=_(),ve},o.flush=function(E){var n=this,c=E.transmuxing;c.executeStart=_();var v=this.decrypter,f=this.currentTransmuxState,g=this.decryptionPromise;if(g)return g.then(function(){return n.flush(E)});var y=[],M=f.timeOffset;if(v){var D=v.flush();D&&y.push(this.push(D,null,E))}var P=this.demuxer,B=this.remuxer;if(!P||!B)return this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),c.executeEnd=_(),[i(E)];var N=P.flush(M);return d(N)?N.then(function(F){return n.flushRemux(y,F,E),y}):(this.flushRemux(y,N,E),y)},o.flushRemux=function(E,n,c){var v=n.audioTrack,f=n.videoTrack,g=n.id3Track,y=n.textTrack,M=this.currentTransmuxState,D=M.accurateTimeOffset,P=M.timeOffset;I.logger.log("[transmuxer.ts]: Flushed fragment "+c.sn+(c.part>-1?" p: "+c.part:"")+" of level "+c.level);var B=this.remuxer.remux(v,f,g,y,P,D,!0,this.id);E.push({remuxResult:B,chunkMeta:c}),c.transmuxing.executeEnd=_()},o.resetInitialTimestamp=function(E){var n=this.demuxer,c=this.remuxer;!n||!c||(n.resetTimeStamp(E),c.resetTimeStamp(E))},o.resetContiguity=function(){var E=this.demuxer,n=this.remuxer;!E||!n||(E.resetContiguity(),n.resetNextTimestamp())},o.resetInitSegment=function(E,n,c,v){var f=this.demuxer,g=this.remuxer;!f||!g||(f.resetInitSegment(E,n,c,v),g.resetInitSegment(E,n,c))},o.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},o.transmux=function(E,n,c,v,f){var g;return n&&n.method==="SAMPLE-AES"?g=this.transmuxSampleAes(E,n,c,v,f):g=this.transmuxUnencrypted(E,c,v,f),g},o.transmuxUnencrypted=function(E,n,c,v){var f=this.demuxer.demux(E,n,!1,!this.config.progressive),g=f.audioTrack,y=f.videoTrack,M=f.id3Track,D=f.textTrack,P=this.remuxer.remux(g,y,M,D,n,c,!1,this.id);return{remuxResult:P,chunkMeta:v}},o.transmuxSampleAes=function(E,n,c,v,f){var g=this;return this.demuxer.demuxSampleAes(E,n,c).then(function(y){var M=g.remuxer.remux(y.audioTrack,y.videoTrack,y.id3Track,y.textTrack,c,v,!1,g.id);return{remuxResult:M,chunkMeta:f}})},o.configureTransmuxer=function(E,n){for(var c=this.config,v=this.observer,f=this.typeSupported,g=this.vendor,y=n.audioCodec,M=n.defaultInitPts,D=n.duration,P=n.initSegmentData,B=n.videoCodec,N,F=0,H=A.length;F<H;F++)if(A[F].demux.probe(E)){N=A[F];break}N||(I.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),N={demux:C.default,remux:x.default});var V=this.demuxer,X=this.remuxer,$=N.remux,j=N.demux;(!X||!(X instanceof $))&&(this.remuxer=new $(v,c,f,g)),(!V||!(V instanceof j))&&(this.demuxer=new j(v,c,f),this.probe=j.probe),this.resetInitSegment(P,y,B,D),this.resetInitialTimestamp(M)},o.needsProbing=function(E,n,c){return!this.demuxer||!this.remuxer||n||c},o.getDecrypter=function(){var E=this.decrypter;return E||(E=this.decrypter=new u.default(this.observer,this.config)),E},l}();function m(l,o){var h=null;return l.byteLength>0&&o!=null&&o.key!=null&&o.iv!==null&&o.method!=null&&(h=o),h}var i=function(o){return{remuxResult:{},chunkMeta:o}};function d(l){return"then"in l&&l.then instanceof Function}var p=function(o,h,E,n,c){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=o,this.videoCodec=h,this.initSegmentData=E,this.duration=n,this.defaultInitPts=c},T=function(o,h,E,n,c,v){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=o,this.contiguous=h,this.accurateTimeOffset=E,this.trackSwitch=n,this.timeOffset=c,this.initSegmentChange=v}},"./src/demux/tsdemuxer.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"discardEPB",function(){return p});var a=e("./src/demux/adts.ts"),s=e("./src/demux/mpegaudio.ts"),u=e("./src/demux/exp-golomb.ts"),R=e("./src/demux/sample-aes.ts"),C=e("./src/events.ts"),O=e("./src/utils/mp4-tools.ts"),L=e("./src/utils/logger.ts"),b=e("./src/errors.ts"),x=e("./src/types/demuxer.ts");function I(){return I=Object.assign?Object.assign.bind():function(T){for(var l=1;l<arguments.length;l++){var o=arguments[l];for(var h in o)Object.prototype.hasOwnProperty.call(o,h)&&(T[h]=o[h])}return T},I.apply(this,arguments)}var _=function(){function T(o,h,E){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=o,this.config=h,this.typeSupported=E}T.probe=function(h){return h[0]===71&&h[188]===71},T.createTrack=function(h,E){return{container:h==="video"||h==="audio"?"video/mp2t":void 0,type:h,id:O.RemuxerTrackIdConfig[h],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:h==="audio"?E:void 0}};var l=T.prototype;return l.resetInitSegment=function(h,E,n,c){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=T.createTrack("video"),this._audioTrack=T.createTrack("audio",c),this._id3Track=T.createTrack("id3"),this._txtTrack=T.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=E,this.videoCodec=n,this._duration=c},l.resetTimeStamp=function(){},l.resetContiguity=function(){var h=this._audioTrack,E=this._avcTrack,n=this._id3Track;h&&(h.pesData=null),E&&(E.pesData=null),n&&(n.pesData=null),this.aacOverFlow=null},l.demux=function(h,E,n,c){n===void 0&&(n=!1),c===void 0&&(c=!1),n||(this.sampleAes=null);var v,f=this._avcTrack,g=this._audioTrack,y=this._id3Track,M=this._txtTrack,D=f.pid,P=f.pesData,B=g.pid,N=y.pid,F=g.pesData,H=y.pesData,V=null,X=this.pmtParsed,$=this._pmtId,j=h.length;if(this.remainderData&&(h=Object(O.appendUint8Array)(this.remainderData,h),j=h.length,this.remainderData=null),j<188&&!c)return this.remainderData=h,{audioTrack:g,videoTrack:f,id3Track:y,textTrack:M};j-=j%188,j<h.byteLength&&!c&&(this.remainderData=new Uint8Array(h.buffer,j,h.buffer.byteLength-j));for(var J=0,ee=0;ee<j;ee+=188)if(h[ee]===71){var te=!!(h[ee+1]&64),le=((h[ee+1]&31)<<8)+h[ee+2],ue=(h[ee+3]&48)>>4,ie=void 0;if(ue>1){if(ie=ee+5+h[ee+4],ie===ee+188)continue}else ie=ee+4;switch(le){case D:te&&(P&&(v=i(P))&&this.parseAVCPES(f,M,v,!1),P={data:[],size:0}),P&&(P.data.push(h.subarray(ie,ee+188)),P.size+=ee+188-ie);break;case B:if(te){if(F&&(v=i(F)))switch(g.segmentCodec){case"aac":this.parseAACPES(g,v);break;case"mp3":this.parseMPEGPES(g,v);break}F={data:[],size:0}}F&&(F.data.push(h.subarray(ie,ee+188)),F.size+=ee+188-ie);break;case N:te&&(H&&(v=i(H))&&this.parseID3PES(y,v),H={data:[],size:0}),H&&(H.data.push(h.subarray(ie,ee+188)),H.size+=ee+188-ie);break;case 0:te&&(ie+=h[ie]+1),$=this._pmtId=S(h,ie);break;case $:{te&&(ie+=h[ie]+1);var he=m(h,ie,this.typeSupported,n);D=he.avc,D>0&&(f.pid=D),B=he.audio,B>0&&(g.pid=B,g.segmentCodec=he.segmentCodec),N=he.id3,N>0&&(y.pid=N),V!==null&&!X&&(L.logger.log("unknown PID '"+V+"' in TS found"),V=null),X=this.pmtParsed=!0;break}case 17:case 8191:break;default:V=le;break}}else J++;J>0&&this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+J+" TS packet/s that do not start with 0x47"}),f.pesData=P,g.pesData=F,y.pesData=H;var ve={audioTrack:g,videoTrack:f,id3Track:y,textTrack:M};return c&&this.extractRemainingSamples(ve),ve},l.flush=function(){var h=this.remainderData;this.remainderData=null;var E;return h?E=this.demux(h,-1,!1,!0):E={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(E),this.sampleAes?this.decrypt(E,this.sampleAes):E},l.extractRemainingSamples=function(h){var E=h.audioTrack,n=h.videoTrack,c=h.id3Track,v=h.textTrack,f=n.pesData,g=E.pesData,y=c.pesData,M;if(f&&(M=i(f))?(this.parseAVCPES(n,v,M,!0),n.pesData=null):n.pesData=f,g&&(M=i(g))){switch(E.segmentCodec){case"aac":this.parseAACPES(E,M);break;case"mp3":this.parseMPEGPES(E,M);break}E.pesData=null}else g!=null&&g.size&&L.logger.log("last AAC PES packet truncated,might overlap between fragments"),E.pesData=g;y&&(M=i(y))?(this.parseID3PES(c,M),c.pesData=null):c.pesData=y},l.demuxSampleAes=function(h,E,n){var c=this.demux(h,n,!0,!this.config.progressive),v=this.sampleAes=new R.default(this.observer,this.config,E);return this.decrypt(c,v)},l.decrypt=function(h,E){return new Promise(function(n){var c=h.audioTrack,v=h.videoTrack;c.samples&&c.segmentCodec==="aac"?E.decryptAacSamples(c.samples,0,function(){v.samples?E.decryptAvcSamples(v.samples,0,0,function(){n(h)}):n(h)}):v.samples&&E.decryptAvcSamples(v.samples,0,0,function(){n(h)})})},l.destroy=function(){this._duration=0},l.parseAVCPES=function(h,E,n,c){var v=this,f=this.parseAVCNALu(h,n.data),g=!1,y=this.avcSample,M,D=!1;n.data=null,y&&f.length&&!h.audFound&&(d(y,h),y=this.avcSample=A(!1,n.pts,n.dts,"")),f.forEach(function(P){switch(P.type){case 1:{M=!0,y||(y=v.avcSample=A(!0,n.pts,n.dts,"")),g&&(y.debug+="NDR "),y.frame=!0;var B=P.data;if(D&&B.length>4){var N=new u.default(B).readSliceType();(N===2||N===4||N===7||N===9)&&(y.key=!0)}break}case 5:M=!0,y||(y=v.avcSample=A(!0,n.pts,n.dts,"")),g&&(y.debug+="IDR "),y.key=!0,y.frame=!0;break;case 6:{M=!0,g&&y&&(y.debug+="SEI "),Object(O.parseSEIMessageFromNALu)(p(P.data),n.pts,E.samples);break}case 7:if(M=!0,D=!0,g&&y&&(y.debug+="SPS "),!h.sps){var F=new u.default(P.data),H=F.readSPS();h.width=H.width,h.height=H.height,h.pixelRatio=H.pixelRatio,h.sps=[P.data],h.duration=v._duration;for(var V=P.data.subarray(1,4),X="avc1.",$=0;$<3;$++){var j=V[$].toString(16);j.length<2&&(j="0"+j),X+=j}h.codec=X}break;case 8:M=!0,g&&y&&(y.debug+="PPS "),h.pps||(h.pps=[P.data]);break;case 9:M=!1,h.audFound=!0,y&&d(y,h),y=v.avcSample=A(!1,n.pts,n.dts,g?"AUD ":"");break;case 12:M=!0;break;default:M=!1,y&&(y.debug+="unknown NAL "+P.type+" ");break}if(y&&M){var J=y.units;J.push(P)}}),c&&y&&(d(y,h),this.avcSample=null)},l.getLastNalUnit=function(h){var E,n=this.avcSample,c;if((!n||n.units.length===0)&&(n=h[h.length-1]),(E=n)!==null&&E!==void 0&&E.units){var v=n.units;c=v[v.length-1]}return c},l.parseAVCNALu=function(h,E){var n=E.byteLength,c=h.naluState||0,v=c,f=[],g=0,y,M,D,P=-1,B=0;for(c===-1&&(P=0,B=E[0]&31,c=0,g=1);g<n;){if(y=E[g++],!c){c=y?0:1;continue}if(c===1){c=y?0:2;continue}if(!y)c=3;else if(y===1){if(P>=0){var N={data:E.subarray(P,g-c-1),type:B};f.push(N)}else{var F=this.getLastNalUnit(h.samples);if(F&&(v&&g<=4-v&&F.state&&(F.data=F.data.subarray(0,F.data.byteLength-v)),M=g-c-1,M>0)){var H=new Uint8Array(F.data.byteLength+M);H.set(F.data,0),H.set(E.subarray(0,M),F.data.byteLength),F.data=H,F.state=0}}g<n?(D=E[g]&31,P=g,B=D,c=0):c=-1}else c=0}if(P>=0&&c>=0){var V={data:E.subarray(P,n),type:B,state:c};f.push(V)}if(f.length===0){var X=this.getLastNalUnit(h.samples);if(X){var $=new Uint8Array(X.data.byteLength+E.byteLength);$.set(X.data,0),$.set(E,X.data.byteLength),X.data=$}}return h.naluState=c,f},l.parseAACPES=function(h,E){var n=0,c=this.aacOverFlow,v=E.data;if(c){this.aacOverFlow=null;var f=c.missing,g=c.sample.unit.byteLength;if(f===-1){var y=new Uint8Array(g+v.byteLength);y.set(c.sample.unit,0),y.set(v,g),v=y}else{var M=g-f;c.sample.unit.set(v.subarray(0,f),M),h.samples.push(c.sample),n=c.missing}}var D,P;for(D=n,P=v.length;D<P-1&&!a.isHeader(v,D);D++);if(D!==n){var B,N;if(D<P-1?(B="AAC PES did not start with ADTS header,offset:"+D,N=!1):(B="no ADTS header found in AAC PES",N=!0),L.logger.warn("parsing error:"+B),this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.FRAG_PARSING_ERROR,fatal:N,reason:B}),N)return}a.initTrackConfig(h,this.observer,v,D,this.audioCodec);var F;if(E.pts!==void 0)F=E.pts;else if(c){var H=a.getFrameDuration(h.samplerate);F=c.sample.pts+H}else{L.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var V=0,X;D<P;)if(X=a.appendFrame(h,v,D,F,V),D+=X.length,X.missing){this.aacOverFlow=X;break}else for(V++;D<P-1&&!a.isHeader(v,D);D++);},l.parseMPEGPES=function(h,E){var n=E.data,c=n.length,v=0,f=0,g=E.pts;if(g===void 0){L.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;f<c;)if(s.isHeader(n,f)){var y=s.appendFrame(h,n,f,g,v);if(y)f+=y.length,v++;else break}else f++},l.parseID3PES=function(h,E){if(E.pts===void 0){L.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var n=I({},E,{type:this._avcTrack?x.MetadataSchema.emsg:x.MetadataSchema.audioId3});h.samples.push(n)},T}();function A(T,l,o,h){return{key:T,frame:!1,pts:l,dts:o,units:[],debug:h,length:0}}function S(T,l){return(T[l+10]&31)<<8|T[l+11]}function m(T,l,o,h){var E={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=(T[l+1]&15)<<8|T[l+2],c=l+3+n-4,v=(T[l+10]&15)<<8|T[l+11];for(l+=12+v;l<c;){var f=(T[l+1]&31)<<8|T[l+2];switch(T[l]){case 207:if(!h){L.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:E.audio===-1&&(E.audio=f);break;case 21:E.id3===-1&&(E.id3=f);break;case 219:if(!h){L.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:E.avc===-1&&(E.avc=f);break;case 3:case 4:o.mpeg!==!0&&o.mp3!==!0?L.logger.log("MPEG audio found, not supported in this browser"):E.audio===-1&&(E.audio=f,E.segmentCodec="mp3");break;case 36:L.logger.warn("Unsupported HEVC stream type found");break;default:break}l+=((T[l+3]&15)<<8|T[l+4])+5}return E}function i(T){var l=0,o,h,E,n,c,v=T.data;if(!T||T.size===0)return null;for(;v[0].length<19&&v.length>1;){var f=new Uint8Array(v[0].length+v[1].length);f.set(v[0]),f.set(v[1],v[0].length),v[0]=f,v.splice(1,1)}o=v[0];var g=(o[0]<<16)+(o[1]<<8)+o[2];if(g===1){if(h=(o[4]<<8)+o[5],h&&h>T.size-6)return null;var y=o[7];y&192&&(n=(o[9]&14)*536870912+(o[10]&255)*4194304+(o[11]&254)*16384+(o[12]&255)*128+(o[13]&254)/2,y&64?(c=(o[14]&14)*536870912+(o[15]&255)*4194304+(o[16]&254)*16384+(o[17]&255)*128+(o[18]&254)/2,n-c>60*9e4&&(L.logger.warn(Math.round((n-c)/9e4)+"s delta between PTS and DTS, align them"),n=c)):c=n),E=o[8];var M=E+9;if(T.size<=M)return null;T.size-=M;for(var D=new Uint8Array(T.size),P=0,B=v.length;P<B;P++){o=v[P];var N=o.byteLength;if(M)if(M>N){M-=N;continue}else o=o.subarray(M),N-=M,M=0;D.set(o,l),l+=N}return h&&(h-=E+3),{data:D,pts:n,dts:c,len:h}}return null}function d(T,l){if(T.units.length&&T.frame){if(T.pts===void 0){var o=l.samples,h=o.length;if(h){var E=o[h-1];T.pts=E.pts,T.dts=E.dts}else{l.dropped++;return}}l.samples.push(T)}T.debug.length&&L.logger.log(T.pts+"/"+T.dts+":"+T.debug)}function p(T){for(var l=T.byteLength,o=[],h=1;h<l-2;)T[h]===0&&T[h+1]===0&&T[h+2]===3?(o.push(h+2),h+=2):h++;if(o.length===0)return T;var E=l-o.length,n=new Uint8Array(E),c=0;for(h=0;h<E;c++,h++)c===o[0]&&(c++,o.shift()),n[h]=T[c];return n}t.default=_},"./src/errors.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"ErrorTypes",function(){return a}),e.d(t,"ErrorDetails",function(){return s});var a;(function(u){u.NETWORK_ERROR="networkError",u.MEDIA_ERROR="mediaError",u.KEY_SYSTEM_ERROR="keySystemError",u.MUX_ERROR="muxError",u.OTHER_ERROR="otherError"})(a||(a={}));var s;(function(u){u.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",u.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",u.KEY_SYSTEM_NO_SESSION="keySystemNoSession",u.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",u.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",u.MANIFEST_LOAD_ERROR="manifestLoadError",u.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",u.MANIFEST_PARSING_ERROR="manifestParsingError",u.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",u.LEVEL_EMPTY_ERROR="levelEmptyError",u.LEVEL_LOAD_ERROR="levelLoadError",u.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",u.LEVEL_SWITCH_ERROR="levelSwitchError",u.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",u.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",u.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",u.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",u.FRAG_LOAD_ERROR="fragLoadError",u.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",u.FRAG_DECRYPT_ERROR="fragDecryptError",u.FRAG_PARSING_ERROR="fragParsingError",u.REMUX_ALLOC_ERROR="remuxAllocError",u.KEY_LOAD_ERROR="keyLoadError",u.KEY_LOAD_TIMEOUT="keyLoadTimeOut",u.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",u.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",u.BUFFER_APPEND_ERROR="bufferAppendError",u.BUFFER_APPENDING_ERROR="bufferAppendingError",u.BUFFER_STALLED_ERROR="bufferStalledError",u.BUFFER_FULL_ERROR="bufferFullError",u.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",u.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",u.INTERNAL_EXCEPTION="internalException",u.INTERNAL_ABORTED="aborted",u.UNKNOWN="unknown"})(s||(s={}))},"./src/events.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"Events",function(){return a});var a;(function(s){s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached"})(a||(a={}))},"./src/hls.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return l});var a=e("./node_modules/url-toolkit/src/url-toolkit.js"),s=e.n(a),u=e("./src/loader/playlist-loader.ts"),R=e("./src/loader/key-loader.ts"),C=e("./src/controller/id3-track-controller.ts"),O=e("./src/controller/latency-controller.ts"),L=e("./src/controller/level-controller.ts"),b=e("./src/controller/fragment-tracker.ts"),x=e("./src/controller/stream-controller.ts"),I=e("./src/is-supported.ts"),_=e("./src/utils/logger.ts"),A=e("./src/config.ts"),S=e("./node_modules/eventemitter3/index.js"),m=e.n(S),i=e("./src/events.ts"),d=e("./src/errors.ts");function p(o,h){for(var E=0;E<h.length;E++){var n=h[E];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(o,n.key,n)}}function T(o,h,E){return h&&p(o.prototype,h),E&&p(o,E),Object.defineProperty(o,"prototype",{writable:!1}),o}var l=function(){o.isSupported=function(){return Object(I.isSupported)()};function o(E){E===void 0&&(E={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new S.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 n=this.config=Object(A.mergeConfig)(o.DefaultConfig,E);this.userConfig=E,Object(_.enableLogs)(n.debug),this._autoLevelCapping=-1,n.progressive&&Object(A.enableStreamingMode)(n);var c=n.abrController,v=n.bufferController,f=n.capLevelController,g=n.fpsController,y=this.abrController=new c(this),M=this.bufferController=new v(this),D=this.capLevelController=new f(this),P=new g(this),B=new u.default(this),N=new R.default(this),F=new C.default(this),H=this.levelController=new L.default(this),V=new b.FragmentTracker(this),X=this.streamController=new x.default(this,V);D.setStreamController(X),P.setStreamController(X);var $=[B,N,H,X];this.networkControllers=$;var j=[y,M,D,P,F,V];this.audioTrackController=this.createController(n.audioTrackController,null,$),this.createController(n.audioStreamController,V,$),this.subtitleTrackController=this.createController(n.subtitleTrackController,null,$),this.createController(n.subtitleStreamController,V,$),this.createController(n.timelineController,null,j),this.emeController=this.createController(n.emeController,null,j),this.cmcdController=this.createController(n.cmcdController,null,j),this.latencyController=this.createController(O.default,null,j),this.coreComponents=j}var h=o.prototype;return h.createController=function(n,c,v){if(n){var f=c?new n(this,c):new n(this);return v&&v.push(f),f}return null},h.on=function(n,c,v){v===void 0&&(v=this),this._emitter.on(n,c,v)},h.once=function(n,c,v){v===void 0&&(v=this),this._emitter.once(n,c,v)},h.removeAllListeners=function(n){this._emitter.removeAllListeners(n)},h.off=function(n,c,v,f){v===void 0&&(v=this),this._emitter.off(n,c,v,f)},h.listeners=function(n){return this._emitter.listeners(n)},h.emit=function(n,c,v){return this._emitter.emit(n,c,v)},h.trigger=function(n,c){if(this.config.debug)return this.emit(n,n,c);try{return this.emit(n,n,c)}catch(v){_.logger.error("An internal error happened while handling event "+n+'. Error message: "'+v.message+'". Here is a stacktrace:',v),this.trigger(i.Events.ERROR,{type:d.ErrorTypes.OTHER_ERROR,details:d.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:n,error:v})}return!1},h.listenerCount=function(n){return this._emitter.listenerCount(n)},h.destroy=function(){_.logger.log("destroy"),this.trigger(i.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(n){return n.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(n){return n.destroy()}),this.coreComponents.length=0},h.attachMedia=function(n){_.logger.log("attachMedia"),this._media=n,this.trigger(i.Events.MEDIA_ATTACHING,{media:n})},h.detachMedia=function(){_.logger.log("detachMedia"),this.trigger(i.Events.MEDIA_DETACHING,void 0),this._media=null},h.loadSource=function(n){this.stopLoad();var c=this.media,v=this.url,f=this.url=a.buildAbsoluteURL(self.location.href,n,{alwaysNormalize:!0});_.logger.log("loadSource:"+f),c&&v&&v!==f&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(c)),this.trigger(i.Events.MANIFEST_LOADING,{url:n})},h.startLoad=function(n){n===void 0&&(n=-1),_.logger.log("startLoad("+n+")"),this.networkControllers.forEach(function(c){c.startLoad(n)})},h.stopLoad=function(){_.logger.log("stopLoad"),this.networkControllers.forEach(function(n){n.stopLoad()})},h.swapAudioCodec=function(){_.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},h.recoverMediaError=function(){_.logger.log("recoverMediaError");var n=this._media;this.detachMedia(),n&&this.attachMedia(n)},h.removeLevel=function(n,c){c===void 0&&(c=0),this.levelController.removeLevel(n,c)},T(o,[{key:"levels",get:function(){var n=this.levelController.levels;return n||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(n){_.logger.log("set currentLevel:"+n),this.loadLevel=n,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(n){_.logger.log("set nextLevel:"+n),this.levelController.manualLevel=n,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(n){_.logger.log("set loadLevel:"+n),this.levelController.manualLevel=n}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(n){this.levelController.nextLoadLevel=n}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(n){_.logger.log("set firstLevel:"+n),this.levelController.firstLevel=n}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(n){_.logger.log("set startLevel:"+n),n!==-1&&(n=Math.max(n,this.minAutoLevel)),this.levelController.startLevel=n}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(n){var c=!!n;c!==this.config.capLevelToPlayerSize&&(c?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=c)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(n){this._autoLevelCapping!==n&&(_.logger.log("set autoLevelCapping:"+n),this._autoLevelCapping=n)}},{key:"bandwidthEstimate",get:function(){var n=this.abrController.bwEstimator;return n?n.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var n=this.levels,c=this.config.minAutoBitrate;if(!n)return 0;for(var v=n.length,f=0;f<v;f++)if(n[f].maxBitrate>=c)return f;return 0}},{key:"maxAutoLevel",get:function(){var n=this.levels,c=this.autoLevelCapping,v;return c===-1&&n&&n.length?v=n.length-1:v=c,v}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(n){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,n)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"audioTracks",get:function(){var n=this.audioTrackController;return n?n.audioTracks:[]}},{key:"audioTrack",get:function(){var n=this.audioTrackController;return n?n.audioTrack:-1},set:function(n){var c=this.audioTrackController;c&&(c.audioTrack=n)}},{key:"subtitleTracks",get:function(){var n=this.subtitleTrackController;return n?n.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var n=this.subtitleTrackController;return n?n.subtitleTrack:-1},set:function(n){var c=this.subtitleTrackController;c&&(c.subtitleTrack=n)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var n=this.subtitleTrackController;return n?n.subtitleDisplay:!1},set:function(n){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=n)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(n){this.config.lowLatencyMode=n}},{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 i.Events}},{key:"ErrorTypes",get:function(){return d.ErrorTypes}},{key:"ErrorDetails",get:function(){return d.ErrorDetails}},{key:"DefaultConfig",get:function(){return o.defaultConfig?o.defaultConfig:A.hlsDefaultConfig},set:function(n){o.defaultConfig=n}}]),o}();l.defaultConfig=void 0},"./src/is-supported.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"isSupported",function(){return u}),e.d(t,"changeTypeSupported",function(){return R});var a=e("./src/utils/mediasource-helper.ts");function s(){return self.SourceBuffer||self.WebKitSourceBuffer}function u(){var C=Object(a.getMediaSource)();if(!C)return!1;var O=s(),L=C&&typeof C.isTypeSupported=="function"&&C.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),b=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!L&&!!b}function R(){var C,O=s();return typeof(O==null||(C=O.prototype)===null||C===void 0?void 0:C.changeType)=="function"}},"./src/loader/date-range.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"DateRangeAttribute",function(){return L}),e.d(t,"DateRange",function(){return b});var a=e("./src/polyfills/number.ts"),s=e("./src/utils/attr-list.ts"),u=e("./src/utils/logger.ts");function R(){return R=Object.assign?Object.assign.bind():function(x){for(var I=1;I<arguments.length;I++){var _=arguments[I];for(var A in _)Object.prototype.hasOwnProperty.call(_,A)&&(x[A]=_[A])}return x},R.apply(this,arguments)}function C(x,I){for(var _=0;_<I.length;_++){var A=I[_];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(x,A.key,A)}}function O(x,I,_){return I&&C(x.prototype,I),_&&C(x,_),Object.defineProperty(x,"prototype",{writable:!1}),x}var L;(function(x){x.ID="ID",x.CLASS="CLASS",x.START_DATE="START-DATE",x.DURATION="DURATION",x.END_DATE="END-DATE",x.END_ON_NEXT="END-ON-NEXT",x.PLANNED_DURATION="PLANNED-DURATION",x.SCTE35_OUT="SCTE35-OUT",x.SCTE35_IN="SCTE35-IN"})(L||(L={}));var b=function(){function x(I,_){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,_){var A=_.attr;for(var S in A)if(Object.prototype.hasOwnProperty.call(I,S)&&I[S]!==A[S]){u.logger.warn('DATERANGE tag attribute: "'+S+'" does not match for tags with ID: "'+I.ID+'"'),this._badValueForSameId=S;break}I=R(new s.AttrList({}),A,I)}if(this.attr=I,this._startDate=new Date(I[L.START_DATE]),L.END_DATE in this.attr){var m=new Date(this.attr[L.END_DATE]);Object(a.isFiniteNumber)(m.getTime())&&(this._endDate=m)}}return O(x,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var _=this.duration;return _!==null?new Date(this._startDate.getTime()+_*1e3):null}},{key:"duration",get:function(){if(L.DURATION in this.attr){var _=this.attr.decimalFloatingPoint(L.DURATION);if(Object(a.isFiniteNumber)(_))return _}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return L.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(L.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(L.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(a.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),x}()},"./src/loader/fragment-loader.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return _}),e.d(t,"LoadError",function(){return S});var a=e("./src/polyfills/number.ts"),s=e("./src/errors.ts");function u(m,i){m.prototype=Object.create(i.prototype),m.prototype.constructor=m,b(m,i)}function R(m){var i=typeof Map=="function"?new Map:void 0;return R=function(p){if(p===null||!L(p))return p;if(typeof p!="function")throw new TypeError("Super expression must either be null or a function");if(typeof i!="undefined"){if(i.has(p))return i.get(p);i.set(p,T)}function T(){return C(p,arguments,x(this).constructor)}return T.prototype=Object.create(p.prototype,{constructor:{value:T,enumerable:!1,writable:!0,configurable:!0}}),b(T,p)},R(m)}function C(m,i,d){return O()?C=Reflect.construct.bind():C=function(T,l,o){var h=[null];h.push.apply(h,l);var E=Function.bind.apply(T,h),n=new E;return o&&b(n,o.prototype),n},C.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 L(m){return Function.toString.call(m).indexOf("[native code]")!==-1}function b(m,i){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,T){return p.__proto__=T,p},b(m,i)}function x(m){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(d){return d.__proto__||Object.getPrototypeOf(d)},x(m)}var I=Math.pow(2,17),_=function(){function m(d){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=d}var i=m.prototype;return i.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},i.abort=function(){this.loader&&this.loader.abort()},i.load=function(p,T){var l=this,o=p.url;if(!o)return Promise.reject(new S({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:p,networkDetails:null},"Fragment does not have a "+(o?"part list":"url")));this.abort();var h=this.config,E=h.fLoader,n=h.loader;return new Promise(function(c,v){l.loader&&l.loader.destroy();var f=l.loader=p.loader=E?new E(h):new n(h),g=A(p),y={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:p.sn==="initSegment"?1/0:I};p.stats=f.stats,f.load(g,y,{onSuccess:function(D,P,B,N){l.resetLoader(p,f),c({frag:p,part:null,payload:D.data,networkDetails:N})},onError:function(D,P,B){l.resetLoader(p,f),v(new S({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:p,response:D,networkDetails:B}))},onAbort:function(D,P,B){l.resetLoader(p,f),v(new S({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:p,networkDetails:B}))},onTimeout:function(D,P,B){l.resetLoader(p,f),v(new S({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:p,networkDetails:B}))},onProgress:function(D,P,B,N){T&&T({frag:p,part:null,payload:B,networkDetails:N})}})})},i.loadPart=function(p,T,l){var o=this;this.abort();var h=this.config,E=h.fLoader,n=h.loader;return new Promise(function(c,v){o.loader&&o.loader.destroy();var f=o.loader=p.loader=E?new E(h):new n(h),g=A(p,T),y={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:I};T.stats=f.stats,f.load(g,y,{onSuccess:function(D,P,B,N){o.resetLoader(p,f),o.updateStatsFromPart(p,T);var F={frag:p,part:T,payload:D.data,networkDetails:N};l(F),c(F)},onError:function(D,P,B){o.resetLoader(p,f),v(new S({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:p,part:T,response:D,networkDetails:B}))},onAbort:function(D,P,B){p.stats.aborted=T.stats.aborted,o.resetLoader(p,f),v(new S({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:p,part:T,networkDetails:B}))},onTimeout:function(D,P,B){o.resetLoader(p,f),v(new S({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:p,part:T,networkDetails:B}))}})})},i.updateStatsFromPart=function(p,T){var l=p.stats,o=T.stats,h=o.total;if(l.loaded+=o.loaded,h){var E=Math.round(p.duration/T.duration),n=Math.min(Math.round(l.loaded/h),E),c=E-n,v=c*Math.round(l.loaded/n);l.total=l.loaded+v}else l.total=Math.max(l.loaded,l.total);var f=l.loading,g=o.loading;f.start?f.first+=g.first-g.start:(f.start=g.start,f.first=g.first),f.end=g.end},i.resetLoader=function(p,T){p.loader=null,this.loader===T&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),T.destroy()},m}();function A(m,i){i===void 0&&(i=null);var d=i||m,p={frag:m,part:i,responseType:"arraybuffer",url:d.url,headers:{},rangeStart:0,rangeEnd:0},T=d.byteRangeStartOffset,l=d.byteRangeEndOffset;return Object(a.isFiniteNumber)(T)&&Object(a.isFiniteNumber)(l)&&(p.rangeStart=T,p.rangeEnd=l),p}var S=function(m){u(i,m);function i(d){for(var p,T=arguments.length,l=new Array(T>1?T-1:0),o=1;o<T;o++)l[o-1]=arguments[o];return p=m.call.apply(m,[this].concat(l))||this,p.data=void 0,p.data=d,p}return i}(R(Error))},"./src/loader/fragment.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"ElementaryStreamTypes",function(){return _}),e.d(t,"BaseSegment",function(){return A}),e.d(t,"Fragment",function(){return S}),e.d(t,"Part",function(){return m});var a=e("./src/polyfills/number.ts"),s=e("./node_modules/url-toolkit/src/url-toolkit.js"),u=e.n(s),R=e("./src/utils/logger.ts"),C=e("./src/loader/level-key.ts"),O=e("./src/loader/load-stats.ts");function L(i,d){i.prototype=Object.create(d.prototype),i.prototype.constructor=i,b(i,d)}function b(i,d){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,l){return T.__proto__=l,T},b(i,d)}function x(i,d){for(var p=0;p<d.length;p++){var T=d[p];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(i,T.key,T)}}function I(i,d,p){return d&&x(i.prototype,d),p&&x(i,p),Object.defineProperty(i,"prototype",{writable:!1}),i}var _;(function(i){i.AUDIO="audio",i.VIDEO="video",i.AUDIOVIDEO="audiovideo"})(_||(_={}));var A=function(){function i(p){var T;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(T={},T[_.AUDIO]=null,T[_.VIDEO]=null,T[_.AUDIOVIDEO]=null,T),this.baseurl=p}var d=i.prototype;return d.setByteRange=function(T,l){var o=T.split("@",2),h=[];o.length===1?h[0]=l?l.byteRangeEndOffset:0:h[0]=parseInt(o[1]),h[1]=parseInt(o[0])+h[0],this._byteRange=h},I(i,[{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(s.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(T){this._url=T}}]),i}(),S=function(i){L(d,i);function d(T,l){var o;return o=i.call(this,l)||this,o._decryptdata=null,o.rawProgramDateTime=null,o.programDateTime=null,o.tagList=[],o.duration=0,o.sn=0,o.levelkey=void 0,o.type=void 0,o.loader=null,o.level=-1,o.cc=0,o.startPTS=void 0,o.endPTS=void 0,o.appendedPTS=void 0,o.startDTS=void 0,o.endDTS=void 0,o.start=0,o.deltaPTS=void 0,o.maxStartPTS=void 0,o.minEndPTS=void 0,o.stats=new O.LoadStats,o.urlId=0,o.data=void 0,o.bitrateTest=!1,o.title=null,o.initSegment=null,o.type=T,o}var p=d.prototype;return p.createInitializationVector=function(l){for(var o=new Uint8Array(16),h=12;h<16;h++)o[h]=l>>8*(15-h)&255;return o},p.setDecryptDataFromLevelKey=function(l,o){var h=l;return(l==null?void 0:l.method)==="AES-128"&&l.uri&&!l.iv&&(h=C.LevelKey.fromURI(l.uri),h.method=l.method,h.iv=this.createInitializationVector(o),h.keyFormat="identity"),h},p.setElementaryStreamInfo=function(l,o,h,E,n,c){c===void 0&&(c=!1);var v=this.elementaryStreams,f=v[l];if(!f){v[l]={startPTS:o,endPTS:h,startDTS:E,endDTS:n,partial:c};return}f.startPTS=Math.min(f.startPTS,o),f.endPTS=Math.max(f.endPTS,h),f.startDTS=Math.min(f.startDTS,E),f.endDTS=Math.max(f.endDTS,n)},p.clearElementaryStreamInfo=function(){var l=this.elementaryStreams;l[_.AUDIO]=null,l[_.VIDEO]=null,l[_.AUDIOVIDEO]=null},I(d,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var l=this.sn;typeof l!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&R.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),l=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,l)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(a.isFiniteNumber)(this.programDateTime))return null;var l=Object(a.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+l*1e3}},{key:"encrypted",get:function(){var l;return!!((l=this.decryptdata)!==null&&l!==void 0&&l.keyFormat&&this.decryptdata.uri)}}]),d}(A),m=function(i){L(d,i);function d(p,T,l,o,h){var E;E=i.call(this,l)||this,E.fragOffset=0,E.duration=0,E.gap=!1,E.independent=!1,E.relurl=void 0,E.fragment=void 0,E.index=void 0,E.stats=new O.LoadStats,E.duration=p.decimalFloatingPoint("DURATION"),E.gap=p.bool("GAP"),E.independent=p.bool("INDEPENDENT"),E.relurl=p.enumeratedString("URI"),E.fragment=T,E.index=o;var n=p.enumeratedString("BYTERANGE");return n&&E.setByteRange(n,h),h&&(E.fragOffset=h.fragOffset+h.duration),E}return I(d,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var T=this.elementaryStreams;return!!(T.audio||T.video||T.audiovideo)}}]),d}(A)},"./src/loader/key-loader.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return R});var a=e("./src/events.ts"),s=e("./src/errors.ts"),u=e("./src/utils/logger.ts"),R=function(){function C(L){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=L,this.registerListeners()}var O=C.prototype;return O.startLoad=function(b){},O.stopLoad=function(){this.destroyInternalLoaders()},O.registerListeners=function(){this.hls.on(a.Events.KEY_LOADING,this.onKeyLoading,this)},O.unregisterListeners=function(){this.hls.off(a.Events.KEY_LOADING,this.onKeyLoading)},O.destroyInternalLoaders=function(){for(var b in this.loaders){var x=this.loaders[b];x&&x.destroy()}this.loaders={}},O.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},O.onKeyLoading=function(b,x){var I=x.frag,_=I.type,A=this.loaders[_];if(!I.decryptdata){u.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var S=I.decryptdata.uri;if(S!==this.decrypturl||this.decryptkey===null){var m=this.hls.config;if(A&&(u.logger.warn("abort previous key loader for type:"+_),A.abort()),!S){u.logger.warn("key uri is falsy");return}var i=m.loader,d=I.loader=this.loaders[_]=new i(m);this.decrypturl=S,this.decryptkey=null;var p={url:S,frag:I,responseType:"arraybuffer"},T={timeout:m.fragLoadingTimeOut,maxRetry:0,retryDelay:m.fragLoadingRetryDelay,maxRetryDelay:m.fragLoadingMaxRetryTimeout,highWaterMark:0},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};d.load(p,T,l)}else this.decryptkey&&(I.decryptdata.key=this.decryptkey,this.hls.trigger(a.Events.KEY_LOADED,{frag:I}))},O.loadsuccess=function(b,x,I){var _=I.frag;if(!_.decryptdata){u.logger.error("after key load, decryptdata unset");return}this.decryptkey=_.decryptdata.key=new Uint8Array(b.data),_.loader=null,delete this.loaders[_.type],this.hls.trigger(a.Events.KEY_LOADED,{frag:_})},O.loaderror=function(b,x){var I=x.frag,_=I.loader;_&&_.abort(),delete this.loaders[I.type],this.hls.trigger(a.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:I,response:b})},O.loadtimeout=function(b,x){var I=x.frag,_=I.loader;_&&_.abort(),delete this.loaders[I.type],this.hls.trigger(a.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:I})},C}()},"./src/loader/level-details.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"LevelDetails",function(){return C});var a=e("./src/polyfills/number.ts");function s(O,L){for(var b=0;b<L.length;b++){var x=L[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(O,x.key,x)}}function u(O,L,b){return L&&s(O.prototype,L),b&&s(O,b),Object.defineProperty(O,"prototype",{writable:!1}),O}var R=10,C=function(){function O(b){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=b}var L=O.prototype;return L.reloaded=function(x){if(!x){this.advanced=!0,this.updated=!0;return}var I=this.lastPartSn-x.lastPartSn,_=this.lastPartIndex-x.lastPartIndex;this.updated=this.endSN!==x.endSN||!!_||!!I,this.advanced=this.endSN>x.endSN||I>0||I===0&&_>0,this.updated||this.advanced?this.misses=Math.floor(x.misses*.6):this.misses=x.misses+1,this.availabilityDelay=x.availabilityDelay},u(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(a.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||R}},{key:"drift",get:function(){var x=this.driftEndTime-this.driftStartTime;if(x>0){var I=this.driftEnd-this.driftStart;return I*1e3/x}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var x;return(x=this.fragments)!==null&&x!==void 0&&x.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),O}()},"./src/loader/level-key.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"LevelKey",function(){return C});var a=e("./node_modules/url-toolkit/src/url-toolkit.js"),s=e.n(a);function u(O,L){for(var b=0;b<L.length;b++){var x=L[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(O,x.key,x)}}function R(O,L,b){return L&&u(O.prototype,L),b&&u(O,b),Object.defineProperty(O,"prototype",{writable:!1}),O}var C=function(){O.fromURL=function(b,x){return new O(b,x)},O.fromURI=function(b){return new O(b)};function O(L,b){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,b?this._uri=Object(a.buildAbsoluteURL)(L,b,{alwaysNormalize:!0}):this._uri=L}return R(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"LoadStats",function(){return a});var a=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(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return p});var a=e("./src/polyfills/number.ts"),s=e("./node_modules/url-toolkit/src/url-toolkit.js"),u=e.n(s),R=e("./src/loader/date-range.ts"),C=e("./src/loader/fragment.ts"),O=e("./src/loader/level-details.ts"),L=e("./src/loader/level-key.ts"),b=e("./src/utils/attr-list.ts"),x=e("./src/utils/logger.ts"),I=e("./src/utils/codecs.ts"),_=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,A=/#EXT-X-MEDIA:(.*)/g,S=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),m=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("|")),i=/\.(mp4|m4s|m4v|m4a)$/i;function d(n){var c,v;return i.test((c=(v=s.parseURL(n))===null||v===void 0?void 0:v.path)!=null?c:"")}var p=function(){function n(){}return n.findGroup=function(v,f){for(var g=0;g<v.length;g++){var y=v[g];if(y.id===f)return y}},n.convertAVC1ToAVCOTI=function(v){var f=v.split(".");if(f.length>2){var g=f.shift()+".";return g+=parseInt(f.shift()).toString(16),g+=("000"+parseInt(f.shift()).toString(16)).slice(-4),g}return v},n.resolve=function(v,f){return s.buildAbsoluteURL(f,v,{alwaysNormalize:!0})},n.parseMasterPlaylist=function(v,f){var g=[],y={},M=!1;_.lastIndex=0;for(var D;(D=_.exec(v))!=null;)if(D[1]){var P=new b.AttrList(D[1]),B={attrs:P,bitrate:P.decimalInteger("AVERAGE-BANDWIDTH")||P.decimalInteger("BANDWIDTH"),name:P.NAME,url:n.resolve(D[2],f)},N=P.decimalResolution("RESOLUTION");N&&(B.width=N.width,B.height=N.height),T((P.CODECS||"").split(/[ ,]+/).filter(function(H){return H}),B),B.videoCodec&&B.videoCodec.indexOf("avc1")!==-1&&(B.videoCodec=n.convertAVC1ToAVCOTI(B.videoCodec)),g.push(B)}else if(D[3]){var F=new b.AttrList(D[3]);F["DATA-ID"]&&(M=!0,y[F["DATA-ID"]]=F)}return{levels:g,sessionData:M?y:null}},n.parseMasterPlaylistMedia=function(v,f,g,y){y===void 0&&(y=[]);var M,D=[],P=0;for(A.lastIndex=0;(M=A.exec(v))!==null;){var B=new b.AttrList(M[1]);if(B.TYPE===g){var N={attrs:B,bitrate:0,id:P++,groupId:B["GROUP-ID"],instreamId:B["INSTREAM-ID"],name:B.NAME||B.LANGUAGE||"",type:g,default:B.bool("DEFAULT"),autoselect:B.bool("AUTOSELECT"),forced:B.bool("FORCED"),lang:B.LANGUAGE,url:B.URI?n.resolve(B.URI,f):""};if(y.length){var F=n.findGroup(y,N.groupId)||y[0];l(N,F,"audioCodec"),l(N,F,"textCodec")}D.push(N)}}return D},n.parseLevelPlaylist=function(v,f,g,y,M){var D=new O.LevelDetails(f),P=D.fragments,B=null,N=0,F=0,H=0,V=0,X=null,$=new C.Fragment(y,f),j,J,ee,te=-1,le=!1;for(S.lastIndex=0,D.m3u8=v;(j=S.exec(v))!==null;){le&&(le=!1,$=new C.Fragment(y,f),$.start=H,$.sn=N,$.cc=V,$.level=g,B&&($.initSegment=B,$.rawProgramDateTime=B.rawProgramDateTime,B.rawProgramDateTime=null));var ue=j[1];if(ue){$.duration=parseFloat(ue);var ie=(" "+j[2]).slice(1);$.title=ie||null,$.tagList.push(ie?["INF",ue,ie]:["INF",ue])}else if(j[3])Object(a.isFiniteNumber)($.duration)&&($.start=H,ee&&($.levelkey=ee),$.sn=N,$.level=g,$.cc=V,$.urlId=M,P.push($),$.relurl=(" "+j[3]).slice(1),h($,X),X=$,H+=$.duration,N++,F=0,le=!0);else if(j[4]){var he=(" "+j[4]).slice(1);X?$.setByteRange(he,X):$.setByteRange(he)}else if(j[5])$.rawProgramDateTime=(" "+j[5]).slice(1),$.tagList.push(["PROGRAM-DATE-TIME",$.rawProgramDateTime]),te===-1&&(te=P.length);else{if(j=j[0].match(m),!j){x.logger.warn("No matches on slow regex match for level playlist!");continue}for(J=1;J<j.length&&typeof j[J]=="undefined";J++);var ve=(" "+j[J]).slice(1),ae=(" "+j[J+1]).slice(1),Re=j[J+2]?(" "+j[J+2]).slice(1):"";switch(ve){case"PLAYLIST-TYPE":D.type=ae.toUpperCase();break;case"MEDIA-SEQUENCE":N=D.startSN=parseInt(ae);break;case"SKIP":{var Le=new b.AttrList(ae),De=Le.decimalInteger("SKIPPED-SEGMENTS");if(Object(a.isFiniteNumber)(De)){D.skippedSegments=De;for(var _e=De;_e--;)P.unshift(null);N+=De}var we=Le.enumeratedString("RECENTLY-REMOVED-DATERANGES");we&&(D.recentlyRemovedDateranges=we.split(" "));break}case"TARGETDURATION":D.targetduration=parseFloat(ae);break;case"VERSION":D.version=parseInt(ae);break;case"EXTM3U":break;case"ENDLIST":D.live=!1;break;case"#":(ae||Re)&&$.tagList.push(Re?[ae,Re]:[ae]);break;case"DISCONTINUITY":V++,$.tagList.push(["DIS"]);break;case"GAP":$.tagList.push([ve]);break;case"BITRATE":$.tagList.push([ve,ae]);break;case"DATERANGE":{var Ze=new b.AttrList(ae),He=new R.DateRange(Ze,D.dateRanges[Ze.ID]);He.isValid||D.skippedSegments?D.dateRanges[He.id]=He:x.logger.warn('Ignoring invalid DATERANGE tag: "'+ae+'"'),$.tagList.push(["EXT-X-DATERANGE",ae]);break}case"DISCONTINUITY-SEQUENCE":V=parseInt(ae);break;case"KEY":{var tt,Ke=new b.AttrList(ae),ot=Ke.enumeratedString("METHOD"),ct=Ke.URI,ft=Ke.hexadecimalInteger("IV"),lt=Ke.enumeratedString("KEYFORMATVERSIONS"),It=Ke.enumeratedString("KEYID"),rt=(tt=Ke.enumeratedString("KEYFORMAT"))!=null?tt:"identity",Mt=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Mt.indexOf(rt)>-1){x.logger.warn("Keyformat "+rt+" is not supported from the manifest");continue}else if(rt!=="identity")continue;ot&&(ee=L.LevelKey.fromURL(f,ct),ct&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(ot)>=0&&(ee.method=ot,ee.keyFormat=rt,It&&(ee.keyID=It),lt&&(ee.keyFormatVersions=lt),ee.iv=ft));break}case"START":{var Ye=new b.AttrList(ae),Je=Ye.decimalFloatingPoint("TIME-OFFSET");Object(a.isFiniteNumber)(Je)&&(D.startTimeOffset=Je);break}case"MAP":{var yt=new b.AttrList(ae);if($.duration){var qe=new C.Fragment(y,f);E(qe,yt,g,ee),B=qe,$.initSegment=B,B.rawProgramDateTime&&!$.rawProgramDateTime&&($.rawProgramDateTime=B.rawProgramDateTime)}else E($,yt,g,ee),B=$,le=!0;break}case"SERVER-CONTROL":{var Ge=new b.AttrList(ae);D.canBlockReload=Ge.bool("CAN-BLOCK-RELOAD"),D.canSkipUntil=Ge.optionalFloat("CAN-SKIP-UNTIL",0),D.canSkipDateRanges=D.canSkipUntil>0&&Ge.bool("CAN-SKIP-DATERANGES"),D.partHoldBack=Ge.optionalFloat("PART-HOLD-BACK",0),D.holdBack=Ge.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var kt=new b.AttrList(ae);D.partTarget=kt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var ht=D.partList;ht||(ht=D.partList=[]);var Ht=F>0?ht[ht.length-1]:void 0,Ar=F++,_t=new C.Part(new b.AttrList(ae),$,f,Ar,Ht);ht.push(_t),$.duration+=_t.duration;break}case"PRELOAD-HINT":{var Fr=new b.AttrList(ae);D.preloadHint=Fr;break}case"RENDITION-REPORT":{var _r=new b.AttrList(ae);D.renditionReports=D.renditionReports||[],D.renditionReports.push(_r);break}default:x.logger.warn("line parsed but not handled: "+j);break}}}X&&!X.relurl?(P.pop(),H-=X.duration,D.partList&&(D.fragmentHint=X)):D.partList&&(h($,X),$.cc=V,D.fragmentHint=$);var wt=P.length,Gt=P[0],Ut=P[wt-1];if(H+=D.skippedSegments*D.targetduration,H>0&&wt&&Ut){D.averagetargetduration=H/wt;var Sr=Ut.sn;D.endSN=Sr!=="initSegment"?Sr:0,Gt&&(D.startCC=Gt.cc,Gt.initSegment||D.fragments.every(function(fr){return fr.relurl&&d(fr.relurl)})&&(x.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),$=new C.Fragment(y,f),$.relurl=Ut.relurl,$.level=g,$.sn="initSegment",Gt.initSegment=$,D.needSidxRanges=!0))}else D.endSN=0,D.startCC=0;return D.fragmentHint&&(H+=D.fragmentHint.duration),D.totalduration=H,D.endCC=V,te>0&&o(P,te),D},n}();function T(n,c){["video","audio","text"].forEach(function(v){var f=n.filter(function(y){return Object(I.isCodecType)(y,v)});if(f.length){var g=f.filter(function(y){return y.lastIndexOf("avc1",0)===0||y.lastIndexOf("mp4a",0)===0});c[v+"Codec"]=g.length>0?g[0]:f[0],n=n.filter(function(y){return f.indexOf(y)===-1})}}),c.unknownCodecs=n}function l(n,c,v){var f=c[v];f&&(n[v]=f)}function o(n,c){for(var v=n[c],f=c;f--;){var g=n[f];if(!g)return;g.programDateTime=v.programDateTime-g.duration*1e3,v=g}}function h(n,c){n.rawProgramDateTime?n.programDateTime=Date.parse(n.rawProgramDateTime):c!=null&&c.programDateTime&&(n.programDateTime=c.endProgramDateTime),Object(a.isFiniteNumber)(n.programDateTime)||(n.programDateTime=null,n.rawProgramDateTime=null)}function E(n,c,v,f){n.relurl=c.URI,c.BYTERANGE&&n.setByteRange(c.BYTERANGE),n.level=v,n.sn="initSegment",f&&(n.levelkey=f),n.initSegment=null}},"./src/loader/playlist-loader.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/polyfills/number.ts"),s=e("./src/events.ts"),u=e("./src/errors.ts"),R=e("./src/utils/logger.ts"),C=e("./src/utils/mp4-tools.ts"),O=e("./src/loader/m3u8-parser.ts"),L=e("./src/types/loader.ts"),b=e("./src/utils/attr-list.ts");function x(A){var S=A.type;switch(S){case L.PlaylistContextType.AUDIO_TRACK:return L.PlaylistLevelType.AUDIO;case L.PlaylistContextType.SUBTITLE_TRACK:return L.PlaylistLevelType.SUBTITLE;default:return L.PlaylistLevelType.MAIN}}function I(A,S){var m=A.url;return(m===void 0||m.indexOf("data:")===0)&&(m=S.url),m}var _=function(){function A(m){this.hls=void 0,this.loaders=Object.create(null),this.hls=m,this.registerListeners()}var S=A.prototype;return S.startLoad=function(i){},S.stopLoad=function(){this.destroyInternalLoaders()},S.registerListeners=function(){var i=this.hls;i.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.on(s.Events.LEVEL_LOADING,this.onLevelLoading,this),i.on(s.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),i.on(s.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},S.unregisterListeners=function(){var i=this.hls;i.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.off(s.Events.LEVEL_LOADING,this.onLevelLoading,this),i.off(s.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),i.off(s.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},S.createInternalLoader=function(i){var d=this.hls.config,p=d.pLoader,T=d.loader,l=p||T,o=new l(d);return i.loader=o,this.loaders[i.type]=o,o},S.getInternalLoader=function(i){return this.loaders[i.type]},S.resetInternalLoader=function(i){this.loaders[i]&&delete this.loaders[i]},S.destroyInternalLoaders=function(){for(var i in this.loaders){var d=this.loaders[i];d&&d.destroy(),this.resetInternalLoader(i)}},S.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},S.onManifestLoading=function(i,d){var p=d.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:L.PlaylistContextType.MANIFEST,url:p,deliveryDirectives:null})},S.onLevelLoading=function(i,d){var p=d.id,T=d.level,l=d.url,o=d.deliveryDirectives;this.load({id:p,groupId:null,level:T,responseType:"text",type:L.PlaylistContextType.LEVEL,url:l,deliveryDirectives:o})},S.onAudioTrackLoading=function(i,d){var p=d.id,T=d.groupId,l=d.url,o=d.deliveryDirectives;this.load({id:p,groupId:T,level:null,responseType:"text",type:L.PlaylistContextType.AUDIO_TRACK,url:l,deliveryDirectives:o})},S.onSubtitleTrackLoading=function(i,d){var p=d.id,T=d.groupId,l=d.url,o=d.deliveryDirectives;this.load({id:p,groupId:T,level:null,responseType:"text",type:L.PlaylistContextType.SUBTITLE_TRACK,url:l,deliveryDirectives:o})},S.load=function(i){var d,p=this.hls.config,T=this.getInternalLoader(i);if(T){var l=T.context;if(l&&l.url===i.url){R.logger.trace("[playlist-loader]: playlist request ongoing");return}R.logger.log("[playlist-loader]: aborting previous loader for type: "+i.type),T.abort()}var o,h,E,n;switch(i.type){case L.PlaylistContextType.MANIFEST:o=p.manifestLoadingMaxRetry,h=p.manifestLoadingTimeOut,E=p.manifestLoadingRetryDelay,n=p.manifestLoadingMaxRetryTimeout;break;case L.PlaylistContextType.LEVEL:case L.PlaylistContextType.AUDIO_TRACK:case L.PlaylistContextType.SUBTITLE_TRACK:o=0,h=p.levelLoadingTimeOut;break;default:o=p.levelLoadingMaxRetry,h=p.levelLoadingTimeOut,E=p.levelLoadingRetryDelay,n=p.levelLoadingMaxRetryTimeout;break}if(T=this.createInternalLoader(i),(d=i.deliveryDirectives)!==null&&d!==void 0&&d.part){var c;if(i.type===L.PlaylistContextType.LEVEL&&i.level!==null?c=this.hls.levels[i.level].details:i.type===L.PlaylistContextType.AUDIO_TRACK&&i.id!==null?c=this.hls.audioTracks[i.id].details:i.type===L.PlaylistContextType.SUBTITLE_TRACK&&i.id!==null&&(c=this.hls.subtitleTracks[i.id].details),c){var v=c.partTarget,f=c.targetduration;v&&f&&(h=Math.min(Math.max(v*3,f*.8)*1e3,h))}}var g={timeout:h,maxRetry:o,retryDelay:E,maxRetryDelay:n,highWaterMark:0},y={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};T.load(i,g,y)},S.loadsuccess=function(i,d,p,T){if(T===void 0&&(T=null),p.isSidxRequest){this.handleSidxRequest(i,p),this.handlePlaylistLoaded(i,d,p,T);return}this.resetInternalLoader(p.type);var l=i.data;if(l.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(i,p,"no EXTM3U delimiter",T);return}d.parsing.start=performance.now(),l.indexOf("#EXTINF:")>0||l.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(i,d,p,T):this.handleMasterPlaylist(i,d,p,T)},S.loaderror=function(i,d,p){p===void 0&&(p=null),this.handleNetworkError(d,p,!1,i)},S.loadtimeout=function(i,d,p){p===void 0&&(p=null),this.handleNetworkError(d,p,!0)},S.handleMasterPlaylist=function(i,d,p,T){var l=this.hls,o=i.data,h=I(i,p),E=O.default.parseMasterPlaylist(o,h),n=E.levels,c=E.sessionData;if(!n.length){this.handleManifestParsingError(i,p,"no level found in manifest",T);return}var v=n.map(function(P){return{id:P.attrs.AUDIO,audioCodec:P.audioCodec}}),f=n.map(function(P){return{id:P.attrs.SUBTITLES,textCodec:P.textCodec}}),g=O.default.parseMasterPlaylistMedia(o,h,"AUDIO",v),y=O.default.parseMasterPlaylistMedia(o,h,"SUBTITLES",f),M=O.default.parseMasterPlaylistMedia(o,h,"CLOSED-CAPTIONS");if(g.length){var D=g.some(function(P){return!P.url});!D&&n[0].audioCodec&&!n[0].attrs.AUDIO&&(R.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new b.AttrList({}),bitrate:0,url:""}))}l.trigger(s.Events.MANIFEST_LOADED,{levels:n,audioTracks:g,subtitles:y,captions:M,url:h,stats:d,networkDetails:T,sessionData:c})},S.handleTrackOrLevelPlaylist=function(i,d,p,T){var l=this.hls,o=p.id,h=p.level,E=p.type,n=I(i,p),c=Object(a.isFiniteNumber)(o)?o:0,v=Object(a.isFiniteNumber)(h)?h:c,f=x(p),g=O.default.parseLevelPlaylist(i.data,n,v,f,c);if(!g.fragments.length){l.trigger(s.Events.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:u.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:n,reason:"no fragments found in level",level:typeof p.level=="number"?p.level:void 0});return}if(E===L.PlaylistContextType.MANIFEST){var y={attrs:new b.AttrList({}),bitrate:0,details:g,name:"",url:n};l.trigger(s.Events.MANIFEST_LOADED,{levels:[y],audioTracks:[],url:n,stats:d,networkDetails:T,sessionData:null})}if(d.parsing.end=performance.now(),g.needSidxRanges){var M,D=(M=g.fragments[0].initSegment)===null||M===void 0?void 0:M.url;this.load({url:D,isSidxRequest:!0,type:E,level:h,levelDetails:g,id:o,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}p.levelDetails=g,this.handlePlaylistLoaded(i,d,p,T)},S.handleSidxRequest=function(i,d){var p=new Uint8Array(i.data),T=Object(C.findBox)(p,["sidx"])[0];if(!!T){var l=Object(C.parseSegmentIndex)(T);if(!!l){var o=l.references,h=d.levelDetails;o.forEach(function(E,n){var c=E.info,v=h.fragments[n];if(v.byteRange.length===0&&v.setByteRange(String(1+c.end-c.start)+"@"+String(c.start)),v.initSegment){var f=Object(C.findBox)(p,["moov"])[0],g=f?f.length:null;v.initSegment.setByteRange(String(g)+"@0")}})}}},S.handleManifestParsingError=function(i,d,p,T){this.hls.trigger(s.Events.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:u.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:d.type===L.PlaylistContextType.MANIFEST,url:i.url,reason:p,response:i,context:d,networkDetails:T})},S.handleNetworkError=function(i,d,p,T){p===void 0&&(p=!1),R.logger.warn("[playlist-loader]: A network "+(p?"timeout":"error")+" occurred while loading "+i.type+" level: "+i.level+" id: "+i.id+' group-id: "'+i.groupId+'"');var l=u.ErrorDetails.UNKNOWN,o=!1,h=this.getInternalLoader(i);switch(i.type){case L.PlaylistContextType.MANIFEST:l=p?u.ErrorDetails.MANIFEST_LOAD_TIMEOUT:u.ErrorDetails.MANIFEST_LOAD_ERROR,o=!0;break;case L.PlaylistContextType.LEVEL:l=p?u.ErrorDetails.LEVEL_LOAD_TIMEOUT:u.ErrorDetails.LEVEL_LOAD_ERROR,o=!1;break;case L.PlaylistContextType.AUDIO_TRACK:l=p?u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,o=!1;break;case L.PlaylistContextType.SUBTITLE_TRACK:l=p?u.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:u.ErrorDetails.SUBTITLE_LOAD_ERROR,o=!1;break}h&&this.resetInternalLoader(i.type);var E={type:u.ErrorTypes.NETWORK_ERROR,details:l,fatal:o,url:i.url,loader:h,context:i,networkDetails:d};T&&(E.response=T),this.hls.trigger(s.Events.ERROR,E)},S.handlePlaylistLoaded=function(i,d,p,T){var l=p.type,o=p.level,h=p.id,E=p.groupId,n=p.loader,c=p.levelDetails,v=p.deliveryDirectives;if(!(c!=null&&c.targetduration)){this.handleManifestParsingError(i,p,"invalid target duration",T);return}if(!!n)switch(c.live&&(n.getCacheAge&&(c.ageHeader=n.getCacheAge()||0),(!n.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0)),l){case L.PlaylistContextType.MANIFEST:case L.PlaylistContextType.LEVEL:this.hls.trigger(s.Events.LEVEL_LOADED,{details:c,level:o||0,id:h||0,stats:d,networkDetails:T,deliveryDirectives:v});break;case L.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(s.Events.AUDIO_TRACK_LOADED,{details:c,id:h||0,groupId:E||"",stats:d,networkDetails:T,deliveryDirectives:v});break;case L.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(s.Events.SUBTITLE_TRACK_LOADED,{details:c,id:h||0,groupId:E||"",stats:d,networkDetails:T,deliveryDirectives:v});break}},A}();t.default=_},"./src/polyfills/number.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"isFiniteNumber",function(){return a}),e.d(t,"MAX_SAFE_INTEGER",function(){return s});var a=Number.isFinite||function(u){return typeof u=="number"&&isFinite(u)},s=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(r,t,e){"use strict";e.r(t);var a=function(){function s(){}return s.getSilentFrame=function(R,C){switch(R){case"mp4a.40.2":if(C===1)return new Uint8Array([0,200,0,128,35,128]);if(C===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(C===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(C===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(C===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(C===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(C===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(C===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(C===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}},s}();t.default=a},"./src/remux/mp4-generator.ts":function(r,t,e){"use strict";e.r(t);var a=Math.pow(2,32)-1,s=function(){function u(){}return u.init=function(){u.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 C;for(C in u.types)u.types.hasOwnProperty(C)&&(u.types[C]=[C.charCodeAt(0),C.charCodeAt(1),C.charCodeAt(2),C.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]),L=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]);u.HDLR_TYPES={video:O,audio:L};var b=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]);u.STTS=u.STSC=u.STCO=x,u.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),u.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),u.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),u.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var I=new Uint8Array([105,115,111,109]),_=new Uint8Array([97,118,99,49]),A=new Uint8Array([0,0,0,1]);u.FTYP=u.box(u.types.ftyp,I,A,I,_),u.DINF=u.box(u.types.dinf,u.box(u.types.dref,b))},u.box=function(C){for(var O=8,L=arguments.length,b=new Array(L>1?L-1:0),x=1;x<L;x++)b[x-1]=arguments[x];for(var I=b.length,_=I;I--;)O+=b[I].byteLength;var A=new Uint8Array(O);for(A[0]=O>>24&255,A[1]=O>>16&255,A[2]=O>>8&255,A[3]=O&255,A.set(C,4),I=0,O=8;I<_;I++)A.set(b[I],O),O+=b[I].byteLength;return A},u.hdlr=function(C){return u.box(u.types.hdlr,u.HDLR_TYPES[C])},u.mdat=function(C){return u.box(u.types.mdat,C)},u.mdhd=function(C,O){O*=C;var L=Math.floor(O/(a+1)),b=Math.floor(O%(a+1));return u.box(u.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,C>>24&255,C>>16&255,C>>8&255,C&255,L>>24,L>>16&255,L>>8&255,L&255,b>>24,b>>16&255,b>>8&255,b&255,85,196,0,0]))},u.mdia=function(C){return u.box(u.types.mdia,u.mdhd(C.timescale,C.duration),u.hdlr(C.type),u.minf(C))},u.mfhd=function(C){return u.box(u.types.mfhd,new Uint8Array([0,0,0,0,C>>24,C>>16&255,C>>8&255,C&255]))},u.minf=function(C){return C.type==="audio"?u.box(u.types.minf,u.box(u.types.smhd,u.SMHD),u.DINF,u.stbl(C)):u.box(u.types.minf,u.box(u.types.vmhd,u.VMHD),u.DINF,u.stbl(C))},u.moof=function(C,O,L){return u.box(u.types.moof,u.mfhd(C),u.traf(L,O))},u.moov=function(C){for(var O=C.length,L=[];O--;)L[O]=u.trak(C[O]);return u.box.apply(null,[u.types.moov,u.mvhd(C[0].timescale,C[0].duration)].concat(L).concat(u.mvex(C)))},u.mvex=function(C){for(var O=C.length,L=[];O--;)L[O]=u.trex(C[O]);return u.box.apply(null,[u.types.mvex].concat(L))},u.mvhd=function(C,O){O*=C;var L=Math.floor(O/(a+1)),b=Math.floor(O%(a+1)),x=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,C>>24&255,C>>16&255,C>>8&255,C&255,L>>24,L>>16&255,L>>8&255,L&255,b>>24,b>>16&255,b>>8&255,b&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 u.box(u.types.mvhd,x)},u.sdtp=function(C){var O=C.samples||[],L=new Uint8Array(4+O.length),b,x;for(b=0;b<O.length;b++)x=O[b].flags,L[b+4]=x.dependsOn<<4|x.isDependedOn<<2|x.hasRedundancy;return u.box(u.types.sdtp,L)},u.stbl=function(C){return u.box(u.types.stbl,u.stsd(C),u.box(u.types.stts,u.STTS),u.box(u.types.stsc,u.STSC),u.box(u.types.stsz,u.STSZ),u.box(u.types.stco,u.STCO))},u.avc1=function(C){var O=[],L=[],b,x,I;for(b=0;b<C.sps.length;b++)x=C.sps[b],I=x.byteLength,O.push(I>>>8&255),O.push(I&255),O=O.concat(Array.prototype.slice.call(x));for(b=0;b<C.pps.length;b++)x=C.pps[b],I=x.byteLength,L.push(I>>>8&255),L.push(I&255),L=L.concat(Array.prototype.slice.call(x));var _=u.box(u.types.avcC,new Uint8Array([1,O[3],O[4],O[5],255,224|C.sps.length].concat(O).concat([C.pps.length]).concat(L))),A=C.width,S=C.height,m=C.pixelRatio[0],i=C.pixelRatio[1];return u.box(u.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,A>>8&255,A&255,S>>8&255,S&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]),_,u.box(u.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),u.box(u.types.pasp,new Uint8Array([m>>24,m>>16&255,m>>8&255,m&255,i>>24,i>>16&255,i>>8&255,i&255])))},u.esds=function(C){var O=C.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(C.config).concat([6,1,2]))},u.mp4a=function(C){var O=C.samplerate;return u.box(u.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,C.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),u.box(u.types.esds,u.esds(C)))},u.mp3=function(C){var O=C.samplerate;return u.box(u.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,C.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},u.stsd=function(C){return C.type==="audio"?C.segmentCodec==="mp3"&&C.codec==="mp3"?u.box(u.types.stsd,u.STSD,u.mp3(C)):u.box(u.types.stsd,u.STSD,u.mp4a(C)):u.box(u.types.stsd,u.STSD,u.avc1(C))},u.tkhd=function(C){var O=C.id,L=C.duration*C.timescale,b=C.width,x=C.height,I=Math.floor(L/(a+1)),_=Math.floor(L%(a+1));return u.box(u.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,I>>24,I>>16&255,I>>8&255,I&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,b>>8&255,b&255,0,0,x>>8&255,x&255,0,0]))},u.traf=function(C,O){var L=u.sdtp(C),b=C.id,x=Math.floor(O/(a+1)),I=Math.floor(O%(a+1));return u.box(u.types.traf,u.box(u.types.tfhd,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255])),u.box(u.types.tfdt,new Uint8Array([1,0,0,0,x>>24,x>>16&255,x>>8&255,x&255,I>>24,I>>16&255,I>>8&255,I&255])),u.trun(C,L.length+16+20+8+16+8+8),L)},u.trak=function(C){return C.duration=C.duration||4294967295,u.box(u.types.trak,u.tkhd(C),u.mdia(C))},u.trex=function(C){var O=C.id;return u.box(u.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]))},u.trun=function(C,O){var L=C.samples||[],b=L.length,x=12+16*b,I=new Uint8Array(x),_,A,S,m,i,d;for(O+=8+x,I.set([C.type==="video"?1:0,0,15,1,b>>>24&255,b>>>16&255,b>>>8&255,b&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),_=0;_<b;_++)A=L[_],S=A.duration,m=A.size,i=A.flags,d=A.cts,I.set([S>>>24&255,S>>>16&255,S>>>8&255,S&255,m>>>24&255,m>>>16&255,m>>>8&255,m&255,i.isLeading<<2|i.dependsOn,i.isDependedOn<<6|i.hasRedundancy<<4|i.paddingValue<<1|i.isNonSync,i.degradPrio&240<<8,i.degradPrio&15,d>>>24&255,d>>>16&255,d>>>8&255,d&255],12+16*_);return u.box(u.types.trun,I)},u.initSegment=function(C){u.types||u.init();var O=u.moov(C),L=new Uint8Array(u.FTYP.byteLength+O.byteLength);return L.set(u.FTYP),L.set(O,u.FTYP.byteLength),L},u}();s.types=void 0,s.HDLR_TYPES=void 0,s.STTS=void 0,s.STSC=void 0,s.STCO=void 0,s.STSZ=void 0,s.VMHD=void 0,s.SMHD=void 0,s.STSD=void 0,s.FTYP=void 0,s.DINF=void 0,t.default=s},"./src/remux/mp4-remuxer.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return i}),e.d(t,"normalizePts",function(){return d}),e.d(t,"flushTextTrackMetadataCueSamples",function(){return T}),e.d(t,"flushTextTrackUserdataCueSamples",function(){return l});var a=e("./src/polyfills/number.ts"),s=e("./src/remux/aac-helper.ts"),u=e("./src/remux/mp4-generator.ts"),R=e("./src/events.ts"),C=e("./src/errors.ts"),O=e("./src/utils/logger.ts"),L=e("./src/types/loader.ts"),b=e("./src/utils/timescale-conversion.ts");function x(){return x=Object.assign?Object.assign.bind():function(E){for(var n=1;n<arguments.length;n++){var c=arguments[n];for(var v in c)Object.prototype.hasOwnProperty.call(c,v)&&(E[v]=c[v])}return E},x.apply(this,arguments)}var I=10*1e3,_=1024,A=1152,S=null,m=null,i=function(){function E(c,v,f,g){if(g===void 0&&(g=""),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=c,this.config=v,this.typeSupported=f,this.ISGenerated=!1,S===null){var y=navigator.userAgent||"",M=y.match(/Chrome\/(\d+)/i);S=M?parseInt(M[1]):0}if(m===null){var D=navigator.userAgent.match(/Safari\/(\d+)/i);m=D?parseInt(D[1]):0}}var n=E.prototype;return n.destroy=function(){},n.resetTimeStamp=function(v){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=v},n.resetNextTimestamp=function(){O.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},n.resetInitSegment=function(){O.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},n.getVideoStartPts=function(v){var f=!1,g=v.reduce(function(y,M){var D=M.pts-y;return D<-4294967296?(f=!0,d(y,M.pts)):D>0?y:M.pts},v[0].pts);return f&&O.logger.debug("PTS rollover detected"),g},n.remux=function(v,f,g,y,M,D,P,B){var N,F,H,V,X,$,j=M,J=M,ee=v.pid>-1,te=f.pid>-1,le=f.samples.length,ue=v.samples.length>0,ie=P&&le>0||le>1,he=(!ee||ue)&&(!te||ie)||this.ISGenerated||P;if(he){this.ISGenerated||(H=this.generateIS(v,f,M));var ve=this.isVideoContiguous,ae=-1,Re;if(ie&&(ae=p(f.samples),!ve&&this.config.forceKeyFrameOnDiscontinuity))if($=!0,ae>0){O.logger.warn("[mp4-remuxer]: Dropped "+ae+" out of "+le+" video samples due to a missing keyframe");var Le=this.getVideoStartPts(f.samples);f.samples=f.samples.slice(ae),f.dropped+=ae,J+=(f.samples[0].pts-Le)/f.inputTimeScale,Re=J}else ae===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+le+" video samples"),$=!1);if(this.ISGenerated){if(ue&&ie){var De=this.getVideoStartPts(f.samples),_e=d(v.samples[0].pts,De)-De,we=_e/f.inputTimeScale;j+=Math.max(0,we),J+=Math.max(0,-we)}if(ue){if(v.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),H=this.generateIS(v,f,M)),F=this.remuxAudio(v,j,this.isAudioContiguous,D,te||ie||B===L.PlaylistLevelType.AUDIO?J:void 0),ie){var Ze=F?F.endPTS-F.startPTS:0;f.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),H=this.generateIS(v,f,M)),N=this.remuxVideo(f,J,ve,Ze)}}else ie&&(N=this.remuxVideo(f,J,ve,0));N&&(N.firstKeyFrame=ae,N.independent=ae!==-1,N.firstKeyFramePTS=Re)}}return this.ISGenerated&&(g.samples.length&&(X=T(g,M,this._initPTS,this._initDTS)),y.samples.length&&(V=l(y,M,this._initPTS))),{audio:F,video:N,initSegment:H,independent:$,text:V,id3:X}},n.generateIS=function(v,f,g){var y=v.samples,M=f.samples,D=this.typeSupported,P={},B=!Object(a.isFiniteNumber)(this._initPTS),N="audio/mp4",F,H,V;if(B&&(F=H=1/0),v.config&&y.length){switch(v.timescale=v.samplerate,v.segmentCodec){case"mp3":D.mpeg?(N="audio/mpeg",v.codec=""):D.mp3&&(v.codec="mp3");break}P.audio={id:"audio",container:N,codec:v.codec,initSegment:v.segmentCodec==="mp3"&&D.mpeg?new Uint8Array(0):u.default.initSegment([v]),metadata:{channelCount:v.channelCount}},B&&(V=v.inputTimeScale,F=H=y[0].pts-Math.round(V*g))}if(f.sps&&f.pps&&M.length&&(f.timescale=f.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:f.codec,initSegment:u.default.initSegment([f]),metadata:{width:f.width,height:f.height}},B)){V=f.inputTimeScale;var X=this.getVideoStartPts(M),$=Math.round(V*g);H=Math.min(H,d(M[0].dts,X)-$),F=Math.min(F,X-$)}if(Object.keys(P).length)return this.ISGenerated=!0,B&&(this._initPTS=F,this._initDTS=H),{tracks:P,initPTS:F,timescale:V}},n.remuxVideo=function(v,f,g,y){var M=v.inputTimeScale,D=v.samples,P=[],B=D.length,N=this._initPTS,F=this.nextAvcDts,H=8,V=this.videoSampleDuration,X,$,j=Number.POSITIVE_INFINITY,J=Number.NEGATIVE_INFINITY,ee=!1;if(!g||F===null){var te=f*M,le=D[0].pts-d(D[0].dts,D[0].pts);F=te-le}for(var ue=0;ue<B;ue++){var ie=D[ue];ie.pts=d(ie.pts-N,F),ie.dts=d(ie.dts-N,F),ie.dts<D[ue>0?ue-1:ue].dts&&(ee=!0)}ee&&D.sort(function(Wr,tn){var xr=Wr.dts-tn.dts,va=Wr.pts-tn.pts;return xr||va}),X=D[0].dts,$=D[D.length-1].dts;var he=$-X,ve=he?Math.round(he/(B-1)):V||v.inputTimeScale/30;if(g){var ae=X-F,Re=ae>ve,Le=ae<-1;if(Re||Le){Re?O.logger.warn("AVC: "+Object(b.toMsFromMpegTsClock)(ae,!0)+" ms ("+ae+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(b.toMsFromMpegTsClock)(-ae,!0)+" ms ("+ae+"dts) overlapping between fragments detected"),X=F;var De=D[0].pts-ae;D[0].dts=X,D[0].pts=De,O.logger.log("Video: First PTS/DTS adjusted: "+Object(b.toMsFromMpegTsClock)(De,!0)+"/"+Object(b.toMsFromMpegTsClock)(X,!0)+", delta: "+Object(b.toMsFromMpegTsClock)(ae,!0)+" ms")}}X=Math.max(0,X);for(var _e=0,we=0,Ze=0;Ze<B;Ze++){for(var He=D[Ze],tt=He.units,Ke=tt.length,ot=0,ct=0;ct<Ke;ct++)ot+=tt[ct].data.length;we+=ot,_e+=Ke,He.length=ot,He.dts=Math.max(He.dts,X),j=Math.min(He.pts,j),J=Math.max(He.pts,J)}$=D[B-1].dts;var ft=we+4*_e+8,lt;try{lt=new Uint8Array(ft)}catch{this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:C.ErrorTypes.MUX_ERROR,details:C.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ft,reason:"fail allocating video mdat "+ft});return}var It=new DataView(lt.buffer);It.setUint32(0,ft),lt.set(u.default.types.mdat,4);for(var rt=!1,Mt=Number.POSITIVE_INFINITY,Ye=Number.POSITIVE_INFINITY,Je=Number.NEGATIVE_INFINITY,yt=Number.NEGATIVE_INFINITY,qe=0;qe<B;qe++){for(var Ge=D[qe],kt=Ge.units,ht=0,Ht=0,Ar=kt.length;Ht<Ar;Ht++){var _t=kt[Ht],Fr=_t.data,_r=_t.data.byteLength;It.setUint32(H,_r),H+=4,lt.set(Fr,H),H+=_r,ht+=4+_r}var wt=void 0;if(qe<B-1)V=D[qe+1].dts-Ge.dts,wt=D[qe+1].pts-Ge.pts;else{var Gt=this.config,Ut=qe>0?Ge.dts-D[qe-1].dts:ve;if(wt=qe>0?Ge.pts-D[qe-1].pts:ve,Gt.stretchShortVideoTrack&&this.nextAudioPts!==null){var Sr=Math.floor(Gt.maxBufferHole*M),fr=(y?j+y*M:this.nextAudioPts)-Ge.pts;fr>Sr?(V=fr-Ut,V<0?V=Ut:rt=!0,O.logger.log("[mp4-remuxer]: It is approximately "+fr/90+" ms to the next segment; using duration "+V/90+" ms for the last video frame.")):V=Ut}else V=Ut}var fa=Math.round(Ge.pts-Ge.dts);Mt=Math.min(Mt,V),Je=Math.max(Je,V),Ye=Math.min(Ye,wt),yt=Math.max(yt,wt),P.push(new o(Ge.key,V,ht,fa))}if(P.length){if(S){if(S<70){var hi=P[0].flags;hi.dependsOn=2,hi.isNonSync=0}}else if(m&&yt-Ye<Je-Mt&&ve/Je<.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 Kr=X,St=0,qi=P.length;St<qi;St++){var mi=Kr+P[St].duration,en=Kr+P[St].cts;if(St<qi-1){var vi=mi+P[St+1].cts;P[St].duration=vi-en}else P[St].duration=St?P[St-1].duration:ve;P[St].cts=0,Kr=mi}}}console.assert(V!==null,"mp4SampleDuration must be computed"),V=rt||!V?ve:V,this.nextAvcDts=F=$+V,this.videoSampleDuration=V,this.isVideoContiguous=!0;var ha=u.default.moof(v.sequenceNumber++,X,x({},v,{samples:P})),ma="video",Nt={data1:ha,data2:lt,startPTS:j/M,endPTS:(J+V)/M,startDTS:X/M,endDTS:F/M,type:ma,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:v.dropped};return v.samples=[],v.dropped=0,console.assert(lt.length,"MDAT length must not be zero"),Nt},n.remuxAudio=function(v,f,g,y,M){var D=v.inputTimeScale,P=v.samplerate?v.samplerate:D,B=D/P,N=v.segmentCodec==="aac"?_:A,F=N*B,H=this._initPTS,V=v.segmentCodec==="mp3"&&this.typeSupported.mpeg,X=[],$=M!==void 0,j=v.samples,J=V?0:8,ee=this.nextAudioPts||-1,te=f*D;if(this.isAudioContiguous=g=g||j.length&&ee>0&&(y&&Math.abs(te-ee)<9e3||Math.abs(d(j[0].pts-H,te)-ee)<20*F),j.forEach(function(_t){_t.pts=d(_t.pts-H,te)}),!g||ee<0){if(j=j.filter(function(_t){return _t.pts>=0}),!j.length)return;M===0?ee=0:y&&!$?ee=Math.max(0,te):ee=j[0].pts}if(v.segmentCodec==="aac")for(var le=this.config.maxAudioFramesDrift,ue=0,ie=ee;ue<j.length;ue++){var he=j[ue],ve=he.pts,ae=ve-ie,Re=Math.abs(1e3*ae/D);if(ae<=-le*F&&$)ue===0&&(O.logger.warn("Audio frame @ "+(ve/D).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*ae/D)+" ms."),this.nextAudioPts=ee=ie=ve);else if(ae>=le*F&&Re<I&&$){var Le=Math.round(ae/F);ie=ve-Le*F,ie<0&&(Le--,ie+=F),ue===0&&(this.nextAudioPts=ee=ie),O.logger.warn("[mp4-remuxer]: Injecting "+Le+" audio frame @ "+(ie/D).toFixed(3)+"s due to "+Math.round(1e3*ae/D)+" ms gap.");for(var De=0;De<Le;De++){var _e=Math.max(ie,0),we=s.default.getSilentFrame(v.manifestCodec||v.codec,v.channelCount);we||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),we=he.unit.subarray()),j.splice(ue,0,{unit:we,pts:_e}),ie+=F,ue++}}he.pts=ie,ie+=F}for(var Ze=null,He=null,tt,Ke=0,ot=j.length;ot--;)Ke+=j[ot].unit.byteLength;for(var ct=0,ft=j.length;ct<ft;ct++){var lt=j[ct],It=lt.unit,rt=lt.pts;if(He!==null){var Mt=X[ct-1];Mt.duration=Math.round((rt-He)/B)}else if(g&&v.segmentCodec==="aac"&&(rt=ee),Ze=rt,Ke>0){Ke+=J;try{tt=new Uint8Array(Ke)}catch{this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:C.ErrorTypes.MUX_ERROR,details:C.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ke,reason:"fail allocating audio mdat "+Ke});return}if(!V){var Ye=new DataView(tt.buffer);Ye.setUint32(0,Ke),tt.set(u.default.types.mdat,4)}}else return;tt.set(It,J);var Je=It.byteLength;J+=Je,X.push(new o(!0,N,Je,0)),He=rt}var yt=X.length;if(!!yt){var qe=X[X.length-1];this.nextAudioPts=ee=He+B*qe.duration;var Ge=V?new Uint8Array(0):u.default.moof(v.sequenceNumber++,Ze/B,x({},v,{samples:X}));v.samples=[];var kt=Ze/D,ht=ee/D,Ht="audio",Ar={data1:Ge,data2:tt,startPTS:kt,endPTS:ht,startDTS:kt,endDTS:ht,type:Ht,hasAudio:!0,hasVideo:!1,nb:yt};return this.isAudioContiguous=!0,console.assert(tt.length,"MDAT length must not be zero"),Ar}},n.remuxEmptyAudio=function(v,f,g,y){var M=v.inputTimeScale,D=v.samplerate?v.samplerate:M,P=M/D,B=this.nextAudioPts,N=(B!==null?B:y.startDTS*M)+this._initDTS,F=y.endDTS*M+this._initDTS,H=P*_,V=Math.ceil((F-N)/H),X=s.default.getSilentFrame(v.manifestCodec||v.codec,v.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!X){O.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var $=[],j=0;j<V;j++){var J=N+j*H;$.push({unit:X,pts:J,dts:J})}return v.samples=$,this.remuxAudio(v,f,g,!1)},E}();function d(E,n){var c;if(n===null)return E;for(n<E?c=-8589934592:c=8589934592;Math.abs(E-n)>4294967296;)E+=c;return E}function p(E){for(var n=0;n<E.length;n++)if(E[n].key)return n;return-1}function T(E,n,c,v){var f=E.samples.length;if(!!f){for(var g=E.inputTimeScale,y=0;y<f;y++){var M=E.samples[y];M.pts=d(M.pts-c,n*g)/g,M.dts=d(M.dts-v,n*g)/g}var D=E.samples;return E.samples=[],{samples:D}}}function l(E,n,c){var v=E.samples.length;if(!!v){for(var f=E.inputTimeScale,g=0;g<v;g++){var y=E.samples[g];y.pts=d(y.pts-c,n*f)/f}E.samples.sort(function(D,P){return D.pts-P.pts});var M=E.samples;return E.samples=[],{samples:M}}}var o=function(n,c,v,f){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=c,this.size=v,this.cts=f,this.flags=new h(n)},h=function(n){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=n?2:1,this.isNonSync=n?0:1}},"./src/remux/passthrough-remuxer.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/polyfills/number.ts"),s=e("./src/remux/mp4-remuxer.ts"),u=e("./src/utils/mp4-tools.ts"),R=e("./src/loader/fragment.ts"),C=e("./src/utils/logger.ts"),O=function(){function b(){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=b.prototype;return x.destroy=function(){},x.resetTimeStamp=function(_){this.initPTS=_,this.lastEndTime=null},x.resetNextTimestamp=function(){this.lastEndTime=null},x.resetInitSegment=function(_,A,S){this.audioCodec=A,this.videoCodec=S,this.generateInitSegment(_),this.emitInitSegment=!0},x.generateInitSegment=function(_){var A=this.audioCodec,S=this.videoCodec;if(!_||!_.byteLength){this.initTracks=void 0,this.initData=void 0;return}var m=this.initData=Object(u.parseInitSegment)(_);A||(A=L(m.audio,R.ElementaryStreamTypes.AUDIO)),S||(S=L(m.video,R.ElementaryStreamTypes.VIDEO));var i={};m.audio&&m.video?i.audiovideo={container:"video/mp4",codec:A+","+S,initSegment:_,id:"main"}:m.audio?i.audio={container:"audio/mp4",codec:A,initSegment:_,id:"audio"}:m.video?i.video={container:"video/mp4",codec:S,initSegment:_,id:"main"}:C.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=i},x.remux=function(_,A,S,m,i){var d,p=this.initPTS,T=this.lastEndTime,l={audio:void 0,video:void 0,text:m,id3:S,initSegment:void 0};Object(a.isFiniteNumber)(T)||(T=this.lastEndTime=i||0);var o=A.samples;if(!o||!o.length)return l;var h={initPTS:void 0,timescale:1},E=this.initData;if((!E||!E.length)&&(this.generateInitSegment(o),E=this.initData),!E||!E.length)return C.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),l;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);var n=Object(u.getStartDTS)(E,o);Object(a.isFiniteNumber)(p)||(this.initPTS=h.initPTS=p=n-i);var c=Object(u.getDuration)(o,E),v=_?n-p:T,f=v+c;Object(u.offsetStartDTS)(E,o,p),c>0?this.lastEndTime=f:(C.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var g=!!E.audio,y=!!E.video,M="";g&&(M+="audio"),y&&(M+="video");var D={data1:o,startPTS:v,startDTS:v,endPTS:f,endDTS:f,type:M,hasAudio:g,hasVideo:y,nb:1,dropped:0};l.audio=D.type==="audio"?D:void 0,l.video=D.type!=="audio"?D:void 0,l.initSegment=h;var P=(d=this.initPTS)!=null?d:0;return l.id3=Object(s.flushTextTrackMetadataCueSamples)(S,i,P,P),m.samples.length&&(l.text=Object(s.flushTextTrackUserdataCueSamples)(m,i,P)),l},b}();function L(b,x){var I=b==null?void 0:b.codec;return I&&I.length>4?I:I==="hvc1"||I==="hev1"?"hvc1.1.c.L120.90":I==="av01"?"av01.0.04M.08":I==="avc1"||x===R.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}t.default=O},"./src/task-loop.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return a});var a=function(){function s(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var u=s.prototype;return u.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},u.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},u.onHandlerDestroyed=function(){},u.hasInterval=function(){return!!this._tickInterval},u.hasNextTick=function(){return!!this._tickTimer},u.setInterval=function(C){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,C),!0)},u.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},u.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},u.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},u.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},u.doTick=function(){},s}()},"./src/types/cmcd.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"CMCDVersion",function(){return a}),e.d(t,"CMCDObjectType",function(){return s}),e.d(t,"CMCDStreamingFormat",function(){return u}),e.d(t,"CMCDStreamType",function(){return R});var a=1,s;(function(C){C.MANIFEST="m",C.AUDIO="a",C.VIDEO="v",C.MUXED="av",C.INIT="i",C.CAPTION="c",C.TIMED_TEXT="tt",C.KEY="k",C.OTHER="o"})(s||(s={}));var u;(function(C){C.DASH="d",C.HLS="h",C.SMOOTH="s",C.OTHER="o"})(u||(u={}));var R;(function(C){C.VOD="v",C.LIVE="l"})(R||(R={}))},"./src/types/demuxer.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"MetadataSchema",function(){return a});var a;(function(s){s.audioId3="org.id3",s.dateRange="com.apple.quicktime.HLS",s.emsg="https://aomedia.org/emsg/ID3"})(a||(a={}))},"./src/types/level.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"HlsSkip",function(){return u}),e.d(t,"getSkipValue",function(){return R}),e.d(t,"HlsUrlParameters",function(){return C}),e.d(t,"Level",function(){return O});function a(L,b){for(var x=0;x<b.length;x++){var I=b[x];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(L,I.key,I)}}function s(L,b,x){return b&&a(L.prototype,b),x&&a(L,x),Object.defineProperty(L,"prototype",{writable:!1}),L}var u;(function(L){L.No="",L.Yes="YES",L.v2="v2"})(u||(u={}));function R(L,b){var x=L.canSkipUntil,I=L.canSkipDateRanges,_=L.endSN,A=b!==void 0?b-_:0;return x&&A<x?I?u.v2:u.Yes:u.No}var C=function(){function L(x,I,_){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=x,this.part=I,this.skip=_}var b=L.prototype;return b.addDirectives=function(I){var _=new self.URL(I);return this.msn!==void 0&&_.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&_.searchParams.set("_HLS_part",this.part.toString()),this.skip&&_.searchParams.set("_HLS_skip",this.skip),_.toString()},L}(),O=function(){function L(b){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=[b.url],this.attrs=b.attrs,this.bitrate=b.bitrate,b.details&&(this.details=b.details),this.id=b.id||0,this.name=b.name,this.width=b.width||0,this.height=b.height||0,this.audioCodec=b.audioCodec,this.videoCodec=b.videoCodec,this.unknownCodecs=b.unknownCodecs,this.codecSet=[b.videoCodec,b.audioCodec].filter(function(x){return x}).join(",").replace(/\.[^.,]+/g,"")}return s(L,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(x){var I=x%this.url.length;this._urlId!==I&&(this.details=void 0,this._urlId=I)}}]),L}()},"./src/types/loader.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"PlaylistContextType",function(){return a}),e.d(t,"PlaylistLevelType",function(){return s});var a;(function(u){u.MANIFEST="manifest",u.LEVEL="level",u.AUDIO_TRACK="audioTrack",u.SUBTITLE_TRACK="subtitleTrack"})(a||(a={}));var s;(function(u){u.MAIN="main",u.AUDIO="audio",u.SUBTITLE="subtitle"})(s||(s={}))},"./src/types/transmuxer.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"ChunkMetadata",function(){return a});var a=function(R,C,O,L,b,x){L===void 0&&(L=0),b===void 0&&(b=-1),x===void 0&&(x=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=s(),this.buffering={audio:s(),video:s(),audiovideo:s()},this.level=R,this.sn=C,this.id=O,this.size=L,this.part=b,this.partial=x};function s(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"AttrList",function(){return u});var a=/^(\d+)x(\d+)$/,s=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,u=function(){function R(O){typeof O=="string"&&(O=R.parseAttrList(O));for(var L in O)O.hasOwnProperty(L)&&(this[L]=O[L])}var C=R.prototype;return C.decimalInteger=function(L){var b=parseInt(this[L],10);return b>Number.MAX_SAFE_INTEGER?1/0:b},C.hexadecimalInteger=function(L){if(this[L]){var b=(this[L]||"0x").slice(2);b=(b.length&1?"0":"")+b;for(var x=new Uint8Array(b.length/2),I=0;I<b.length/2;I++)x[I]=parseInt(b.slice(I*2,I*2+2),16);return x}else return null},C.hexadecimalIntegerAsNumber=function(L){var b=parseInt(this[L],16);return b>Number.MAX_SAFE_INTEGER?1/0:b},C.decimalFloatingPoint=function(L){return parseFloat(this[L])},C.optionalFloat=function(L,b){var x=this[L];return x?parseFloat(x):b},C.enumeratedString=function(L){return this[L]},C.bool=function(L){return this[L]==="YES"},C.decimalResolution=function(L){var b=a.exec(this[L]);if(b!==null)return{width:parseInt(b[1],10),height:parseInt(b[2],10)}},R.parseAttrList=function(L){var b,x={},I='"';for(s.lastIndex=0;(b=s.exec(L))!==null;){var _=b[2];_.indexOf(I)===0&&_.lastIndexOf(I)===_.length-1&&(_=_.slice(1,-1)),x[b[1]]=_}return x},R}()},"./src/utils/binary-search.ts":function(r,t,e){"use strict";e.r(t);var a={search:function(u,R){for(var C=0,O=u.length-1,L=null,b=null;C<=O;){L=(C+O)/2|0,b=u[L];var x=R(b);if(x>0)C=L+1;else if(x<0)O=L-1;else return b}return null}};t.default=a},"./src/utils/buffer-helper.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"BufferHelper",function(){return u});var a=e("./src/utils/logger.ts"),s={length:0,start:function(){return 0},end:function(){return 0}},u=function(){function R(){}return R.isBuffered=function(O,L){try{if(O){for(var b=R.getBuffered(O),x=0;x<b.length;x++)if(L>=b.start(x)&&L<=b.end(x))return!0}}catch{}return!1},R.bufferInfo=function(O,L,b){try{if(O){var x=R.getBuffered(O),I=[],_;for(_=0;_<x.length;_++)I.push({start:x.start(_),end:x.end(_)});return this.bufferedInfo(I,L,b)}}catch{}return{len:0,start:L,end:L,nextStart:void 0}},R.bufferedInfo=function(O,L,b){L=Math.max(0,L),O.sort(function(o,h){var E=o.start-h.start;return E||h.end-o.end});var x=[];if(b)for(var I=0;I<O.length;I++){var _=x.length;if(_){var A=x[_-1].end;O[I].start-A<b?O[I].end>A&&(x[_-1].end=O[I].end):x.push(O[I])}else x.push(O[I])}else x=O;for(var S=0,m,i=L,d=L,p=0;p<x.length;p++){var T=x[p].start,l=x[p].end;if(L+b>=T&&L<l)i=T,d=l,S=d-L;else if(L+b<T){m=T;break}}return{len:S,start:i||0,end:d||0,nextStart:m}},R.getBuffered=function(O){try{return O.buffered}catch(L){return a.logger.log("failed to get media.buffered",L),s}},R}()},"./src/utils/cea-608-parser.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"Row",function(){return d}),e.d(t,"CaptionScreen",function(){return p});var a=e("./src/utils/logger.ts"),s={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},u=function(c){var v=c;return s.hasOwnProperty(c)&&(v=s[c]),String.fromCharCode(v)},R=15,C=100,O={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},L={17:2,18:4,21:6,22:8,23:10,19:13,20:15},b={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},x={25:2,26:4,29:6,30:8,31:10,27:13,28:15},I=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],_;(function(n){n[n.ERROR=0]="ERROR",n[n.TEXT=1]="TEXT",n[n.WARNING=2]="WARNING",n[n.INFO=2]="INFO",n[n.DEBUG=3]="DEBUG",n[n.DATA=3]="DATA"})(_||(_={}));var A=function(){function n(){this.time=null,this.verboseLevel=_.ERROR}var c=n.prototype;return c.log=function(f,g){this.verboseLevel>=f&&a.logger.log(this.time+" ["+f+"] "+g)},n}(),S=function(c){for(var v=[],f=0;f<c.length;f++)v.push(c[f].toString(16));return v},m=function(){function n(v,f,g,y,M){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=v||"white",this.underline=f||!1,this.italics=g||!1,this.background=y||"black",this.flash=M||!1}var c=n.prototype;return c.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},c.setStyles=function(f){for(var g=["foreground","underline","italics","background","flash"],y=0;y<g.length;y++){var M=g[y];f.hasOwnProperty(M)&&(this[M]=f[M])}},c.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},c.equals=function(f){return this.foreground===f.foreground&&this.underline===f.underline&&this.italics===f.italics&&this.background===f.background&&this.flash===f.flash},c.copy=function(f){this.foreground=f.foreground,this.underline=f.underline,this.italics=f.italics,this.background=f.background,this.flash=f.flash},c.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},n}(),i=function(){function n(v,f,g,y,M,D){this.uchar=void 0,this.penState=void 0,this.uchar=v||" ",this.penState=new m(f,g,y,M,D)}var c=n.prototype;return c.reset=function(){this.uchar=" ",this.penState.reset()},c.setChar=function(f,g){this.uchar=f,this.penState.copy(g)},c.setPenState=function(f){this.penState.copy(f)},c.equals=function(f){return this.uchar===f.uchar&&this.penState.equals(f.penState)},c.copy=function(f){this.uchar=f.uchar,this.penState.copy(f.penState)},c.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},n}(),d=function(){function n(v){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var f=0;f<C;f++)this.chars.push(new i);this.logger=v,this.pos=0,this.currPenState=new m}var c=n.prototype;return c.equals=function(f){for(var g=!0,y=0;y<C;y++)if(!this.chars[y].equals(f.chars[y])){g=!1;break}return g},c.copy=function(f){for(var g=0;g<C;g++)this.chars[g].copy(f.chars[g])},c.isEmpty=function(){for(var f=!0,g=0;g<C;g++)if(!this.chars[g].isEmpty()){f=!1;break}return f},c.setCursor=function(f){this.pos!==f&&(this.pos=f),this.pos<0?(this.logger.log(_.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>C&&(this.logger.log(_.DEBUG,"Too large cursor position "+this.pos),this.pos=C)},c.moveCursor=function(f){var g=this.pos+f;if(f>1)for(var y=this.pos+1;y<g+1;y++)this.chars[y].setPenState(this.currPenState);this.setCursor(g)},c.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},c.insertChar=function(f){f>=144&&this.backSpace();var g=u(f);if(this.pos>=C){this.logger.log(_.ERROR,"Cannot insert "+f.toString(16)+" ("+g+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(g,this.currPenState),this.moveCursor(1)},c.clearFromPos=function(f){var g;for(g=f;g<C;g++)this.chars[g].reset()},c.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},c.clearToEndOfRow=function(){this.clearFromPos(this.pos)},c.getTextString=function(){for(var f=[],g=!0,y=0;y<C;y++){var M=this.chars[y].uchar;M!==" "&&(g=!1),f.push(M)}return g?"":f.join("")},c.setPenStyles=function(f){this.currPenState.setStyles(f);var g=this.chars[this.pos];g.setPenState(this.currPenState)},n}(),p=function(){function n(v){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var f=0;f<R;f++)this.rows.push(new d(v));this.logger=v,this.currRow=R-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var c=n.prototype;return c.reset=function(){for(var f=0;f<R;f++)this.rows[f].clear();this.currRow=R-1},c.equals=function(f){for(var g=!0,y=0;y<R;y++)if(!this.rows[y].equals(f.rows[y])){g=!1;break}return g},c.copy=function(f){for(var g=0;g<R;g++)this.rows[g].copy(f.rows[g])},c.isEmpty=function(){for(var f=!0,g=0;g<R;g++)if(!this.rows[g].isEmpty()){f=!1;break}return f},c.backSpace=function(){var f=this.rows[this.currRow];f.backSpace()},c.clearToEndOfRow=function(){var f=this.rows[this.currRow];f.clearToEndOfRow()},c.insertChar=function(f){var g=this.rows[this.currRow];g.insertChar(f)},c.setPen=function(f){var g=this.rows[this.currRow];g.setPenStyles(f)},c.moveCursor=function(f){var g=this.rows[this.currRow];g.moveCursor(f)},c.setCursor=function(f){this.logger.log(_.INFO,"setCursor: "+f);var g=this.rows[this.currRow];g.setCursor(f)},c.setPAC=function(f){this.logger.log(_.INFO,"pacData = "+JSON.stringify(f));var g=f.row-1;if(this.nrRollUpRows&&g<this.nrRollUpRows-1&&(g=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==g){for(var y=0;y<R;y++)this.rows[y].clear();var M=this.currRow+1-this.nrRollUpRows,D=this.lastOutputScreen;if(D){var P=D.rows[M].cueStartTime,B=this.logger.time;if(P&&B!==null&&P<B)for(var N=0;N<this.nrRollUpRows;N++)this.rows[g-this.nrRollUpRows+N+1].copy(D.rows[M+N])}}this.currRow=g;var F=this.rows[this.currRow];if(f.indent!==null){var H=f.indent,V=Math.max(H-1,0);F.setCursor(f.indent),f.color=F.chars[V].penState.foreground}var X={foreground:f.color,underline:f.underline,italics:f.italics,background:"black",flash:!1};this.setPen(X)},c.setBkgData=function(f){this.logger.log(_.INFO,"bkgData = "+JSON.stringify(f)),this.backSpace(),this.setPen(f),this.insertChar(32)},c.setRollUpRows=function(f){this.nrRollUpRows=f},c.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(_.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(_.TEXT,this.getDisplayText());var f=this.currRow+1-this.nrRollUpRows,g=this.rows.splice(f,1)[0];g.clear(),this.rows.splice(this.currRow,0,g),this.logger.log(_.INFO,"Rolling up")},c.getDisplayText=function(f){f=f||!1;for(var g=[],y="",M=-1,D=0;D<R;D++){var P=this.rows[D].getTextString();P&&(M=D+1,f?g.push("Row "+M+": '"+P+"'"):g.push(P.trim()))}return g.length>0&&(f?y="["+g.join(" | ")+"]":y=g.join(`
20
+ `)),y},c.getTextAndFormat=function(){return this.rows},n}(),T=function(){function n(v,f,g){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=v,this.outputFilter=f,this.mode=null,this.verbose=0,this.displayedMemory=new p(g),this.nonDisplayedMemory=new p(g),this.lastOutputScreen=new p(g),this.currRollUpRow=this.displayedMemory.rows[R-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=g}var c=n.prototype;return c.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[R-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},c.getHandler=function(){return this.outputFilter},c.setHandler=function(f){this.outputFilter=f},c.setPAC=function(f){this.writeScreen.setPAC(f)},c.setBkgData=function(f){this.writeScreen.setBkgData(f)},c.setMode=function(f){f!==this.mode&&(this.mode=f,this.logger.log(_.INFO,"MODE="+f),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=f)},c.insertChars=function(f){for(var g=0;g<f.length;g++)this.writeScreen.insertChar(f[g]);var y=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(_.INFO,y+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(_.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},c.ccRCL=function(){this.logger.log(_.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},c.ccBS=function(){this.logger.log(_.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},c.ccAOF=function(){},c.ccAON=function(){},c.ccDER=function(){this.logger.log(_.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},c.ccRU=function(f){this.logger.log(_.INFO,"RU("+f+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(f)},c.ccFON=function(){this.logger.log(_.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},c.ccRDC=function(){this.logger.log(_.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},c.ccTR=function(){this.logger.log(_.INFO,"TR"),this.setMode("MODE_TEXT")},c.ccRTD=function(){this.logger.log(_.INFO,"RTD"),this.setMode("MODE_TEXT")},c.ccEDM=function(){this.logger.log(_.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},c.ccCR=function(){this.logger.log(_.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},c.ccENM=function(){this.logger.log(_.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},c.ccEOC=function(){if(this.logger.log(_.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var f=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=f,this.writeScreen=this.nonDisplayedMemory,this.logger.log(_.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},c.ccTO=function(f){this.logger.log(_.INFO,"TO("+f+") - Tab Offset"),this.writeScreen.moveCursor(f)},c.ccMIDROW=function(f){var g={flash:!1};if(g.underline=f%2===1,g.italics=f>=46,g.italics)g.foreground="white";else{var y=Math.floor(f/2)-16,M=["white","green","blue","cyan","red","yellow","magenta"];g.foreground=M[y]}this.logger.log(_.INFO,"MIDROW: "+JSON.stringify(g)),this.writeScreen.setPen(g)},c.outputDataUpdate=function(f){f===void 0&&(f=!1);var g=this.logger.time;g!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=g:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,g,this.lastOutputScreen),f&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:g),this.lastOutputScreen.copy(this.displayedMemory))},c.cueSplitAtTime=function(f){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,f,this.displayedMemory),this.cueStartTime=f))},n}(),l=function(){function n(v,f,g){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var y=new A;this.channels=[null,new T(v,f,y),new T(v+1,g,y)],this.cmdHistory=E(),this.logger=y}var c=n.prototype;return c.getHandler=function(f){return this.channels[f].getHandler()},c.setHandler=function(f,g){this.channels[f].setHandler(g)},c.addData=function(f,g){var y,M,D,P=!1;this.logger.time=f;for(var B=0;B<g.length;B+=2)if(M=g[B]&127,D=g[B+1]&127,!(M===0&&D===0)){if(this.logger.log(_.DATA,"["+S([g[B],g[B+1]])+"] -> ("+S([M,D])+")"),y=this.parseCmd(M,D),y||(y=this.parseMidrow(M,D)),y||(y=this.parsePAC(M,D)),y||(y=this.parseBackgroundAttributes(M,D)),!y&&(P=this.parseChars(M,D),P)){var N=this.currentChannel;if(N&&N>0){var F=this.channels[N];F.insertChars(P)}else this.logger.log(_.WARNING,"No channel found yet. TEXT-MODE?")}!y&&!P&&this.logger.log(_.WARNING,"Couldn't parse cleaned data "+S([M,D])+" orig: "+S([g[B],g[B+1]]))}},c.parseCmd=function(f,g){var y=this.cmdHistory,M=(f===20||f===28||f===21||f===29)&&g>=32&&g<=47,D=(f===23||f===31)&&g>=33&&g<=35;if(!(M||D))return!1;if(h(f,g,y))return o(null,null,y),this.logger.log(_.DEBUG,"Repeated command ("+S([f,g])+") is dropped"),!0;var P=f===20||f===21||f===23?1:2,B=this.channels[P];return f===20||f===21||f===28||f===29?g===32?B.ccRCL():g===33?B.ccBS():g===34?B.ccAOF():g===35?B.ccAON():g===36?B.ccDER():g===37?B.ccRU(2):g===38?B.ccRU(3):g===39?B.ccRU(4):g===40?B.ccFON():g===41?B.ccRDC():g===42?B.ccTR():g===43?B.ccRTD():g===44?B.ccEDM():g===45?B.ccCR():g===46?B.ccENM():g===47&&B.ccEOC():B.ccTO(g-32),o(f,g,y),this.currentChannel=P,!0},c.parseMidrow=function(f,g){var y=0;if((f===17||f===25)&&g>=32&&g<=47){if(f===17?y=1:y=2,y!==this.currentChannel)return this.logger.log(_.ERROR,"Mismatch channel in midrow parsing"),!1;var M=this.channels[y];return M?(M.ccMIDROW(g),this.logger.log(_.DEBUG,"MIDROW ("+S([f,g])+")"),!0):!1}return!1},c.parsePAC=function(f,g){var y,M=this.cmdHistory,D=(f>=17&&f<=23||f>=25&&f<=31)&&g>=64&&g<=127,P=(f===16||f===24)&&g>=64&&g<=95;if(!(D||P))return!1;if(h(f,g,M))return o(null,null,M),!0;var B=f<=23?1:2;g>=64&&g<=95?y=B===1?O[f]:b[f]:y=B===1?L[f]:x[f];var N=this.channels[B];return N?(N.setPAC(this.interpretPAC(y,g)),o(f,g,M),this.currentChannel=B,!0):!1},c.interpretPAC=function(f,g){var y,M={color:null,italics:!1,indent:null,underline:!1,row:f};return g>95?y=g-96:y=g-64,M.underline=(y&1)===1,y<=13?M.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(y/2)]:y<=15?(M.italics=!0,M.color="white"):M.indent=Math.floor((y-16)/2)*4,M},c.parseChars=function(f,g){var y,M=null,D=null;if(f>=25?(y=2,D=f-8):(y=1,D=f),D>=17&&D<=19){var P;D===17?P=g+80:D===18?P=g+112:P=g+144,this.logger.log(_.INFO,"Special char '"+u(P)+"' in channel "+y),M=[P]}else f>=32&&f<=127&&(M=g===0?[f]:[f,g]);if(M){var B=S(M);this.logger.log(_.DEBUG,"Char codes = "+B.join(",")),o(f,g,this.cmdHistory)}return M},c.parseBackgroundAttributes=function(f,g){var y=(f===16||f===24)&&g>=32&&g<=47,M=(f===23||f===31)&&g>=45&&g<=47;if(!(y||M))return!1;var D,P={};f===16||f===24?(D=Math.floor((g-32)/2),P.background=I[D],g%2===1&&(P.background=P.background+"_semi")):g===45?P.background="transparent":(P.foreground="black",g===47&&(P.underline=!0));var B=f<=23?1:2,N=this.channels[B];return N.setBkgData(P),o(f,g,this.cmdHistory),!0},c.reset=function(){for(var f=0;f<Object.keys(this.channels).length;f++){var g=this.channels[f];g&&g.reset()}this.cmdHistory=E()},c.cueSplitAtTime=function(f){for(var g=0;g<this.channels.length;g++){var y=this.channels[g];y&&y.cueSplitAtTime(f)}},n}();function o(n,c,v){v.a=n,v.b=c}function h(n,c,v){return v.a===n&&v.b===c}function E(){return{a:null,b:null}}t.default=l},"./src/utils/codecs.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"isCodecType",function(){return s}),e.d(t,"isCodecSupportedInMp4",function(){return u});var a={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 s(R,C){var O=a[C];return!!O&&O[R.slice(0,4)]===!0}function u(R,C){return MediaSource.isTypeSupported((C||"video")+'/mp4;codecs="'+R+'"')}},"./src/utils/cues.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/utils/vttparser.ts"),s=e("./src/utils/webvtt-parser.ts"),u=e("./src/utils/texttrack-utils.ts"),R=/\s/,C={newCue:function(L,b,x,I){for(var _=[],A,S,m,i,d,p=self.VTTCue||self.TextTrackCue,T=0;T<I.rows.length;T++)if(A=I.rows[T],m=!0,i=0,d="",!A.isEmpty()){for(var l=0;l<A.chars.length;l++)R.test(A.chars[l].uchar)&&m?i++:(d+=A.chars[l].uchar,m=!1);A.cueStartTime=b,b===x&&(x+=1e-4),i>=16?i--:i++;var o=Object(a.fixLineBreaks)(d.trim()),h=Object(s.generateCueId)(b,x,o);(!L||!L.cues||!L.cues.getCueById(h))&&(S=new p(b,x,o),S.id=h,S.line=T+1,S.align="left",S.position=10+Math.min(80,Math.floor(i*8/32)*10),_.push(S))}return L&&_.length&&(_.sort(function(E,n){return E.line==="auto"||n.line==="auto"?0:E.line>8&&n.line>8?n.line-E.line:E.line-n.line}),_.forEach(function(E){return Object(u.addCueToTrack)(L,E)})),_}};t.default=C},"./src/utils/discontinuities.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"findFirstFragWithCC",function(){return R}),e.d(t,"shouldAlignOnDiscontinuities",function(){return C}),e.d(t,"findDiscontinuousReferenceFrag",function(){return O}),e.d(t,"adjustSlidingStart",function(){return b}),e.d(t,"alignStream",function(){return x}),e.d(t,"alignPDT",function(){return _}),e.d(t,"alignFragmentByPDTDelta",function(){return A}),e.d(t,"alignMediaPlaylistByPDT",function(){return S});var a=e("./src/polyfills/number.ts"),s=e("./src/utils/logger.ts"),u=e("./src/controller/level-helper.ts");function R(m,i){for(var d=null,p=0,T=m.length;p<T;p++){var l=m[p];if(l&&l.cc===i){d=l;break}}return d}function C(m,i,d){return!!(i.details&&(d.endCC>d.startCC||m&&m.cc<d.startCC))}function O(m,i){var d=m.fragments,p=i.fragments;if(!p.length||!d.length){s.logger.log("No fragments to align");return}var T=R(d,p[0].cc);if(!T||T&&!T.startPTS){s.logger.log("No frag in previous level to align on");return}return T}function L(m,i){if(m){var d=m.start+i;m.start=m.startPTS=d,m.endPTS=d+m.duration}}function b(m,i){for(var d=i.fragments,p=0,T=d.length;p<T;p++)L(d[p],m);i.fragmentHint&&L(i.fragmentHint,m),i.alignedSliding=!0}function x(m,i,d){!i||(I(m,d,i),!d.alignedSliding&&i.details&&_(d,i.details),!d.alignedSliding&&i.details&&!d.skippedSegments&&Object(u.adjustSliding)(i.details,d))}function I(m,i,d){if(C(m,d,i)){var p=O(d.details,i);p&&Object(a.isFiniteNumber)(p.start)&&(s.logger.log("Adjusting PTS using last level due to CC increase within current level "+i.url),b(p.start,i))}}function _(m,i){if(!(!i.fragments.length||!m.hasProgramDateTime||!i.hasProgramDateTime)){var d=i.fragments[0].programDateTime,p=m.fragments[0].programDateTime,T=(p-d)/1e3+i.fragments[0].start;T&&Object(a.isFiniteNumber)(T)&&(s.logger.log("Adjusting PTS using programDateTime delta "+(p-d)+"ms, sliding:"+T.toFixed(3)+" "+m.url+" "),b(T,m))}}function A(m,i){var d=m.programDateTime;if(!!d){var p=(d-i)/1e3;m.start=m.startPTS=p,m.endPTS=p+m.duration}}function S(m,i){if(!(!i.fragments.length||!m.hasProgramDateTime||!i.hasProgramDateTime)){var d=i.fragments[0].programDateTime,p=i.fragments[0].start,T=d-p*1e3;m.fragments.forEach(function(l){A(l,T)}),m.fragmentHint&&A(m.fragmentHint,T),m.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/utils/ewma.ts"),s=function(){function u(C,O,L){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=L,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new a.default(C),this.fast_=new a.default(O)}var R=u.prototype;return R.update=function(O,L){var b=this.slow_,x=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new a.default(O,b.getEstimate(),b.getTotalWeight())),this.fast_.halfLife!==L&&(this.fast_=new a.default(L,x.getEstimate(),x.getTotalWeight()))},R.sample=function(O,L){O=Math.max(O,this.minDelayMs_);var b=8*L,x=O/1e3,I=b/x;this.fast_.sample(x,I),this.slow_.sample(x,I)},R.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},R.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},R.destroy=function(){},u}();t.default=s},"./src/utils/ewma.ts":function(r,t,e){"use strict";e.r(t);var a=function(){function s(R,C,O){C===void 0&&(C=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=R,this.alpha_=R?Math.exp(Math.log(.5)/R):0,this.estimate_=C,this.totalWeight_=O}var u=s.prototype;return u.sample=function(C,O){var L=Math.pow(this.alpha_,C);this.estimate_=O*(1-L)+L*this.estimate_,this.totalWeight_+=C},u.getTotalWeight=function(){return this.totalWeight_},u.getEstimate=function(){if(this.alpha_){var C=1-Math.pow(this.alpha_,this.totalWeight_);if(C)return this.estimate_/C}return this.estimate_},s}();t.default=a},"./src/utils/fetch-loader.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"fetchSupported",function(){return A});var a=e("./src/polyfills/number.ts"),s=e("./src/loader/load-stats.ts"),u=e("./src/demux/chunk-cache.ts");function R(p,T){p.prototype=Object.create(T.prototype),p.prototype.constructor=p,x(p,T)}function C(p){var T=typeof Map=="function"?new Map:void 0;return C=function(o){if(o===null||!b(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(typeof T!="undefined"){if(T.has(o))return T.get(o);T.set(o,h)}function h(){return O(o,arguments,I(this).constructor)}return h.prototype=Object.create(o.prototype,{constructor:{value:h,enumerable:!1,writable:!0,configurable:!0}}),x(h,o)},C(p)}function O(p,T,l){return L()?O=Reflect.construct.bind():O=function(h,E,n){var c=[null];c.push.apply(c,E);var v=Function.bind.apply(h,c),f=new v;return n&&x(f,n.prototype),f},O.apply(null,arguments)}function L(){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 b(p){return Function.toString.call(p).indexOf("[native code]")!==-1}function x(p,T){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,h){return o.__proto__=h,o},x(p,T)}function I(p){return I=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},I(p)}function _(){return _=Object.assign?Object.assign.bind():function(p){for(var T=1;T<arguments.length;T++){var l=arguments[T];for(var o in l)Object.prototype.hasOwnProperty.call(l,o)&&(p[o]=l[o])}return p},_.apply(this,arguments)}function A(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var S=function(){function p(l){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=l.fetchSetup||i,this.controller=new self.AbortController,this.stats=new s.LoadStats}var T=p.prototype;return T.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},T.abortInternal=function(){var o=this.response;(!o||!o.ok)&&(this.stats.aborted=!0,this.controller.abort())},T.abort=function(){var o;this.abortInternal(),(o=this.callbacks)!==null&&o!==void 0&&o.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},T.load=function(o,h,E){var n=this,c=this.stats;if(c.loading.start)throw new Error("Loader can only be used once.");c.loading.start=self.performance.now();var v=m(o,this.controller.signal),f=E.onProgress,g=o.responseType==="arraybuffer",y=g?"byteLength":"length";this.context=o,this.config=h,this.callbacks=E,this.request=this.fetchSetup(o,v),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){n.abortInternal(),E.onTimeout(c,o,n.response)},h.timeout),self.fetch(this.request).then(function(M){if(n.response=n.loader=M,!M.ok){var D=M.status,P=M.statusText;throw new d(P||"fetch, bad network response",D,M)}return c.loading.first=Math.max(self.performance.now(),c.loading.start),c.total=parseInt(M.headers.get("Content-Length")||"0"),f&&Object(a.isFiniteNumber)(h.highWaterMark)?n.loadProgressively(M,c,o,h.highWaterMark,f):g?M.arrayBuffer():M.text()}).then(function(M){var D=n.response;self.clearTimeout(n.requestTimeout),c.loading.end=Math.max(self.performance.now(),c.loading.first),c.loaded=c.total=M[y];var P={url:D.url,data:M};f&&!Object(a.isFiniteNumber)(h.highWaterMark)&&f(c,o,M,D),E.onSuccess(P,c,o,D)}).catch(function(M){if(self.clearTimeout(n.requestTimeout),!c.aborted){var D=M&&M.code||0,P=M?M.message:null;E.onError({code:D,text:P},o,M?M.details:null)}})},T.getCacheAge=function(){var o=null;if(this.response){var h=this.response.headers.get("age");o=h?parseFloat(h):null}return o},T.loadProgressively=function(o,h,E,n,c){n===void 0&&(n=0);var v=new u.default,f=o.body.getReader(),g=function y(){return f.read().then(function(M){if(M.done)return v.dataLength&&c(h,E,v.flush(),o),Promise.resolve(new ArrayBuffer(0));var D=M.value,P=D.length;return h.loaded+=P,P<n||v.dataLength?(v.push(D),v.dataLength>=n&&c(h,E,v.flush(),o)):c(h,E,D,o),y()}).catch(function(){return Promise.reject()})};return g()},p}();function m(p,T){var l={method:"GET",mode:"cors",credentials:"same-origin",signal:T,headers:new self.Headers(_({},p.headers))};return p.rangeEnd&&l.headers.set("Range","bytes="+p.rangeStart+"-"+String(p.rangeEnd-1)),l}function i(p,T){return new self.Request(p.url,T)}var d=function(p){R(T,p);function T(l,o,h){var E;return E=p.call(this,l)||this,E.code=void 0,E.details=void 0,E.code=o,E.details=h,E}return T}(C(Error));t.default=S},"./src/utils/imsc1-ttml-parser.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"IMSC1_CODEC",function(){return b}),e.d(t,"parseIMSC1",function(){return A});var a=e("./src/utils/mp4-tools.ts"),s=e("./src/utils/vttparser.ts"),u=e("./src/utils/vttcue.ts"),R=e("./src/demux/id3.ts"),C=e("./src/utils/timescale-conversion.ts"),O=e("./src/utils/webvtt-parser.ts");function L(){return L=Object.assign?Object.assign.bind():function(n){for(var c=1;c<arguments.length;c++){var v=arguments[c];for(var f in v)Object.prototype.hasOwnProperty.call(v,f)&&(n[f]=v[f])}return n},L.apply(this,arguments)}var b="stpp.ttml.im1t",x=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,I=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,_={left:"start",center:"center",right:"end",start:"start",end:"end"};function A(n,c,v,f,g){var y=Object(a.findBox)(new Uint8Array(n),["mdat"]);if(y.length===0){g(new Error("Could not parse IMSC1 mdat"));return}var M=y.map(function(P){return Object(R.utf8ArrayToStr)(P)}),D=Object(C.toTimescaleFromScale)(c,1,v);try{M.forEach(function(P){return f(S(P,D))})}catch(P){g(P)}}function S(n,c){var v=new DOMParser,f=v.parseFromString(n,"text/xml"),g=f.getElementsByTagName("tt")[0];if(!g)throw new Error("Invalid ttml");var y={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},M=Object.keys(y).reduce(function(F,H){return F[H]=g.getAttribute("ttp:"+H)||y[H],F},{}),D=g.getAttribute("xml:space")!=="preserve",P=i(m(g,"styling","style")),B=i(m(g,"layout","region")),N=m(g,"body","[begin]");return[].map.call(N,function(F){var H=d(F,D);if(!H||!F.hasAttribute("begin"))return null;var V=o(F.getAttribute("begin"),M),X=o(F.getAttribute("dur"),M),$=o(F.getAttribute("end"),M);if(V===null)throw l(F);if($===null){if(X===null)throw l(F);$=V+X}var j=new u.default(V-c,$-c,H);j.id=Object(O.generateCueId)(j.startTime,j.endTime,j.text);var J=B[F.getAttribute("region")],ee=P[F.getAttribute("style")];j.position=10,j.size=80;var te=p(J,ee,P),le=te.textAlign;if(le){var ue=_[le];ue&&(j.lineAlign=ue),j.align=le}return L(j,te),j}).filter(function(F){return F!==null})}function m(n,c,v){var f=n.getElementsByTagName(c)[0];return f?[].slice.call(f.querySelectorAll(v)):[]}function i(n){return n.reduce(function(c,v){var f=v.getAttribute("xml:id");return f&&(c[f]=v),c},{})}function d(n,c){return[].slice.call(n.childNodes).reduce(function(v,f,g){var y;return f.nodeName==="br"&&g?v+`
21
+ `:(y=f.childNodes)!==null&&y!==void 0&&y.length?d(f,c):c?v+f.textContent.trim().replace(/\s+/g," "):v+f.textContent},"")}function p(n,c,v){var f="http://www.w3.org/ns/ttml#styling",g=null,y=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],M=n!=null&&n.hasAttribute("style")?n.getAttribute("style"):null;return M&&v.hasOwnProperty(M)&&(g=v[M]),y.reduce(function(D,P){var B=T(c,f,P)||T(n,f,P)||T(g,f,P);return B&&(D[P]=B),D},{})}function T(n,c,v){return n&&n.hasAttributeNS(c,v)?n.getAttributeNS(c,v):null}function l(n){return new Error("Could not parse ttml timestamp "+n)}function o(n,c){if(!n)return null;var v=Object(s.parseTimeStamp)(n);return v===null&&(x.test(n)?v=h(n,c):I.test(n)&&(v=E(n,c))),v}function h(n,c){var v=x.exec(n),f=(v[4]|0)+(v[5]|0)/c.subFrameRate;return(v[1]|0)*3600+(v[2]|0)*60+(v[3]|0)+f/c.frameRate}function E(n,c){var v=I.exec(n),f=Number(v[1]),g=v[2];switch(g){case"h":return f*3600;case"m":return f*60;case"ms":return f*1e3;case"f":return f/c.frameRate;case"t":return f/c.tickRate}return f}},"./src/utils/logger.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"enableLogs",function(){return O}),e.d(t,"logger",function(){return L});var a=function(){},s={trace:a,debug:a,log:a,warn:a,info:a,error:a},u=s;function R(b){var x=self.console[b];return x?x.bind(self.console,"["+b+"] >"):a}function C(b){for(var x=arguments.length,I=new Array(x>1?x-1:0),_=1;_<x;_++)I[_-1]=arguments[_];I.forEach(function(A){u[A]=b[A]?b[A].bind(b):R(A)})}function O(b){if(self.console&&b===!0||typeof b=="object"){C(b,"debug","log","info","warn","error");try{u.log()}catch{u=s}}else u=s}var L=u},"./src/utils/mediakeys-helper.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"KeySystems",function(){return a}),e.d(t,"requestMediaKeySystemAccess",function(){return s});var a;(function(u){u.WIDEVINE="com.widevine.alpha",u.PLAYREADY="com.microsoft.playready"})(a||(a={}));var s=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"getMediaSource",function(){return a});function a(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"RemuxerTrackIdConfig",function(){return O}),e.d(t,"bin2str",function(){return L}),e.d(t,"readUint16",function(){return b}),e.d(t,"readUint32",function(){return x}),e.d(t,"readSint32",function(){return I}),e.d(t,"writeUint32",function(){return _}),e.d(t,"findBox",function(){return A}),e.d(t,"parseSegmentIndex",function(){return S}),e.d(t,"parseInitSegment",function(){return m}),e.d(t,"getStartDTS",function(){return i}),e.d(t,"getDuration",function(){return d}),e.d(t,"computeRawDurationFromSamples",function(){return p}),e.d(t,"offsetStartDTS",function(){return T}),e.d(t,"segmentValidRange",function(){return l}),e.d(t,"appendUint8Array",function(){return o}),e.d(t,"parseSamples",function(){return h}),e.d(t,"parseSEIMessageFromNALu",function(){return c}),e.d(t,"parseEmsg",function(){return f});var a=e("./src/utils/typed-array.ts"),s=e("./src/loader/fragment.ts"),u=e("./src/demux/id3.ts"),R=Math.pow(2,32)-1,C=[].push,O={video:1,audio:2,id3:3,text:4};function L(g){return String.fromCharCode.apply(null,g)}function b(g,y){var M=g[y]<<8|g[y+1];return M<0?65536+M:M}function x(g,y){var M=I(g,y);return M<0?4294967296+M:M}function I(g,y){return g[y]<<24|g[y+1]<<16|g[y+2]<<8|g[y+3]}function _(g,y,M){g[y]=M>>24,g[y+1]=M>>16&255,g[y+2]=M>>8&255,g[y+3]=M&255}function A(g,y){var M=[];if(!y.length)return M;for(var D=g.byteLength,P=0;P<D;){var B=x(g,P),N=L(g.subarray(P+4,P+8)),F=B>1?P+B:D;if(N===y[0])if(y.length===1)M.push(g.subarray(P+8,F));else{var H=A(g.subarray(P+8,F),y.slice(1));H.length&&C.apply(M,H)}P=F}return M}function S(g){var y=[],M=g[0],D=8,P=x(g,D);D+=4;var B=0,N=0;M===0?D+=8:D+=16,D+=2;var F=g.length+N,H=b(g,D);D+=2;for(var V=0;V<H;V++){var X=D,$=x(g,X);X+=4;var j=$&2147483647,J=($&2147483648)>>>31;if(J===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ee=x(g,X);X+=4,y.push({referenceSize:j,subsegmentDuration:ee,info:{duration:ee/P,start:F,end:F+j-1}}),F+=j,X+=4,D=X}return{earliestPresentationTime:B,timescale:P,version:M,referencesCount:H,references:y}}function m(g){for(var y=[],M=A(g,["moov","trak"]),D=0;D<M.length;D++){var P=M[D],B=A(P,["tkhd"])[0];if(B){var N=B[0],F=N===0?12:20,H=x(B,F),V=A(P,["mdia","mdhd"])[0];if(V){N=V[0],F=N===0?12:20;var X=x(V,F),$=A(P,["mdia","hdlr"])[0];if($){var j=L($.subarray(8,12)),J={soun:s.ElementaryStreamTypes.AUDIO,vide:s.ElementaryStreamTypes.VIDEO}[j];if(J){var ee=A(P,["mdia","minf","stbl","stsd"])[0],te=void 0;ee&&(te=L(ee.subarray(12,16))),y[H]={timescale:X,type:J},y[J]={timescale:X,id:H,codec:te}}}}}}var le=A(g,["moov","mvex","trex"]);return le.forEach(function(ue){var ie=x(ue,4),he=y[ie];he&&(he.default={duration:x(ue,12),flags:x(ue,20)})}),y}function i(g,y){return A(y,["moof","traf"]).reduce(function(M,D){var P=A(D,["tfdt"])[0],B=P[0],N=A(D,["tfhd"]).reduce(function(F,H){var V=x(H,4),X=g[V];if(X){var $=x(P,4);B===1&&($*=Math.pow(2,32),$+=x(P,8));var j=X.timescale||9e4,J=$/j;if(isFinite(J)&&(F===null||J<F))return J}return F},null);return N!==null&&isFinite(N)&&(M===null||N<M)?N:M},null)||0}function d(g,y){for(var M=0,D=0,P=0,B=A(g,["moof","traf"]),N=0;N<B.length;N++){var F=B[N],H=A(F,["tfhd"])[0],V=x(H,4),X=y[V];if(!!X){var $=X.default,j=x(H,0)|($==null?void 0:$.flags),J=$==null?void 0:$.duration;j&8&&(j&2?J=x(H,12):J=x(H,8));for(var ee=X.timescale||9e4,te=A(F,["trun"]),le=0;le<te.length;le++){if(M=p(te[le]),!M&&J){var ue=x(te[le],4);M=J*ue}X.type===s.ElementaryStreamTypes.VIDEO?D+=M/ee:X.type===s.ElementaryStreamTypes.AUDIO&&(P+=M/ee)}}}if(D===0&&P===0){for(var ie=0,he=A(g,["sidx"]),ve=0;ve<he.length;ve++){var ae=S(he[ve]);ae!=null&&ae.references&&(ie+=ae.references.reduce(function(Re,Le){return Re+Le.info.duration||0},0))}return ie}return D||P}function p(g){var y=x(g,0),M=8;y&1&&(M+=4),y&4&&(M+=4);for(var D=0,P=x(g,4),B=0;B<P;B++){if(y&256){var N=x(g,M);D+=N,M+=4}y&512&&(M+=4),y&1024&&(M+=4),y&2048&&(M+=4)}return D}function T(g,y,M){A(y,["moof","traf"]).forEach(function(D){A(D,["tfhd"]).forEach(function(P){var B=x(P,4),N=g[B];if(!!N){var F=N.timescale||9e4;A(D,["tfdt"]).forEach(function(H){var V=H[0],X=x(H,4);if(V===0)X-=M*F,X=Math.max(X,0),_(H,4,X);else{X*=Math.pow(2,32),X+=x(H,8),X-=M*F,X=Math.max(X,0);var $=Math.floor(X/(R+1)),j=Math.floor(X%(R+1));_(H,4,$),_(H,8,j)}})}})})}function l(g){var y={valid:null,remainder:null},M=A(g,["moof"]);if(M){if(M.length<2)return y.remainder=g,y}else return y;var D=M[M.length-1];return y.valid=Object(a.sliceUint8)(g,0,D.byteOffset-8),y.remainder=Object(a.sliceUint8)(g,D.byteOffset-8),y}function o(g,y){var M=new Uint8Array(g.length+y.length);return M.set(g),M.set(y,g.length),M}function h(g,y){var M=[],D=y.samples,P=y.timescale,B=y.id,N=!1,F=A(D,["moof"]);return F.map(function(H){var V=H.byteOffset-8,X=A(H,["traf"]);X.map(function($){var j=A($,["tfdt"]).map(function(J){var ee=J[0],te=x(J,4);return ee===1&&(te*=Math.pow(2,32),te+=x(J,8)),te/P})[0];return j!==void 0&&(g=j),A($,["tfhd"]).map(function(J){var ee=x(J,4),te=x(J,0)&16777215,le=(te&1)!==0,ue=(te&2)!==0,ie=(te&8)!==0,he=0,ve=(te&16)!==0,ae=0,Re=(te&32)!==0,Le=8;ee===B&&(le&&(Le+=8),ue&&(Le+=4),ie&&(he=x(J,Le),Le+=4),ve&&(ae=x(J,Le),Le+=4),Re&&(Le+=4),y.type==="video"&&(N=E(y.codec)),A($,["trun"]).map(function(De){var _e=De[0],we=x(De,0)&16777215,Ze=(we&1)!==0,He=0,tt=(we&4)!==0,Ke=(we&256)!==0,ot=0,ct=(we&512)!==0,ft=0,lt=(we&1024)!==0,It=(we&2048)!==0,rt=0,Mt=x(De,4),Ye=8;Ze&&(He=x(De,Ye),Ye+=4),tt&&(Ye+=4);for(var Je=He+V,yt=0;yt<Mt;yt++){if(Ke?(ot=x(De,Ye),Ye+=4):ot=he,ct?(ft=x(De,Ye),Ye+=4):ft=ae,lt&&(Ye+=4),It&&(_e===0?rt=x(De,Ye):rt=I(De,Ye),Ye+=4),y.type===s.ElementaryStreamTypes.VIDEO)for(var qe=0;qe<ft;){var Ge=x(D,Je);Je+=4;var kt=D[Je]&31;if(n(N,kt)){var ht=D.subarray(Je,Je+Ge);c(ht,g+rt/P,M)}Je+=Ge,qe+=Ge+4}g+=ot/P}}))})})}),M}function E(g){if(!g)return!1;var y=g.indexOf("."),M=y<0?g:g.substring(0,y);return M==="hvc1"||M==="hev1"||M==="dvh1"||M==="dvhe"}function n(g,y){return g?y===39||y===40:y===6}function c(g,y,M){var D=v(g),P=0;P++;for(var B=0,N=0,F=!1,H=0;P<D.length;){B=0;do{if(P>=D.length)break;H=D[P++],B+=H}while(H===255);N=0;do{if(P>=D.length)break;H=D[P++],N+=H}while(H===255);var V=D.length-P;if(!F&&B===4&&P<D.length){F=!0;var X=D[P++];if(X===181){var $=b(D,P);if(P+=2,$===49){var j=x(D,P);if(P+=4,j===1195456820){var J=D[P++];if(J===3){var ee=D[P++],te=31&ee,le=64&ee,ue=le?2+te*3:0,ie=new Uint8Array(ue);if(le){ie[0]=ee;for(var he=1;he<ue;he++)ie[he]=D[P++]}M.push({type:J,payloadType:B,pts:y,bytes:ie})}}}}}else if(B===5&&N<V){if(F=!0,N>16){for(var ve=[],ae=0;ae<16;ae++){var Re=D[P++].toString(16);ve.push(Re.length==1?"0"+Re:Re),(ae===3||ae===5||ae===7||ae===9)&&ve.push("-")}for(var Le=N-16,De=new Uint8Array(Le),_e=0;_e<Le;_e++)De[_e]=D[P++];M.push({payloadType:B,pts:y,uuid:ve.join(""),userData:Object(u.utf8ArrayToStr)(De),userDataBytes:De})}}else if(N<V)P+=N;else if(N>V)break}}function v(g){for(var y=g.byteLength,M=[],D=1;D<y-2;)g[D]===0&&g[D+1]===0&&g[D+2]===3?(M.push(D+2),D+=2):D++;if(M.length===0)return g;var P=y-M.length,B=new Uint8Array(P),N=0;for(D=0;D<P;N++,D++)N===M[0]&&(N++,M.shift()),B[D]=g[N];return B}function f(g){var y=g[0],M="",D="",P=0,B=0,N=0,F=0,H=0,V=0;if(y===0){for(;L(g.subarray(V,V+1))!=="\0";)M+=L(g.subarray(V,V+1)),V+=1;for(M+=L(g.subarray(V,V+1)),V+=1;L(g.subarray(V,V+1))!=="\0";)D+=L(g.subarray(V,V+1)),V+=1;D+=L(g.subarray(V,V+1)),V+=1,P=x(g,12),B=x(g,16),F=x(g,20),H=x(g,24),V=28}else if(y===1){V+=4,P=x(g,V),V+=4;var X=x(g,V);V+=4;var $=x(g,V);for(V+=4,N=Math.pow(2,32)*X+$,Number.isSafeInteger(N)||(N=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),F=x(g,V),V+=4,H=x(g,V),V+=4;L(g.subarray(V,V+1))!=="\0";)M+=L(g.subarray(V,V+1)),V+=1;for(M+=L(g.subarray(V,V+1)),V+=1;L(g.subarray(V,V+1))!=="\0";)D+=L(g.subarray(V,V+1)),V+=1;D+=L(g.subarray(V,V+1)),V+=1}var j=g.subarray(V,g.byteLength);return{schemeIdUri:M,value:D,timeScale:P,presentationTime:N,presentationTimeDelta:B,eventDuration:F,id:H,payload:j}}},"./src/utils/output-filter.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"default",function(){return a});var a=function(){function s(R,C){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=R,this.trackName=C}var u=s.prototype;return u.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},u.newCue=function(C,O,L){(this.startTime===null||this.startTime>C)&&(this.startTime=C),this.endTime=O,this.screen=L,this.timelineController.createCaptionsTrack(this.trackName)},u.reset=function(){this.cueRanges=[],this.startTime=null},s}()},"./src/utils/texttrack-utils.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"sendAddTrackEvent",function(){return s}),e.d(t,"addCueToTrack",function(){return u}),e.d(t,"clearCurrentCues",function(){return R}),e.d(t,"removeCuesInRange",function(){return C}),e.d(t,"getCuesInRange",function(){return L});var a=e("./src/utils/logger.ts");function s(b,x){var I;try{I=new Event("addtrack")}catch{I=document.createEvent("Event"),I.initEvent("addtrack",!1,!1)}I.track=b,x.dispatchEvent(I)}function u(b,x){var I=b.mode;if(I==="disabled"&&(b.mode="hidden"),b.cues&&!b.cues.getCueById(x.id))try{if(b.addCue(x),!b.cues.getCueById(x.id))throw new Error("addCue is failed for: "+x)}catch(A){a.logger.debug("[texttrack-utils]: "+A);var _=new self.TextTrackCue(x.startTime,x.endTime,x.text);_.id=x.id,b.addCue(_)}I==="disabled"&&(b.mode=I)}function R(b){var x=b.mode;if(x==="disabled"&&(b.mode="hidden"),b.cues)for(var I=b.cues.length;I--;)b.removeCue(b.cues[I]);x==="disabled"&&(b.mode=x)}function C(b,x,I,_){var A=b.mode;if(A==="disabled"&&(b.mode="hidden"),b.cues&&b.cues.length>0)for(var S=L(b.cues,x,I),m=0;m<S.length;m++)(!_||_(S[m]))&&b.removeCue(S[m]);A==="disabled"&&(b.mode=A)}function O(b,x){if(x<b[0].startTime)return 0;var I=b.length-1;if(x>b[I].endTime)return-1;for(var _=0,A=I;_<=A;){var S=Math.floor((A+_)/2);if(x<b[S].startTime)A=S-1;else if(x>b[S].startTime&&_<I)_=S+1;else return S}return b[_].startTime-x<x-b[A].startTime?_:A}function L(b,x,I){var _=[],A=O(b,x);if(A>-1)for(var S=A,m=b.length;S<m;S++){var i=b[S];if(i.startTime>=x&&i.endTime<=I)_.push(i);else if(i.startTime>I)return _}return _}},"./src/utils/time-ranges.ts":function(r,t,e){"use strict";e.r(t);var a={toString:function(u){for(var R="",C=u.length,O=0;O<C;O++)R+="["+u.start(O).toFixed(3)+","+u.end(O).toFixed(3)+"]";return R}};t.default=a},"./src/utils/timescale-conversion.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"toTimescaleFromBase",function(){return s}),e.d(t,"toTimescaleFromScale",function(){return u}),e.d(t,"toMsFromMpegTsClock",function(){return R}),e.d(t,"toMpegTsClockFromTimescale",function(){return C});var a=9e4;function s(O,L,b,x){b===void 0&&(b=1),x===void 0&&(x=!1);var I=O*L*b;return x?Math.round(I):I}function u(O,L,b,x){return b===void 0&&(b=1),x===void 0&&(x=!1),s(O,L,1/b,x)}function R(O,L){return L===void 0&&(L=!1),s(O,1e3,1/a,L)}function C(O,L){return L===void 0&&(L=1),s(O,a,1/L)}},"./src/utils/typed-array.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"sliceUint8",function(){return a});function a(s,u,R){return Uint8Array.prototype.slice?s.slice(u,R):new Uint8Array(Array.prototype.slice.call(s,u,R))}},"./src/utils/vttcue.ts":function(r,t,e){"use strict";e.r(t),t.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var a=["","lr","rl"],s=["start","middle","end","left","right"];function u(b,x){if(typeof x!="string"||!Array.isArray(b))return!1;var I=x.toLowerCase();return~b.indexOf(I)?I:!1}function R(b){return u(a,b)}function C(b){return u(s,b)}function O(b){for(var x=arguments.length,I=new Array(x>1?x-1:0),_=1;_<x;_++)I[_-1]=arguments[_];for(var A=1;A<arguments.length;A++){var S=arguments[A];for(var m in S)b[m]=S[m]}return b}function L(b,x,I){var _=this,A={enumerable:!0};_.hasBeenReset=!1;var S="",m=!1,i=b,d=x,p=I,T=null,l="",o=!0,h="auto",E="start",n=50,c="middle",v=50,f="middle";Object.defineProperty(_,"id",O({},A,{get:function(){return S},set:function(y){S=""+y}})),Object.defineProperty(_,"pauseOnExit",O({},A,{get:function(){return m},set:function(y){m=!!y}})),Object.defineProperty(_,"startTime",O({},A,{get:function(){return i},set:function(y){if(typeof y!="number")throw new TypeError("Start time must be set to a number.");i=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"endTime",O({},A,{get:function(){return d},set:function(y){if(typeof y!="number")throw new TypeError("End time must be set to a number.");d=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"text",O({},A,{get:function(){return p},set:function(y){p=""+y,this.hasBeenReset=!0}})),Object.defineProperty(_,"region",O({},A,{get:function(){return T},set:function(y){T=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"vertical",O({},A,{get:function(){return l},set:function(y){var M=R(y);if(M===!1)throw new SyntaxError("An invalid or illegal string was specified.");l=M,this.hasBeenReset=!0}})),Object.defineProperty(_,"snapToLines",O({},A,{get:function(){return o},set:function(y){o=!!y,this.hasBeenReset=!0}})),Object.defineProperty(_,"line",O({},A,{get:function(){return h},set:function(y){if(typeof y!="number"&&y!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");h=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"lineAlign",O({},A,{get:function(){return E},set:function(y){var M=C(y);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");E=M,this.hasBeenReset=!0}})),Object.defineProperty(_,"position",O({},A,{get:function(){return n},set:function(y){if(y<0||y>100)throw new Error("Position must be between 0 and 100.");n=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"positionAlign",O({},A,{get:function(){return c},set:function(y){var M=C(y);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");c=M,this.hasBeenReset=!0}})),Object.defineProperty(_,"size",O({},A,{get:function(){return v},set:function(y){if(y<0||y>100)throw new Error("Size must be between 0 and 100.");v=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"align",O({},A,{get:function(){return f},set:function(y){var M=C(y);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");f=M,this.hasBeenReset=!0}})),_.displayState=void 0}return L.prototype.getCueAsHTML=function(){var b=self.WebVTT;return b.convertCueToDOMTree(self,this.text)},L}()},"./src/utils/vttparser.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"parseTimeStamp",function(){return u}),e.d(t,"fixLineBreaks",function(){return x}),e.d(t,"VTTParser",function(){return I});var a=e("./src/utils/vttcue.ts"),s=function(){function _(){}var A=_.prototype;return A.decode=function(m,i){if(!m)return"";if(typeof m!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(m))},_}();function u(_){function A(m,i,d,p){return(m|0)*3600+(i|0)*60+(d|0)+parseFloat(p||0)}var S=_.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return S?parseFloat(S[2])>59?A(S[2],S[3],0,S[4]):A(S[1],S[2],S[3],S[4]):null}var R=function(){function _(){this.values=Object.create(null)}var A=_.prototype;return A.set=function(m,i){!this.get(m)&&i!==""&&(this.values[m]=i)},A.get=function(m,i,d){return d?this.has(m)?this.values[m]:i[d]:this.has(m)?this.values[m]:i},A.has=function(m){return m in this.values},A.alt=function(m,i,d){for(var p=0;p<d.length;++p)if(i===d[p]){this.set(m,i);break}},A.integer=function(m,i){/^-?\d+$/.test(i)&&this.set(m,parseInt(i,10))},A.percent=function(m,i){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(i)){var d=parseFloat(i);if(d>=0&&d<=100)return this.set(m,d),!0}return!1},_}();function C(_,A,S,m){var i=m?_.split(m):[_];for(var d in i)if(typeof i[d]=="string"){var p=i[d].split(S);if(p.length===2){var T=p[0],l=p[1];A(T,l)}}}var O=new a.default(0,0,""),L=O.align==="middle"?"middle":"center";function b(_,A,S){var m=_;function i(){var T=u(_);if(T===null)throw new Error("Malformed timestamp: "+m);return _=_.replace(/^[^\sa-zA-Z-]+/,""),T}function d(T,l){var o=new R;C(T,function(n,c){var v;switch(n){case"region":for(var f=S.length-1;f>=0;f--)if(S[f].id===c){o.set(n,S[f].region);break}break;case"vertical":o.alt(n,c,["rl","lr"]);break;case"line":v=c.split(","),o.integer(n,v[0]),o.percent(n,v[0])&&o.set("snapToLines",!1),o.alt(n,v[0],["auto"]),v.length===2&&o.alt("lineAlign",v[1],["start",L,"end"]);break;case"position":v=c.split(","),o.percent(n,v[0]),v.length===2&&o.alt("positionAlign",v[1],["start",L,"end","line-left","line-right","auto"]);break;case"size":o.percent(n,c);break;case"align":o.alt(n,c,["start",L,"end","left","right"]);break}},/:/,/\s/),l.region=o.get("region",null),l.vertical=o.get("vertical","");var h=o.get("line","auto");h==="auto"&&O.line===-1&&(h=-1),l.line=h,l.lineAlign=o.get("lineAlign","start"),l.snapToLines=o.get("snapToLines",!0),l.size=o.get("size",100),l.align=o.get("align",L);var E=o.get("position","auto");E==="auto"&&O.position===50&&(E=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=E}function p(){_=_.replace(/^\s+/,"")}if(p(),A.startTime=i(),p(),_.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+m);_=_.slice(3),p(),A.endTime=i(),p(),d(_,A)}function x(_){return _.replace(/<br(?: \/)?>/gi,`
22
+ `)}var I=function(){function _(){this.state="INITIAL",this.buffer="",this.decoder=new s,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var A=_.prototype;return A.parse=function(m){var i=this;m&&(i.buffer+=i.decoder.decode(m,{stream:!0}));function d(){var E=i.buffer,n=0;for(E=x(E);n<E.length&&E[n]!=="\r"&&E[n]!==`
23
23
  `;)++n;var c=E.slice(0,n);return E[n]==="\r"&&++n,E[n]===`
24
- `&&++n,i.buffer=E.slice(n),c}function p(E){C(E,function(n,c){},/:/)}try{var T="";if(i.state==="INITIAL"){if(!/\r\n|\n/.test(i.buffer))return this;T=d();var l=T.match(/^()?WEBVTT([ \t].*)?$/);if(!l||!l[0])throw new Error("Malformed WebVTT signature.");i.state="HEADER"}for(var o=!1;i.buffer;){if(!/\r\n|\n/.test(i.buffer))return this;switch(o?o=!1:T=d(),i.state){case"HEADER":/:/.test(T)?p(T):T||(i.state="ID");continue;case"NOTE":T||(i.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(T)){i.state="NOTE";break}if(!T)continue;if(i.cue=new s.default(0,0,""),i.state="CUE",T.indexOf("-->")===-1){i.cue.id=T;continue}case"CUE":if(!i.cue){i.state="BADCUE";continue}try{b(T,i.cue,i.regionList)}catch{i.cue=null,i.state="BADCUE";continue}i.state="CUETEXT";continue;case"CUETEXT":{var h=T.indexOf("-->")!==-1;if(!T||h&&(o=!0)){i.oncue&&i.cue&&i.oncue(i.cue),i.cue=null,i.state="ID";continue}if(i.cue===null)continue;i.cue.text&&(i.cue.text+=`
25
- `),i.cue.text+=T}continue;case"BADCUE":T||(i.state="ID")}}}catch{i.state==="CUETEXT"&&i.cue&&i.oncue&&i.oncue(i.cue),i.cue=null,i.state=i.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},A.flush=function(){var v=this;try{if((v.cue||v.state==="HEADER")&&(v.buffer+=`
24
+ `&&++n,i.buffer=E.slice(n),c}function p(E){C(E,function(n,c){},/:/)}try{var T="";if(i.state==="INITIAL"){if(!/\r\n|\n/.test(i.buffer))return this;T=d();var l=T.match(/^()?WEBVTT([ \t].*)?$/);if(!l||!l[0])throw new Error("Malformed WebVTT signature.");i.state="HEADER"}for(var o=!1;i.buffer;){if(!/\r\n|\n/.test(i.buffer))return this;switch(o?o=!1:T=d(),i.state){case"HEADER":/:/.test(T)?p(T):T||(i.state="ID");continue;case"NOTE":T||(i.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(T)){i.state="NOTE";break}if(!T)continue;if(i.cue=new a.default(0,0,""),i.state="CUE",T.indexOf("-->")===-1){i.cue.id=T;continue}case"CUE":if(!i.cue){i.state="BADCUE";continue}try{b(T,i.cue,i.regionList)}catch{i.cue=null,i.state="BADCUE";continue}i.state="CUETEXT";continue;case"CUETEXT":{var h=T.indexOf("-->")!==-1;if(!T||h&&(o=!0)){i.oncue&&i.cue&&i.oncue(i.cue),i.cue=null,i.state="ID";continue}if(i.cue===null)continue;i.cue.text&&(i.cue.text+=`
25
+ `),i.cue.text+=T}continue;case"BADCUE":T||(i.state="ID")}}}catch{i.state==="CUETEXT"&&i.cue&&i.oncue&&i.oncue(i.cue),i.cue=null,i.state=i.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},A.flush=function(){var m=this;try{if((m.cue||m.state==="HEADER")&&(m.buffer+=`
26
26
 
27
- `,v.parse()),v.state==="INITIAL"||v.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(i){v.onparsingerror&&v.onparsingerror(i)}return v.onflush&&v.onflush(),this},_}()},"./src/utils/webvtt-parser.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"generateCueId",function(){return I}),e.d(t,"parseWebVTT",function(){return A});var s=e("./src/polyfills/number.ts"),a=e("./src/utils/vttparser.ts"),u=e("./src/demux/id3.ts"),R=e("./src/utils/timescale-conversion.ts"),C=e("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,L=function(v,i,d){return d===void 0&&(d=0),v.slice(d,d+i.length)===i},b=function(v){var i=parseInt(v.slice(-3)),d=parseInt(v.slice(-6,-4)),p=parseInt(v.slice(-9,-7)),T=v.length>9?parseInt(v.substring(0,v.indexOf(":"))):0;if(!Object(s.isFiniteNumber)(i)||!Object(s.isFiniteNumber)(d)||!Object(s.isFiniteNumber)(p)||!Object(s.isFiniteNumber)(T))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+v);return i+=1e3*d,i+=60*1e3*p,i+=60*60*1e3*T,i},x=function(v){for(var i=5381,d=v.length;d;)i=i*33^v.charCodeAt(--d);return(i>>>0).toString()};function I(S,v,i){return x(S.toString())+x(v.toString())+x(i)}var _=function(v,i,d){var p=v[i],T=v[p.prevCC];if(!T||!T.new&&p.new){v.ccOffset=v.presentationOffset=p.start,p.new=!1;return}for(;(l=T)!==null&&l!==void 0&&l.new;){var l;v.ccOffset+=p.start-T.start,p.new=!1,p=T,T=v[p.prevCC]}v.presentationOffset=d};function A(S,v,i,d,p,T,l,o){var h=new a.VTTParser,E=Object(u.utf8ArrayToStr)(new Uint8Array(S)).trim().replace(O,`
27
+ `,m.parse()),m.state==="INITIAL"||m.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(i){m.onparsingerror&&m.onparsingerror(i)}return m.onflush&&m.onflush(),this},_}()},"./src/utils/webvtt-parser.ts":function(r,t,e){"use strict";e.r(t),e.d(t,"generateCueId",function(){return I}),e.d(t,"parseWebVTT",function(){return A});var a=e("./src/polyfills/number.ts"),s=e("./src/utils/vttparser.ts"),u=e("./src/demux/id3.ts"),R=e("./src/utils/timescale-conversion.ts"),C=e("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,L=function(m,i,d){return d===void 0&&(d=0),m.slice(d,d+i.length)===i},b=function(m){var i=parseInt(m.slice(-3)),d=parseInt(m.slice(-6,-4)),p=parseInt(m.slice(-9,-7)),T=m.length>9?parseInt(m.substring(0,m.indexOf(":"))):0;if(!Object(a.isFiniteNumber)(i)||!Object(a.isFiniteNumber)(d)||!Object(a.isFiniteNumber)(p)||!Object(a.isFiniteNumber)(T))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+m);return i+=1e3*d,i+=60*1e3*p,i+=60*60*1e3*T,i},x=function(m){for(var i=5381,d=m.length;d;)i=i*33^m.charCodeAt(--d);return(i>>>0).toString()};function I(S,m,i){return x(S.toString())+x(m.toString())+x(i)}var _=function(m,i,d){var p=m[i],T=m[p.prevCC];if(!T||!T.new&&p.new){m.ccOffset=m.presentationOffset=p.start,p.new=!1;return}for(;(l=T)!==null&&l!==void 0&&l.new;){var l;m.ccOffset+=p.start-T.start,p.new=!1,p=T,T=m[p.prevCC]}m.presentationOffset=d};function A(S,m,i,d,p,T,l,o){var h=new s.VTTParser,E=Object(u.utf8ArrayToStr)(new Uint8Array(S)).trim().replace(O,`
28
28
  `).split(`
29
- `),n=[],c=Object(R.toMpegTsClockFromTimescale)(v,i),m="00:00.000",f=0,g=0,y,M=!0;h.oncue=function(D){var P=d[p],B=d.ccOffset,N=(f-c)/9e4;P!=null&&P.new&&(g!==void 0?B=d.ccOffset=P.start:_(d,p,N)),N&&(B=N-d.presentationOffset);var F=D.endTime-D.startTime,H=Object(C.normalizePts)((D.startTime+B-g)*9e4,T*9e4)/9e4;D.startTime=Math.max(H,0),D.endTime=Math.max(H+F,0);var V=D.text.trim();D.text=decodeURIComponent(encodeURIComponent(V)),D.id||(D.id=I(D.startTime,D.endTime,V)),D.endTime>0&&n.push(D)},h.onparsingerror=function(D){y=D},h.onflush=function(){if(y){o(y);return}l(n)},E.forEach(function(D){if(M)if(L(D,"X-TIMESTAMP-MAP=")){M=!1,D.slice(16).split(",").forEach(function(P){L(P,"LOCAL:")?m=P.slice(6):L(P,"MPEGTS:")&&(f=parseInt(P.slice(7)))});try{g=b(m)/1e3}catch(P){y=P}return}else D===""&&(M=!1);h.parse(D+`
30
- `)}),h.flush()}},"./src/utils/xhr-loader.ts":function(r,t,e){"use strict";e.r(t);var s=e("./src/utils/logger.ts"),a=e("./src/loader/load-stats.ts"),u=/^age:\s*[\d.]+\s*$/m,R=function(){function C(L){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=L?L.xhrSetup:null,this.stats=new a.LoadStats,this.retryDelay=0}var O=C.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.abortInternal=function(){var b=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),b&&(b.onreadystatechange=null,b.onprogress=null,b.readyState!==4&&(this.stats.aborted=!0,b.abort()))},O.abort=function(){var b;this.abortInternal(),(b=this.callbacks)!==null&&b!==void 0&&b.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(b,x,I){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=b,this.config=x,this.callbacks=I,this.retryDelay=x.retryDelay,this.loadInternal()},O.loadInternal=function(){var b=this.config,x=this.context;if(!!b){var I=this.loader=new self.XMLHttpRequest,_=this.stats;_.loading.first=0,_.loaded=0;var A=this.xhrSetup;try{if(A)try{A(I,x.url)}catch{I.open("GET",x.url,!0),A(I,x.url)}I.readyState||I.open("GET",x.url,!0);var S=this.context.headers;if(S)for(var v in S)I.setRequestHeader(v,S[v])}catch(i){this.callbacks.onError({code:I.status,text:i.message},x,I);return}x.rangeEnd&&I.setRequestHeader("Range","bytes="+x.rangeStart+"-"+(x.rangeEnd-1)),I.onreadystatechange=this.readystatechange.bind(this),I.onprogress=this.loadprogress.bind(this),I.responseType=x.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),b.timeout),I.send()}},O.readystatechange=function(){var b=this.context,x=this.loader,I=this.stats;if(!(!b||!x)){var _=x.readyState,A=this.config;if(!I.aborted&&_>=2)if(self.clearTimeout(this.requestTimeout),I.loading.first===0&&(I.loading.first=Math.max(self.performance.now(),I.loading.start)),_===4){x.onreadystatechange=null,x.onprogress=null;var S=x.status;if(S>=200&&S<300){I.loading.end=Math.max(self.performance.now(),I.loading.first);var v,i;if(b.responseType==="arraybuffer"?(v=x.response,i=v.byteLength):(v=x.responseText,i=v.length),I.loaded=I.total=i,!this.callbacks)return;var d=this.callbacks.onProgress;if(d&&d(I,b,v,x),!this.callbacks)return;var p={url:x.responseURL,data:v};this.callbacks.onSuccess(p,I,b,x)}else I.retry>=A.maxRetry||S>=400&&S<499?(s.logger.error(S+" while loading "+b.url),this.callbacks.onError({code:S,text:x.statusText},b,x)):(s.logger.warn(S+" while loading "+b.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,A.maxRetryDelay),I.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),A.timeout)}},O.loadtimeout=function(){s.logger.warn("timeout while loading "+this.context.url);var b=this.callbacks;b&&(this.abortInternal(),b.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(b){var x=this.stats;x.loaded=b.loaded,b.lengthComputable&&(x.total=b.total)},O.getCacheAge=function(){var b=null;if(this.loader&&u.test(this.loader.getAllResponseHeaders())){var x=this.loader.getResponseHeader("age");b=x?parseFloat(x):null}return b},C}();t.default=R}}).default})});var Hr=class{addEventListener(){}removeEventListener(){}dispatchEvent(t){return!0}};if(typeof DocumentFragment=="undefined"){class r extends Hr{}globalThis.DocumentFragment=r}var pi=class extends Hr{},ga=class extends Hr{},Fd={get(r){},define(r,t,e){},upgrade(r){},whenDefined(r){return Promise.resolve(pi)}},Ei,pa=class{constructor(t,e={}){Ne(this,Ei,void 0);mt(this,Ei,e==null?void 0:e.detail)}get detail(){return xe(this,Ei)}initCustomEvent(){}};Ei=new WeakMap;function Kd(r,t){return new pi}var Zs={document:{createElement:Kd},DocumentFragment,customElements:Fd,CustomEvent:pa,EventTarget:Hr,HTMLElement:pi,HTMLVideoElement:ga},Js=typeof window=="undefined"||typeof globalThis.customElements=="undefined",je=Js?Zs:globalThis,Nt=Js?Zs.document:globalThis.document;var de={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_CAPTIONS_REQUEST:"mediashowcaptionsrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_CAPTIONS_REQUEST:"mediadisablecaptionsrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},yi={MEDIA_AIRPLAY_UNAVAILABLE:"mediaairplayunavailablechange",MEDIA_PIP_UNAVAILABLE:"mediapipunavailablechange",MEDIA_PAUSED:"mediapausedchange",MEDIA_HAS_PLAYED:"mediahasplayedchange",MEDIA_MUTED:"mediamutedchange",MEDIA_VOLUME_LEVEL:"mediavolumelevelchange",MEDIA_VOLUME:"mediavolumechange",MEDIA_VOLUME_UNAVAILABLE:"mediavolumeunavailablechange",MEDIA_IS_PIP:"mediaispipchange",MEDIA_IS_CASTING:"mediaiscastingchange",MEDIA_CAPTIONS_LIST:"mediacaptionslistchange",MEDIA_SUBTITLES_LIST:"mediasubtitleslistchange",MEDIA_CAPTIONS_SHOWING:"mediacaptionsshowingchange",MEDIA_SUBTITLES_SHOWING:"mediasubtitlesshowingchange",MEDIA_IS_FULLSCREEN:"mediaisfullscreenchange",MEDIA_PLAYBACK_RATE:"mediaplaybackratechange",MEDIA_CURRENT_TIME:"mediacurrenttimechange",MEDIA_DURATION:"mediadurationchange",MEDIA_SEEKABLE:"mediaseekablechange",MEDIA_PREVIEW_IMAGE:"mediapreviewimagechange",MEDIA_PREVIEW_COORDS:"mediapreviewcoordschange",MEDIA_LOADING:"medialoadingchange",USER_INACTIVE:"userinactivechange"},G={MEDIA_AIRPLAY_UNAVAILABLE:"media-airplay-unavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"media-fullscreen-unavailable",MEDIA_PIP_UNAVAILABLE:"media-pip-unavailable",MEDIA_CAST_UNAVAILABLE:"media-cast-unavailable",MEDIA_PAUSED:"media-paused",MEDIA_HAS_PLAYED:"media-has-played",MEDIA_MUTED:"media-muted",MEDIA_VOLUME_LEVEL:"media-volume-level",MEDIA_VOLUME:"media-volume",MEDIA_VOLUME_UNAVAILABLE:"media-volume-unavailable",MEDIA_IS_PIP:"media-is-pip",MEDIA_IS_CASTING:"media-is-casting",MEDIA_CAPTIONS_LIST:"media-captions-list",MEDIA_SUBTITLES_LIST:"media-subtitles-list",MEDIA_CAPTIONS_SHOWING:"media-captions-showing",MEDIA_SUBTITLES_SHOWING:"media-subtitles-showing",MEDIA_IS_FULLSCREEN:"media-is-fullscreen",MEDIA_PLAYBACK_RATE:"media-playback-rate",MEDIA_CURRENT_TIME:"media-current-time",MEDIA_DURATION:"media-duration",MEDIA_SEEKABLE:"media-seekable",MEDIA_PREVIEW_TIME:"media-preview-time",MEDIA_PREVIEW_IMAGE:"media-preview-image",MEDIA_PREVIEW_COORDS:"media-preview-coords",MEDIA_CHROME_ATTRIBUTES:"media-chrome-attributes",MEDIA_CONTROLLER:"media-controller",MEDIA_LOADING:"media-loading",MEDIA_BUFFERED:"media-buffered"},wh=Object.entries(yi).reduce((r,[t,e])=>{let s=G[t];return s&&(r[e]=s),r},{userinactivechange:"user-inactive"}),qs=Object.entries(G).reduce((r,[t,e])=>{let s=yi[t];return s&&(r[e]=s),r},{"user-inactive":"userinactivechange"}),Gr={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},Ar={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var Ea={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Bt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"};var lt={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:r=1}={})=>`current playback rate ${r}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading"},ze={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",AIRPLAY:()=>"air play",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:r=30}={})=>`seek forward ${r} seconds`,SEEK_BACK_N_SECS:({seekOffset:r=30}={})=>`seek back ${r} seconds`},Hd={...lt,...ze};var Gd=r=>typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r),eo=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],jd=(r,t)=>{let e=r===1?eo[t].singular:eo[t].plural;return`${r} ${e}`},_r=r=>{if(!Gd(r))return"";let t=Math.abs(r),e=t!==r,s=new Date(0,0,0,0,0,t,0);return`${[s.getHours(),s.getMinutes(),s.getSeconds()].map((C,O)=>C&&jd(C,O)).filter(C=>C).join(", ")}${e?" remaining":""}`};function Yt(r,t){let e=!1;r<0&&(e=!0,r=0-r),r=r<0?0:r;let s=Math.floor(r%60),a=Math.floor(r/60%60),u=Math.floor(r/3600),R=Math.floor(t/60%60),C=Math.floor(t/3600);return(isNaN(r)||r===1/0)&&(u=a=s="-"),u=u>0||C>0?u+":":"",a=((u||R>=10)&&a<10?"0"+a:a)+":",s=s<10?"0"+s:s,(e?"-":"")+u+a+s}var to={HTMLElement:function(){this.addEventListener=()=>{},this.removeEventListener=()=>{},this.dispatchEvent=()=>{}},customElements:{get:function(){},define:function(){},whenDefined:function(){}},CustomEvent:function(){}},$d={createElement:function(){return new to.HTMLElement}},ro=typeof window=="undefined"||typeof window.customElements=="undefined",ae=ro?to:window,re=ro?$d:window.document;function ce(r,t){ae.customElements.get(r)||(ae.customElements.define(r,t),ae[t.name]=t)}var Yd=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)},Sr=(r,t,e)=>(Yd(r,t,"read from private field"),e?e.call(r):t.get(r)),ya=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},rn,jr,Ta,io=re.createElement("template");io.innerHTML=`
29
+ `),n=[],c=Object(R.toMpegTsClockFromTimescale)(m,i),v="00:00.000",f=0,g=0,y,M=!0;h.oncue=function(D){var P=d[p],B=d.ccOffset,N=(f-c)/9e4;P!=null&&P.new&&(g!==void 0?B=d.ccOffset=P.start:_(d,p,N)),N&&(B=N-d.presentationOffset);var F=D.endTime-D.startTime,H=Object(C.normalizePts)((D.startTime+B-g)*9e4,T*9e4)/9e4;D.startTime=Math.max(H,0),D.endTime=Math.max(H+F,0);var V=D.text.trim();D.text=decodeURIComponent(encodeURIComponent(V)),D.id||(D.id=I(D.startTime,D.endTime,V)),D.endTime>0&&n.push(D)},h.onparsingerror=function(D){y=D},h.onflush=function(){if(y){o(y);return}l(n)},E.forEach(function(D){if(M)if(L(D,"X-TIMESTAMP-MAP=")){M=!1,D.slice(16).split(",").forEach(function(P){L(P,"LOCAL:")?v=P.slice(6):L(P,"MPEGTS:")&&(f=parseInt(P.slice(7)))});try{g=b(v)/1e3}catch(P){y=P}return}else D===""&&(M=!1);h.parse(D+`
30
+ `)}),h.flush()}},"./src/utils/xhr-loader.ts":function(r,t,e){"use strict";e.r(t);var a=e("./src/utils/logger.ts"),s=e("./src/loader/load-stats.ts"),u=/^age:\s*[\d.]+\s*$/m,R=function(){function C(L){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=L?L.xhrSetup:null,this.stats=new s.LoadStats,this.retryDelay=0}var O=C.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.abortInternal=function(){var b=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),b&&(b.onreadystatechange=null,b.onprogress=null,b.readyState!==4&&(this.stats.aborted=!0,b.abort()))},O.abort=function(){var b;this.abortInternal(),(b=this.callbacks)!==null&&b!==void 0&&b.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(b,x,I){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=b,this.config=x,this.callbacks=I,this.retryDelay=x.retryDelay,this.loadInternal()},O.loadInternal=function(){var b=this.config,x=this.context;if(!!b){var I=this.loader=new self.XMLHttpRequest,_=this.stats;_.loading.first=0,_.loaded=0;var A=this.xhrSetup;try{if(A)try{A(I,x.url)}catch{I.open("GET",x.url,!0),A(I,x.url)}I.readyState||I.open("GET",x.url,!0);var S=this.context.headers;if(S)for(var m in S)I.setRequestHeader(m,S[m])}catch(i){this.callbacks.onError({code:I.status,text:i.message},x,I);return}x.rangeEnd&&I.setRequestHeader("Range","bytes="+x.rangeStart+"-"+(x.rangeEnd-1)),I.onreadystatechange=this.readystatechange.bind(this),I.onprogress=this.loadprogress.bind(this),I.responseType=x.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),b.timeout),I.send()}},O.readystatechange=function(){var b=this.context,x=this.loader,I=this.stats;if(!(!b||!x)){var _=x.readyState,A=this.config;if(!I.aborted&&_>=2)if(self.clearTimeout(this.requestTimeout),I.loading.first===0&&(I.loading.first=Math.max(self.performance.now(),I.loading.start)),_===4){x.onreadystatechange=null,x.onprogress=null;var S=x.status;if(S>=200&&S<300){I.loading.end=Math.max(self.performance.now(),I.loading.first);var m,i;if(b.responseType==="arraybuffer"?(m=x.response,i=m.byteLength):(m=x.responseText,i=m.length),I.loaded=I.total=i,!this.callbacks)return;var d=this.callbacks.onProgress;if(d&&d(I,b,m,x),!this.callbacks)return;var p={url:x.responseURL,data:m};this.callbacks.onSuccess(p,I,b,x)}else I.retry>=A.maxRetry||S>=400&&S<499?(a.logger.error(S+" while loading "+b.url),this.callbacks.onError({code:S,text:x.statusText},b,x)):(a.logger.warn(S+" while loading "+b.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,A.maxRetryDelay),I.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),A.timeout)}},O.loadtimeout=function(){a.logger.warn("timeout while loading "+this.context.url);var b=this.callbacks;b&&(this.abortInternal(),b.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(b){var x=this.stats;x.loaded=b.loaded,b.lengthComputable&&(x.total=b.total)},O.getCacheAge=function(){var b=null;if(this.loader&&u.test(this.loader.getAllResponseHeaders())){var x=this.loader.getResponseHeader("age");b=x?parseFloat(x):null}return b},C}();t.default=R}}).default})});var Gr=class{addEventListener(){}removeEventListener(){}dispatchEvent(t){return!0}};if(typeof DocumentFragment=="undefined"){class r extends Gr{}globalThis.DocumentFragment=r}var yi=class extends Gr{},Sa=class extends Gr{},zd={get(r){},define(r,t,e){},upgrade(r){},whenDefined(r){return Promise.resolve(yi)}},Ti,xa=class{constructor(t,e={}){Be(this,Ti,void 0);gt(this,Ti,e==null?void 0:e.detail)}get detail(){return xe(this,Ti)}initCustomEvent(){}};Ti=new WeakMap;function Xd(r,t){return new yi}var so={document:{createElement:Xd},DocumentFragment,customElements:zd,CustomEvent:xa,EventTarget:Gr,HTMLElement:yi,HTMLVideoElement:Sa},oo=typeof window=="undefined"||typeof globalThis.customElements=="undefined",je=oo?so:globalThis,Bt=oo?so.document:globalThis.document;var ce={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_CAPTIONS_REQUEST:"mediashowcaptionsrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_CAPTIONS_REQUEST:"mediadisablecaptionsrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},bi={MEDIA_AIRPLAY_UNAVAILABLE:"mediaairplayunavailablechange",MEDIA_PIP_UNAVAILABLE:"mediapipunavailablechange",MEDIA_PAUSED:"mediapausedchange",MEDIA_HAS_PLAYED:"mediahasplayedchange",MEDIA_MUTED:"mediamutedchange",MEDIA_VOLUME_LEVEL:"mediavolumelevelchange",MEDIA_VOLUME:"mediavolumechange",MEDIA_VOLUME_UNAVAILABLE:"mediavolumeunavailablechange",MEDIA_IS_PIP:"mediaispipchange",MEDIA_IS_CASTING:"mediaiscastingchange",MEDIA_CAPTIONS_LIST:"mediacaptionslistchange",MEDIA_SUBTITLES_LIST:"mediasubtitleslistchange",MEDIA_CAPTIONS_SHOWING:"mediacaptionsshowingchange",MEDIA_SUBTITLES_SHOWING:"mediasubtitlesshowingchange",MEDIA_IS_FULLSCREEN:"mediaisfullscreenchange",MEDIA_PLAYBACK_RATE:"mediaplaybackratechange",MEDIA_CURRENT_TIME:"mediacurrenttimechange",MEDIA_DURATION:"mediadurationchange",MEDIA_SEEKABLE:"mediaseekablechange",MEDIA_PREVIEW_IMAGE:"mediapreviewimagechange",MEDIA_PREVIEW_COORDS:"mediapreviewcoordschange",MEDIA_LOADING:"medialoadingchange",USER_INACTIVE:"userinactivechange"},G={MEDIA_AIRPLAY_UNAVAILABLE:"media-airplay-unavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"media-fullscreen-unavailable",MEDIA_PIP_UNAVAILABLE:"media-pip-unavailable",MEDIA_CAST_UNAVAILABLE:"media-cast-unavailable",MEDIA_PAUSED:"media-paused",MEDIA_HAS_PLAYED:"media-has-played",MEDIA_MUTED:"media-muted",MEDIA_VOLUME_LEVEL:"media-volume-level",MEDIA_VOLUME:"media-volume",MEDIA_VOLUME_UNAVAILABLE:"media-volume-unavailable",MEDIA_IS_PIP:"media-is-pip",MEDIA_IS_CASTING:"media-is-casting",MEDIA_CAPTIONS_LIST:"media-captions-list",MEDIA_SUBTITLES_LIST:"media-subtitles-list",MEDIA_CAPTIONS_SHOWING:"media-captions-showing",MEDIA_SUBTITLES_SHOWING:"media-subtitles-showing",MEDIA_IS_FULLSCREEN:"media-is-fullscreen",MEDIA_PLAYBACK_RATE:"media-playback-rate",MEDIA_CURRENT_TIME:"media-current-time",MEDIA_DURATION:"media-duration",MEDIA_SEEKABLE:"media-seekable",MEDIA_PREVIEW_TIME:"media-preview-time",MEDIA_PREVIEW_IMAGE:"media-preview-image",MEDIA_PREVIEW_COORDS:"media-preview-coords",MEDIA_CHROME_ATTRIBUTES:"media-chrome-attributes",MEDIA_CONTROLLER:"media-controller",MEDIA_LOADING:"media-loading",MEDIA_BUFFERED:"media-buffered"},$h=Object.entries(bi).reduce((r,[t,e])=>{let a=G[t];return a&&(r[e]=a),r},{userinactivechange:"user-inactive"}),lo=Object.entries(G).reduce((r,[t,e])=>{let a=bi[t];return a&&(r[e]=a),r},{"user-inactive":"userinactivechange"}),jr={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},Dr={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var La={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Ft={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"};var ut={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:r=1}={})=>`current playback rate ${r}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading"},Xe={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",AIRPLAY:()=>"air play",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:r=30}={})=>`seek forward ${r} seconds`,SEEK_BACK_N_SECS:({seekOffset:r=30}={})=>`seek back ${r} seconds`},Zd={...ut,...Xe};var Jd=r=>typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r),uo=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],qd=(r,t)=>{let e=r===1?uo[t].singular:uo[t].plural;return`${r} ${e}`},Ir=r=>{if(!Jd(r))return"";let t=Math.abs(r),e=t!==r,a=new Date(0,0,0,0,0,t,0);return`${[a.getHours(),a.getMinutes(),a.getSeconds()].map((C,O)=>C&&qd(C,O)).filter(C=>C).join(", ")}${e?" remaining":""}`};function zt(r,t){let e=!1;r<0&&(e=!0,r=0-r),r=r<0?0:r;let a=Math.floor(r%60),s=Math.floor(r/60%60),u=Math.floor(r/3600),R=Math.floor(t/60%60),C=Math.floor(t/3600);return(isNaN(r)||r===1/0)&&(u=s=a="-"),u=u>0||C>0?u+":":"",s=((u||R>=10)&&s<10?"0"+s:s)+":",a=a<10?"0"+a:a,(e?"-":"")+u+s+a}var co={HTMLElement:function(){this.addEventListener=()=>{},this.removeEventListener=()=>{},this.dispatchEvent=()=>{}},customElements:{get:function(){},define:function(){},whenDefined:function(){}},CustomEvent:function(){}},tc={createElement:function(){return new co.HTMLElement}},fo=typeof window=="undefined"||typeof window.customElements=="undefined",se=fo?co:window,re=fo?tc:window.document;function fe(r,t){se.customElements.get(r)||(se.customElements.define(r,t),se[t.name]=t)}var rc=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)},Mr=(r,t,e)=>(rc(r,t,"read from private field"),e?e.call(r):t.get(r)),Da=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},on,Vr,Ia,ho=re.createElement("template");ho.innerHTML=`
31
31
  <style>
32
32
  :host {
33
33
  display: inline-flex;
@@ -79,12 +79,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
79
79
  min-width: 100%;
80
80
  }
81
81
  </style>
82
- `;var nn=class extends ae.HTMLElement{constructor(t={}){super(),ya(this,rn,u=>{this.handleClick(u)}),ya(this,jr,u=>{let{key:R}=u;if(!this.keysUsed.includes(R)){this.removeEventListener("keyup",Sr(this,jr));return}this.handleClick(u)}),ya(this,Ta,u=>{let{metaKey:R,altKey:C,key:O}=u;if(R||C||!this.keysUsed.includes(O)){this.removeEventListener("keyup",Sr(this,jr));return}this.addEventListener("keyup",Sr(this,jr),{once:!0})});let e=this.attachShadow({mode:"open"}),s=io.content.cloneNode(!0);this.nativeEl=s;let a=t.slotTemplate;a||(a=re.createElement("template"),a.innerHTML=`<slot>${t.defaultContent||""}</slot>`),this.nativeEl.appendChild(a.content.cloneNode(!0)),e.appendChild(s)}static get observedAttributes(){return["disabled",G.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",Sr(this,rn)),this.addEventListener("keydown",Sr(this,Ta)),this.setAttribute("tabindex",0)}disable(){this.removeEventListener("click",Sr(this,rn)),this.removeEventListener("keyup",Sr(this,jr)),this.removeAttribute("tabindex")}attributeChangedCallback(t,e,s){var a,u;if(t===G.MEDIA_CONTROLLER){if(e){let R=re.getElementById(e);(a=R==null?void 0:R.unassociateElement)==null||a.call(R,this)}if(s){let R=re.getElementById(s);(u=R==null?void 0:R.associateElement)==null||u.call(R,this)}}else t==="disabled"&&s!==e&&(s==null?this.enable():this.disable())}connectedCallback(){var t;this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let s=re.getElementById(e);(t=s==null?void 0:s.associateElement)==null||t.call(s,this)}}disconnectedCallback(){var t;this.disable();let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let s=re.getElementById(e);(t=s==null?void 0:s.unassociateElement)==null||t.call(s,this)}}get keysUsed(){return["Enter"," "]}handleClick(){}};rn=new WeakMap;jr=new WeakMap;Ta=new WeakMap;ce("media-chrome-button",nn);var Xe=nn;var zd=`<svg aria-hidden="true" viewBox="0 0 26 24">
82
+ `;var ln=class extends se.HTMLElement{constructor(t={}){super(),Da(this,on,u=>{this.handleClick(u)}),Da(this,Vr,u=>{let{key:R}=u;if(!this.keysUsed.includes(R)){this.removeEventListener("keyup",Mr(this,Vr));return}this.handleClick(u)}),Da(this,Ia,u=>{let{metaKey:R,altKey:C,key:O}=u;if(R||C||!this.keysUsed.includes(O)){this.removeEventListener("keyup",Mr(this,Vr));return}this.addEventListener("keyup",Mr(this,Vr),{once:!0})});let e=this.attachShadow({mode:"open"}),a=ho.content.cloneNode(!0);this.nativeEl=a;let s=t.slotTemplate;s||(s=re.createElement("template"),s.innerHTML=`<slot>${t.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),e.appendChild(a)}static get observedAttributes(){return["disabled",G.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",Mr(this,on)),this.addEventListener("keydown",Mr(this,Ia)),this.setAttribute("tabindex",0)}disable(){this.removeEventListener("click",Mr(this,on)),this.removeEventListener("keyup",Mr(this,Vr)),this.removeAttribute("tabindex")}attributeChangedCallback(t,e,a){var s,u;if(t===G.MEDIA_CONTROLLER){if(e){let R=re.getElementById(e);(s=R==null?void 0:R.unassociateElement)==null||s.call(R,this)}if(a){let R=re.getElementById(a);(u=R==null?void 0:R.associateElement)==null||u.call(R,this)}}else t==="disabled"&&a!==e&&(a==null?this.enable():this.disable())}connectedCallback(){var t;this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let a=re.getElementById(e);(t=a==null?void 0:a.associateElement)==null||t.call(a,this)}}disconnectedCallback(){var t;this.disable();let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let a=re.getElementById(e);(t=a==null?void 0:a.unassociateElement)==null||t.call(a,this)}}get keysUsed(){return["Enter"," "]}handleClick(){}};on=new WeakMap;Vr=new WeakMap;Ia=new WeakMap;fe("media-chrome-button",ln);var Qe=ln;var ic=`<svg aria-hidden="true" viewBox="0 0 26 24">
83
83
  <path d="M22.13 3H3.87a.87.87 0 0 0-.87.87v13.26a.87.87 0 0 0 .87.87h3.4L9 16H5V5h16v11h-4l1.72 2h3.4a.87.87 0 0 0 .87-.87V3.87a.87.87 0 0 0-.86-.87Zm-8.75 11.44a.5.5 0 0 0-.76 0l-4.91 5.73a.5.5 0 0 0 .38.83h9.82a.501.501 0 0 0 .38-.83l-4.91-5.73Z"/>
84
84
  </svg>
85
- `,no=re.createElement("template");no.innerHTML=`
86
- <slot name="airplay">${zd}</slot>
87
- `;var ba=class extends Xe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(t={}){super({slotTemplate:no,...t})}connectedCallback(){this.setAttribute("aria-label",ze.AIRPLAY()),super.connectedCallback()}handleClick(t){let e=new ae.CustomEvent(de.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};ce("media-airplay-button",ba);var Xd='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',Qd='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',so=re.createElement("template");so.innerHTML=`
85
+ `,mo=re.createElement("template");mo.innerHTML=`
86
+ <slot name="airplay">${ic}</slot>
87
+ `;var Ma=class extends Qe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(t={}){super({slotTemplate:mo,...t})}connectedCallback(){this.setAttribute("aria-label",Xe.AIRPLAY()),super.connectedCallback()}handleClick(t){let e=new se.CustomEvent(ce.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};fe("media-airplay-button",Ma);var nc='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',ac='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',go=re.createElement("template");go.innerHTML=`
88
88
  <style>
89
89
  :host([${G.MEDIA_IS_CASTING}]) slot:not([name=exit]) > *,
90
90
  :host([${G.MEDIA_IS_CASTING}]) ::slotted(:not([slot=exit])) {
@@ -98,16 +98,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
98
98
  }
99
99
  </style>
100
100
 
101
- <slot name="enter">${Xd}</slot>
102
- <slot name="exit">${Qd}</slot>
103
- `;var ao=r=>{let e=r.getAttribute(G.MEDIA_IS_CASTING)!=null?ze.EXIT_CAST():ze.ENTER_CAST();r.setAttribute("aria-label",e)},Aa=class extends Xe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_IS_CASTING,G.MEDIA_CAST_UNAVAILABLE]}constructor(t={}){super({slotTemplate:so,...t})}connectedCallback(){ao(this),super.connectedCallback()}attributeChangedCallback(t,e,s){t===G.MEDIA_IS_CASTING&&ao(this),super.attributeChangedCallback(t,e,s)}handleClick(t){let e=this.getAttribute(G.MEDIA_IS_CASTING)!=null?de.MEDIA_EXIT_CAST_REQUEST:de.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new ae.CustomEvent(e,{composed:!0,bubbles:!0}))}};ce("media-cast-button",Aa);var an=(r,t,e=".value")=>{let s=r.querySelector(e);!s||(s.textContent=t)},Zd=(r,t)=>{let e=`slot[name="${t}"]`,s=r.shadowRoot.querySelector(e);return s?s.children:[]},sn=(r,t)=>Zd(r,t)[0],Ti=(r,t)=>!r||!t?!1:r.contains(t)?!0:Ti(r,t.getRootNode().host),bi=(r,t)=>{if(!r)return null;let e=r.closest(t);return e||bi(r.getRootNode().host,t)};function tr(r,t){var e,s;let a;for(a of r.querySelectorAll("style"))for(let u of(s=(e=a.sheet)==null?void 0:e.cssRules)!=null?s:[])if(u.selectorText===t)return u;return a!=null&&a.sheet?(a.sheet.insertRule(`${t}{}`,a.sheet.cssRules.length),a.sheet.cssRules[a.sheet.cssRules.length-1]):{style:{setProperty:()=>{}}}}var lo=re.createElement("template");lo.innerHTML=`
101
+ <slot name="enter">${nc}</slot>
102
+ <slot name="exit">${ac}</slot>
103
+ `;var vo=r=>{let e=r.getAttribute(G.MEDIA_IS_CASTING)!=null?Xe.EXIT_CAST():Xe.ENTER_CAST();r.setAttribute("aria-label",e)},Ra=class extends Qe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_IS_CASTING,G.MEDIA_CAST_UNAVAILABLE]}constructor(t={}){super({slotTemplate:go,...t})}connectedCallback(){vo(this),super.connectedCallback()}attributeChangedCallback(t,e,a){t===G.MEDIA_IS_CASTING&&vo(this),super.attributeChangedCallback(t,e,a)}handleClick(t){let e=this.getAttribute(G.MEDIA_IS_CASTING)!=null?ce.MEDIA_EXIT_CAST_REQUEST:ce.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new se.CustomEvent(e,{composed:!0,bubbles:!0}))}};fe("media-cast-button",Ra);var un=(r,t,e=".value")=>{let a=r.querySelector(e);!a||(a.textContent=t)},sc=(r,t)=>{let e=`slot[name="${t}"]`,a=r.shadowRoot.querySelector(e);return a?a.children:[]},dn=(r,t)=>sc(r,t)[0],Ai=(r,t)=>!r||!t?!1:r.contains(t)?!0:Ai(r,t.getRootNode().host),_i=(r,t)=>{if(!r)return null;let e=r.closest(t);return e||_i(r.getRootNode().host,t)};function qt(r,t){var e;let a;for(a of r.querySelectorAll("style")){let s;try{s=(e=a.sheet)==null?void 0:e.cssRules}catch{continue}for(let u of s!=null?s:[])if(u.selectorText===t)return u}return a!=null&&a.sheet?(a.sheet.insertRule(`${t}{}`,a.sheet.cssRules.length),a.sheet.cssRules[a.sheet.cssRules.length-1]):{style:{setProperty:()=>{}}}}var Eo=re.createElement("template");Eo.innerHTML=`
104
104
  <style>
105
105
  :host {
106
106
  display: inline-block;
107
107
  box-sizing: border-box;
108
108
  }
109
109
  </style>
110
- `;var _a=class extends ae.HTMLElement{static get observedAttributes(){return[G.MEDIA_CONTROLLER,G.MEDIA_PAUSED]}constructor(t={}){super();let e=this.attachShadow({mode:"open"}),s=lo.content.cloneNode(!0);this.nativeEl=s;let a=t.slotTemplate;a||(a=re.createElement("template"),a.innerHTML=`<slot>${t.defaultContent||""}</slot>`),this.nativeEl.appendChild(a.content.cloneNode(!0)),e.appendChild(s)}attributeChangedCallback(t,e,s){var a,u;if(t===G.MEDIA_CONTROLLER){if(e){let R=re.getElementById(e);(a=R==null?void 0:R.unassociateElement)==null||a.call(R,this)}if(s){let R=re.getElementById(s);(u=R==null?void 0:R.associateElement)==null||u.call(R,this)}}}connectedCallback(){var t;this.setAttribute("tabindex",-1),this.setAttribute("aria-hidden",!0);let e=oo(this);this.getAttribute(G.MEDIA_CONTROLLER)&&((t=e==null?void 0:e.associateElement)==null||t.call(e,this)),e==null||e.addEventListener("pointerdown",this),e==null||e.addEventListener("click",this)}disconnectedCallback(){var t;let e=oo(this);this.getAttribute(G.MEDIA_CONTROLLER)&&((t=e==null?void 0:e.unassociateElement)==null||t.call(e,this)),e==null||e.removeEventListener("pointerdown",this),e==null||e.removeEventListener("click",this)}handleEvent(t){var e;let s=(e=t.composedPath())==null?void 0:e[0];if(!!["video","media-controller"].includes(s==null?void 0:s.localName)){if(t.type==="pointerdown")this._pointerType=t.pointerType;else if(t.type==="click"){let{clientX:u,clientY:R}=t,{left:C,top:O,width:L,height:b}=this.getBoundingClientRect(),x=u-C,I=R-O;if(x<0||I<0||x>L||I>b||L===0&&b===0)return;let{pointerType:_=this._pointerType}=t;if(this._pointerType=void 0,_===Ea.TOUCH){this.handleTap(t);return}else if(_===Ea.MOUSE){this.handleMouseClick(t);return}}}}handleTap(){}handleMouseClick(){let t=this.getAttribute(G.MEDIA_PAUSED)!=null?de.MEDIA_PLAY_REQUEST:de.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new ae.CustomEvent(t,{composed:!0,bubbles:!0}))}};function oo(r){let t=r.getAttribute(G.MEDIA_CONTROLLER);return t?re.getElementById(t):bi(r,"media-controller")}ce("media-gesture-receiver",_a);var uo=re.createElement("template");uo.innerHTML=`
110
+ `;var Ca=class extends se.HTMLElement{static get observedAttributes(){return[G.MEDIA_CONTROLLER,G.MEDIA_PAUSED]}constructor(t={}){super();let e=this.attachShadow({mode:"open"}),a=Eo.content.cloneNode(!0);this.nativeEl=a;let s=t.slotTemplate;s||(s=re.createElement("template"),s.innerHTML=`<slot>${t.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),e.appendChild(a)}attributeChangedCallback(t,e,a){var s,u;if(t===G.MEDIA_CONTROLLER){if(e){let R=re.getElementById(e);(s=R==null?void 0:R.unassociateElement)==null||s.call(R,this)}if(a){let R=re.getElementById(a);(u=R==null?void 0:R.associateElement)==null||u.call(R,this)}}}connectedCallback(){var t;this.setAttribute("tabindex",-1),this.setAttribute("aria-hidden",!0);let e=po(this);this.getAttribute(G.MEDIA_CONTROLLER)&&((t=e==null?void 0:e.associateElement)==null||t.call(e,this)),e==null||e.addEventListener("pointerdown",this),e==null||e.addEventListener("click",this)}disconnectedCallback(){var t;let e=po(this);this.getAttribute(G.MEDIA_CONTROLLER)&&((t=e==null?void 0:e.unassociateElement)==null||t.call(e,this)),e==null||e.removeEventListener("pointerdown",this),e==null||e.removeEventListener("click",this)}handleEvent(t){var e;let a=(e=t.composedPath())==null?void 0:e[0];if(!!["video","media-controller"].includes(a==null?void 0:a.localName)){if(t.type==="pointerdown")this._pointerType=t.pointerType;else if(t.type==="click"){let{clientX:u,clientY:R}=t,{left:C,top:O,width:L,height:b}=this.getBoundingClientRect(),x=u-C,I=R-O;if(x<0||I<0||x>L||I>b||L===0&&b===0)return;let{pointerType:_=this._pointerType}=t;if(this._pointerType=void 0,_===La.TOUCH){this.handleTap(t);return}else if(_===La.MOUSE){this.handleMouseClick(t);return}}}}handleTap(){}handleMouseClick(){let t=this.getAttribute(G.MEDIA_PAUSED)!=null?ce.MEDIA_PLAY_REQUEST:ce.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new se.CustomEvent(t,{composed:!0,bubbles:!0}))}};function po(r){let t=r.getAttribute(G.MEDIA_CONTROLLER);return t?re.getElementById(t):_i(r,"media-controller")}fe("media-gesture-receiver",Ca);var yo=re.createElement("template");yo.innerHTML=`
111
111
  <style>
112
112
 
113
113
  :host([media-is-fullscreen]) ::slotted([slot=media]) {
@@ -218,7 +218,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
218
218
 
219
219
  <slot part="bottom chrome"></slot>
220
220
  </span>
221
- `;var Jd=Object.values(G),on=class extends ae.HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(uo.content.cloneNode(!0));let t=u=>{let R=this.media;for(let C of u)C.type==="childList"&&(C.removedNodes.forEach(O=>{if(O.slot=="media"&&C.target==this){let L=C.previousSibling&&C.previousSibling.previousElementSibling;if(!L||!R)this.mediaUnsetCallback(O);else{let b=L.slot!=="media";for(;(L=L.previousSibling)!==null;)L.slot=="media"&&(b=!1);b&&this.mediaUnsetCallback(O)}}}),R&&C.addedNodes.forEach(O=>{O==R&&this.handleMediaUpdated(R).then(L=>this.mediaSetCallback(L))}))};new MutationObserver(t).observe(this,{childList:!0,subtree:!0});let s=this.media,a=this.querySelector(":scope > slot[slot=media]");a&&a.addEventListener("slotchange",()=>{if(!a.assignedElements({flatten:!0}).length){this.mediaUnsetCallback(s);return}this.media&&(s=this.media,this.handleMediaUpdated(this.media).then(R=>this.mediaSetCallback(R)))})}static get observedAttributes(){return["autohide","gestures-disabled"].concat(Jd)}attributeChangedCallback(t,e,s){t.toLowerCase()=="autohide"&&(this.autohide=s)}get media(){let t=this.querySelector(":scope > [slot=media]");return(t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t}mediaSetCallback(t){this._mediaClickPlayToggle=()=>{let e=t.paused?de.MEDIA_PLAY_REQUEST:de.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new ae.CustomEvent(e,{composed:!0,bubbles:!0}))}}handleMediaUpdated(t){let e=u=>Promise.resolve(u),s=u=>(console.error('<media-chrome>: Media element set with slot="media" does not appear to be compatible.',u),Promise.reject(u));if(!t)return s(t);let a=t.nodeName.toLowerCase();return a.includes("-")?ae.customElements.whenDefined(a).then(()=>e(t)):e(t)}mediaUnsetCallback(){}connectedCallback(){let e=this.getAttribute("audio")!=null?lt.AUDIO_PLAYER():lt.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",e),this.media&&this.handleMediaUpdated(this.media).then(R=>this.mediaSetCallback(R)),this.setAttribute("user-inactive","user-inactive");let s=()=>{if(this.autohide<0)return;this.setAttribute("user-inactive","user-inactive");let R=new ae.CustomEvent(yi.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(R)},a=()=>{this.removeAttribute("user-inactive");let R=new ae.CustomEvent(yi.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(R)},u=()=>{a(),ae.clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=ae.setTimeout(()=>{s()},this.autohide*1e3))};this.addEventListener("keyup",()=>{u()}),this.addEventListener("pointerup",R=>{R.pointerType==="touch"?[this,this.media].includes(R.target)&&!this.hasAttribute("user-inactive")?s():u():R.composedPath().some(C=>{var O;return["media-play-button","media-fullscreen-button"].includes((O=C==null?void 0:C.nodeName)==null?void 0:O.toLowerCase())})&&u()}),this.addEventListener("pointermove",R=>{R.pointerType==="mouse"&&R.target!==this&&(a(),ae.clearTimeout(this._inactiveTimeout),[this,this.media].includes(R.target)&&u())}),this.addEventListener("mouseleave",()=>{s()}),this.addEventListener("keyup",()=>{this.setAttribute("media-keyboard-control","")}),this.addEventListener("mouseup",()=>{this.removeAttribute("media-keyboard-control")})}set autohide(t){t=Number(t),this._autohide=isNaN(t)?0:t}get autohide(){return this._autohide===void 0?2:this._autohide}};ce("media-container-temp",on);var co=on;var fo=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)},at=(r,t,e)=>(fo(r,t,"read from private field"),e?e.call(r):t.get(r)),Sa=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},xa=(r,t,e,s)=>(fo(r,t,"write to private field"),s?s.call(r,e):t.set(r,e),e),Vr,$r,Tt,ln=class{constructor(t,e){Sa(this,Vr,void 0),Sa(this,$r,void 0),Sa(this,Tt,[]),xa(this,Vr,t),xa(this,$r,e)}[Symbol.iterator](){return at(this,Tt).values()}get length(){return at(this,Tt).length}get value(){var t;return(t=at(this,Tt).join(" "))!=null?t:""}set value(t){var e;t!==this.value&&(xa(this,Tt,[]),this.add(...(e=t==null?void 0:t.split(" "))!=null?e:[]))}toString(){return this.value}item(t){return at(this,Tt)[t]}values(){return at(this,Tt).values()}keys(){return at(this,Tt).keys()}forEach(t){at(this,Tt).forEach(t)}add(...t){var e,s;t.forEach(a=>{this.contains(a)||at(this,Tt).push(a)}),!(this.value===""&&!((e=at(this,Vr))!=null&&e.hasAttribute(`${at(this,$r)}`)))&&((s=at(this,Vr))==null||s.setAttribute(`${at(this,$r)}`,`${this.value}`))}remove(...t){var e;t.forEach(s=>{at(this,Tt).splice(at(this,Tt).indexOf(s),1)}),(e=at(this,Vr))==null||e.setAttribute(`${at(this,$r)}`,`${this.value}`)}contains(t){return at(this,Tt).includes(t)}toggle(t,e){return typeof e!="undefined"?e?(this.add(t),!0):(this.remove(t),!1):this.contains(t)?(this.remove(t),!1):(this.add(t),!0)}replace(t,e){this.remove(t),this.add(e)}};Vr=new WeakMap;$r=new WeakMap;Tt=new WeakMap;var tt={enter:"requestFullscreen",exit:"exitFullscreen",event:"fullscreenchange",element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};re.fullscreenElement===void 0&&(tt.enter="webkitRequestFullScreen",tt.exit=re.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",tt.event="webkitfullscreenchange",tt.element="webkitFullscreenElement",tt.error="webkitfullscreenerror",tt.enabled="webkitFullscreenEnabled");function un(r,t=!1){return r.split("_").map(function(e,s){return(s||t?e[0].toUpperCase():e[0].toLowerCase())+e.slice(1).toLowerCase()}).join("")}var La=(r="")=>r.split(/\s+/),ho=(r="")=>{let[t,e]=r.split(":"),s=e?decodeURIComponent(e):void 0;return{language:t,label:s}},qd=(r="",t={})=>La(r).map(e=>{let s=ho(e);return{...t,...s}}),ec=r=>Array.isArray(r)?r.map(t=>typeof t=="string"?ho(t):t):typeof r=="string"?qd(r):[r],tc=({label:r,language:t}={})=>r?`${t}:${encodeURIComponent(r)}`:t,Ft=(r=[])=>Array.prototype.map.call(r,tc).join(" "),rc=(r,t)=>e=>e[r]===t,vo=r=>{let t=Object.entries(r).map(([e,s])=>rc(e,s));return e=>t.every(s=>s(e))},Ai=(r,t=[],e=[])=>{let s=ec(e).map(vo),a=u=>s.some(R=>R(u));Array.from(t).filter(a).forEach(u=>{u.mode=r})},Yr=(r,t=()=>!0)=>{if(!(r!=null&&r.textTracks))return[];let e=typeof t=="function"?t:vo(t);return Array.from(r.textTracks).filter(e)},Da=r=>{let t=!!r.getAttribute(G.MEDIA_CAPTIONS_SHOWING),e=!r.hasAttribute("no-subtitles-fallback")&&!!r.getAttribute(G.MEDIA_SUBTITLES_SHOWING);return t||e},dn=r=>{var t,e,s,a;if(Da(r)){let R=r.getAttribute(G.MEDIA_CAPTIONS_SHOWING);if(R){let O=new window.CustomEvent(de.MEDIA_DISABLE_CAPTIONS_REQUEST,{composed:!0,bubbles:!0,detail:R});r.dispatchEvent(O)}let C=r.getAttribute(G.MEDIA_SUBTITLES_SHOWING);if(C&&!r.hasAttribute("no-subtitles-fallback")){let O=new window.CustomEvent(de.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:C});r.dispatchEvent(O)}}else{let[R]=(e=La((t=r.getAttribute(G.MEDIA_CAPTIONS_LIST))!=null?t:""))!=null?e:[];if(R){let C=new window.CustomEvent(de.MEDIA_SHOW_CAPTIONS_REQUEST,{composed:!0,bubbles:!0,detail:R});r.dispatchEvent(C)}else if(r.hasAttribute("no-subtitles-fallback"))console.error("Attempting to enable closed captions but none are available! Please verify your media content if this is unexpected.");else{let[C]=(a=La((s=r.getAttribute(G.MEDIA_SUBTITLES_LIST))!=null?s:""))!=null?a:[];if(C){let O=new window.CustomEvent(de.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:C});r.dispatchEvent(O)}}}};var Eo=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)},zr=(r,t,e)=>(Eo(r,t,"read from private field"),e?e.call(r):t.get(r)),Ia=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},Xr=(r,t,e)=>(Eo(r,t,"access private method"),e),dr,Qr,Li,fn,Ra,yo=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],ic=10,mo=0,vn=class extends co{constructor(){super(),Ia(this,Qr),Ia(this,fn),Ia(this,dr,new ln(this,"hotkeys")),fc||(this._airplayUnavailable=Bt.UNSUPPORTED),po||(this._fullscreenUnavailable=Bt.UNAVAILABLE),hc||(this._castUnavailable=Bt.UNSUPPORTED),dc||(this._pipUnavailable=Bt.UNSUPPORTED),xi!==void 0?xi||(this._volumeUnavailable=Bt.UNSUPPORTED):cc.then(()=>{xi||(this._volumeUnavailable=Bt.UNSUPPORTED,this.propagateMediaState(G.MEDIA_VOLUME_UNAVAILABLE,this._volumeUnavailable))}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associatedElements=[],this.associateElement(this);let t={MEDIA_PLAY_REQUEST:()=>this.media.play(),MEDIA_PAUSE_REQUEST:()=>this.media.pause(),MEDIA_MUTE_REQUEST:()=>this.media.muted=!0,MEDIA_UNMUTE_REQUEST:()=>{let e=this.media;e.muted=!1,e.volume===0&&(e.volume=.25)},MEDIA_VOLUME_REQUEST:e=>{let s=this.media,a=e.detail;s.volume=a,a>0&&s.muted&&(s.muted=!1);try{ae.localStorage.setItem("media-chrome-pref-volume",a.toString())}catch{}},MEDIA_ENTER_FULLSCREEN_REQUEST:()=>{if(!po){console.warn("Fullscreen support is unavailable; not entering fullscreen");return}let e=this.media;re.pictureInPictureElement&&re.exitPictureInPicture(),super[tt.enter]?super[tt.enter]():e.webkitEnterFullscreen?e.webkitEnterFullscreen():e.requestFullscreen?e.requestFullscreen():console.warn("MediaChrome: Fullscreen not supported")},MEDIA_EXIT_FULLSCREEN_REQUEST:()=>{re[tt.exit]()},MEDIA_ENTER_PIP_REQUEST:()=>{let e=this.media;if(!re.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!e.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}re[tt.element]&&re[tt.exit]();let s=a=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};e.requestPictureInPicture().catch(a=>{if(a.code===11)if(e.readyState===0&&e.preload==="none"){let u=function(){e.removeEventListener("loadedmetadata",R),e.preload="none"},R=function(){e.requestPictureInPicture().catch(s),u()};e.addEventListener("loadedmetadata",R),e.preload="metadata",setTimeout(()=>{e.readyState===0&&s(),u()},1e3)}else throw a;else throw a})},MEDIA_EXIT_PIP_REQUEST:()=>{re.pictureInPictureElement&&re.exitPictureInPicture()},MEDIA_ENTER_CAST_REQUEST:()=>{var e;let s=this.media;!((e=globalThis.CastableVideoElement)!=null&&e.castEnabled)||(re[tt.element]&&re[tt.exit](),s.requestCast())},MEDIA_EXIT_CAST_REQUEST:async()=>{var e;(e=globalThis.CastableVideoElement)!=null&&e.castElement&&globalThis.CastableVideoElement.exitCast()},MEDIA_SEEK_REQUEST:e=>{let s=this.media,a=e.detail;(s.readyState>0||s.readyState===void 0)&&(s.currentTime=a)},MEDIA_PLAYBACK_RATE_REQUEST:e=>{this.media.playbackRate=e.detail},MEDIA_PREVIEW_REQUEST:e=>{var s;let a=this.media;if(!a)return;let u=e.detail;u===null&&this.propagateMediaState(G.MEDIA_PREVIEW_TIME,void 0),this.propagateMediaState(G.MEDIA_PREVIEW_TIME,u);let[R]=Yr(a,{kind:Gr.METADATA,label:"thumbnails"});if(!(R&&R.cues))return;if(u===null){this.propagateMediaState(G.MEDIA_PREVIEW_IMAGE,void 0),this.propagateMediaState(G.MEDIA_PREVIEW_COORDS,void 0);return}let C=Array.prototype.find.call(R.cues,x=>x.startTime>=u);if(!C)return;let O=/'^(?:[a-z]+:)?\/\//i.test(C.text)||(s=a.querySelector('track[label="thumbnails"]'))==null?void 0:s.src,L=new URL(C.text,O),b=new URLSearchParams(L.hash).get("#xywh");this.propagateMediaState(G.MEDIA_PREVIEW_IMAGE,L.href),this.propagateMediaState(G.MEDIA_PREVIEW_COORDS,b.split(",").join(" "))},MEDIA_SHOW_CAPTIONS_REQUEST:e=>{let s=hn(this),{detail:a=[]}=e;Ai(Ar.SHOWING,s,a)},MEDIA_DISABLE_CAPTIONS_REQUEST:e=>{let s=hn(this),{detail:a=[]}=e;Ai(Ar.DISABLED,s,a)},MEDIA_SHOW_SUBTITLES_REQUEST:e=>{let s=Si(this),{detail:a=[]}=e;Ai(Ar.SHOWING,s,a)},MEDIA_DISABLE_SUBTITLES_REQUEST:e=>{let s=Si(this),{detail:a=[]}=e;Ai(Ar.DISABLED,s,a)},MEDIA_AIRPLAY_REQUEST:()=>{let{media:e}=this;if(!!e){if(!(e.webkitShowPlaybackTargetPicker&&ae.WebKitPlaybackTargetAvailabilityEvent)){console.warn("received a request to select AirPlay but AirPlay is not supported in this environment");return}e.webkitShowPlaybackTargetPicker()}}};if(Object.keys(t).forEach(e=>{let s=`_handle${un(e,!0)}`;this[s]=a=>{if(a.stopPropagation(),!this.media){console.warn("MediaController: No media available.");return}t[e](a,this.media)},this.addEventListener(de[e],this[s])}),this._mediaStatePropagators={"play,pause,emptied":()=>{this.propagateMediaState(G.MEDIA_PAUSED,To(this))},"playing,emptied":()=>{var e;this.propagateMediaState(G.MEDIA_HAS_PLAYED,!((e=this.media)!=null&&e.paused))},volumechange:()=>{this.propagateMediaState(G.MEDIA_MUTED,bo(this)),this.propagateMediaState(G.MEDIA_VOLUME,Ao(this)),this.propagateMediaState(G.MEDIA_VOLUME_LEVEL,_o(this))},[tt.event]:e=>{let a=!!re[tt.element]&&(e==null?void 0:e.target),u=Ti(this,a);this.propagateMediaState(G.MEDIA_IS_FULLSCREEN,u)},"enterpictureinpicture,leavepictureinpicture":e=>{var s;let a;if(e)a=e.type=="enterpictureinpicture";else{let u=(s=this.getRootNode().pictureInPictureElement)!=null?s:re.pictureInPictureElement;a=this.media&&Ti(this.media,u)}this.propagateMediaState(G.MEDIA_IS_PIP,a)},"entercast,leavecast,castchange":e=>{var s;let a=(s=globalThis.CastableVideoElement)==null?void 0:s.castElement,u=this.media&&Ti(this.media,a);(e==null?void 0:e.type)==="castchange"&&(e==null?void 0:e.detail)==="CONNECTING"&&(u="connecting"),this.propagateMediaState(G.MEDIA_IS_CASTING,u)},"timeupdate,loadedmetadata":()=>{this.propagateMediaState(G.MEDIA_CURRENT_TIME,So(this))},"durationchange,loadedmetadata,emptied":()=>{this.propagateMediaState(G.MEDIA_DURATION,xo(this))},"loadedmetadata,emptied,progress":()=>{var e;this.propagateMediaState(G.MEDIA_SEEKABLE,(e=Lo(this))==null?void 0:e.join(":"))},"progress,emptied":()=>{var e;this.propagateMediaState(G.MEDIA_BUFFERED,mc((e=this.media)==null?void 0:e.buffered))},"ratechange,loadstart":()=>{this.propagateMediaState(G.MEDIA_PLAYBACK_RATE,Do(this))},"waiting,playing,emptied":()=>{var e;let s=((e=this.media)==null?void 0:e.readyState)<3;this.propagateMediaState(G.MEDIA_LOADING,s)}},this._airplayUnavailable!==Bt.UNSUPPORTED){let e=s=>{(s==null?void 0:s.availability)==="available"?this._airplayUnavailable=void 0:(s==null?void 0:s.availability)==="not-available"&&(this._airplayUnavailable=Bt.UNAVAILABLE),this.propagateMediaState(G.MEDIA_AIRPLAY_UNAVAILABLE,this._airplayUnavailable)};this._mediaStatePropagators.webkitplaybacktargetavailabilitychanged=e}if(this._castUnavailable!==Bt.UNSUPPORTED){let e=()=>{var s;let a=(s=globalThis.CastableVideoElement)==null?void 0:s.castState;a!=null&&a.includes("CONNECT")?this._castUnavailable=void 0:this._castUnavailable=Bt.UNAVAILABLE,this.propagateMediaState(G.MEDIA_CAST_UNAVAILABLE,this._castUnavailable)};this._mediaStatePropagators.castchange=e}this._textTrackMediaStatePropagators={"addtrack,removetrack,loadstart":()=>{this.propagateMediaState(G.MEDIA_CAPTIONS_LIST,Ft(hn(this))||void 0),this.propagateMediaState(G.MEDIA_SUBTITLES_LIST,Ft(Si(this))||void 0),this.propagateMediaState(G.MEDIA_CAPTIONS_SHOWING,Ft(Ca(this))||void 0),this.propagateMediaState(G.MEDIA_SUBTITLES_SHOWING,Ft(go(this))||void 0)},change:()=>{this.propagateMediaState(G.MEDIA_CAPTIONS_SHOWING,Ft(Ca(this))||void 0),this.propagateMediaState(G.MEDIA_SUBTITLES_SHOWING,Ft(go(this))||void 0)}},this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat("nohotkeys","hotkeys")}attributeChangedCallback(t,e,s){t==="nohotkeys"?s!==e&&s===""?(this.hasAttribute("hotkeys")&&console.warn("Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):s!==e&&s===null&&this.enableHotkeys():t==="hotkeys"&&(zr(this,dr).value=s),super.attributeChangedCallback(t,e,s)}mediaSetCallback(t){super.mediaSetCallback(t),t.hasAttribute("tabindex")||t.setAttribute("tabindex",-1),Object.keys(this._mediaStatePropagators).forEach(e=>{let s=e.split(","),a=this._mediaStatePropagators[e];s.forEach(u=>{(u==tt.event?this.getRootNode():t).addEventListener(u,a)}),a()}),Object.entries(this._textTrackMediaStatePropagators).forEach(([e,s])=>{e.split(",").forEach(u=>{t.textTracks&&t.textTracks.addEventListener(u,s)}),s()});try{let e=ae.localStorage.getItem("media-chrome-pref-volume");e!==null&&(t.volume=e)}catch(e){console.debug("Error getting volume pref",e)}}mediaUnsetCallback(t){super.mediaUnsetCallback(t),Object.keys(this._mediaStatePropagators).forEach(e=>{let s=e.split(","),a=this._mediaStatePropagators[e];s.forEach(u=>{(u==tt.event?this.getRootNode():t).removeEventListener(u,a)})}),Object.entries(this._textTrackMediaStatePropagators).forEach(([e,s])=>{e.split(",").forEach(u=>{t.textTracks&&t.textTracks.removeEventListener(u,s)}),s()}),this.propagateMediaState(G.MEDIA_PAUSED,!0)}propagateMediaState(t,e){xr(this.mediaStateReceivers,t,e);let s=new ae.CustomEvent(qs[t],{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(s)}associateElement(t){if(!t)return;let{associatedElementSubscriptions:e}=this;if(e.has(t))return;let s=this.registerMediaStateReceiver.bind(this),a=this.unregisterMediaStateReceiver.bind(this),u=oc(t,s,a);Object.keys(de).forEach(R=>{t.addEventListener(de[R],this[`_handle${un(R,!0)}`])}),e.set(t,u)}unassociateElement(t){if(!t)return;let{associatedElementSubscriptions:e}=this;if(!e.has(t))return;e.get(t)(),e.delete(t),Object.keys(de).forEach(a=>{t.removeEventListener(de[a],this[`_handle${un(a,!0)}`])})}registerMediaStateReceiver(t){if(!t)return;let e=this.mediaStateReceivers;e.indexOf(t)>-1||(e.push(t),xr([t],G.MEDIA_VOLUME_UNAVAILABLE,this._volumeUnavailable),xr([t],G.MEDIA_AIRPLAY_UNAVAILABLE,this._airplayUnavailable),xr([t],G.MEDIA_FULLSCREEN_UNAVAILABLE,this._fullscreenUnavailable),xr([t],G.MEDIA_CAST_UNAVAILABLE,this._castUnavailable),xr([t],G.MEDIA_PIP_UNAVAILABLE,this._pipUnavailable),this.media&&Object.keys(G).forEach(a=>{a.includes("UNAVAILABLE")||xr([t],G[a],Ma[G[a]]?Ma[G[a]](this):Ma.default(this,G[a]))}))}unregisterMediaStateReceiver(t){let e=this.mediaStateReceivers,s=e.indexOf(t);s<0||e.splice(s,1)}enableHotkeys(){this.addEventListener("keydown",Xr(this,fn,Ra))}disableHotkeys(){this.removeEventListener("keydown",Xr(this,fn,Ra)),this.removeEventListener("keyup",Xr(this,Qr,Li))}get hotkeys(){return zr(this,dr)}keyboardShortcutHandler(t){var e,s,a,u;if(((u=(a=(e=t.target.getAttribute("keysused"))==null?void 0:e.split(" "))!=null?a:(s=t.target)==null?void 0:s.keysUsed)!=null?u:[]).map(_=>_==="Space"?" ":_).filter(Boolean).includes(t.key))return;let C,O,L,b,x,I=ic;if(!zr(this,dr).contains(`no${t.key.toLowerCase()}`)&&!(t.key===" "&&zr(this,dr).contains("nospace")))switch(t.key){case" ":case"k":C=this.getAttribute(G.MEDIA_PAUSED)!=null?de.MEDIA_PLAY_REQUEST:de.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new ae.CustomEvent(C,{composed:!0,bubbles:!0}));break;case"m":C=this.getAttribute(G.MEDIA_VOLUME_LEVEL)==="off"?de.MEDIA_UNMUTE_REQUEST:de.MEDIA_MUTE_REQUEST,this.dispatchEvent(new ae.CustomEvent(C,{composed:!0,bubbles:!0}));break;case"f":C=this.getAttribute(G.MEDIA_IS_FULLSCREEN)!=null?de.MEDIA_EXIT_FULLSCREEN_REQUEST:de.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new ae.CustomEvent(C,{composed:!0,bubbles:!0}));break;case"c":dn(this);break;case"ArrowLeft":O=this.getAttribute(G.MEDIA_CURRENT_TIME),L=O&&!Number.isNaN(+O)?+O:mo,b=Math.max(L-I,0),x=new ae.CustomEvent(de.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:b}),this.dispatchEvent(x);break;case"ArrowRight":O=this.getAttribute(G.MEDIA_CURRENT_TIME),L=O&&!Number.isNaN(+O)?+O:mo,b=Math.max(L+I,0),x=new ae.CustomEvent(de.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:b}),this.dispatchEvent(x);break;default:break}}};dr=new WeakMap;Qr=new WeakSet;Li=function(r){let{key:t}=r;if(!yo.includes(t)){this.removeEventListener("keyup",Xr(this,Qr,Li));return}this.keyboardShortcutHandler(r)};fn=new WeakSet;Ra=function(r){let{metaKey:t,altKey:e,key:s}=r;if(t||e||!yo.includes(s)){this.removeEventListener("keyup",Xr(this,Qr,Li));return}[" ","ArrowLeft","ArrowRight"].includes(s)&&!(zr(this,dr).contains(`no${s.toLowerCase()}`)||s===" "&&zr(this,dr).contains("nospace"))&&r.preventDefault(),this.addEventListener("keyup",Xr(this,Qr,Li),{once:!0})};var Ma={default(r,t){return r.getAttribute(t)},[G.MEDIA_CAPTIONS_LIST](r){return Ft(hn(r))||void 0},[G.MEDIA_SUBTITLES_LIST](r){return Ft(Si(r))||void 0},[G.MEDIA_SUBTITLES_LIST](r){return Ft(Si(r))||void 0},[G.MEDIA_CAPTIONS_SHOWING](r){return Ft(Ca(r))||void 0},[G.MEDIA_PAUSED](r){return To(r)},[G.MEDIA_MUTED](r){return bo(r)},[G.MEDIA_VOLUME](r){return Ao(r)},[G.MEDIA_VOLUME_LEVEL](r){return _o(r)},[G.MEDIA_CURRENT_TIME](r){return So(r)},[G.MEDIA_DURATION](r){return xo(r)},[G.MEDIA_SEEKABLE](r){var t;return(t=Lo(r))==null?void 0:t.join(":")},[G.MEDIA_PLAYBACK_RATE](r){return Do(r)}},To=r=>r.media?r.media.paused:!0,bo=r=>!!(r.media&&r.media.muted),Ao=r=>{let t=r.media;return t?t.volume:1},_o=r=>{let t="high";if(!r.media)return t;let{muted:e,volume:s}=r.media;return s===0||e?t="off":s<.5?t="low":s<.75&&(t="medium"),t},So=r=>{let t=r.media;return t?t.currentTime:0},xo=r=>{let t=r==null?void 0:r.media;return Number.isFinite(t==null?void 0:t.duration)?t.duration:NaN},Lo=r=>{var t;let e=r==null?void 0:r.media;if(!((t=e==null?void 0:e.seekable)!=null&&t.length))return;let s=e.seekable.start(0),a=e.seekable.end(e.seekable.length-1);if(!(!s&&!a))return[Number(s.toFixed(3)),Number(a.toFixed(3))]},Do=r=>{let t=r.media;return t?t.playbackRate:1},Si=r=>Yr(r.media,{kind:Gr.SUBTITLES}),hn=r=>Yr(r.media,{kind:Gr.CAPTIONS}),go=r=>Yr(r.media,{kind:Gr.SUBTITLES,mode:Ar.SHOWING}),Ca=r=>Yr(r.media,{kind:Gr.CAPTIONS,mode:Ar.SHOWING}),nc=Object.values(G),Io=r=>{var t,e,s,a;let{observedAttributes:u}=r.constructor;!u&&((t=r.nodeName)==null?void 0:t.includes("-"))&&(ae.customElements.upgrade(r),{observedAttributes:u}=r.constructor);let R=(a=(s=(e=r==null?void 0:r.getAttribute)==null?void 0:e.call(r,G.MEDIA_CHROME_ATTRIBUTES))==null?void 0:s.split)==null?void 0:a.call(s,/\s+/);return Array.isArray(u||R)?(u||R).filter(C=>nc.includes(C)):[]},Oa=r=>!!Io(r).length,ac=async(r,t,e)=>(r.isConnected||await Mo(0),e==null?r.removeAttribute(t):typeof e=="boolean"?e?r.setAttribute(t,""):r.removeAttribute(t):Number.isNaN(e)?r.removeAttribute(t):r.setAttribute(t,e)),sc=r=>{var t;return!!((t=r.closest)!=null&&t.call(r,'*[slot="media"]'))},_i=(r,t)=>{if(sc(r))return;let e=(a,u)=>{var R,C;Oa(a)&&u(a);let{children:O=[]}=a!=null?a:{},L=(C=(R=a==null?void 0:a.shadowRoot)==null?void 0:R.children)!=null?C:[];[...O,...L].forEach(x=>_i(x,u))},s=r==null?void 0:r.nodeName.toLowerCase();if(s.includes("-")&&!Oa(r)){ae.customElements.whenDefined(s).then(()=>{e(r,t)});return}e(r,t)},xr=(r,t,e)=>{r.forEach(s=>{!Io(s).includes(t)||ac(s,t,e)})},oc=(r,t,e)=>{_i(r,t);let s=O=>{var L;let b=(L=O==null?void 0:O.composedPath()[0])!=null?L:O.target;t(b)},a=O=>{var L;let b=(L=O==null?void 0:O.composedPath()[0])!=null?L:O.target;e(b)};r.addEventListener(de.REGISTER_MEDIA_STATE_RECEIVER,s),r.addEventListener(de.UNREGISTER_MEDIA_STATE_RECEIVER,a);let u=O=>{O.forEach(L=>{let{addedNodes:b=[],removedNodes:x=[],type:I,target:_,attributeName:A}=L;I==="childList"?(Array.prototype.forEach.call(b,S=>_i(S,t)),Array.prototype.forEach.call(x,S=>_i(S,e))):I==="attributes"&&A===G.MEDIA_CHROME_ATTRIBUTES&&(Oa(_)?t(_):e(_))})},R=new MutationObserver(u);return R.observe(r,{childList:!0,attributes:!0,subtree:!0}),()=>{_i(r,e),R.disconnect(),r.removeEventListener(de.REGISTER_MEDIA_STATE_RECEIVER,s),r.removeEventListener(de.UNREGISTER_MEDIA_STATE_RECEIVER,a)}},cn,Pa=()=>{var r,t;return cn||(cn=(t=(r=re)==null?void 0:r.createElement)==null?void 0:t.call(r,"video"),cn)},lc=async(r=Pa())=>{if(!r)return!1;let t=r.volume;return r.volume=t/2+.1,await Mo(0),r.volume!==t},Mo=r=>new Promise(t=>setTimeout(t,r)),uc=(r=Pa())=>typeof(r==null?void 0:r.requestPictureInPicture)=="function",dc=uc(),xi,cc=lc().then(r=>(xi=r,xi)),fc=!!ae.WebKitPlaybackTargetAvailabilityEvent,hc=!!ae.chrome,vc=(r=Pa())=>{let t=re[tt.enabled];return!t&&r&&(t="webkitSupportsFullscreen"in r),t},po=vc();function mc(r=[]){return Array.from(r).map((t,e)=>[Number(r.start(e).toFixed(3)),Number(r.end(e).toFixed(3))].join(":")).join(" ")}ce("media-controller",vn);var Di=vn;var Co=re.createElement("template"),Ro=`
221
+ `;var oc=Object.values(G),cn=class extends se.HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(yo.content.cloneNode(!0));let t=u=>{let R=this.media;for(let C of u)C.type==="childList"&&(C.removedNodes.forEach(O=>{if(O.slot=="media"&&C.target==this){let L=C.previousSibling&&C.previousSibling.previousElementSibling;if(!L||!R)this.mediaUnsetCallback(O);else{let b=L.slot!=="media";for(;(L=L.previousSibling)!==null;)L.slot=="media"&&(b=!1);b&&this.mediaUnsetCallback(O)}}}),R&&C.addedNodes.forEach(O=>{O==R&&this.handleMediaUpdated(R).then(L=>this.mediaSetCallback(L))}))};new MutationObserver(t).observe(this,{childList:!0,subtree:!0});let a=this.media,s=this.querySelector(":scope > slot[slot=media]");s&&s.addEventListener("slotchange",()=>{if(!s.assignedElements({flatten:!0}).length){this.mediaUnsetCallback(a);return}this.media&&(a=this.media,this.handleMediaUpdated(this.media).then(R=>this.mediaSetCallback(R)))})}static get observedAttributes(){return["autohide","gestures-disabled"].concat(oc)}attributeChangedCallback(t,e,a){t.toLowerCase()=="autohide"&&(this.autohide=a)}get media(){let t=this.querySelector(":scope > [slot=media]");return(t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t}mediaSetCallback(t){this._mediaClickPlayToggle=()=>{let e=t.paused?ce.MEDIA_PLAY_REQUEST:ce.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new se.CustomEvent(e,{composed:!0,bubbles:!0}))}}handleMediaUpdated(t){let e=u=>Promise.resolve(u),a=u=>(console.error('<media-chrome>: Media element set with slot="media" does not appear to be compatible.',u),Promise.reject(u));if(!t)return a(t);let s=t.nodeName.toLowerCase();return s.includes("-")?se.customElements.whenDefined(s).then(()=>e(t)):e(t)}mediaUnsetCallback(){}connectedCallback(){let e=this.getAttribute("audio")!=null?ut.AUDIO_PLAYER():ut.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",e),this.media&&this.handleMediaUpdated(this.media).then(R=>this.mediaSetCallback(R)),this.setAttribute("user-inactive","user-inactive");let a=()=>{if(this.autohide<0)return;this.setAttribute("user-inactive","user-inactive");let R=new se.CustomEvent(bi.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(R)},s=()=>{this.removeAttribute("user-inactive");let R=new se.CustomEvent(bi.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(R)},u=()=>{s(),se.clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=se.setTimeout(()=>{a()},this.autohide*1e3))};this.addEventListener("keyup",()=>{u()}),this.addEventListener("pointerup",R=>{R.pointerType==="touch"?[this,this.media].includes(R.target)&&!this.hasAttribute("user-inactive")?a():u():R.composedPath().some(C=>{var O;return["media-play-button","media-fullscreen-button"].includes((O=C==null?void 0:C.nodeName)==null?void 0:O.toLowerCase())})&&u()}),this.addEventListener("pointermove",R=>{R.pointerType==="mouse"&&R.target!==this&&(s(),se.clearTimeout(this._inactiveTimeout),[this,this.media].includes(R.target)&&u())}),this.addEventListener("mouseleave",()=>{a()}),this.addEventListener("keyup",()=>{this.setAttribute("media-keyboard-control","")}),this.addEventListener("mouseup",()=>{this.removeAttribute("media-keyboard-control")})}set autohide(t){t=Number(t),this._autohide=isNaN(t)?0:t}get autohide(){return this._autohide===void 0?2:this._autohide}};fe("media-container-temp",cn);var To=cn;var bo=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)},st=(r,t,e)=>(bo(r,t,"read from private field"),e?e.call(r):t.get(r)),Oa=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},Pa=(r,t,e,a)=>(bo(r,t,"write to private field"),a?a.call(r,e):t.set(r,e),e),$r,Yr,bt,fn=class{constructor(t,e){Oa(this,$r,void 0),Oa(this,Yr,void 0),Oa(this,bt,[]),Pa(this,$r,t),Pa(this,Yr,e)}[Symbol.iterator](){return st(this,bt).values()}get length(){return st(this,bt).length}get value(){var t;return(t=st(this,bt).join(" "))!=null?t:""}set value(t){var e;t!==this.value&&(Pa(this,bt,[]),this.add(...(e=t==null?void 0:t.split(" "))!=null?e:[]))}toString(){return this.value}item(t){return st(this,bt)[t]}values(){return st(this,bt).values()}keys(){return st(this,bt).keys()}forEach(t){st(this,bt).forEach(t)}add(...t){var e,a;t.forEach(s=>{this.contains(s)||st(this,bt).push(s)}),!(this.value===""&&!((e=st(this,$r))!=null&&e.hasAttribute(`${st(this,Yr)}`)))&&((a=st(this,$r))==null||a.setAttribute(`${st(this,Yr)}`,`${this.value}`))}remove(...t){var e;t.forEach(a=>{st(this,bt).splice(st(this,bt).indexOf(a),1)}),(e=st(this,$r))==null||e.setAttribute(`${st(this,Yr)}`,`${this.value}`)}contains(t){return st(this,bt).includes(t)}toggle(t,e){return typeof e!="undefined"?e?(this.add(t),!0):(this.remove(t),!1):this.contains(t)?(this.remove(t),!1):(this.add(t),!0)}replace(t,e){this.remove(t),this.add(e)}};$r=new WeakMap;Yr=new WeakMap;bt=new WeakMap;var it={enter:"requestFullscreen",exit:"exitFullscreen",event:"fullscreenchange",element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};re.fullscreenElement===void 0&&(it.enter="webkitRequestFullScreen",it.exit=re.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",it.event="webkitfullscreenchange",it.element="webkitFullscreenElement",it.error="webkitfullscreenerror",it.enabled="webkitFullscreenEnabled");function hn(r,t=!1){return r.split("_").map(function(e,a){return(a||t?e[0].toUpperCase():e[0].toLowerCase())+e.slice(1).toLowerCase()}).join("")}var ka=(r="")=>r.split(/\s+/),Ao=(r="")=>{let[t,e]=r.split(":"),a=e?decodeURIComponent(e):void 0;return{language:t,label:a}},lc=(r="",t={})=>ka(r).map(e=>{let a=Ao(e);return{...t,...a}}),uc=r=>Array.isArray(r)?r.map(t=>typeof t=="string"?Ao(t):t):typeof r=="string"?lc(r):[r],dc=({label:r,language:t}={})=>r?`${t}:${encodeURIComponent(r)}`:t,Kt=(r=[])=>Array.prototype.map.call(r,dc).join(" "),cc=(r,t)=>e=>e[r]===t,_o=r=>{let t=Object.entries(r).map(([e,a])=>cc(e,a));return e=>t.every(a=>a(e))},Si=(r,t=[],e=[])=>{let a=uc(e).map(_o),s=u=>a.some(R=>R(u));Array.from(t).filter(s).forEach(u=>{u.mode=r})},zr=(r,t=()=>!0)=>{if(!(r!=null&&r.textTracks))return[];let e=typeof t=="function"?t:_o(t);return Array.from(r.textTracks).filter(e)},wa=r=>{let t=!!r.getAttribute(G.MEDIA_CAPTIONS_SHOWING),e=!r.hasAttribute("no-subtitles-fallback")&&!!r.getAttribute(G.MEDIA_SUBTITLES_SHOWING);return t||e},mn=r=>{var t,e,a,s;if(wa(r)){let R=r.getAttribute(G.MEDIA_CAPTIONS_SHOWING);if(R){let O=new window.CustomEvent(ce.MEDIA_DISABLE_CAPTIONS_REQUEST,{composed:!0,bubbles:!0,detail:R});r.dispatchEvent(O)}let C=r.getAttribute(G.MEDIA_SUBTITLES_SHOWING);if(C&&!r.hasAttribute("no-subtitles-fallback")){let O=new window.CustomEvent(ce.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:C});r.dispatchEvent(O)}}else{let[R]=(e=ka((t=r.getAttribute(G.MEDIA_CAPTIONS_LIST))!=null?t:""))!=null?e:[];if(R){let C=new window.CustomEvent(ce.MEDIA_SHOW_CAPTIONS_REQUEST,{composed:!0,bubbles:!0,detail:R});r.dispatchEvent(C)}else if(r.hasAttribute("no-subtitles-fallback"))console.error("Attempting to enable closed captions but none are available! Please verify your media content if this is unexpected.");else{let[C]=(s=ka((a=r.getAttribute(G.MEDIA_SUBTITLES_LIST))!=null?a:""))!=null?s:[];if(C){let O=new window.CustomEvent(ce.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:C});r.dispatchEvent(O)}}}};var Do=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)},Xr=(r,t,e)=>(Do(r,t,"read from private field"),e?e.call(r):t.get(r)),Ua=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},Qr=(r,t,e)=>(Do(r,t,"access private method"),e),hr,Zr,Ii,gn,Ba,Io=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],fc=10,So=0,En=class extends To{constructor(){super(),Ua(this,Zr),Ua(this,gn),Ua(this,hr,new fn(this,"hotkeys")),bc||(this._airplayUnavailable=Ft.UNSUPPORTED),Lo||(this._fullscreenUnavailable=Ft.UNAVAILABLE),Ac||(this._castUnavailable=Ft.UNSUPPORTED),yc||(this._pipUnavailable=Ft.UNSUPPORTED),Di!==void 0?Di||(this._volumeUnavailable=Ft.UNSUPPORTED):Tc.then(()=>{Di||(this._volumeUnavailable=Ft.UNSUPPORTED,this.propagateMediaState(G.MEDIA_VOLUME_UNAVAILABLE,this._volumeUnavailable))}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associatedElements=[],this.associateElement(this);let t={MEDIA_PLAY_REQUEST:()=>this.media.play(),MEDIA_PAUSE_REQUEST:()=>this.media.pause(),MEDIA_MUTE_REQUEST:()=>this.media.muted=!0,MEDIA_UNMUTE_REQUEST:()=>{let e=this.media;e.muted=!1,e.volume===0&&(e.volume=.25)},MEDIA_VOLUME_REQUEST:e=>{let a=this.media,s=e.detail;a.volume=s,s>0&&a.muted&&(a.muted=!1);try{se.localStorage.setItem("media-chrome-pref-volume",s.toString())}catch{}},MEDIA_ENTER_FULLSCREEN_REQUEST:()=>{if(!Lo){console.warn("Fullscreen support is unavailable; not entering fullscreen");return}let e=this.media;re.pictureInPictureElement&&re.exitPictureInPicture(),super[it.enter]?super[it.enter]():e.webkitEnterFullscreen?e.webkitEnterFullscreen():e.requestFullscreen?e.requestFullscreen():console.warn("MediaChrome: Fullscreen not supported")},MEDIA_EXIT_FULLSCREEN_REQUEST:()=>{re[it.exit]()},MEDIA_ENTER_PIP_REQUEST:()=>{let e=this.media;if(!re.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!e.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}re[it.element]&&re[it.exit]();let a=s=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};e.requestPictureInPicture().catch(s=>{if(s.code===11)if(e.readyState===0&&e.preload==="none"){let u=function(){e.removeEventListener("loadedmetadata",R),e.preload="none"},R=function(){e.requestPictureInPicture().catch(a),u()};e.addEventListener("loadedmetadata",R),e.preload="metadata",setTimeout(()=>{e.readyState===0&&a(),u()},1e3)}else throw s;else throw s})},MEDIA_EXIT_PIP_REQUEST:()=>{re.pictureInPictureElement&&re.exitPictureInPicture()},MEDIA_ENTER_CAST_REQUEST:()=>{var e;let a=this.media;!((e=globalThis.CastableVideoElement)!=null&&e.castEnabled)||(re[it.element]&&re[it.exit](),a.requestCast())},MEDIA_EXIT_CAST_REQUEST:async()=>{var e;(e=globalThis.CastableVideoElement)!=null&&e.castElement&&globalThis.CastableVideoElement.exitCast()},MEDIA_SEEK_REQUEST:e=>{let a=this.media,s=e.detail;(a.readyState>0||a.readyState===void 0)&&(a.currentTime=s)},MEDIA_PLAYBACK_RATE_REQUEST:e=>{this.media.playbackRate=e.detail},MEDIA_PREVIEW_REQUEST:e=>{var a;let s=this.media;if(!s)return;let u=e.detail;u===null&&this.propagateMediaState(G.MEDIA_PREVIEW_TIME,void 0),this.propagateMediaState(G.MEDIA_PREVIEW_TIME,u);let[R]=zr(s,{kind:jr.METADATA,label:"thumbnails"});if(!(R&&R.cues))return;if(u===null){this.propagateMediaState(G.MEDIA_PREVIEW_IMAGE,void 0),this.propagateMediaState(G.MEDIA_PREVIEW_COORDS,void 0);return}let C=Array.prototype.find.call(R.cues,x=>x.startTime>=u);if(!C)return;let O=/'^(?:[a-z]+:)?\/\//i.test(C.text)||(a=s.querySelector('track[label="thumbnails"]'))==null?void 0:a.src,L=new URL(C.text,O),b=new URLSearchParams(L.hash).get("#xywh");this.propagateMediaState(G.MEDIA_PREVIEW_IMAGE,L.href),this.propagateMediaState(G.MEDIA_PREVIEW_COORDS,b.split(",").join(" "))},MEDIA_SHOW_CAPTIONS_REQUEST:e=>{let a=pn(this),{detail:s=[]}=e;Si(Dr.SHOWING,a,s)},MEDIA_DISABLE_CAPTIONS_REQUEST:e=>{let a=pn(this),{detail:s=[]}=e;Si(Dr.DISABLED,a,s)},MEDIA_SHOW_SUBTITLES_REQUEST:e=>{let a=Li(this),{detail:s=[]}=e;Si(Dr.SHOWING,a,s)},MEDIA_DISABLE_SUBTITLES_REQUEST:e=>{let a=Li(this),{detail:s=[]}=e;Si(Dr.DISABLED,a,s)},MEDIA_AIRPLAY_REQUEST:()=>{let{media:e}=this;if(!!e){if(!(e.webkitShowPlaybackTargetPicker&&se.WebKitPlaybackTargetAvailabilityEvent)){console.warn("received a request to select AirPlay but AirPlay is not supported in this environment");return}e.webkitShowPlaybackTargetPicker()}}};if(Object.keys(t).forEach(e=>{let a=`_handle${hn(e,!0)}`;this[a]=s=>{if(s.stopPropagation(),!this.media){console.warn("MediaController: No media available.");return}t[e](s,this.media)},this.addEventListener(ce[e],this[a])}),this._mediaStatePropagators={"play,pause,emptied":()=>{this.propagateMediaState(G.MEDIA_PAUSED,Mo(this))},"playing,emptied":()=>{var e;this.propagateMediaState(G.MEDIA_HAS_PLAYED,!((e=this.media)!=null&&e.paused))},volumechange:()=>{this.propagateMediaState(G.MEDIA_MUTED,Ro(this)),this.propagateMediaState(G.MEDIA_VOLUME,Co(this)),this.propagateMediaState(G.MEDIA_VOLUME_LEVEL,Oo(this))},[it.event]:e=>{let s=!!re[it.element]&&(e==null?void 0:e.target),u=Ai(this,s);this.propagateMediaState(G.MEDIA_IS_FULLSCREEN,u)},"enterpictureinpicture,leavepictureinpicture":e=>{var a;let s;if(e)s=e.type=="enterpictureinpicture";else{let u=(a=this.getRootNode().pictureInPictureElement)!=null?a:re.pictureInPictureElement;s=this.media&&Ai(this.media,u)}this.propagateMediaState(G.MEDIA_IS_PIP,s)},"entercast,leavecast,castchange":e=>{var a;let s=(a=globalThis.CastableVideoElement)==null?void 0:a.castElement,u=this.media&&Ai(this.media,s);(e==null?void 0:e.type)==="castchange"&&(e==null?void 0:e.detail)==="CONNECTING"&&(u="connecting"),this.propagateMediaState(G.MEDIA_IS_CASTING,u)},"timeupdate,loadedmetadata":()=>{this.propagateMediaState(G.MEDIA_CURRENT_TIME,Po(this))},"durationchange,loadedmetadata,emptied":()=>{this.propagateMediaState(G.MEDIA_DURATION,ko(this))},"loadedmetadata,emptied,progress":()=>{var e;this.propagateMediaState(G.MEDIA_SEEKABLE,(e=wo(this))==null?void 0:e.join(":"))},"progress,emptied":()=>{var e;this.propagateMediaState(G.MEDIA_BUFFERED,Sc((e=this.media)==null?void 0:e.buffered))},"ratechange,loadstart":()=>{this.propagateMediaState(G.MEDIA_PLAYBACK_RATE,Uo(this))},"waiting,playing,emptied":()=>{var e;let a=((e=this.media)==null?void 0:e.readyState)<3;this.propagateMediaState(G.MEDIA_LOADING,a)}},this._airplayUnavailable!==Ft.UNSUPPORTED){let e=a=>{(a==null?void 0:a.availability)==="available"?this._airplayUnavailable=void 0:(a==null?void 0:a.availability)==="not-available"&&(this._airplayUnavailable=Ft.UNAVAILABLE),this.propagateMediaState(G.MEDIA_AIRPLAY_UNAVAILABLE,this._airplayUnavailable)};this._mediaStatePropagators.webkitplaybacktargetavailabilitychanged=e}if(this._castUnavailable!==Ft.UNSUPPORTED){let e=()=>{var a;let s=(a=globalThis.CastableVideoElement)==null?void 0:a.castState;s!=null&&s.includes("CONNECT")?this._castUnavailable=void 0:this._castUnavailable=Ft.UNAVAILABLE,this.propagateMediaState(G.MEDIA_CAST_UNAVAILABLE,this._castUnavailable)};this._mediaStatePropagators.castchange=e}this._textTrackMediaStatePropagators={"addtrack,removetrack,loadstart":()=>{this.propagateMediaState(G.MEDIA_CAPTIONS_LIST,Kt(pn(this))||void 0),this.propagateMediaState(G.MEDIA_SUBTITLES_LIST,Kt(Li(this))||void 0),this.propagateMediaState(G.MEDIA_CAPTIONS_SHOWING,Kt(Fa(this))||void 0),this.propagateMediaState(G.MEDIA_SUBTITLES_SHOWING,Kt(xo(this))||void 0)},change:()=>{this.propagateMediaState(G.MEDIA_CAPTIONS_SHOWING,Kt(Fa(this))||void 0),this.propagateMediaState(G.MEDIA_SUBTITLES_SHOWING,Kt(xo(this))||void 0)}},this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat("nohotkeys","hotkeys")}attributeChangedCallback(t,e,a){t==="nohotkeys"?a!==e&&a===""?(this.hasAttribute("hotkeys")&&console.warn("Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):a!==e&&a===null&&this.enableHotkeys():t==="hotkeys"&&(Xr(this,hr).value=a),super.attributeChangedCallback(t,e,a)}mediaSetCallback(t){super.mediaSetCallback(t),t.hasAttribute("tabindex")||t.setAttribute("tabindex",-1),Object.keys(this._mediaStatePropagators).forEach(e=>{let a=e.split(","),s=this._mediaStatePropagators[e];a.forEach(u=>{(u==it.event?this.getRootNode():t).addEventListener(u,s)}),s()}),Object.entries(this._textTrackMediaStatePropagators).forEach(([e,a])=>{e.split(",").forEach(u=>{t.textTracks&&t.textTracks.addEventListener(u,a)}),a()});try{let e=se.localStorage.getItem("media-chrome-pref-volume");e!==null&&(t.volume=e)}catch(e){console.debug("Error getting volume pref",e)}}mediaUnsetCallback(t){super.mediaUnsetCallback(t),Object.keys(this._mediaStatePropagators).forEach(e=>{let a=e.split(","),s=this._mediaStatePropagators[e];a.forEach(u=>{(u==it.event?this.getRootNode():t).removeEventListener(u,s)})}),Object.entries(this._textTrackMediaStatePropagators).forEach(([e,a])=>{e.split(",").forEach(u=>{t.textTracks&&t.textTracks.removeEventListener(u,a)}),a()}),this.propagateMediaState(G.MEDIA_PAUSED,!0)}propagateMediaState(t,e){Rr(this.mediaStateReceivers,t,e);let a=new se.CustomEvent(lo[t],{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(a)}associateElement(t){if(!t)return;let{associatedElementSubscriptions:e}=this;if(e.has(t))return;let a=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),u=gc(t,a,s);Object.keys(ce).forEach(R=>{t.addEventListener(ce[R],this[`_handle${hn(R,!0)}`])}),e.set(t,u)}unassociateElement(t){if(!t)return;let{associatedElementSubscriptions:e}=this;if(!e.has(t))return;e.get(t)(),e.delete(t),Object.keys(ce).forEach(s=>{t.removeEventListener(ce[s],this[`_handle${hn(s,!0)}`])})}registerMediaStateReceiver(t){if(!t)return;let e=this.mediaStateReceivers;e.indexOf(t)>-1||(e.push(t),Rr([t],G.MEDIA_VOLUME_UNAVAILABLE,this._volumeUnavailable),Rr([t],G.MEDIA_AIRPLAY_UNAVAILABLE,this._airplayUnavailable),Rr([t],G.MEDIA_FULLSCREEN_UNAVAILABLE,this._fullscreenUnavailable),Rr([t],G.MEDIA_CAST_UNAVAILABLE,this._castUnavailable),Rr([t],G.MEDIA_PIP_UNAVAILABLE,this._pipUnavailable),this.media&&Object.keys(G).forEach(s=>{s.includes("UNAVAILABLE")||Rr([t],G[s],Na[G[s]]?Na[G[s]](this):Na.default(this,G[s]))}))}unregisterMediaStateReceiver(t){let e=this.mediaStateReceivers,a=e.indexOf(t);a<0||e.splice(a,1)}enableHotkeys(){this.addEventListener("keydown",Qr(this,gn,Ba))}disableHotkeys(){this.removeEventListener("keydown",Qr(this,gn,Ba)),this.removeEventListener("keyup",Qr(this,Zr,Ii))}get hotkeys(){return Xr(this,hr)}keyboardShortcutHandler(t){var e,a,s,u;if(((u=(s=(e=t.target.getAttribute("keysused"))==null?void 0:e.split(" "))!=null?s:(a=t.target)==null?void 0:a.keysUsed)!=null?u:[]).map(_=>_==="Space"?" ":_).filter(Boolean).includes(t.key))return;let C,O,L,b,x,I=fc;if(!Xr(this,hr).contains(`no${t.key.toLowerCase()}`)&&!(t.key===" "&&Xr(this,hr).contains("nospace")))switch(t.key){case" ":case"k":C=this.getAttribute(G.MEDIA_PAUSED)!=null?ce.MEDIA_PLAY_REQUEST:ce.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new se.CustomEvent(C,{composed:!0,bubbles:!0}));break;case"m":C=this.getAttribute(G.MEDIA_VOLUME_LEVEL)==="off"?ce.MEDIA_UNMUTE_REQUEST:ce.MEDIA_MUTE_REQUEST,this.dispatchEvent(new se.CustomEvent(C,{composed:!0,bubbles:!0}));break;case"f":C=this.getAttribute(G.MEDIA_IS_FULLSCREEN)!=null?ce.MEDIA_EXIT_FULLSCREEN_REQUEST:ce.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new se.CustomEvent(C,{composed:!0,bubbles:!0}));break;case"c":mn(this);break;case"ArrowLeft":O=this.getAttribute(G.MEDIA_CURRENT_TIME),L=O&&!Number.isNaN(+O)?+O:So,b=Math.max(L-I,0),x=new se.CustomEvent(ce.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:b}),this.dispatchEvent(x);break;case"ArrowRight":O=this.getAttribute(G.MEDIA_CURRENT_TIME),L=O&&!Number.isNaN(+O)?+O:So,b=Math.max(L+I,0),x=new se.CustomEvent(ce.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:b}),this.dispatchEvent(x);break;default:break}}};hr=new WeakMap;Zr=new WeakSet;Ii=function(r){let{key:t}=r;if(!Io.includes(t)){this.removeEventListener("keyup",Qr(this,Zr,Ii));return}this.keyboardShortcutHandler(r)};gn=new WeakSet;Ba=function(r){let{metaKey:t,altKey:e,key:a}=r;if(t||e||!Io.includes(a)){this.removeEventListener("keyup",Qr(this,Zr,Ii));return}[" ","ArrowLeft","ArrowRight"].includes(a)&&!(Xr(this,hr).contains(`no${a.toLowerCase()}`)||a===" "&&Xr(this,hr).contains("nospace"))&&r.preventDefault(),this.addEventListener("keyup",Qr(this,Zr,Ii),{once:!0})};var Na={default(r,t){return r.getAttribute(t)},[G.MEDIA_CAPTIONS_LIST](r){return Kt(pn(r))||void 0},[G.MEDIA_SUBTITLES_LIST](r){return Kt(Li(r))||void 0},[G.MEDIA_SUBTITLES_LIST](r){return Kt(Li(r))||void 0},[G.MEDIA_CAPTIONS_SHOWING](r){return Kt(Fa(r))||void 0},[G.MEDIA_PAUSED](r){return Mo(r)},[G.MEDIA_MUTED](r){return Ro(r)},[G.MEDIA_VOLUME](r){return Co(r)},[G.MEDIA_VOLUME_LEVEL](r){return Oo(r)},[G.MEDIA_CURRENT_TIME](r){return Po(r)},[G.MEDIA_DURATION](r){return ko(r)},[G.MEDIA_SEEKABLE](r){var t;return(t=wo(r))==null?void 0:t.join(":")},[G.MEDIA_PLAYBACK_RATE](r){return Uo(r)}},Mo=r=>r.media?r.media.paused:!0,Ro=r=>!!(r.media&&r.media.muted),Co=r=>{let t=r.media;return t?t.volume:1},Oo=r=>{let t="high";if(!r.media)return t;let{muted:e,volume:a}=r.media;return a===0||e?t="off":a<.5?t="low":a<.75&&(t="medium"),t},Po=r=>{let t=r.media;return t?t.currentTime:0},ko=r=>{let t=r==null?void 0:r.media;return Number.isFinite(t==null?void 0:t.duration)?t.duration:NaN},wo=r=>{var t;let e=r==null?void 0:r.media;if(!((t=e==null?void 0:e.seekable)!=null&&t.length))return;let a=e.seekable.start(0),s=e.seekable.end(e.seekable.length-1);if(!(!a&&!s))return[Number(a.toFixed(3)),Number(s.toFixed(3))]},Uo=r=>{let t=r.media;return t?t.playbackRate:1},Li=r=>zr(r.media,{kind:jr.SUBTITLES}),pn=r=>zr(r.media,{kind:jr.CAPTIONS}),xo=r=>zr(r.media,{kind:jr.SUBTITLES,mode:Dr.SHOWING}),Fa=r=>zr(r.media,{kind:jr.CAPTIONS,mode:Dr.SHOWING}),hc=Object.values(G),No=r=>{var t,e,a,s;let{observedAttributes:u}=r.constructor;!u&&((t=r.nodeName)==null?void 0:t.includes("-"))&&(se.customElements.upgrade(r),{observedAttributes:u}=r.constructor);let R=(s=(a=(e=r==null?void 0:r.getAttribute)==null?void 0:e.call(r,G.MEDIA_CHROME_ATTRIBUTES))==null?void 0:a.split)==null?void 0:s.call(a,/\s+/);return Array.isArray(u||R)?(u||R).filter(C=>hc.includes(C)):[]},Ka=r=>!!No(r).length,mc=async(r,t,e)=>(r.isConnected||await Bo(0),e==null?r.removeAttribute(t):typeof e=="boolean"?e?r.setAttribute(t,""):r.removeAttribute(t):Number.isNaN(e)?r.removeAttribute(t):r.setAttribute(t,e)),vc=r=>{var t;return!!((t=r.closest)!=null&&t.call(r,'*[slot="media"]'))},xi=(r,t)=>{if(vc(r))return;let e=(s,u)=>{var R,C;Ka(s)&&u(s);let{children:O=[]}=s!=null?s:{},L=(C=(R=s==null?void 0:s.shadowRoot)==null?void 0:R.children)!=null?C:[];[...O,...L].forEach(x=>xi(x,u))},a=r==null?void 0:r.nodeName.toLowerCase();if(a.includes("-")&&!Ka(r)){se.customElements.whenDefined(a).then(()=>{e(r,t)});return}e(r,t)},Rr=(r,t,e)=>{r.forEach(a=>{!No(a).includes(t)||mc(a,t,e)})},gc=(r,t,e)=>{xi(r,t);let a=O=>{var L;let b=(L=O==null?void 0:O.composedPath()[0])!=null?L:O.target;t(b)},s=O=>{var L;let b=(L=O==null?void 0:O.composedPath()[0])!=null?L:O.target;e(b)};r.addEventListener(ce.REGISTER_MEDIA_STATE_RECEIVER,a),r.addEventListener(ce.UNREGISTER_MEDIA_STATE_RECEIVER,s);let u=O=>{O.forEach(L=>{let{addedNodes:b=[],removedNodes:x=[],type:I,target:_,attributeName:A}=L;I==="childList"?(Array.prototype.forEach.call(b,S=>xi(S,t)),Array.prototype.forEach.call(x,S=>xi(S,e))):I==="attributes"&&A===G.MEDIA_CHROME_ATTRIBUTES&&(Ka(_)?t(_):e(_))})},R=new MutationObserver(u);return R.observe(r,{childList:!0,attributes:!0,subtree:!0}),()=>{xi(r,e),R.disconnect(),r.removeEventListener(ce.REGISTER_MEDIA_STATE_RECEIVER,a),r.removeEventListener(ce.UNREGISTER_MEDIA_STATE_RECEIVER,s)}},vn,Wa=()=>{var r,t;return vn||(vn=(t=(r=re)==null?void 0:r.createElement)==null?void 0:t.call(r,"video"),vn)},pc=async(r=Wa())=>{if(!r)return!1;let t=r.volume;return r.volume=t/2+.1,await Bo(0),r.volume!==t},Bo=r=>new Promise(t=>setTimeout(t,r)),Ec=(r=Wa())=>typeof(r==null?void 0:r.requestPictureInPicture)=="function",yc=Ec(),Di,Tc=pc().then(r=>(Di=r,Di)),bc=!!se.WebKitPlaybackTargetAvailabilityEvent,Ac=!!se.chrome,_c=(r=Wa())=>{let t=re[it.enabled];return!t&&r&&(t="webkitSupportsFullscreen"in r),t},Lo=_c();function Sc(r=[]){return Array.from(r).map((t,e)=>[Number(r.start(e).toFixed(3)),Number(r.end(e).toFixed(3))].join(":")).join(" ")}fe("media-controller",En);var Mi=En;var Ko=re.createElement("template"),Fo=`
222
222
  height: var(--thumb-height);
223
223
  width: var(--media-range-thumb-width, 10px);
224
224
  border: var(--media-range-thumb-border, none);
@@ -229,18 +229,20 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
229
229
  transition: var(--media-range-thumb-transition, none);
230
230
  transform: var(--media-range-thumb-transform, none);
231
231
  opacity: var(--media-range-thumb-opacity, 1);
232
- `,mn=`
232
+ `,Ha=`
233
233
  width: var(--media-range-track-width, 100%);
234
234
  min-width: 40px;
235
235
  height: var(--track-height);
236
236
  border: var(--media-range-track-border, none);
237
+ outline: var(--media-range-track-outline);
238
+ outline-offset: var(--media-range-track-outline-offset);
237
239
  border-radius: var(--media-range-track-border-radius, 0);
238
240
  background: var(--media-range-track-progress-internal, var(--media-range-track-background, #eee));
239
241
  box-shadow: var(--media-range-track-box-shadow, none);
240
242
  transition: var(--media-range-track-transition, none);
241
243
  transform: translate(var(--media-range-track-translate-x, 0), var(--media-range-track-translate-y, 0));
242
244
  cursor: pointer;
243
- `;Co.innerHTML=`
245
+ `;Ko.innerHTML=`
244
246
  <style>
245
247
  :host {
246
248
  --thumb-height: var(--media-range-thumb-height, 10px);
@@ -248,12 +250,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
248
250
  --media-range-padding: var(--media-control-padding, 10px);
249
251
  --_media-range-padding: var(--media-range-padding, 10px);
250
252
 
251
- position: relative;
252
- display: inline-flex;
253
- align-items: center;
254
- justify-content: center;
255
253
  vertical-align: middle;
256
254
  box-sizing: border-box;
255
+ display: inline-block;
256
+ position: relative;
257
257
  background: var(--media-control-background, rgba(20,20,30, 0.7));
258
258
  transition: background 0.15s linear;
259
259
  width: 100px;
@@ -269,6 +269,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
269
269
  background: var(--media-control-hover-background, rgba(50,50,60, 0.7));
270
270
  }
271
271
 
272
+ #container {
273
+ position: relative;
274
+ height: 100%;
275
+ }
276
+
272
277
  input[type=range] {
273
278
 
274
279
  -webkit-appearance: none;
@@ -286,19 +291,19 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
286
291
 
287
292
  input[type=range]::-webkit-slider-thumb {
288
293
  -webkit-appearance: none;
289
- ${Ro}
294
+ ${Fo}
290
295
 
291
296
  margin-top: calc(calc(0px - var(--thumb-height) + var(--track-height)) / 2);
292
297
  }
293
298
 
294
299
 
295
300
  input[type=range]::-moz-range-thumb {
296
- ${Ro}
301
+ ${Fo}
297
302
  translate: var(--media-range-track-translate-x, 0) var(--media-range-track-translate-y, 0);
298
303
  }
299
304
 
300
- input[type=range]::-webkit-slider-runnable-track { ${mn} }
301
- input[type=range]::-moz-range-track { ${mn} }
305
+ input[type=range]::-webkit-slider-runnable-track { ${Ha} }
306
+ input[type=range]::-moz-range-track { ${Ha} }
302
307
  input[type=range]::-ms-track {
303
308
 
304
309
  width: 100%;
@@ -308,24 +313,23 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
308
313
  border-color: transparent;
309
314
  color: transparent;
310
315
 
311
- ${mn}
316
+ ${Ha}
312
317
  }
313
318
 
314
319
  #background,
315
320
  #pointer {
316
- ${mn}
317
- width: auto;
321
+ min-width: 40px;
322
+ width: var(--media-range-track-width, 100%);
323
+ height: var(--track-height);
324
+ border-radius: var(--media-range-track-border-radius, 0);
318
325
  position: absolute;
319
326
  top: 50%;
320
327
  transform: translate(var(--media-range-track-translate-x, 0px), calc(var(--media-range-track-translate-y, 0px) - 50%));
321
- left: var(--media-range-padding-left, var(--_media-range-padding));
322
- right: var(--media-range-padding-right, var(--_media-range-padding));
323
328
  background: var(--media-range-track-background, #333);
324
329
  }
325
330
 
326
331
  #pointer {
327
332
  min-width: auto;
328
- right: auto;
329
333
  background: var(--media-range-track-pointer-background);
330
334
  border-right: var(--media-range-track-pointer-border-right);
331
335
  transition: visibility .25s, opacity .25s;
@@ -343,10 +347,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
343
347
 
344
348
  z-index: 1;
345
349
  display: var(--media-time-range-hover-display, none);
346
- box-sizing: border-box;
347
350
  position: absolute;
348
- left: var(--media-range-padding-left, var(--_media-range-padding));
349
- right: var(--media-range-padding-right, var(--_media-range-padding));
351
+ width: 100%;
350
352
  bottom: var(--media-time-range-hover-bottom, -5px);
351
353
  height: var(--media-time-range-hover-height, max(calc(100% + 5px), 20px));
352
354
  }
@@ -383,11 +385,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
383
385
  background-color: #777;
384
386
  }
385
387
  </style>
386
- <div id="background"></div>
387
- <div id="pointer"></div>
388
- <div id="hoverzone"></div>
389
- <input id="range" type="range" min="0" max="1000" step="any" value="0">
390
- `;var gn=class extends ae.HTMLElement{static get observedAttributes(){return["disabled","aria-disabled",G.MEDIA_CONTROLLER]}constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Co.content.cloneNode(!0)),this.range=this.shadowRoot.querySelector("#range"),this.range.addEventListener("input",this.updateBar.bind(this))}attributeChangedCallback(t,e,s){var a,u;if(t===G.MEDIA_CONTROLLER){if(e){let R=re.getElementById(e);(a=R==null?void 0:R.unassociateElement)==null||a.call(R,this)}if(s){let R=re.getElementById(s);(u=R==null?void 0:R.associateElement)==null||u.call(R,this)}}else(t==="disabled"||t==="aria-disabled"&&e!==s)&&(s==null?this.range.removeAttribute(t):this.range.setAttribute(t,s))}connectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let s=re.getElementById(e);(t=s==null?void 0:s.associateElement)==null||t.call(s,this)}this.updateBar()}disconnectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let s=re.getElementById(e);(t=s==null?void 0:s.unassociateElement)==null||t.call(s,this)}}updatePointerBar(t){let e=this.range.getBoundingClientRect(),s=(t.clientX-e.left)/e.width;s=Math.max(0,Math.min(1,s));let{style:a}=tr(this.shadowRoot,"#pointer");a.setProperty("width",`${s*e.width}px`)}updateBar(){let t=this.getBarColors(),e="linear-gradient(to right, ",s=0;t.forEach(u=>{u[1]<s||(e=e+`${u[0]} ${s}%, ${u[0]} ${u[1]}%,`,s=u[1])}),e=e.slice(0,e.length-1)+")";let{style:a}=tr(this.shadowRoot,":host");a.setProperty("--media-range-track-progress-internal",e)}getBarColors(){let t=this.range,e=t.value-t.min,s=t.max-t.min,a=e/s*100,u=0;if(t.value>t.min&&t.value<t.max){let C=getComputedStyle(this).getPropertyValue("--media-range-thumb-width")||"10px";u=parseInt(C)*(.5-a/100)/t.offsetWidth*100}return[["var(--media-range-bar-color, #fff)",a+u],["transparent",100]]}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};ce("media-chrome-range",gn);var Ii=gn;var Oo=re.createElement("template");Oo.innerHTML=`
388
+ <div id="container">
389
+ <div id="background"></div>
390
+ <div id="pointer"></div>
391
+ <div id="hoverzone"></div>
392
+ <input id="range" type="range" min="0" max="1000" step="any" value="0">
393
+ </div>
394
+ `;var yn=class extends se.HTMLElement{static get observedAttributes(){return["disabled","aria-disabled",G.MEDIA_CONTROLLER]}constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ko.content.cloneNode(!0)),this.container=this.shadowRoot.querySelector("#container"),this.range=this.shadowRoot.querySelector("#range"),this.range.addEventListener("input",this.updateBar.bind(this))}attributeChangedCallback(t,e,a){var s,u;if(t===G.MEDIA_CONTROLLER){if(e){let R=re.getElementById(e);(s=R==null?void 0:R.unassociateElement)==null||s.call(R,this)}if(a){let R=re.getElementById(a);(u=R==null?void 0:R.associateElement)==null||u.call(R,this)}}else(t==="disabled"||t==="aria-disabled"&&e!==a)&&(a==null?this.range.removeAttribute(t):this.range.setAttribute(t,a))}connectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let a=re.getElementById(e);(t=a==null?void 0:a.associateElement)==null||t.call(a,this)}this.updateBar()}disconnectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let a=re.getElementById(e);(t=a==null?void 0:a.unassociateElement)==null||t.call(a,this)}}updatePointerBar(t){let e=this.range.getBoundingClientRect(),a=(t.clientX-e.left)/e.width;a=Math.max(0,Math.min(1,a));let{style:s}=qt(this.shadowRoot,"#pointer");s.setProperty("width",`${a*e.width}px`)}updateBar(){let t=this.getBarColors(),e="linear-gradient(to right, ",a=0;t.forEach(u=>{u[1]<a||(e=e+`${u[0]} ${a}%, ${u[0]} ${u[1]}%,`,a=u[1])}),e=e.slice(0,e.length-1)+")";let{style:s}=qt(this.shadowRoot,":host");s.setProperty("--media-range-track-progress-internal",e)}getBarColors(){let t=this.range,e=t.value-t.min,a=t.max-t.min,s=e/a*100,u=0;if(t.value>t.min&&t.value<t.max){let C=getComputedStyle(this).getPropertyValue("--media-range-thumb-width")||"10px";u=parseInt(C)*(.5-s/100)/t.offsetWidth*100}return[["var(--media-range-bar-color, #fff)",s+u],["transparent",100]]}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};fe("media-chrome-range",yn);var Ri=yn;var Wo=re.createElement("template");Wo.innerHTML=`
391
395
  <style>
392
396
  :host {
393
397
 
@@ -406,7 +410,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
406
410
  </style>
407
411
 
408
412
  <slot></slot>
409
- `;var ka=class extends ae.HTMLElement{static get observedAttributes(){return[G.MEDIA_CONTROLLER]}constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Oo.content.cloneNode(!0))}attributeChangedCallback(t,e,s){var a,u;if(t===G.MEDIA_CONTROLLER){if(e){let R=re.getElementById(e);(a=R==null?void 0:R.unassociateElement)==null||a.call(R,this)}if(s){let R=re.getElementById(s);(u=R==null?void 0:R.associateElement)==null||u.call(R,this)}}}connectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let s=re.getElementById(e);(t=s==null?void 0:s.associateElement)==null||t.call(s,this)}}disconnectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let s=re.getElementById(e);(t=s==null?void 0:s.unassociateElement)==null||t.call(s,this)}}};ce("media-control-bar",ka);var Po=re.createElement("template");Po.innerHTML=`
413
+ `;var Ga=class extends se.HTMLElement{static get observedAttributes(){return[G.MEDIA_CONTROLLER]}constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Wo.content.cloneNode(!0))}attributeChangedCallback(t,e,a){var s,u;if(t===G.MEDIA_CONTROLLER){if(e){let R=re.getElementById(e);(s=R==null?void 0:R.unassociateElement)==null||s.call(R,this)}if(a){let R=re.getElementById(a);(u=R==null?void 0:R.associateElement)==null||u.call(R,this)}}}connectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let a=re.getElementById(e);(t=a==null?void 0:a.associateElement)==null||t.call(a,this)}}disconnectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let a=re.getElementById(e);(t=a==null?void 0:a.unassociateElement)==null||t.call(a,this)}}};fe("media-control-bar",Ga);var Ho=re.createElement("template");Ho.innerHTML=`
410
414
  <style>
411
415
  :host {
412
416
  display: inline-flex;
@@ -441,11 +445,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
441
445
  <span id="container">
442
446
  <slot></slot>
443
447
  </span>
444
- `;var pn=class extends ae.HTMLElement{static get observedAttributes(){return[G.MEDIA_CONTROLLER]}constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Po.content.cloneNode(!0)),this.container=this.shadowRoot.querySelector("#container")}attributeChangedCallback(t,e,s){var a,u;if(t===G.MEDIA_CONTROLLER){if(e){let R=re.getElementById(e);(a=R==null?void 0:R.unassociateElement)==null||a.call(R,this)}if(s){let R=re.getElementById(s);(u=R==null?void 0:R.associateElement)==null||u.call(R,this)}}}connectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let s=re.getElementById(e);(t=s==null?void 0:s.associateElement)==null||t.call(s,this)}}disconnectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let s=re.getElementById(e);(t=s==null?void 0:s.unassociateElement)==null||t.call(s,this)}}};ce("media-text-display",pn);var cr=pn;var wa=class extends cr{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_CURRENT_TIME]}attributeChangedCallback(t,e,s){t===G.MEDIA_CURRENT_TIME&&(this.container.innerHTML=Yt(s)),super.attributeChangedCallback(t,e,s)}};ce("media-current-time-display",wa);var Ua=class extends cr{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_DURATION]}attributeChangedCallback(t,e,s){t===G.MEDIA_DURATION&&(this.container.innerHTML=Yt(s)),super.attributeChangedCallback(t,e,s)}};ce("media-duration-display",Ua);var gc="&nbsp;/&nbsp;",pc=(r,{timesSep:t=gc}={})=>{var e,s,a;let u=r.getAttribute("remaining")!=null,R=r.getAttribute("show-duration")!=null,C=(e=r.mediaCurrentTime)!=null?e:0,O=(a=(s=r.mediaDuration)!=null?s:r.mediaSeekableEnd)!=null?a:0,L=u?Yt(0-(O-C)):Yt(C);return R?`${L}${t}${Yt(O)}`:L},Ec="video not loaded, unknown time.",yc=r=>{let t=r.mediaCurrentTime,e=r.mediaDuration||r.mediaSeekableEnd;if(t==null||e==null){r.setAttribute("aria-valuetext",Ec);return}let s=r.hasAttribute("remaining"),a=r.hasAttribute("show-duration"),u=s?_r(0-(e-t)):_r(t);if(!a){r.setAttribute("aria-valuetext",u);return}let R=_r(e),C=`${u} of ${R}`;r.setAttribute("aria-valuetext",C)},Na=class extends cr{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_CURRENT_TIME,G.MEDIA_DURATION,G.MEDIA_SEEKABLE,"remaining","show-duration","disabled"]}constructor(){super()}connectedCallback(){this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",lt.PLAYBACK_TIME()),super.connectedCallback()}disconnectedCallback(){this.disable()}attributeChangedCallback(t,e,s){if([G.MEDIA_CURRENT_TIME,G.MEDIA_DURATION,G.MEDIA_SEEKABLE,"remaining","show-duration"].includes(t)){let a=pc(this);yc(this),this.container.innerHTML=a}else t==="disabled"&&s!==e&&(s==null?this.enable():this.disable());super.attributeChangedCallback(t,e,s)}enable(){this.setAttribute("tabindex",0)}disable(){this.removeAttribute("tabindex")}get mediaDuration(){let t=this.getAttribute(G.MEDIA_DURATION);return t!=null?+t:void 0}get mediaCurrentTime(){let t=this.getAttribute(G.MEDIA_CURRENT_TIME);return t!=null?+t:void 0}get mediaSeekable(){let t=this.getAttribute(G.MEDIA_SEEKABLE);if(!!t)return t.split(":").map(e=>+e)}get mediaSeekableEnd(){var t;let[,e]=(t=this.mediaSeekable)!=null?t:[];return e}get mediaSeekableStart(){var t;let[e]=(t=this.mediaSeekable)!=null?t:[];return e}};ce("media-time-display",Na);var Tc=`<svg aria-hidden="true" viewBox="0 0 26 24">
448
+ `;var Tn=class extends se.HTMLElement{static get observedAttributes(){return[G.MEDIA_CONTROLLER]}constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ho.content.cloneNode(!0)),this.container=this.shadowRoot.querySelector("#container")}attributeChangedCallback(t,e,a){var s,u;if(t===G.MEDIA_CONTROLLER){if(e){let R=re.getElementById(e);(s=R==null?void 0:R.unassociateElement)==null||s.call(R,this)}if(a){let R=re.getElementById(a);(u=R==null?void 0:R.associateElement)==null||u.call(R,this)}}}connectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let a=re.getElementById(e);(t=a==null?void 0:a.associateElement)==null||t.call(a,this)}}disconnectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let a=re.getElementById(e);(t=a==null?void 0:a.unassociateElement)==null||t.call(a,this)}}};fe("media-text-display",Tn);var mr=Tn;var ja=class extends mr{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_CURRENT_TIME]}attributeChangedCallback(t,e,a){t===G.MEDIA_CURRENT_TIME&&(this.container.innerHTML=zt(a)),super.attributeChangedCallback(t,e,a)}};fe("media-current-time-display",ja);var Va=class extends mr{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_DURATION]}attributeChangedCallback(t,e,a){t===G.MEDIA_DURATION&&(this.container.innerHTML=zt(a)),super.attributeChangedCallback(t,e,a)}};fe("media-duration-display",Va);var xc="&nbsp;/&nbsp;",Lc=(r,{timesSep:t=xc}={})=>{var e,a,s;let u=r.getAttribute("remaining")!=null,R=r.getAttribute("show-duration")!=null,C=(e=r.mediaCurrentTime)!=null?e:0,O=(s=(a=r.mediaDuration)!=null?a:r.mediaSeekableEnd)!=null?s:0,L=u?zt(0-(O-C)):zt(C);return R?`${L}${t}${zt(O)}`:L},Dc="video not loaded, unknown time.",Ic=r=>{let t=r.mediaCurrentTime,e=r.mediaDuration||r.mediaSeekableEnd;if(t==null||e==null){r.setAttribute("aria-valuetext",Dc);return}let a=r.hasAttribute("remaining"),s=r.hasAttribute("show-duration"),u=a?Ir(0-(e-t)):Ir(t);if(!s){r.setAttribute("aria-valuetext",u);return}let R=Ir(e),C=`${u} of ${R}`;r.setAttribute("aria-valuetext",C)},$a=class extends mr{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_CURRENT_TIME,G.MEDIA_DURATION,G.MEDIA_SEEKABLE,"remaining","show-duration","disabled"]}constructor(){super()}connectedCallback(){this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",ut.PLAYBACK_TIME()),super.connectedCallback()}disconnectedCallback(){this.disable()}attributeChangedCallback(t,e,a){if([G.MEDIA_CURRENT_TIME,G.MEDIA_DURATION,G.MEDIA_SEEKABLE,"remaining","show-duration"].includes(t)){let s=Lc(this);Ic(this),this.container.innerHTML=s}else t==="disabled"&&a!==e&&(a==null?this.enable():this.disable());super.attributeChangedCallback(t,e,a)}enable(){this.setAttribute("tabindex",0)}disable(){this.removeAttribute("tabindex")}get mediaDuration(){let t=this.getAttribute(G.MEDIA_DURATION);return t!=null?+t:void 0}get mediaCurrentTime(){let t=this.getAttribute(G.MEDIA_CURRENT_TIME);return t!=null?+t:void 0}get mediaSeekable(){let t=this.getAttribute(G.MEDIA_SEEKABLE);if(!!t)return t.split(":").map(e=>+e)}get mediaSeekableEnd(){var t;let[,e]=(t=this.mediaSeekable)!=null?t:[];return e}get mediaSeekableStart(){var t;let[e]=(t=this.mediaSeekable)!=null?t:[];return e}};fe("media-time-display",$a);var Mc=`<svg aria-hidden="true" viewBox="0 0 26 24">
445
449
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
446
- </svg>`,bc=`<svg aria-hidden="true" viewBox="0 0 26 24">
450
+ </svg>`,Rc=`<svg aria-hidden="true" viewBox="0 0 26 24">
447
451
  <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
448
- </svg>`,wo=re.createElement("template");wo.innerHTML=`
452
+ </svg>`,jo=re.createElement("template");jo.innerHTML=`
449
453
  <style>
450
454
  :host([aria-checked="true"]) slot:not([name=on]) > *,
451
455
  :host([aria-checked="true"]) ::slotted(:not([slot=on])) {
@@ -459,15 +463,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
459
463
  }
460
464
  </style>
461
465
 
462
- <slot name="on">${Tc}</slot>
463
- <slot name="off">${bc}</slot>
464
- `;var ko=r=>{r.setAttribute("aria-checked",Da(r))},Ba=class extends Xe{static get observedAttributes(){return[...super.observedAttributes,"no-subtitles-fallback","default-showing",G.MEDIA_CAPTIONS_LIST,G.MEDIA_CAPTIONS_SHOWING,G.MEDIA_SUBTITLES_LIST,G.MEDIA_SUBTITLES_SHOWING]}constructor(t={}){super({slotTemplate:wo,...t}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",lt.CLOSED_CAPTIONS()),ko(this)}attributeChangedCallback(t,e,s){if([G.MEDIA_CAPTIONS_SHOWING,G.MEDIA_SUBTITLES_SHOWING].includes(t)&&ko(this),this.hasAttribute("default-showing")&&this.getAttribute("aria-checked")!=="true"){let a=!this.hasAttribute("no-subtitles-fallback");if((a?[G.MEDIA_CAPTIONS_LIST,G.MEDIA_SUBTITLES_LIST]:[G.MEDIA_CAPTIONS_LIST]).includes(t)){let R=!!this.getAttribute(G.MEDIA_CAPTIONS_LIST)||!!(a&&this.getAttribute(G.MEDIA_SUBTITLES_LIST));this._captionsReady!==R&&(this._captionsReady=R,this._captionsReady&&this.handleClick())}}super.attributeChangedCallback(t,e,s)}handleClick(t){dn(this)}};ce("media-captions-button",Ba);var Fa=30,Ac=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${Fa}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,Bo=re.createElement("template");Bo.innerHTML=`
465
- <slot name="forward">${Ac}</slot>
466
- `;var _c=0,Uo=r=>{let t=Math.abs(+r.getAttribute("seek-offset")),e=ze.SEEK_FORWARD_N_SECS({seekOffset:t});r.setAttribute("aria-label",e)},No=r=>{let t=sn(r,"forward"),e=r.getAttribute("seek-offset");an(t,e)},Ka=class extends Xe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_CURRENT_TIME,"seek-offset"]}constructor(t={}){super({slotTemplate:Bo,...t})}connectedCallback(){this.hasAttribute("seek-offset")||this.setAttribute("seek-offset",Fa),Uo(this),No(this),super.connectedCallback()}attributeChangedCallback(t,e,s){t==="seek-offset"&&(s==null&&this.setAttribute("seek-offset",Fa),No(this),Uo(this)),super.attributeChangedCallback(t,e,s)}handleClick(){let t=this.getAttribute(G.MEDIA_CURRENT_TIME),e=+this.getAttribute("seek-offset"),a=(t&&!Number.isNaN(+t)?+t:_c)+e,u=new ae.CustomEvent(de.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:a});this.dispatchEvent(u)}};ce("media-seek-forward-button",Ka);var Sc=`<svg aria-hidden="true" viewBox="0 0 26 24">
466
+ <slot name="on">${Mc}</slot>
467
+ <slot name="off">${Rc}</slot>
468
+ `;var Go=r=>{r.setAttribute("aria-checked",wa(r))},Ya=class extends Qe{static get observedAttributes(){return[...super.observedAttributes,"no-subtitles-fallback","default-showing",G.MEDIA_CAPTIONS_LIST,G.MEDIA_CAPTIONS_SHOWING,G.MEDIA_SUBTITLES_LIST,G.MEDIA_SUBTITLES_SHOWING]}constructor(t={}){super({slotTemplate:jo,...t}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",ut.CLOSED_CAPTIONS()),Go(this)}attributeChangedCallback(t,e,a){if([G.MEDIA_CAPTIONS_SHOWING,G.MEDIA_SUBTITLES_SHOWING].includes(t)&&Go(this),this.hasAttribute("default-showing")&&this.getAttribute("aria-checked")!=="true"){let s=!this.hasAttribute("no-subtitles-fallback");if((s?[G.MEDIA_CAPTIONS_LIST,G.MEDIA_SUBTITLES_LIST]:[G.MEDIA_CAPTIONS_LIST]).includes(t)){let R=!!this.getAttribute(G.MEDIA_CAPTIONS_LIST)||!!(s&&this.getAttribute(G.MEDIA_SUBTITLES_LIST));this._captionsReady!==R&&(this._captionsReady=R,this._captionsReady&&this.handleClick())}}super.attributeChangedCallback(t,e,a)}handleClick(t){mn(this)}};fe("media-captions-button",Ya);var za=30,Cc=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${za}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,Yo=re.createElement("template");Yo.innerHTML=`
469
+ <slot name="forward">${Cc}</slot>
470
+ `;var Oc=0,Vo=r=>{let t=Math.abs(+r.getAttribute("seek-offset")),e=Xe.SEEK_FORWARD_N_SECS({seekOffset:t});r.setAttribute("aria-label",e)},$o=r=>{let t=dn(r,"forward"),e=r.getAttribute("seek-offset");un(t,e)},Xa=class extends Qe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_CURRENT_TIME,"seek-offset"]}constructor(t={}){super({slotTemplate:Yo,...t})}connectedCallback(){this.hasAttribute("seek-offset")||this.setAttribute("seek-offset",za),Vo(this),$o(this),super.connectedCallback()}attributeChangedCallback(t,e,a){t==="seek-offset"&&(a==null&&this.setAttribute("seek-offset",za),$o(this),Vo(this)),super.attributeChangedCallback(t,e,a)}handleClick(){let t=this.getAttribute(G.MEDIA_CURRENT_TIME),e=+this.getAttribute("seek-offset"),s=(t&&!Number.isNaN(+t)?+t:Oc)+e,u=new se.CustomEvent(ce.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(u)}};fe("media-seek-forward-button",Xa);var Pc=`<svg aria-hidden="true" viewBox="0 0 26 24">
467
471
  <path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
468
- </svg>`,xc=`<svg aria-hidden="true" viewBox="0 0 26 24">
472
+ </svg>`,kc=`<svg aria-hidden="true" viewBox="0 0 26 24">
469
473
  <path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
470
- </svg>`,Ko=re.createElement("template");Ko.innerHTML=`
474
+ </svg>`,Xo=re.createElement("template");Xo.innerHTML=`
471
475
  <style>
472
476
  :host([${G.MEDIA_IS_FULLSCREEN}]) slot:not([name=exit]) > *,
473
477
  :host([${G.MEDIA_IS_FULLSCREEN}]) ::slotted(:not([slot=exit])) {
@@ -481,15 +485,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
481
485
  }
482
486
  </style>
483
487
 
484
- <slot name="enter">${Sc}</slot>
485
- <slot name="exit">${xc}</slot>
486
- `;var Fo=r=>{let e=r.getAttribute(G.MEDIA_IS_FULLSCREEN)!=null?ze.EXIT_FULLSCREEN():ze.ENTER_FULLSCREEN();r.setAttribute("aria-label",e)},Wa=class extends Xe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_IS_FULLSCREEN,G.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(t={}){super({slotTemplate:Ko,...t})}connectedCallback(){Fo(this),super.connectedCallback()}attributeChangedCallback(t,e,s){t===G.MEDIA_IS_FULLSCREEN&&Fo(this),super.attributeChangedCallback(t,e,s)}handleClick(t){let e=this.getAttribute(G.MEDIA_IS_FULLSCREEN)!=null?de.MEDIA_EXIT_FULLSCREEN_REQUEST:de.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new ae.CustomEvent(e,{composed:!0,bubbles:!0}))}};ce("media-fullscreen-button",Wa);var Lc=`<svg aria-hidden="true" viewBox="0 0 24 24">
488
+ <slot name="enter">${Pc}</slot>
489
+ <slot name="exit">${kc}</slot>
490
+ `;var zo=r=>{let e=r.getAttribute(G.MEDIA_IS_FULLSCREEN)!=null?Xe.EXIT_FULLSCREEN():Xe.ENTER_FULLSCREEN();r.setAttribute("aria-label",e)},Qa=class extends Qe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_IS_FULLSCREEN,G.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(t={}){super({slotTemplate:Xo,...t})}connectedCallback(){zo(this),super.connectedCallback()}attributeChangedCallback(t,e,a){t===G.MEDIA_IS_FULLSCREEN&&zo(this),super.attributeChangedCallback(t,e,a)}handleClick(t){let e=this.getAttribute(G.MEDIA_IS_FULLSCREEN)!=null?ce.MEDIA_EXIT_FULLSCREEN_REQUEST:ce.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new se.CustomEvent(e,{composed:!0,bubbles:!0}))}};fe("media-fullscreen-button",Qa);var wc=`<svg aria-hidden="true" viewBox="0 0 24 24">
487
491
  <path d="M16.5 12A4.5 4.5 0 0 0 14 8v2.18l2.45 2.45a4.22 4.22 0 0 0 .05-.63Zm2.5 0a6.84 6.84 0 0 1-.54 2.64L20 16.15A8.8 8.8 0 0 0 21 12a9 9 0 0 0-7-8.77v2.06A7 7 0 0 1 19 12ZM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25A6.92 6.92 0 0 1 14 18.7v2.06A9 9 0 0 0 17.69 19l2 2.05L21 19.73l-9-9L4.27 3ZM12 4 9.91 6.09 12 8.18V4Z"/>
488
- </svg>`,Wo=`<svg aria-hidden="true" viewBox="0 0 24 24">
492
+ </svg>`,Qo=`<svg aria-hidden="true" viewBox="0 0 24 24">
489
493
  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4Z"/>
490
- </svg>`,Dc=`<svg aria-hidden="true" viewBox="0 0 24 24">
494
+ </svg>`,Uc=`<svg aria-hidden="true" viewBox="0 0 24 24">
491
495
  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4ZM14 3.23v2.06a7 7 0 0 1 0 13.42v2.06a9 9 0 0 0 0-17.54Z"/>
492
- </svg>`,Go=re.createElement("template");Go.innerHTML=`
496
+ </svg>`,Jo=re.createElement("template");Jo.innerHTML=`
493
497
  <style>
494
498
 
495
499
  :host(:not([${G.MEDIA_VOLUME_LEVEL}])) slot:not([name=high]) > *,
@@ -515,13 +519,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
515
519
  }
516
520
  </style>
517
521
 
518
- <slot name="off">${Lc}</slot>
519
- <slot name="low">${Wo}</slot>
520
- <slot name="medium">${Wo}</slot>
521
- <slot name="high">${Dc}</slot>
522
- `;var Ho=r=>{let e=r.getAttribute(G.MEDIA_VOLUME_LEVEL)==="off"?ze.UNMUTE():ze.MUTE();r.setAttribute("aria-label",e)},Ha=class extends Xe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_VOLUME_LEVEL]}constructor(t={}){super({slotTemplate:Go,...t})}connectedCallback(){Ho(this),super.connectedCallback()}attributeChangedCallback(t,e,s){t===G.MEDIA_VOLUME_LEVEL&&Ho(this),super.attributeChangedCallback(t,e,s)}handleClick(t){let e=this.getAttribute(G.MEDIA_VOLUME_LEVEL)==="off"?de.MEDIA_UNMUTE_REQUEST:de.MEDIA_MUTE_REQUEST;this.dispatchEvent(new ae.CustomEvent(e,{composed:!0,bubbles:!0}))}};ce("media-mute-button",Ha);var jo=`<svg aria-hidden="true" viewBox="0 0 28 24">
522
+ <slot name="off">${wc}</slot>
523
+ <slot name="low">${Qo}</slot>
524
+ <slot name="medium">${Qo}</slot>
525
+ <slot name="high">${Uc}</slot>
526
+ `;var Zo=r=>{let e=r.getAttribute(G.MEDIA_VOLUME_LEVEL)==="off"?Xe.UNMUTE():Xe.MUTE();r.setAttribute("aria-label",e)},Za=class extends Qe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_VOLUME_LEVEL]}constructor(t={}){super({slotTemplate:Jo,...t})}connectedCallback(){Zo(this),super.connectedCallback()}attributeChangedCallback(t,e,a){t===G.MEDIA_VOLUME_LEVEL&&Zo(this),super.attributeChangedCallback(t,e,a)}handleClick(t){let e=this.getAttribute(G.MEDIA_VOLUME_LEVEL)==="off"?ce.MEDIA_UNMUTE_REQUEST:ce.MEDIA_MUTE_REQUEST;this.dispatchEvent(new se.CustomEvent(e,{composed:!0,bubbles:!0}))}};fe("media-mute-button",Za);var qo=`<svg aria-hidden="true" viewBox="0 0 28 24">
523
527
  <path d="M24 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h20a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Zm-1 16H5V5h18v14Zm-3-8h-7v5h7v-5Z"/>
524
- </svg>`,$o=re.createElement("template");$o.innerHTML=`
528
+ </svg>`,tl=re.createElement("template");tl.innerHTML=`
525
529
  <style>
526
530
  :host([${G.MEDIA_IS_PIP}]) slot:not([name=exit]) > *,
527
531
  :host([${G.MEDIA_IS_PIP}]) ::slotted(:not([slot=exit])) {
@@ -535,13 +539,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
535
539
  }
536
540
  </style>
537
541
 
538
- <slot name="enter">${jo}</slot>
539
- <slot name="exit">${jo}</slot>
540
- `;var Vo=r=>{let e=r.getAttribute(G.MEDIA_IS_PIP)!=null?ze.EXIT_PIP():ze.ENTER_PIP();r.setAttribute("aria-label",e)},Ga=class extends Xe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_IS_PIP,G.MEDIA_PIP_UNAVAILABLE]}constructor(t={}){super({slotTemplate:$o,...t})}connectedCallback(){Vo(this),super.connectedCallback()}attributeChangedCallback(t,e,s){t===G.MEDIA_IS_PIP&&Vo(this),super.attributeChangedCallback(t,e,s)}handleClick(t){let e=this.getAttribute(G.MEDIA_IS_PIP)!=null?de.MEDIA_EXIT_PIP_REQUEST:de.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new ae.CustomEvent(e,{composed:!0,bubbles:!0}))}};ce("media-pip-button",Ga);var Ic=`<svg aria-hidden="true" viewBox="0 0 24 24">
542
+ <slot name="enter">${qo}</slot>
543
+ <slot name="exit">${qo}</slot>
544
+ `;var el=r=>{let e=r.getAttribute(G.MEDIA_IS_PIP)!=null?Xe.EXIT_PIP():Xe.ENTER_PIP();r.setAttribute("aria-label",e)},Ja=class extends Qe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_IS_PIP,G.MEDIA_PIP_UNAVAILABLE]}constructor(t={}){super({slotTemplate:tl,...t})}connectedCallback(){el(this),super.connectedCallback()}attributeChangedCallback(t,e,a){t===G.MEDIA_IS_PIP&&el(this),super.attributeChangedCallback(t,e,a)}handleClick(t){let e=this.getAttribute(G.MEDIA_IS_PIP)!=null?ce.MEDIA_EXIT_PIP_REQUEST:ce.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new se.CustomEvent(e,{composed:!0,bubbles:!0}))}};fe("media-pip-button",Ja);var Nc=`<svg aria-hidden="true" viewBox="0 0 24 24">
541
545
  <path d="m6 21 15-9L6 3v18Z"/>
542
- </svg>`,Mc=`<svg aria-hidden="true" viewBox="0 0 24 24">
546
+ </svg>`,Bc=`<svg aria-hidden="true" viewBox="0 0 24 24">
543
547
  <path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
544
- </svg>`,zo=re.createElement("template");zo.innerHTML=`
548
+ </svg>`,il=re.createElement("template");il.innerHTML=`
545
549
  <style>
546
550
  :host([${G.MEDIA_PAUSED}]) slot[name=pause] > *,
547
551
  :host([${G.MEDIA_PAUSED}]) ::slotted([slot=pause]) {
@@ -554,11 +558,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
554
558
  }
555
559
  </style>
556
560
 
557
- <slot name="play">${Ic}</slot>
558
- <slot name="pause">${Mc}</slot>
559
- `;var Yo=r=>{let e=r.getAttribute(G.MEDIA_PAUSED)!=null?ze.PLAY():ze.PAUSE();r.setAttribute("aria-label",e)},ja=class extends Xe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_PAUSED]}constructor(t={}){super({slotTemplate:zo,...t})}connectedCallback(){Yo(this),super.connectedCallback()}attributeChangedCallback(t,e,s){t===G.MEDIA_PAUSED&&Yo(this),super.attributeChangedCallback(t,e,s)}handleClick(t){let e=this.getAttribute(G.MEDIA_PAUSED)!=null?de.MEDIA_PLAY_REQUEST:de.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new ae.CustomEvent(e,{composed:!0,bubbles:!0}))}};ce("media-play-button",ja);var Xo=[1,1.25,1.5,1.75,2],En=1,Qo=re.createElement("template");Qo.innerHTML=`
561
+ <slot name="play">${Nc}</slot>
562
+ <slot name="pause">${Bc}</slot>
563
+ `;var rl=r=>{let e=r.getAttribute(G.MEDIA_PAUSED)!=null?Xe.PLAY():Xe.PAUSE();r.setAttribute("aria-label",e)},qa=class extends Qe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_PAUSED]}constructor(t={}){super({slotTemplate:il,...t})}connectedCallback(){rl(this),super.connectedCallback()}attributeChangedCallback(t,e,a){t===G.MEDIA_PAUSED&&rl(this),super.attributeChangedCallback(t,e,a)}handleClick(t){let e=this.getAttribute(G.MEDIA_PAUSED)!=null?ce.MEDIA_PLAY_REQUEST:ce.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new se.CustomEvent(e,{composed:!0,bubbles:!0}))}};fe("media-play-button",qa);var nl=[1,1.25,1.5,1.75,2],bn=1,al=re.createElement("template");al.innerHTML=`
560
564
  <span id="container"></span>
561
- `;var Va=class extends Xe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_PLAYBACK_RATE,"rates"]}constructor(t={}){super({slotTemplate:Qo,...t}),this._rates=Xo,this.container=this.shadowRoot.querySelector("#container"),this.container.innerHTML=`${En}x`}attributeChangedCallback(t,e,s){if(t==="rates"){let a=(s!=null?s:"").trim().split(/\s*,?\s+/).map(u=>Number(u)).filter(u=>!Number.isNaN(u)).sort((u,R)=>u-R);this._rates=a.length?a:Xo;return}if(t===G.MEDIA_PLAYBACK_RATE){let a=s?+s:Number.NaN,u=Number.isNaN(a)?En:a;this.container.innerHTML=`${u}x`,this.setAttribute("aria-label",lt.PLAYBACK_RATE({playbackRate:u}));return}super.attributeChangedCallback(t,e,s)}handleClick(t){var e,s;let a=+this.getAttribute(G.MEDIA_PLAYBACK_RATE)||En,u=(s=(e=this._rates.find(C=>C>a))!=null?e:this._rates[0])!=null?s:En,R=new ae.CustomEvent(de.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:u});this.dispatchEvent(R)}};ce("media-playback-rate-button",Va);var Zo=re.createElement("template");Zo.innerHTML=`
565
+ `;var es=class extends Qe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_PLAYBACK_RATE,"rates"]}constructor(t={}){super({slotTemplate:al,...t}),this._rates=nl,this.container=this.shadowRoot.querySelector("#container"),this.container.innerHTML=`${bn}x`}attributeChangedCallback(t,e,a){if(t==="rates"){let s=(a!=null?a:"").trim().split(/\s*,?\s+/).map(u=>Number(u)).filter(u=>!Number.isNaN(u)).sort((u,R)=>u-R);this._rates=s.length?s:nl;return}if(t===G.MEDIA_PLAYBACK_RATE){let s=a?+a:Number.NaN,u=Number.isNaN(s)?bn:s;this.container.innerHTML=`${u}x`,this.setAttribute("aria-label",ut.PLAYBACK_RATE({playbackRate:u}));return}super.attributeChangedCallback(t,e,a)}handleClick(t){var e,a;let s=+this.getAttribute(G.MEDIA_PLAYBACK_RATE)||bn,u=(a=(e=this._rates.find(C=>C>s))!=null?e:this._rates[0])!=null?a:bn,R=new se.CustomEvent(ce.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:u});this.dispatchEvent(R)}};fe("media-playback-rate-button",es);var sl=re.createElement("template");sl.innerHTML=`
562
566
  <style>
563
567
  :host {
564
568
  pointer-events: none;
@@ -584,7 +588,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
584
588
  </style>
585
589
 
586
590
  <img aria-hidden="true" id="image"/>
587
- `;var Rc=r=>{r.style.removeProperty("background-image")},Cc=(r,t)=>{r.style["background-image"]=`url('${t}')`},$a=class extends ae.HTMLElement{static get observedAttributes(){return[G.MEDIA_HAS_PLAYED,"placeholder-src","src"]}constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Zo.content.cloneNode(!0)),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(t,e,s){t==="src"&&(s==null?this.image.removeAttribute("src"):this.image.setAttribute("src",s)),t==="placeholder-src"&&(s==null?Rc(this.image):Cc(this.image,s))}};ce("media-poster-image",$a);var Ja=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)},bt=(r,t,e)=>(Ja(r,t,"read from private field"),e?e.call(r):t.get(r)),zt=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},Mi=(r,t,e,s)=>(Ja(r,t,"write to private field"),s?s.call(r,e):t.set(r,e),e),Ya=(r,t,e)=>(Ja(r,t,"access private method"),e),Ri,yn,Tn,Zr,Ci,Xa,An,Sn,bn,Qa,Za,qo,Oc="video not loaded, unknown time.",za=r=>{let t=r.range,e=_r(+t.value),s=_r(+t.max),a=e&&s?`${e} of ${s}`:Oc;t.setAttribute("aria-valuetext",a)},el=re.createElement("template");el.innerHTML=`
591
+ `;var Fc=r=>{r.style.removeProperty("background-image")},Kc=(r,t)=>{r.style["background-image"]=`url('${t}')`},ts=class extends se.HTMLElement{static get observedAttributes(){return[G.MEDIA_HAS_PLAYED,"placeholder-src","src"]}constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(sl.content.cloneNode(!0)),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(t,e,a){t==="src"&&(a==null?this.image.removeAttribute("src"):this.image.setAttribute("src",a)),t==="placeholder-src"&&(a==null?Fc(this.image):Kc(this.image,a))}};fe("media-poster-image",ts);var os=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)},At=(r,t,e)=>(os(r,t,"read from private field"),e?e.call(r):t.get(r)),Xt=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},Ci=(r,t,e,a)=>(os(r,t,"write to private field"),a?a.call(r,e):t.set(r,e),e),rs=(r,t,e)=>(os(r,t,"access private method"),e),Oi,An,_n,Jr,Pi,ns,xn,Dn,Sn,as,ss,ll,Wc="video not loaded, unknown time.",is=r=>{let t=r.range,e=Ir(+t.value),a=Ir(+t.max),s=e&&a?`${e} of ${a}`:Wc;t.setAttribute("aria-valuetext",s)},ul=re.createElement("template");ul.innerHTML=`
588
592
  <style>
589
593
  :host {
590
594
  --media-preview-background-color: rgba(20,20,30, .5);
@@ -596,13 +600,24 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
596
600
  color: #fff;
597
601
  }
598
602
 
603
+ #preview-rail,
604
+ #current-rail {
605
+
606
+ width: 1%;
607
+ position: absolute;
608
+ left: 0;
609
+ bottom: 100%;
610
+ pointer-events: none;
611
+ }
612
+
599
613
  [part~="box"] {
614
+
615
+ position: absolute;
616
+ bottom: 100%;
600
617
  display: flex;
601
618
  flex-direction: column;
602
619
  align-items: center;
603
- position: absolute;
604
- left: 0;
605
- bottom: 100%;
620
+ transform: translateX(-50%);
606
621
  }
607
622
 
608
623
  [part~="preview-box"] {
@@ -666,20 +681,20 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
666
681
  --media-time-range-hover-display: block;
667
682
  }
668
683
  </style>
669
- <span part="box preview-box">
670
- <slot name="preview">
684
+ <div id="preview-rail">
685
+ <slot name="preview" part="box preview-box">
671
686
  <media-preview-thumbnail></media-preview-thumbnail>
672
687
  <media-preview-time-display></media-preview-time-display>
673
688
  </slot>
674
- </span>
675
- <span part="box current-box">
676
- <slot name="current">
689
+ </div>
690
+ <div id="current-rail">
691
+ <slot name="current" part="box current-box">
677
692
 
678
693
  </slot>
679
- </span>
680
- `;var _n=class extends Ii{constructor(){super(),zt(this,bn),zt(this,Za),zt(this,Ri,void 0),zt(this,yn,void 0),zt(this,Tn,t=>{if([...bt(this,Ri)].some(L=>t.composedPath().includes(L)))return;this.updatePointerBar(t);let e=+this.getAttribute(G.MEDIA_DURATION);if(!e)return;let s=this.range.getBoundingClientRect(),a=(t.clientX-s.left)/s.width;a=Math.max(0,Math.min(1,a));let u=Jo(this,bt(this,yn),a),{style:R}=tr(this.shadowRoot,'[part~="preview-box"]');R.transform=`translateX(${u}px)`;let C=a*e,O=new ae.CustomEvent(de.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:C});this.dispatchEvent(O)}),zt(this,Zr,!1),zt(this,Ci,t=>{(!t.composedPath().includes(this)||[...bt(this,Ri)].some(e=>t.composedPath().includes(e)))&&(ae.removeEventListener("pointermove",bt(this,Ci)),Mi(this,Zr,!1),bt(this,An).call(this))}),zt(this,Xa,()=>{ae.addEventListener("pointermove",bt(this,Tn),!1)}),zt(this,An,()=>{ae.removeEventListener("pointermove",bt(this,Tn));let t=new ae.CustomEvent(de.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:null});this.dispatchEvent(t)}),zt(this,Sn,()=>{let t=this.getAttribute(G.MEDIA_DURATION);!bt(this,Zr)&&t&&(Mi(this,Zr,!0),bt(this,Xa).call(this),ae.addEventListener("pointermove",bt(this,Ci),!1))}),this.shadowRoot.appendChild(el.content.cloneNode(!0)),this.range.addEventListener("input",()=>{cancelAnimationFrame(this._refreshId);let e=this.range.value,s=new ae.CustomEvent(de.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(s)}),this._refreshBar=()=>{let t=(performance.now()-this._updateTimestamp)/1e3;this.range.value=this.mediaCurrentTime+t*this.mediaPlaybackRate,this.updateBar(),this.updateCurrentBox(),this._refreshId=requestAnimationFrame(this._refreshBar)},Mi(this,Ri,this.shadowRoot.querySelectorAll('[part~="box"]')),Mi(this,yn,this.shadowRoot.querySelector('[part~="preview-box"]')),Ya(this,bn,Qa).call(this)}static get observedAttributes(){return[...super.observedAttributes,"thumbnails","disabled",G.MEDIA_PAUSED,G.MEDIA_DURATION,G.MEDIA_SEEKABLE,G.MEDIA_CURRENT_TIME,G.MEDIA_PREVIEW_IMAGE,G.MEDIA_PREVIEW_TIME,G.MEDIA_BUFFERED,G.MEDIA_PLAYBACK_RATE,G.MEDIA_LOADING]}connectedCallback(){this.range.setAttribute("aria-label",lt.SEEK()),super.connectedCallback()}disconnectedCallback(){cancelAnimationFrame(this._refreshId),super.disconnectedCallback()}attributeChangedCallback(t,e,s){var a,u,R,C,O;(t===G.MEDIA_CURRENT_TIME||t===G.MEDIA_PAUSED||t===G.MEDIA_LOADING)&&(this._updateTimestamp=performance.now(),this.range.value=this.mediaCurrentTime,za(this),this.updateBar(),this.updateCurrentBox(),cancelAnimationFrame(this._refreshId),!this.mediaPaused&&!this.mediaLoading&&(this._refreshId=requestAnimationFrame(this._refreshBar))),t===G.MEDIA_DURATION&&(this.range.max=Math.floor((u=(a=this.mediaSeekableEnd)!=null?a:this.mediaDuration)!=null?u:1e3),za(this),this.updateBar(),this.updateCurrentBox()),t===G.MEDIA_SEEKABLE&&(this.range.min=(R=this.mediaSeekableStart)!=null?R:0,this.range.max=Math.floor((O=(C=this.mediaSeekableEnd)!=null?C:this.mediaDuration)!=null?O:1e3),za(this),this.updateBar()),t===G.MEDIA_BUFFERED&&this.updateBar(),t==="disabled"&&(s==null?Ya(this,bn,Qa).call(this):Ya(this,Za,qo).call(this)),super.attributeChangedCallback(t,e,s)}get mediaPaused(){return this.hasAttribute(G.MEDIA_PAUSED)}get mediaLoading(){return this.hasAttribute(G.MEDIA_LOADING)}get mediaDuration(){let t=this.getAttribute(G.MEDIA_DURATION);return t!=null?+t:void 0}get mediaCurrentTime(){let t=this.getAttribute(G.MEDIA_CURRENT_TIME);return t!=null?+t:void 0}get mediaPlaybackRate(){let t=this.getAttribute(G.MEDIA_PLAYBACK_RATE);return t!=null?+t:1}get mediaBuffered(){let t=this.getAttribute(G.MEDIA_BUFFERED);return t?t.split(" ").map(e=>e.split(":").map(s=>+s)):[]}get mediaSeekable(){let t=this.getAttribute(G.MEDIA_SEEKABLE);if(!!t)return t.split(":").map(e=>+e)}get mediaSeekableEnd(){var t;let[,e]=(t=this.mediaSeekable)!=null?t:[];return e}get mediaSeekableStart(){var t;let[e]=(t=this.mediaSeekable)!=null?t:[];return e}getBarColors(){var t;let e=super.getBarColors(),{range:s}=this,a=s.max-s.min,u=this.mediaBuffered;if(!u.length||!Number.isFinite(a)||a<=0)return e;let R=this.mediaCurrentTime,[,C=s.min]=(t=u.find(([b,x])=>b<=R&&R<=x))!=null?t:[],L=(C-s.min)/a*100;return e.splice(1,0,["var(--media-time-buffered-color, rgba(255,255,255, .4))",L]),e}updateCurrentBox(){let t=this.shadowRoot.querySelector('[part~="current-box"]'),e=this.range.value/(this.range.max-this.range.min),s=Jo(this,t,e),{style:a}=tr(this.shadowRoot,'[part~="current-box"]');a.transform=`translateX(${s}px)`}};Ri=new WeakMap;yn=new WeakMap;Tn=new WeakMap;Zr=new WeakMap;Ci=new WeakMap;Xa=new WeakMap;An=new WeakMap;Sn=new WeakMap;bn=new WeakSet;Qa=function(){this.addEventListener("pointermove",bt(this,Sn),!1)};Za=new WeakSet;qo=function(){ae.removeEventListener("pointermove",bt(this,Ci)),this.removeEventListener("pointermove",bt(this,Sn)),Mi(this,Zr,!1),bt(this,An).call(this)};function Jo(r,t,e){var s;let a=r.getBoundingClientRect(),u=r.range.getBoundingClientRect(),R=parseInt(getComputedStyle(r).getPropertyValue("--media-box-padding-left")),C=parseInt(getComputedStyle(r).getPropertyValue("--media-box-padding-right")),O=R+e*u.width,L=t.offsetWidth,b=O-L/2,I=((s=r.getAttribute("media-bounds")?bi(r,`#${r.getAttribute("media-bounds")}`):r.parentElement)!=null?s:r).getBoundingClientRect(),_=a.left-I.left,A=I.right-a.left-L-C,S=R-_;return Math.max(S,Math.min(b,A))}ce("media-time-range",_n);var qa=_n;var es=class extends qa{constructor(){super(),console.warn("MediaChrome: <media-progress-range> is deprecated. Use <media-time-range> instead.")}};ce("media-progress-range",es);var ts=30,Pc=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${ts}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,il=re.createElement("template");il.innerHTML=`
681
- <slot name="backward">${Pc}</slot>
682
- `;var kc=0,tl=r=>{let t=Math.abs(+r.getAttribute("seek-offset")),e=ze.SEEK_BACK_N_SECS({seekOffset:t});r.setAttribute("aria-label",e)},rl=r=>{let t=sn(r,"backward"),e=r.getAttribute("seek-offset");an(t,e)},rs=class extends Xe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_CURRENT_TIME]}constructor(t={}){super({slotTemplate:il,...t})}connectedCallback(){this.hasAttribute("seek-offset")||this.setAttribute("seek-offset",ts),tl(this),rl(this),super.connectedCallback()}attributeChangedCallback(t,e,s){t==="seek-offset"&&(s==null&&this.setAttribute("seek-offset",ts),rl(this),tl(this)),super.attributeChangedCallback(t,e,s)}handleClick(){let t=this.getAttribute(G.MEDIA_CURRENT_TIME),e=+this.getAttribute("seek-offset"),s=t&&!Number.isNaN(+t)?+t:kc,a=Math.max(s-e,0),u=new ae.CustomEvent(de.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:a});this.dispatchEvent(u)}};ce("media-seek-backward-button",rs);var is=class extends cr{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_PREVIEW_TIME]}attributeChangedCallback(t,e,s){t===G.MEDIA_PREVIEW_TIME&&s!=null&&(this.container.textContent=Yt(s)),super.attributeChangedCallback(t,e,s)}};ce("media-preview-time-display",is);var nl=re.createElement("template");nl.innerHTML=`
694
+ </div>
695
+ `;var Ln=class extends Ri{constructor(){super(),Xt(this,Sn),Xt(this,ss),Xt(this,Oi,void 0),Xt(this,An,void 0),Xt(this,_n,t=>{if([...At(this,Oi)].some(L=>t.composedPath().includes(L)))return;this.updatePointerBar(t);let e=+this.getAttribute(G.MEDIA_DURATION);if(!e)return;let a=this.range.getBoundingClientRect(),s=(t.clientX-a.left)/a.width;s=Math.max(0,Math.min(1,s));let u=ol(this,At(this,An),s),{style:R}=qt(this.shadowRoot,"#preview-rail");R.transform=`translateX(${u})`;let C=s*e,O=new se.CustomEvent(ce.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:C});this.dispatchEvent(O)}),Xt(this,Jr,!1),Xt(this,Pi,t=>{(!t.composedPath().includes(this)||[...At(this,Oi)].some(e=>t.composedPath().includes(e)))&&(se.removeEventListener("pointermove",At(this,Pi)),Ci(this,Jr,!1),At(this,xn).call(this))}),Xt(this,ns,()=>{se.addEventListener("pointermove",At(this,_n),!1)}),Xt(this,xn,()=>{se.removeEventListener("pointermove",At(this,_n));let t=new se.CustomEvent(ce.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:null});this.dispatchEvent(t)}),Xt(this,Dn,()=>{let t=this.getAttribute(G.MEDIA_DURATION);!At(this,Jr)&&t&&(Ci(this,Jr,!0),At(this,ns).call(this),se.addEventListener("pointermove",At(this,Pi),!1))}),this.container.appendChild(ul.content.cloneNode(!0)),this.range.addEventListener("input",()=>{cancelAnimationFrame(this._refreshId);let e=this.range.value,a=new se.CustomEvent(ce.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(a)}),this._refreshBar=()=>{let t=(performance.now()-this._updateTimestamp)/1e3;this.range.value=this.mediaCurrentTime+t*this.mediaPlaybackRate,this.updateBar(),this.updateCurrentBox(),this._refreshId=requestAnimationFrame(this._refreshBar)},Ci(this,Oi,this.shadowRoot.querySelectorAll('[part~="box"]')),Ci(this,An,this.shadowRoot.querySelector('[part~="preview-box"]')),rs(this,Sn,as).call(this)}static get observedAttributes(){return[...super.observedAttributes,"thumbnails","disabled",G.MEDIA_PAUSED,G.MEDIA_DURATION,G.MEDIA_SEEKABLE,G.MEDIA_CURRENT_TIME,G.MEDIA_PREVIEW_IMAGE,G.MEDIA_PREVIEW_TIME,G.MEDIA_BUFFERED,G.MEDIA_PLAYBACK_RATE,G.MEDIA_LOADING]}connectedCallback(){this.range.setAttribute("aria-label",ut.SEEK()),super.connectedCallback()}disconnectedCallback(){cancelAnimationFrame(this._refreshId),super.disconnectedCallback()}attributeChangedCallback(t,e,a){var s,u,R,C,O;(t===G.MEDIA_CURRENT_TIME||t===G.MEDIA_PAUSED||t===G.MEDIA_LOADING)&&(this._updateTimestamp=performance.now(),this.range.value=this.mediaCurrentTime,is(this),this.updateBar(),this.updateCurrentBox(),cancelAnimationFrame(this._refreshId),!this.mediaPaused&&!this.mediaLoading&&(this._refreshId=requestAnimationFrame(this._refreshBar))),t===G.MEDIA_DURATION&&(this.range.max=Math.floor((u=(s=this.mediaSeekableEnd)!=null?s:this.mediaDuration)!=null?u:1e3),is(this),this.updateBar(),this.updateCurrentBox()),t===G.MEDIA_SEEKABLE&&(this.range.min=(R=this.mediaSeekableStart)!=null?R:0,this.range.max=Math.floor((O=(C=this.mediaSeekableEnd)!=null?C:this.mediaDuration)!=null?O:1e3),is(this),this.updateBar()),t===G.MEDIA_BUFFERED&&this.updateBar(),t==="disabled"&&(a==null?rs(this,Sn,as).call(this):rs(this,ss,ll).call(this)),super.attributeChangedCallback(t,e,a)}get mediaPaused(){return this.hasAttribute(G.MEDIA_PAUSED)}get mediaLoading(){return this.hasAttribute(G.MEDIA_LOADING)}get mediaDuration(){let t=this.getAttribute(G.MEDIA_DURATION);return t!=null?+t:void 0}get mediaCurrentTime(){let t=this.getAttribute(G.MEDIA_CURRENT_TIME);return t!=null?+t:void 0}get mediaPlaybackRate(){let t=this.getAttribute(G.MEDIA_PLAYBACK_RATE);return t!=null?+t:1}get mediaBuffered(){let t=this.getAttribute(G.MEDIA_BUFFERED);return t?t.split(" ").map(e=>e.split(":").map(a=>+a)):[]}get mediaSeekable(){let t=this.getAttribute(G.MEDIA_SEEKABLE);if(!!t)return t.split(":").map(e=>+e)}get mediaSeekableEnd(){var t;let[,e]=(t=this.mediaSeekable)!=null?t:[];return e}get mediaSeekableStart(){var t;let[e]=(t=this.mediaSeekable)!=null?t:[];return e}getBarColors(){var t;let e=super.getBarColors(),{range:a}=this,s=a.max-a.min,u=this.mediaBuffered;if(!u.length||!Number.isFinite(s)||s<=0)return e;let R=this.mediaCurrentTime,[,C=a.min]=(t=u.find(([b,x])=>b<=R&&R<=x))!=null?t:[],L=(C-a.min)/s*100;return e.splice(1,0,["var(--media-time-buffered-color, rgba(255,255,255, .4))",L]),e}updateCurrentBox(){let t=this.shadowRoot.querySelector('[part~="current-box"]'),e=this.range.value/(this.range.max-this.range.min),a=ol(this,t,e),{style:s}=qt(this.shadowRoot,"#current-rail");s.transform=`translateX(${a})`}};Oi=new WeakMap;An=new WeakMap;_n=new WeakMap;Jr=new WeakMap;Pi=new WeakMap;ns=new WeakMap;xn=new WeakMap;Dn=new WeakMap;Sn=new WeakSet;as=function(){this.addEventListener("pointermove",At(this,Dn),!1)};ss=new WeakSet;ll=function(){se.removeEventListener("pointermove",At(this,Pi)),this.removeEventListener("pointermove",At(this,Dn)),Ci(this,Jr,!1),At(this,xn).call(this)};function ol(r,t,e){var a;let s=`${e*100*100}%`,u=t.offsetWidth;if(!u)return s;let R=(a=r.getAttribute("bounds")?_i(r,`#${r.getAttribute("bounds")}`):r.parentElement)!=null?a:r,C=parseInt(getComputedStyle(r).getPropertyValue("--media-box-padding-left")),O=parseInt(getComputedStyle(r).getPropertyValue("--media-box-padding-right")),L=r.range.getBoundingClientRect(),b=R.getBoundingClientRect(),x=(C-(L.left-b.left-u/2))/L.width*100,I=(b.right-L.left-u/2-O)/L.width*100;return Number.isNaN(x)||(s=`max(${x*100}%, ${s})`),Number.isNaN(I)||(s=`min(${s}, ${I*100}%)`),s}fe("media-time-range",Ln);var ls=Ln;var us=class extends ls{constructor(){super(),console.warn("MediaChrome: <media-progress-range> is deprecated. Use <media-time-range> instead.")}};fe("media-progress-range",us);var ds=30,Hc=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${ds}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,fl=re.createElement("template");fl.innerHTML=`
696
+ <slot name="backward">${Hc}</slot>
697
+ `;var Gc=0,dl=r=>{let t=Math.abs(+r.getAttribute("seek-offset")),e=Xe.SEEK_BACK_N_SECS({seekOffset:t});r.setAttribute("aria-label",e)},cl=r=>{let t=dn(r,"backward"),e=r.getAttribute("seek-offset");un(t,e)},cs=class extends Qe{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_CURRENT_TIME]}constructor(t={}){super({slotTemplate:fl,...t})}connectedCallback(){this.hasAttribute("seek-offset")||this.setAttribute("seek-offset",ds),dl(this),cl(this),super.connectedCallback()}attributeChangedCallback(t,e,a){t==="seek-offset"&&(a==null&&this.setAttribute("seek-offset",ds),cl(this),dl(this)),super.attributeChangedCallback(t,e,a)}handleClick(){let t=this.getAttribute(G.MEDIA_CURRENT_TIME),e=+this.getAttribute("seek-offset"),a=t&&!Number.isNaN(+t)?+t:Gc,s=Math.max(a-e,0),u=new se.CustomEvent(ce.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(u)}};fe("media-seek-backward-button",cs);var fs=class extends mr{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_PREVIEW_TIME]}attributeChangedCallback(t,e,a){t===G.MEDIA_PREVIEW_TIME&&a!=null&&(this.container.textContent=zt(a)),super.attributeChangedCallback(t,e,a)}};fe("media-preview-time-display",fs);var hl=re.createElement("template");hl.innerHTML=`
683
698
  <style>
684
699
  :host {
685
700
  box-sizing: border-box;
@@ -693,7 +708,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
693
708
  }
694
709
  </style>
695
710
  <img crossorigin loading="eager" decoding="async" />
696
- `;var ns=class extends ae.HTMLElement{static get observedAttributes(){return[G.MEDIA_CONTROLLER,"time",G.MEDIA_PREVIEW_IMAGE,G.MEDIA_PREVIEW_COORDS]}constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(nl.content.cloneNode(!0))}connectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let s=re.getElementById(e);(t=s==null?void 0:s.associateElement)==null||t.call(s,this)}}disconnectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let s=re.getElementById(e);(t=s==null?void 0:s.unassociateElement)==null||t.call(s,this)}}attributeChangedCallback(t,e,s){var a,u;if(["time",G.MEDIA_PREVIEW_IMAGE,G.MEDIA_PREVIEW_COORDS].includes(t)&&this.update(),t===G.MEDIA_CONTROLLER){if(e){let R=re.getElementById(e);(a=R==null?void 0:R.unassociateElement)==null||a.call(R,this)}if(s){let R=re.getElementById(s);(u=R==null?void 0:R.associateElement)==null||u.call(R,this)}}}update(){let t=this.getAttribute(G.MEDIA_PREVIEW_COORDS),e=this.getAttribute(G.MEDIA_PREVIEW_IMAGE);if(!(t&&e))return;let[s,a,u,R]=t.split(/\s+/).map(o=>+o),C=e.split("#")[0],O=getComputedStyle(this),{maxWidth:L,maxHeight:b,minWidth:x,minHeight:I}=O,_=Math.min(parseInt(L)/u,parseInt(b)/R),A=Math.max(parseInt(x)/u,parseInt(I)/R),S=_<1,v=S?_:A>1?A:1,{style:i}=tr(this.shadowRoot,":host"),d=tr(this.shadowRoot,"img").style,p=this.shadowRoot.querySelector("img"),T=S?"min":"max";i.setProperty(`${T}-width`,"initial","important"),i.setProperty(`${T}-height`,"initial","important"),i.width=`${u*v}px`,i.height=`${R*v}px`;let l=()=>{d.width=`${this.imgWidth*v}px`,d.height=`${this.imgHeight*v}px`,d.display="block"};p.src!==C&&(p.onload=()=>{this.imgWidth=p.naturalWidth,this.imgHeight=p.naturalHeight,l()},p.src=C,l()),l(),d.transform=`translate(-${s*v}px, -${a*v}px)`}};ce("media-preview-thumbnail",ns);var al=re.createElement("template"),wc=`
711
+ `;var hs=class extends se.HTMLElement{static get observedAttributes(){return[G.MEDIA_CONTROLLER,"time",G.MEDIA_PREVIEW_IMAGE,G.MEDIA_PREVIEW_COORDS]}constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(hl.content.cloneNode(!0))}connectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let a=re.getElementById(e);(t=a==null?void 0:a.associateElement)==null||t.call(a,this)}}disconnectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let a=re.getElementById(e);(t=a==null?void 0:a.unassociateElement)==null||t.call(a,this)}}attributeChangedCallback(t,e,a){var s,u;if(["time",G.MEDIA_PREVIEW_IMAGE,G.MEDIA_PREVIEW_COORDS].includes(t)&&this.update(),t===G.MEDIA_CONTROLLER){if(e){let R=re.getElementById(e);(s=R==null?void 0:R.unassociateElement)==null||s.call(R,this)}if(a){let R=re.getElementById(a);(u=R==null?void 0:R.associateElement)==null||u.call(R,this)}}}update(){let t=this.getAttribute(G.MEDIA_PREVIEW_COORDS),e=this.getAttribute(G.MEDIA_PREVIEW_IMAGE);if(!(t&&e))return;let[a,s,u,R]=t.split(/\s+/).map(o=>+o),C=e.split("#")[0],O=getComputedStyle(this),{maxWidth:L,maxHeight:b,minWidth:x,minHeight:I}=O,_=Math.min(parseInt(L)/u,parseInt(b)/R),A=Math.max(parseInt(x)/u,parseInt(I)/R),S=_<1,m=S?_:A>1?A:1,{style:i}=qt(this.shadowRoot,":host"),d=qt(this.shadowRoot,"img").style,p=this.shadowRoot.querySelector("img"),T=S?"min":"max";i.setProperty(`${T}-width`,"initial","important"),i.setProperty(`${T}-height`,"initial","important"),i.width=`${u*m}px`,i.height=`${R*m}px`;let l=()=>{d.width=`${this.imgWidth*m}px`,d.height=`${this.imgHeight*m}px`,d.display="block"};p.src!==C&&(p.onload=()=>{this.imgWidth=p.naturalWidth,this.imgHeight=p.naturalHeight,l()},p.src=C,l()),l(),d.transform=`translate(-${a*m}px, -${s*m}px)`}};fe("media-preview-thumbnail",hs);var ml=re.createElement("template"),jc=`
697
712
  <svg aria-hidden="true" viewBox="0 0 100 100">
698
713
  <path d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
699
714
  <animateTransform
@@ -706,7 +721,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
706
721
  repeatCount="indefinite" />
707
722
  </path>
708
723
  </svg>
709
- `;al.innerHTML=`
724
+ `;ml.innerHTML=`
710
725
  <style>
711
726
  :host {
712
727
  display: inline-block;
@@ -743,15 +758,15 @@ svg, img, ::slotted(svg), ::slotted(img) {
743
758
  }
744
759
  </style>
745
760
 
746
- <slot name="loading">${wc}</slot>
747
- <div id="status" role="status" aria-live="polite">${lt.MEDIA_LOADING()}</div>
748
- `;var Uc=500,as=class extends ae.HTMLElement{static get observedAttributes(){return[G.MEDIA_CONTROLLER,G.MEDIA_PAUSED,G.MEDIA_LOADING,"loading-delay"]}constructor(){super();let t=this.attachShadow({mode:"open"}),e=al.content.cloneNode(!0);t.appendChild(e)}attributeChangedCallback(t,e,s){var a,u,R;if(t===G.MEDIA_LOADING||t===G.MEDIA_PAUSED){let C=this.getAttribute(G.MEDIA_PAUSED)!=null,O=this.getAttribute(G.MEDIA_LOADING)!=null,L=!C&&O;if(!L)this.loadingDelayHandle&&(clearTimeout(this.loadingDelayHandle),this.loadingDelayHandle=void 0),this.removeAttribute("is-loading");else if(!this.loadingDelayHandle&&L){let b=+((a=this.getAttribute("loading-delay"))!=null?a:Uc);this.loadingDelayHandle=setTimeout(()=>{this.setAttribute("is-loading",""),this.loadingDelayHandle=void 0},b)}}else if(t===G.MEDIA_CONTROLLER){if(e){let C=re.getElementById(e);(u=C==null?void 0:C.unassociateElement)==null||u.call(C,this)}if(s){let C=re.getElementById(s);(R=C==null?void 0:C.associateElement)==null||R.call(C,this)}}}connectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let s=re.getElementById(e);(t=s==null?void 0:s.associateElement)==null||t.call(s,this)}}disconnectedCallback(){var t;this.loadingDelayHandle&&(clearTimeout(this.loadingDelayHandle),this.loadingDelayHandle=void 0);let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let s=re.getElementById(e);(t=s==null?void 0:s.unassociateElement)==null||t.call(s,this)}}};ce("media-loading-indicator",as);var sl=re.createElement("template");sl.innerHTML=`
761
+ <slot name="loading">${jc}</slot>
762
+ <div id="status" role="status" aria-live="polite">${ut.MEDIA_LOADING()}</div>
763
+ `;var Vc=500,ms=class extends se.HTMLElement{static get observedAttributes(){return[G.MEDIA_CONTROLLER,G.MEDIA_PAUSED,G.MEDIA_LOADING,"loading-delay"]}constructor(){super();let t=this.attachShadow({mode:"open"}),e=ml.content.cloneNode(!0);t.appendChild(e)}attributeChangedCallback(t,e,a){var s,u,R;if(t===G.MEDIA_LOADING||t===G.MEDIA_PAUSED){let C=this.getAttribute(G.MEDIA_PAUSED)!=null,O=this.getAttribute(G.MEDIA_LOADING)!=null,L=!C&&O;if(!L)this.loadingDelayHandle&&(clearTimeout(this.loadingDelayHandle),this.loadingDelayHandle=void 0),this.removeAttribute("is-loading");else if(!this.loadingDelayHandle&&L){let b=+((s=this.getAttribute("loading-delay"))!=null?s:Vc);this.loadingDelayHandle=setTimeout(()=>{this.setAttribute("is-loading",""),this.loadingDelayHandle=void 0},b)}}else if(t===G.MEDIA_CONTROLLER){if(e){let C=re.getElementById(e);(u=C==null?void 0:C.unassociateElement)==null||u.call(C,this)}if(a){let C=re.getElementById(a);(R=C==null?void 0:C.associateElement)==null||R.call(C,this)}}}connectedCallback(){var t;let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let a=re.getElementById(e);(t=a==null?void 0:a.associateElement)==null||t.call(a,this)}}disconnectedCallback(){var t;this.loadingDelayHandle&&(clearTimeout(this.loadingDelayHandle),this.loadingDelayHandle=void 0);let e=this.getAttribute(G.MEDIA_CONTROLLER);if(e){let a=re.getElementById(e);(t=a==null?void 0:a.unassociateElement)==null||t.call(a,this)}}};fe("media-loading-indicator",ms);var vl=re.createElement("template");vl.innerHTML=`
749
764
  <style>
750
765
  :host {
751
766
  }
752
767
  </style>
753
768
  <slot></slot>
754
- `;var ss=class extends ae.HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(sl.content.cloneNode(!0))}};ce("media-title-bar",ss);var Nc=100,Bc=r=>{var t;if(r.getAttribute(G.MEDIA_MUTED)!=null)return 0;let s=+((t=r.getAttribute(G.MEDIA_VOLUME))!=null?t:1);return Math.round(s*r.range.max)},Fc=({value:r,max:t})=>`${Math.round(r/t*100)}%`,os=class extends Ii{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_VOLUME,G.MEDIA_MUTED,G.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.max=Nc,this.range.addEventListener("input",()=>{let e=this.range.value/this.range.max,s=new ae.CustomEvent(de.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(s)})}connectedCallback(){this.range.setAttribute("aria-label",lt.VOLUME()),super.connectedCallback()}attributeChangedCallback(t,e,s){if(t===G.MEDIA_VOLUME||t===G.MEDIA_MUTED){let a=Bc(this);this.range.value=a,this.range.setAttribute("aria-valuetext",Fc(this.range)),this.updateBar()}super.attributeChangedCallback(t,e,s)}};ce("media-volume-range",os);var Kc=Object.defineProperty,Wc=(r,t,e)=>t in r?Kc(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hc=(r,t,e)=>(Wc(r,typeof t!="symbol"?t+"":t,e),e),Oi=class extends ae.HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.render()}render(){this.shadowRoot.textContent="";let t=re.createElement("template");t.innerHTML=this.constructor.template,this.shadowRoot.append(t.content.cloneNode(!0))}get mediaController(){return this.shadowRoot.querySelector("media-controller")}};Hc(Oi,"template","");ce("media-theme",Oi);var ls=Oi;var us=class extends Di{};ae.customElements.get("media-chrome")||ae.customElements.define("media-chrome",us);var ds=class extends Di{constructor(){super(),console.warn("MediaChrome: <media-container> is deprecated. Use <media-controller>.")}};ae.customElements.get("media-container")||ae.customElements.define("media-container",ds);var Dn=tn(ol(),1),Lr=tn(Ln(),1),vs=tn(Ln(),1),Jr=tn(Ln(),1),ki=class extends Error{constructor(r,t=ki.MEDIA_ERR_CUSTOM,e){var s;super(r),this.name="MediaError",this.code=t,this.fatal=e!=null?e:t>=ki.MEDIA_ERR_NETWORK&&t<=ki.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(s=ki.defaultMessages[this.code])!=null?s:"")}},Ve=ki;Ve.MEDIA_ERR_ABORTED=1,Ve.MEDIA_ERR_NETWORK=2,Ve.MEDIA_ERR_DECODE=3,Ve.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Ve.MEDIA_ERR_ENCRYPTED=5,Ve.MEDIA_ERR_CUSTOM=100,Ve.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 hl=(r,t)=>r in t,ms={ANY:"any",MUTED:"muted"},be={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Ct={MSE:"mse",NATIVE:"native"},qr={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},gs={HLS:qr.M3U8},Gp=Object.keys(gs),jp=[...Object.values(qr),"hls","HLS"],wi=(r,t,e,s)=>{r.addEventListener(t,e,s),r.addEventListener("teardown",()=>{r.removeEventListener(t,e)},{once:!0})};function Gc(r,t,e){t&&e>t&&(e=t);for(let s=0;s<r.length;s++)if(r.start(s)<=e&&r.end(s)>=e)return!0;return!1}var jc=r=>{let t=r.indexOf("?");if(t<0)return[r];let e=r.slice(0,t),s=r.slice(t);return[e,s]},vl=r=>{let t=r.type;if(t){let s=t.toUpperCase();return hl(s,gs)?gs[s]:t}let{src:e}=r;return e?Vc(e):""},Vc=r=>{let t="";try{t=new URL(r).pathname}catch{console.error("invalid url")}let e=t.lastIndexOf(".");if(e<0)return"";let s=t.slice(e+1).toUpperCase();return hl(s,qr)?qr[s]:""},$c=Object.values(ms),ll=r=>typeof r=="boolean"||typeof r=="string"&&$c.includes(r),Yc=({autoplay:r},t,e)=>{if(!t)return()=>{};let s=!1,a=!1,u=ll(r)?r:!!r,R=()=>{s||wi(t,"playing",()=>{s=!0},{once:!0})};if(R(),wi(t,"loadstart",()=>{s=!1,R(),hs(t,u)},{once:!0}),wi(t,"loadstart",()=>{e||(a=!Number.isFinite(t.duration)),hs(t,u)},{once:!0}),e&&e.once(vs.default.Events.LEVEL_LOADED,(C,O)=>{var L;a=(L=O.details.live)!=null?L:!1}),!u){let C=()=>{!a||(e!=null&&e.liveSyncPosition?t.currentTime=e.liveSyncPosition:Number.isFinite(t.seekable.end(0))&&(t.currentTime=t.seekable.end(0)))};e&&wi(t,"play",()=>{t.preload==="metadata"?e.once(vs.default.Events.LEVEL_UPDATED,C):C()},{once:!0})}return C=>{s||(u=ll(C)?C:!!C,hs(t,u))}},hs=(r,t)=>{if(!t)return;let e=r.muted,s=()=>r.muted=e;switch(t){case ms.ANY:r.play().catch(()=>{r.muted=!0,r.play().catch(s)});break;case ms.MUTED:r.muted=!0,r.play().catch(s);break;default:r.play().catch(()=>{});break}},zc=({preload:r,src:t},e,s)=>{if(!e)return()=>{};let a=x=>{x!=null&&["","none","metadata","auto"].includes(x)?e.setAttribute("preload",x):e.removeAttribute("preload")};if(!s)return a(r),a;let u=!1,R=!1,C=s.config.maxBufferLength,O=s.config.maxBufferSize,L=x=>{a(x);let I=x!=null?x:e.preload;R||I==="none"||(I==="metadata"?(s.config.maxBufferLength=1,s.config.maxBufferSize=1):(s.config.maxBufferLength=C,s.config.maxBufferSize=O),b())},b=()=>{!u&&t&&(u=!0,s.loadSource(t))};return wi(e,"play",()=>{R=!0,s.config.maxBufferLength=C,s.config.maxBufferSize=O,b()},{once:!0}),L(r),L};function Xc(r,t){t.on(Jr.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(a,{tracks:u})=>{u.forEach(R=>{var C;let O=(C=R.subtitleTrack)!=null?C:R.closedCaptions,L=t.subtitleTracks.findIndex(({lang:b,name:x,type:I})=>b==(O==null?void 0:O.lang)&&x===R.label&&I.toLowerCase()===R.kind);Es(r,R.kind,R.label,O==null?void 0:O.lang,`${R.kind}${L}`)})});let e=()=>{var a;if(!t.subtitleTracks.length)return;let u=Array.from(r.textTracks).find(C=>C.id&&C.mode==="showing"&&["subtitles","captions"].includes(C.kind)),R=`${(a=t.subtitleTracks[t.subtitleTrack])==null?void 0:a.type.toLowerCase()}${t.subtitleTrack}`;if(u&&(t.subtitleTrack<0||(u==null?void 0:u.id)!==R)){let C=t.subtitleTracks.findIndex(({lang:O,name:L,type:b})=>O==u.language&&L===u.label&&b.toLowerCase()===u.kind);t.subtitleTrack=C}u&&(u==null?void 0:u.id)===R&&u.cues&&Array.from(u.cues).forEach(C=>{u.addCue(C)})};r.textTracks.addEventListener("change",e),t.on(Jr.default.Events.CUES_PARSED,(a,{track:u,cues:R})=>{let C=r.textTracks.getTrackById(u);if(!C)return;let O=C.mode==="disabled";O&&(C.mode="hidden"),R.forEach(L=>{var b;(b=C.cues)!=null&&b.getCueById(L.id)||C.addCue(L)}),O&&(C.mode="disabled")}),t.once(Jr.default.Events.DESTROYING,()=>{r.textTracks.removeEventListener("change",e),r.querySelectorAll("track[data-removeondestroy]").forEach(a=>{a.remove()})});let s=()=>{Array.from(r.textTracks).forEach(a=>{var u,R;if(!["subtitles","caption"].includes(a.kind)&&a.label==="thumbnails"){if(!((u=a.cues)!=null&&u.length)){let C=r.querySelector('track[label="thumbnails"]'),O=(R=C==null?void 0:C.getAttribute("src"))!=null?R:"";C==null||C.removeAttribute("src"),setTimeout(()=>{C==null||C.setAttribute("src",O)},0)}a.mode!=="hidden"&&(a.mode="hidden")}})};t.once(Jr.default.Events.MANIFEST_LOADED,s),t.once(Jr.default.Events.MEDIA_ATTACHED,s)}function Es(r,t,e,s,a){let u=document.createElement("track");return u.kind=t,u.label=e,s&&(u.srclang=s),a&&(u.id=a),u.track.mode="disabled",u.setAttribute("data-removeondestroy",""),r.append(u),u.track}function ml(r,t){let e=Array.prototype.find.call(r.querySelectorAll("track"),s=>s.track===t);e==null||e.remove()}var ul,dl,Qc=(dl=(ul=globalThis==null?void 0:globalThis.navigator)==null?void 0:ul.userAgent)!=null?dl:"",Zc=Qc.toLowerCase().indexOf("android")!==-1,ei=new WeakMap,gl="mux.com",cl,fl,pl=(fl=(cl=Lr.default).isSupported)==null?void 0:fl.call(cl),Jc=Zc,El=()=>Dn.default.utils.now(),yl=Dn.default.utils.generateUUID,Tl=(r,{domain:t=gl}={})=>{if(!r)return;let[e,s=""]=jc(r);return`https://stream.${t}/${e}.m3u8${s}`},qc=r=>{if(!r)return;let[t]=r.split("?");return t||void 0},ef=r=>{if(!r||!r.startsWith("https://stream."))return;let[t]=new URL(r).pathname.slice(1).split(".m3u8");return t||void 0},tf=r=>{var t,e,s;return(t=r==null?void 0:r.metadata)!=null&&t.video_id?r.metadata.video_id:Sl(r)&&(s=(e=qc(r.playbackId))!=null?e:ef(r.src))!=null?s:yl()},bl=r=>{var t;return(t=ei.get(r))==null?void 0:t.error},Al=(r,t,e)=>{ys(t,e);let{metadata:s={}}=r,{view_session_id:a=yl()}=s,u=tf(r);s.view_session_id=a,s.video_id=u,r.metadata=s,ei.set(t,{});let R=rf(r,t);af(r,t,R),sf(r,t,R);let C=Yc(r,t,R),O=zc(r,t,R);return{engine:R,setAutoplay:C,setPreload:O}},ys=(r,t)=>{let e=t==null?void 0:t.engine;e&&(e.detachMedia(),e.destroy()),(r==null?void 0:r.mux)&&!r.mux.deleted&&(r.mux.destroy(),delete r.mux),r&&(r.removeAttribute("src"),r.load(),r.removeEventListener("error",Ll),r.removeEventListener("error",ps),r.removeEventListener("durationchange",xl),ei.delete(r),r.dispatchEvent(new Event("teardown")))};function _l(r,t){var e;let s=vl(r);if(s!==qr.M3U8)return!0;let a=!s||((e=t==null?void 0:t.canPlayType(s))!=null?e:!0),{preferPlayback:u}=r,R=u===Ct.MSE,C=u===Ct.NATIVE;return a&&(C||!(pl&&(R||Jc)))}var rf=(r,t)=>{let{debug:e,streamType:s,startTime:a=-1,metadata:u,experimentalCmcd:R}=r,C=vl(r)===qr.M3U8,O=_l(r,t);if(C&&!O&&pl){let L={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},b=nf(s),x=R?{useHeaders:!0,sessionId:u.view_session_id,contentId:u.video_id}:void 0;return new Lr.default({debug:e,startPosition:a,cmcd:x,...L,...b})}},nf=r=>[be.LIVE,be.DVR].includes(r)?{backBufferLength:8}:[be.LL_LIVE,be.LL_DVR].includes(r)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},Sl=({playbackId:r,src:t,customDomain:e})=>{if(r)return!0;if(typeof t!="string")return!1;let s=window==null?void 0:window.location.href,a=new URL(t,s).hostname.toLocaleLowerCase();return a.includes(gl)||!!e&&a.includes(e.toLocaleLowerCase())},af=(r,t,e)=>{var s;let{envKey:a}=r,u=Sl(r);if((a||u)&&t){let{playerInitTime:R,playerSoftwareName:C,playerSoftwareVersion:O,beaconCollectionDomain:L,debug:b,disableCookies:x}=r,I={...r.metadata,video_title:((s=r==null?void 0:r.metadata)==null?void 0:s.video_title)||void 0},_=A=>typeof A.player_error_code=="string"?!1:typeof r.errorTranslator=="function"?r.errorTranslator(A):A;Dn.default.monitor(t,{debug:b,beaconCollectionDomain:L,hlsjs:e,Hls:e?Lr.default:void 0,automaticErrorTracking:!1,errorTranslator:_,disableCookies:x,data:{...a?{env_key:a}:{},player_software_name:C,player_software:C,player_software_version:O,player_init_time:R,...I}})}},sf=(r,t,e)=>{var s;if(!t){console.warn("attempting to load media before mediaEl exists");return}let a=_l(r,t),{src:u}=r;t&&a?(typeof u=="string"?(t.setAttribute("src",u),r.startTime&&(((s=ei.get(t))!=null?s:{}).startTime=r.startTime,t.addEventListener("durationchange",xl,{once:!0}))):t.removeAttribute("src"),t.addEventListener("error",Ll),t.addEventListener("error",ps)):e&&u?(e.on(Lr.default.Events.ERROR,(R,C)=>{let O={[Lr.default.ErrorTypes.NETWORK_ERROR]:Ve.MEDIA_ERR_NETWORK,[Lr.default.ErrorTypes.MEDIA_ERROR]:Ve.MEDIA_ERR_DECODE},L=new Ve("",O[C.type]);L.fatal=C.fatal,L.data=C,t.dispatchEvent(new CustomEvent("error",{detail:L}))}),t.addEventListener("error",ps),Xc(t,e),e.attachMedia(t)):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 xl(r){var t;let e=r.target,s=(t=ei.get(e))==null?void 0:t.startTime;if(!!s&&Gc(e.seekable,e.duration,s)){let a=e.preload==="auto";a&&(e.preload="none"),e.currentTime=s,a&&(e.preload="auto")}}async function Ll(r){if(!r.isTrusted)return;r.stopImmediatePropagation();let t=r.target;if(!(t!=null&&t.error))return;let{message:e,code:s}=t.error,a=new Ve(e,s);if(t.src&&(s!==Ve.MEDIA_ERR_DECODE||s!==void 0))try{let{status:u}=await fetch(t.src);a.data={response:{code:u}}}catch{}t.dispatchEvent(new CustomEvent("error",{detail:a}))}function ps(r){var t,e;if(!(r instanceof CustomEvent)||!(r.detail instanceof Ve))return;let s=r.target,a=r.detail;!a||!a.fatal||(((t=ei.get(s))!=null?t:{}).error=a,(e=s.mux)==null||e.emit("error",{player_error_code:a.code,player_error_message:a.message}))}var of=Object.defineProperty,lf=(r,t,e)=>t in r?of(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,In=(r,t,e)=>(lf(r,typeof t!="symbol"?t+"":t,e),e),As=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)},fe=(r,t,e)=>(As(r,t,"read from private field"),e?e.call(r):t.get(r)),Be=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},gt=(r,t,e,s)=>(As(r,t,"write to private field"),s?s.call(r,e):t.set(r,e),e),it=(r,t,e)=>(As(r,t,"access private method"),e),Pn=class{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}};if(typeof DocumentFragment=="undefined"){class r extends Pn{}globalThis.DocumentFragment=r}var _s=class extends Pn{},uf=class extends Pn{},df={get(r){},define(r,t,e){},upgrade(r){},whenDefined(r){return Promise.resolve(_s)}},Mn,cf=class{constructor(r,t={}){Be(this,Mn,void 0),gt(this,Mn,t==null?void 0:t.detail)}get detail(){return fe(this,Mn)}initCustomEvent(){}};Mn=new WeakMap;function ff(r,t){return new _s}var Il={document:{createElement:ff},DocumentFragment,customElements:df,CustomEvent:cf,EventTarget:Pn,HTMLElement:_s,HTMLVideoElement:uf},Ml=typeof window=="undefined"||typeof globalThis.customElements=="undefined",fr=Ml?Il:globalThis,Rl=Ml?Il.document:globalThis.document,hf=()=>{try{return"0.10.0"}catch{}return"UNKNOWN"},vf=hf(),mf=()=>vf,gf=r=>{var t,e,s,a,u,R,C,O,L,b,x,I,_,A,S,v,i,d,p,T,l,o,h,E,n,c,m,f,g,y,M,D,P,B,N,F,H,V,X,$;return t=class extends r{constructor(){super(),Be(this,m),Be(this,g),Be(this,M),Be(this,P),Be(this,N),Be(this,H),Be(this,X),In(this,"castEnabled",!1),Be(this,l,{paused:!1}),Be(this,o,void 0),Be(this,h,{}),Be(this,E,void 0),Be(this,n,void 0),Be(this,c,void 0),t.instances.add(this),it(this,N,F).call(this)}static get castElement(){return fe(t,e)}static get castEnabled(){return fe(t,s)}static get castState(){var j;return(j=fe(t,L,b))==null?void 0:j.getCastState()}static async exitCast(){try{await fe(t,L,b).endCurrentSession(!0)}catch(j){console.error(j);return}}get castPlayer(){if(t.castElement===this)return fe(this,o)}attributeChangedCallback(j){if(this.castPlayer)switch(j){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(j={}){var J;it(J=t,p,T).call(J,j),gt(t,e,this),Object.entries(fe(this,h)).forEach(([ee,te])=>{fe(this,o).controller.addEventListener(ee,te)});try{await fe(t,L,b).requestSession()}catch{gt(t,e,void 0);return}fe(this,l).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(ee){console.error(ee)}}async load(){var j,J;if(!this.castPlayer)return super.load();let ee=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),te=[...this.querySelectorAll("track")].filter(({kind:he,src:me})=>me&&(he==="subtitles"||he==="captions")),se=[],ue=0;te.length&&(ee.tracks=te.map(he=>{let me=++ue;se.length===0&&he.track.mode==="showing"&&se.push(me);let ne=new chrome.cast.media.Track(me,chrome.cast.media.TrackType.TEXT);return ne.trackContentId=he.src,ne.trackContentType="text/vtt",ne.subtype=he.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,ne.name=he.label,ne.language=he.srclang,ne})),this.castStreamType==="live"?ee.streamType=chrome.cast.media.StreamType.LIVE:ee.streamType=chrome.cast.media.StreamType.BUFFERED,ee.metadata=new chrome.cast.media.GenericMediaMetadata,ee.metadata.title=this.title,ee.metadata.images=[{url:this.poster}];let ie=new chrome.cast.media.LoadRequest(ee);ie.currentTime=(j=super.currentTime)!=null?j:0,ie.autoplay=!fe(this,l).paused,ie.activeTrackIds=se,await((J=fe(t,x,I))==null?void 0:J.loadMedia(ie)),this.dispatchEvent(new Event("volumechange"))}play(){var j;if(this.castPlayer){this.castPlayer.isPaused&&((j=this.castPlayer.controller)==null||j.playOrPause());return}return super.play()}pause(){var j;if(this.castPlayer){this.castPlayer.isPaused||(j=this.castPlayer.controller)==null||j.playOrPause();return}super.pause()}get castSrc(){var j,J,ee;return(ee=(J=this.getAttribute("cast-src"))!=null?J:(j=this.querySelector("source"))==null?void 0:j.src)!=null?ee:this.currentSrc}set castSrc(j){this.castSrc!=j&&this.setAttribute("cast-src",`${j}`)}get castContentType(){var j;return(j=this.getAttribute("cast-content-type"))!=null?j:void 0}set castContentType(j){this.setAttribute("cast-content-type",`${j}`)}get castStreamType(){var j;return(j=this.getAttribute("cast-stream-type"))!=null?j:void 0}set castStreamType(j){this.setAttribute("cast-stream-type",`${j}`)}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 j;return this.castPlayer?(j=this.castPlayer)==null?void 0:j.isMuted:super.muted}set muted(j){var J;if(this.castPlayer){(j&&!this.castPlayer.isMuted||!j&&this.castPlayer.isMuted)&&((J=this.castPlayer.controller)==null||J.muteOrUnmute());return}super.muted=j}get volume(){var j,J;return this.castPlayer?(J=(j=this.castPlayer)==null?void 0:j.volumeLevel)!=null?J:1:super.volume}set volume(j){var J;if(this.castPlayer){this.castPlayer.volumeLevel=j,(J=this.castPlayer.controller)==null||J.setVolumeLevel();return}super.volume=j}get duration(){var j,J;return this.castPlayer&&fe(this,m,f)?(J=(j=this.castPlayer)==null?void 0:j.duration)!=null?J:NaN:super.duration}get currentTime(){var j,J;return this.castPlayer&&fe(this,m,f)?(J=(j=this.castPlayer)==null?void 0:j.currentTime)!=null?J:0:super.currentTime}set currentTime(j){var J;if(this.castPlayer){this.castPlayer.currentTime=j,(J=this.castPlayer.controller)==null||J.seek();return}super.currentTime=j}get onentercast(){return fe(this,E)}set onentercast(j){fe(this,E)&&(this.removeEventListener("entercast",fe(this,E)),gt(this,E,null)),typeof j=="function"&&(gt(this,E,j),this.addEventListener("entercast",j))}get onleavecast(){return fe(this,n)}set onleavecast(j){fe(this,n)&&(this.removeEventListener("leavecast",fe(this,n)),gt(this,n,null)),typeof j=="function"&&(gt(this,n,j),this.addEventListener("leavecast",j))}get oncastchange(){return fe(this,c)}set oncastchange(j){fe(this,c)&&(this.removeEventListener("castchange",fe(this,c)),gt(this,c,null)),typeof j=="function"&&(gt(this,c,j),this.addEventListener("castchange",j))}},e=new WeakMap,s=new WeakMap,a=new WeakMap,u=new WeakSet,R=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},C=new WeakSet,O=function(){return typeof cast!="undefined"&&cast.framework},L=new WeakSet,b=function(){if(fe(t,C,O))return cast.framework.CastContext.getInstance()},x=new WeakSet,I=function(){var j;return(j=fe(t,L,b))==null?void 0:j.getCurrentSession()},_=new WeakSet,A=function(){var j;return(j=fe(t,x,I))==null?void 0:j.getSessionObj().media[0]},S=new WeakSet,v=function(j){return new Promise((J,ee)=>{fe(t,_,A).editTracksInfo(j,J,ee)})},i=new WeakSet,d=function(j){return new Promise((J,ee)=>{fe(t,_,A).getStatus(j,J,ee)})},p=new WeakSet,T=function(j){return fe(t,L,b).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...j})},l=new WeakMap,o=new WeakMap,h=new WeakMap,E=new WeakMap,n=new WeakMap,c=new WeakMap,m=new WeakSet,f=function(){var j;return(j=this.castPlayer)==null?void 0:j.isMediaLoaded},g=new WeakSet,y=function(){fe(t,e)===this&&(Object.entries(fe(this,h)).forEach(([j,J])=>{fe(this,o).controller.removeEventListener(j,J)}),gt(t,e,void 0),this.muted=fe(this,o).isMuted,this.currentTime=fe(this,o).savedPlayerState.currentTime,fe(this,o).savedPlayerState.isPaused===!1&&this.play())},M=new WeakSet,D=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:fe(t,L,b).getCastState()}))},P=new WeakSet,B=async function(){var j,J;let{SESSION_RESUMED:ee}=cast.framework.SessionState;if(fe(t,L,b).getSessionState()===ee&&this.castSrc===((j=fe(t,_,A))==null?void 0:j.media.contentId)){gt(t,e,this),Object.entries(fe(this,h)).forEach(([te,se])=>{fe(this,o).controller.addEventListener(te,se)});try{await it(J=t,i,d).call(J,new chrome.cast.media.GetStatusRequest)}catch(te){console.error(te)}fe(this,h)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),fe(this,h)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},N=new WeakSet,F=function(){var j;!fe(t,C,O)||this.castEnabled||(this.castEnabled=!0,it(j=t,p,T).call(j),this.textTracks.addEventListener("change",it(this,X,$).bind(this)),it(this,M,D).call(this),gt(this,o,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(fe(this,o)),gt(this,h,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:J})=>{J===!1&&it(this,g,y).call(this),this.dispatchEvent(new Event(J?"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]:()=>{!fe(this,m,f)||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 J,ee;((J=this.castPlayer)==null?void 0:J.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"}[(ee=this.castPlayer)==null?void 0:ee.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!fe(this,m,f)||(await Promise.resolve(),it(this,H,V).call(this))}}))},H=new WeakSet,V=function(){it(this,X,$).call(this)},X=new WeakSet,$=async function(){var j,J,ee,te,se,ue;if(!this.castPlayer)return;let ie=((J=(j=fe(this,o).mediaInfo)==null?void 0:j.tracks)!=null?J:[]).filter(({type:_e})=>_e===chrome.cast.media.TrackType.TEXT),he=[...this.textTracks].filter(({kind:_e})=>_e==="subtitles"||_e==="captions"),me=ie.map(({language:_e,name:ke,trackId:Qe})=>{var He;let{mode:qe}=(He=he.find(Ke=>Ke.language===_e&&Ke.label===ke))!=null?He:{};return qe?{mode:qe,trackId:Qe}:!1}).filter(Boolean),ne=me.filter(({mode:_e})=>_e!=="showing").map(({trackId:_e})=>_e),Re=me.find(({mode:_e})=>_e==="showing"),Le=(se=(te=(ee=fe(t,x,I))==null?void 0:ee.getSessionObj().media[0])==null?void 0:te.activeTrackIds)!=null?se:[],De=Le;if(Le.length&&(De=De.filter(_e=>!ne.includes(_e))),Re!=null&&Re.trackId&&(De=[...De,Re.trackId]),De=[...new Set(De)],!((_e,ke)=>_e.length===ke.length&&_e.every(Qe=>ke.includes(Qe)))(Le,De))try{let _e=new chrome.cast.media.EditTracksInfoRequest(De);await it(ue=t,S,v).call(ue,_e)}catch(_e){console.error(_e)}},Be(t,u),Be(t,C),Be(t,L),Be(t,x),Be(t,_),Be(t,S),Be(t,i),Be(t,p),In(t,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),In(t,"instances",new Set),Be(t,e,void 0),Be(t,s,!1),In(t,"initCast",()=>{var j;fe(t,u,R)?fe(t,C,O)?fe(j=t,a).call(j,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var J;return fe(J=t,a).call(J,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var J;return fe(J=t,a).call(J,chrome.cast.isAvailable)})}}),Be(t,a,j=>{if(j){gt(t,s,!0);let{CAST_STATE_CHANGED:J}=cast.framework.CastContextEventType;fe(t,L,b).addEventListener(J,te=>{t.instances.forEach(se=>{var ue;return it(ue=se,M,D).call(ue,te)})});let{SESSION_STATE_CHANGED:ee}=cast.framework.CastContextEventType;fe(t,L,b).addEventListener(ee,te=>{t.instances.forEach(se=>{var ue;return it(ue=se,P,B).call(ue,te)})}),t.instances.forEach(te=>{var se;return it(se=te,N,F).call(se)})}}),t};if(globalThis.HTMLVideoElement&&globalThis.customElements){let r=gf(HTMLVideoElement);globalThis.customElements.get("castable-video")||(globalThis.customElements.define("castable-video",r,{extends:"video"}),globalThis.CastableVideoElement=r),r.initCast()}var Ss=["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"],Cl=Rl.createElement("template");Cl.innerHTML=`
769
+ `;var vs=class extends se.HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(vl.content.cloneNode(!0))}};fe("media-title-bar",vs);var $c=100,Yc=r=>{var t;if(r.getAttribute(G.MEDIA_MUTED)!=null)return 0;let a=+((t=r.getAttribute(G.MEDIA_VOLUME))!=null?t:1);return Math.round(a*r.range.max)},zc=({value:r,max:t})=>`${Math.round(r/t*100)}%`,gs=class extends Ri{static get observedAttributes(){return[...super.observedAttributes,G.MEDIA_VOLUME,G.MEDIA_MUTED,G.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.max=$c,this.range.addEventListener("input",()=>{let e=this.range.value/this.range.max,a=new se.CustomEvent(ce.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(a)})}connectedCallback(){this.range.setAttribute("aria-label",ut.VOLUME()),super.connectedCallback()}attributeChangedCallback(t,e,a){if(t===G.MEDIA_VOLUME||t===G.MEDIA_MUTED){let s=Yc(this);this.range.value=s,this.range.setAttribute("aria-valuetext",zc(this.range)),this.updateBar()}super.attributeChangedCallback(t,e,a)}};fe("media-volume-range",gs);var Xc=Object.defineProperty,Qc=(r,t,e)=>t in r?Xc(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Zc=(r,t,e)=>(Qc(r,typeof t!="symbol"?t+"":t,e),e),ki=class extends se.HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.render()}render(){this.shadowRoot.textContent="";let t=re.createElement("template");t.innerHTML=this.constructor.template,this.shadowRoot.append(t.content.cloneNode(!0))}get mediaController(){return this.shadowRoot.querySelector("media-controller")}};Zc(ki,"template","");fe("media-theme",ki);var ps=ki;var Es=class extends Mi{};se.customElements.get("media-chrome")||se.customElements.define("media-chrome",Es);var ys=class extends Mi{constructor(){super(),console.warn("MediaChrome: <media-container> is deprecated. Use <media-controller>.")}};se.customElements.get("media-container")||se.customElements.define("media-container",ys);var Rn=sn(gl(),1),Cr=sn(Mn(),1),_s=sn(Mn(),1),qr=sn(Mn(),1),Ui=class extends Error{constructor(r,t=Ui.MEDIA_ERR_CUSTOM,e){var a;super(r),this.name="MediaError",this.code=t,this.fatal=e!=null?e:t>=Ui.MEDIA_ERR_NETWORK&&t<=Ui.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(a=Ui.defaultMessages[this.code])!=null?a:"")}},$e=Ui;$e.MEDIA_ERR_ABORTED=1,$e.MEDIA_ERR_NETWORK=2,$e.MEDIA_ERR_DECODE=3,$e.MEDIA_ERR_SRC_NOT_SUPPORTED=4,$e.MEDIA_ERR_ENCRYPTED=5,$e.MEDIA_ERR_CUSTOM=100,$e.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 Al=(r,t)=>r in t,Ss={ANY:"any",MUTED:"muted"},be={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"},_l={HEADER:"header",QUERY:"query"},ti=Object.values(_l),ei={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},xs={HLS:ei.M3U8},e0=Object.keys(xs),t0=[...Object.values(ei),"hls","HLS"],Ni=(r,t,e,a)=>{r.addEventListener(t,e,a),r.addEventListener("teardown",()=>{r.removeEventListener(t,e)},{once:!0})};function Jc(r,t,e){t&&e>t&&(e=t);for(let a=0;a<r.length;a++)if(r.start(a)<=e&&r.end(a)>=e)return!0;return!1}var qc=r=>{let t=r.indexOf("?");if(t<0)return[r];let e=r.slice(0,t),a=r.slice(t);return[e,a]},Sl=r=>{let t=r.type;if(t){let a=t.toUpperCase();return Al(a,xs)?xs[a]:t}let{src:e}=r;return e?ef(e):""},ef=r=>{let t="";try{t=new URL(r).pathname}catch{console.error("invalid url")}let e=t.lastIndexOf(".");if(e<0)return"";let a=t.slice(e+1).toUpperCase();return Al(a,ei)?ei[a]:""},tf=Object.values(Ss),pl=r=>typeof r=="boolean"||typeof r=="string"&&tf.includes(r),rf=({autoplay:r},t,e)=>{let a=!1,s=!1,u=pl(r)?r:!!r,R=()=>{a||Ni(t,"playing",()=>{a=!0},{once:!0})};if(R(),Ni(t,"loadstart",()=>{a=!1,R(),As(t,u)},{once:!0}),Ni(t,"loadstart",()=>{e||(s=!Number.isFinite(t.duration)),As(t,u)},{once:!0}),e&&e.once(_s.default.Events.LEVEL_LOADED,(C,O)=>{var L;s=(L=O.details.live)!=null?L:!1}),!u){let C=()=>{!s||(e!=null&&e.liveSyncPosition?t.currentTime=e.liveSyncPosition:Number.isFinite(t.seekable.end(0))&&(t.currentTime=t.seekable.end(0)))};e&&Ni(t,"play",()=>{t.preload==="metadata"?e.once(_s.default.Events.LEVEL_UPDATED,C):C()},{once:!0})}return C=>{a||(u=pl(C)?C:!!C,As(t,u))}},As=(r,t)=>{if(!t)return;let e=r.muted,a=()=>r.muted=e;switch(t){case Ss.ANY:r.play().catch(()=>{r.muted=!0,r.play().catch(a)});break;case Ss.MUTED:r.muted=!0,r.play().catch(a);break;default:r.play().catch(()=>{});break}},nf=({preload:r,src:t},e,a)=>{let s=x=>{x!=null&&["","none","metadata","auto"].includes(x)?e.setAttribute("preload",x):e.removeAttribute("preload")};if(!a)return s(r),s;let u=!1,R=!1,C=a.config.maxBufferLength,O=a.config.maxBufferSize,L=x=>{s(x);let I=x!=null?x:e.preload;R||I==="none"||(I==="metadata"?(a.config.maxBufferLength=1,a.config.maxBufferSize=1):(a.config.maxBufferLength=C,a.config.maxBufferSize=O),b())},b=()=>{!u&&t&&(u=!0,a.loadSource(t))};return Ni(e,"play",()=>{R=!0,a.config.maxBufferLength=C,a.config.maxBufferSize=O,b()},{once:!0}),L(r),L};function af(r,t){t.on(qr.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(s,{tracks:u})=>{u.forEach(R=>{var C;let O=(C=R.subtitleTrack)!=null?C:R.closedCaptions,L=t.subtitleTracks.findIndex(({lang:b,name:x,type:I})=>b==(O==null?void 0:O.lang)&&x===R.label&&I.toLowerCase()===R.kind);Ds(r,R.kind,R.label,O==null?void 0:O.lang,`${R.kind}${L}`)})});let e=()=>{var s;if(!t.subtitleTracks.length)return;let u=Array.from(r.textTracks).find(C=>C.id&&C.mode==="showing"&&["subtitles","captions"].includes(C.kind)),R=`${(s=t.subtitleTracks[t.subtitleTrack])==null?void 0:s.type.toLowerCase()}${t.subtitleTrack}`;if(u&&(t.subtitleTrack<0||(u==null?void 0:u.id)!==R)){let C=t.subtitleTracks.findIndex(({lang:O,name:L,type:b})=>O==u.language&&L===u.label&&b.toLowerCase()===u.kind);t.subtitleTrack=C}u&&(u==null?void 0:u.id)===R&&u.cues&&Array.from(u.cues).forEach(C=>{u.addCue(C)})};r.textTracks.addEventListener("change",e),t.on(qr.default.Events.CUES_PARSED,(s,{track:u,cues:R})=>{let C=r.textTracks.getTrackById(u);if(!C)return;let O=C.mode==="disabled";O&&(C.mode="hidden"),R.forEach(L=>{var b;(b=C.cues)!=null&&b.getCueById(L.id)||C.addCue(L)}),O&&(C.mode="disabled")}),t.once(qr.default.Events.DESTROYING,()=>{r.textTracks.removeEventListener("change",e),r.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let a=()=>{Array.from(r.textTracks).forEach(s=>{var u,R;if(!["subtitles","caption"].includes(s.kind)&&s.label==="thumbnails"){if(!((u=s.cues)!=null&&u.length)){let C=r.querySelector('track[label="thumbnails"]'),O=(R=C==null?void 0:C.getAttribute("src"))!=null?R:"";C==null||C.removeAttribute("src"),setTimeout(()=>{C==null||C.setAttribute("src",O)},0)}s.mode!=="hidden"&&(s.mode="hidden")}})};t.once(qr.default.Events.MANIFEST_LOADED,a),t.once(qr.default.Events.MEDIA_ATTACHED,a)}function Ds(r,t,e,a,s){let u=document.createElement("track");return u.kind=t,u.label=e,a&&(u.srclang=a),s&&(u.id=s),u.track.mode="disabled",u.setAttribute("data-removeondestroy",""),r.append(u),u.track}function xl(r,t){let e=Array.prototype.find.call(r.querySelectorAll("track"),a=>a.track===t);e==null||e.remove()}var El,yl,sf=(yl=(El=globalThis==null?void 0:globalThis.navigator)==null?void 0:El.userAgent)!=null?yl:"",of=sf.toLowerCase().indexOf("android")!==-1,ri=new WeakMap,Ll="mux.com",Tl,bl,Dl=(bl=(Tl=Cr.default).isSupported)==null?void 0:bl.call(Tl),lf=of,Il=()=>Rn.default.utils.now(),uf=Rn.default.utils.generateUUID,Ml=(r,{domain:t=Ll}={})=>{if(!r)return;let[e,a=""]=qc(r);return`https://stream.${t}/${e}.m3u8${a}`},df=r=>{if(!r)return;let[t]=r.split("?");return t||void 0},cf=r=>{if(!r||!r.startsWith("https://stream."))return;let[t]=new URL(r).pathname.slice(1).split(".m3u8");return t||void 0},ff=r=>{var t,e,a;return(t=r==null?void 0:r.metadata)!=null&&t.video_id?r.metadata.video_id:Pl(r)&&(a=(e=df(r.playbackId))!=null?e:cf(r.src))!=null?a:r.src},Rl=r=>{var t;return(t=ri.get(r))==null?void 0:t.error},Cl=(r,t,e)=>{Is(t,e);let{metadata:a={}}=r,{view_session_id:s=uf()}=a,u=ff(r);a.view_session_id=s,a.video_id=u,r.metadata=a,ri.set(t,{});let R=hf(r,t);vf(r,t,R),gf(r,t,R);let C=rf(r,t,R),O=nf(r,t,R);return{engine:R,setAutoplay:C,setPreload:O}},Is=(r,t)=>{let e=t==null?void 0:t.engine;e&&(e.detachMedia(),e.destroy()),(r==null?void 0:r.mux)&&!r.mux.deleted&&(r.mux.destroy(),delete r.mux),r&&(r.removeAttribute("src"),r.load(),r.removeEventListener("error",wl),r.removeEventListener("error",Ls),r.removeEventListener("durationchange",kl),ri.delete(r),r.dispatchEvent(new Event("teardown")))};function Ol(r,t){var e;let a=Sl(r);if(a!==ei.M3U8)return!0;let s=!a||((e=t.canPlayType(a))!=null?e:!0),{preferPlayback:u}=r,R=u===Ot.MSE,C=u===Ot.NATIVE;return s&&(C||!(Dl&&(R||lf)))}var hf=(r,t)=>{let{debug:e,streamType:a,startTime:s=-1,metadata:u,experimentalCmcd:R,preferCmcd:C}=r,O=Sl(r)===ei.M3U8,L=Ol(r,t);if(O&&!L&&Dl){let b={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},x=mf(a),I=R?{useHeaders:C===_l.HEADER,sessionId:u.view_session_id,contentId:u.video_id}:void 0;return new Cr.default({debug:e,startPosition:s,cmcd:I,...b,...x})}},mf=r=>[be.LIVE,be.DVR].includes(r)?{backBufferLength:8}:[be.LL_LIVE,be.LL_DVR].includes(r)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},Pl=({playbackId:r,src:t,customDomain:e})=>{if(r)return!0;if(typeof t!="string")return!1;let a=window==null?void 0:window.location.href,s=new URL(t,a).hostname.toLocaleLowerCase();return s.includes(Ll)||!!e&&s.includes(e.toLocaleLowerCase())},vf=(r,t,e)=>{var a;let{envKey:s}=r,u=Pl(r);if(s||u){let{playerInitTime:R,playerSoftwareName:C,playerSoftwareVersion:O,beaconCollectionDomain:L,debug:b,disableCookies:x}=r,I={...r.metadata,video_title:((a=r==null?void 0:r.metadata)==null?void 0:a.video_title)||void 0},_=A=>typeof A.player_error_code=="string"?!1:typeof r.errorTranslator=="function"?r.errorTranslator(A):A;Rn.default.monitor(t,{debug:b,beaconCollectionDomain:L,hlsjs:e,Hls:e?Cr.default:void 0,automaticErrorTracking:!1,errorTranslator:_,disableCookies:x,data:{...s?{env_key:s}:{},player_software_name:C,player_software:C,player_software_version:O,player_init_time:R,...I}})}},gf=(r,t,e)=>{var a;let s=Ol(r,t),{src:u}=r;t&&s?(typeof u=="string"?(t.setAttribute("src",u),r.startTime&&(((a=ri.get(t))!=null?a:{}).startTime=r.startTime,t.addEventListener("durationchange",kl,{once:!0}))):t.removeAttribute("src"),t.addEventListener("error",wl),t.addEventListener("error",Ls)):e&&u?(e.on(Cr.default.Events.ERROR,(R,C)=>{let O={[Cr.default.ErrorTypes.NETWORK_ERROR]:$e.MEDIA_ERR_NETWORK,[Cr.default.ErrorTypes.MEDIA_ERROR]:$e.MEDIA_ERR_DECODE},L=new $e("",O[C.type]);L.fatal=C.fatal,L.data=C,t.dispatchEvent(new CustomEvent("error",{detail:L}))}),t.addEventListener("error",Ls),af(t,e),e.attachMedia(t)):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 kl(r){var t;let e=r.target,a=(t=ri.get(e))==null?void 0:t.startTime;if(!!a&&Jc(e.seekable,e.duration,a)){let s=e.preload==="auto";s&&(e.preload="none"),e.currentTime=a,s&&(e.preload="auto")}}async function wl(r){if(!r.isTrusted)return;r.stopImmediatePropagation();let t=r.target;if(!(t!=null&&t.error))return;let{message:e,code:a}=t.error,s=new $e(e,a);if(t.src&&(a!==$e.MEDIA_ERR_DECODE||a!==void 0))try{let{status:u}=await fetch(t.src);s.data={response:{code:u}}}catch{}t.dispatchEvent(new CustomEvent("error",{detail:s}))}function Ls(r){var t,e;if(!(r instanceof CustomEvent)||!(r.detail instanceof $e))return;let a=r.target,s=r.detail;!s||!s.fatal||(((t=ri.get(a))!=null?t:{}).error=s,(e=a.mux)==null||e.emit("error",{player_error_code:s.code,player_error_message:s.message}))}var pf=Object.defineProperty,Ef=(r,t,e)=>t in r?pf(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cn=(r,t,e)=>(Ef(r,typeof t!="symbol"?t+"":t,e),e),Os=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)},de=(r,t,e)=>(Os(r,t,"read from private field"),e?e.call(r):t.get(r)),Ce=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},Ve=(r,t,e,a)=>(Os(r,t,"write to private field"),a?a.call(r,e):t.set(r,e),e),et=(r,t,e)=>(Os(r,t,"access private method"),e),Wn=class{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}};if(typeof DocumentFragment=="undefined"){class r extends Wn{}globalThis.DocumentFragment=r}var Ps=class extends Wn{},yf=class extends Wn{},Tf={get(r){},define(r,t,e){},upgrade(r){},whenDefined(r){return Promise.resolve(Ps)}},On,bf=class{constructor(r,t={}){Ce(this,On,void 0),Ve(this,On,t==null?void 0:t.detail)}get detail(){return de(this,On)}initCustomEvent(){}};On=new WeakMap;function Af(r,t){return new Ps}var Nl={document:{createElement:Af},DocumentFragment,customElements:Tf,CustomEvent:bf,EventTarget:Wn,HTMLElement:Ps,HTMLVideoElement:yf},Bl=typeof window=="undefined"||typeof globalThis.customElements=="undefined",vr=Bl?Nl:globalThis,Fl=Bl?Nl.document:globalThis.document,_f=()=>{try{return"0.11.0"}catch{}return"UNKNOWN"},Sf=_f(),xf=()=>Sf,Lf=r=>{var t,e,a,s,u,R,C,O,L,b,x,I,_,A,S,m,i,d,p,T,l,o,h,E,n,c,v,f,g,y,M,D,P,B,N,F,H,V,X,$;return t=class extends r{constructor(){super(),Ce(this,v),Ce(this,g),Ce(this,M),Ce(this,P),Ce(this,N),Ce(this,H),Ce(this,X),Cn(this,"castEnabled",!1),Ce(this,l,{paused:!1}),Ce(this,o,void 0),Ce(this,h,{}),Ce(this,E,void 0),Ce(this,n,void 0),Ce(this,c,void 0),t.instances.add(this),et(this,N,F).call(this)}static get castElement(){return de(t,e)}static get castEnabled(){return de(t,a)}static get castState(){var j;return(j=de(t,L,b))==null?void 0:j.getCastState()}static async exitCast(){try{await de(t,L,b).endCurrentSession(!0)}catch(j){console.error(j);return}}get castPlayer(){if(t.castElement===this)return de(this,o)}attributeChangedCallback(j){if(this.castPlayer)switch(j){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(j={}){var J;et(J=t,p,T).call(J,j),Ve(t,e,this),Object.entries(de(this,h)).forEach(([ee,te])=>{de(this,o).controller.addEventListener(ee,te)});try{await de(t,L,b).requestSession()}catch{Ve(t,e,void 0);return}de(this,l).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(ee){console.error(ee)}}async load(){var j,J;if(!this.castPlayer)return super.load();let ee=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),te=[...this.querySelectorAll("track")].filter(({kind:he,src:ve})=>ve&&(he==="subtitles"||he==="captions")),le=[],ue=0;te.length&&(ee.tracks=te.map(he=>{let ve=++ue;le.length===0&&he.track.mode==="showing"&&le.push(ve);let ae=new chrome.cast.media.Track(ve,chrome.cast.media.TrackType.TEXT);return ae.trackContentId=he.src,ae.trackContentType="text/vtt",ae.subtype=he.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,ae.name=he.label,ae.language=he.srclang,ae})),this.castStreamType==="live"?ee.streamType=chrome.cast.media.StreamType.LIVE:ee.streamType=chrome.cast.media.StreamType.BUFFERED,ee.metadata=new chrome.cast.media.GenericMediaMetadata,ee.metadata.title=this.title,ee.metadata.images=[{url:this.poster}];let ie=new chrome.cast.media.LoadRequest(ee);ie.currentTime=(j=super.currentTime)!=null?j:0,ie.autoplay=!de(this,l).paused,ie.activeTrackIds=le,await((J=de(t,x,I))==null?void 0:J.loadMedia(ie)),this.dispatchEvent(new Event("volumechange"))}play(){var j;if(this.castPlayer){this.castPlayer.isPaused&&((j=this.castPlayer.controller)==null||j.playOrPause());return}return super.play()}pause(){var j;if(this.castPlayer){this.castPlayer.isPaused||(j=this.castPlayer.controller)==null||j.playOrPause();return}super.pause()}get castSrc(){var j,J,ee;return(ee=(J=this.getAttribute("cast-src"))!=null?J:(j=this.querySelector("source"))==null?void 0:j.src)!=null?ee:this.currentSrc}set castSrc(j){this.castSrc!=j&&this.setAttribute("cast-src",`${j}`)}get castContentType(){var j;return(j=this.getAttribute("cast-content-type"))!=null?j:void 0}set castContentType(j){this.setAttribute("cast-content-type",`${j}`)}get castStreamType(){var j;return(j=this.getAttribute("cast-stream-type"))!=null?j:void 0}set castStreamType(j){this.setAttribute("cast-stream-type",`${j}`)}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 j;return this.castPlayer?(j=this.castPlayer)==null?void 0:j.isMuted:super.muted}set muted(j){var J;if(this.castPlayer){(j&&!this.castPlayer.isMuted||!j&&this.castPlayer.isMuted)&&((J=this.castPlayer.controller)==null||J.muteOrUnmute());return}super.muted=j}get volume(){var j,J;return this.castPlayer?(J=(j=this.castPlayer)==null?void 0:j.volumeLevel)!=null?J:1:super.volume}set volume(j){var J;if(this.castPlayer){this.castPlayer.volumeLevel=j,(J=this.castPlayer.controller)==null||J.setVolumeLevel();return}super.volume=j}get duration(){var j,J;return this.castPlayer&&de(this,v,f)?(J=(j=this.castPlayer)==null?void 0:j.duration)!=null?J:NaN:super.duration}get currentTime(){var j,J;return this.castPlayer&&de(this,v,f)?(J=(j=this.castPlayer)==null?void 0:j.currentTime)!=null?J:0:super.currentTime}set currentTime(j){var J;if(this.castPlayer){this.castPlayer.currentTime=j,(J=this.castPlayer.controller)==null||J.seek();return}super.currentTime=j}get onentercast(){return de(this,E)}set onentercast(j){de(this,E)&&(this.removeEventListener("entercast",de(this,E)),Ve(this,E,null)),typeof j=="function"&&(Ve(this,E,j),this.addEventListener("entercast",j))}get onleavecast(){return de(this,n)}set onleavecast(j){de(this,n)&&(this.removeEventListener("leavecast",de(this,n)),Ve(this,n,null)),typeof j=="function"&&(Ve(this,n,j),this.addEventListener("leavecast",j))}get oncastchange(){return de(this,c)}set oncastchange(j){de(this,c)&&(this.removeEventListener("castchange",de(this,c)),Ve(this,c,null)),typeof j=="function"&&(Ve(this,c,j),this.addEventListener("castchange",j))}},e=new WeakMap,a=new WeakMap,s=new WeakMap,u=new WeakSet,R=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},C=new WeakSet,O=function(){return typeof cast!="undefined"&&cast.framework},L=new WeakSet,b=function(){if(de(t,C,O))return cast.framework.CastContext.getInstance()},x=new WeakSet,I=function(){var j;return(j=de(t,L,b))==null?void 0:j.getCurrentSession()},_=new WeakSet,A=function(){var j;return(j=de(t,x,I))==null?void 0:j.getSessionObj().media[0]},S=new WeakSet,m=function(j){return new Promise((J,ee)=>{de(t,_,A).editTracksInfo(j,J,ee)})},i=new WeakSet,d=function(j){return new Promise((J,ee)=>{de(t,_,A).getStatus(j,J,ee)})},p=new WeakSet,T=function(j){return de(t,L,b).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...j})},l=new WeakMap,o=new WeakMap,h=new WeakMap,E=new WeakMap,n=new WeakMap,c=new WeakMap,v=new WeakSet,f=function(){var j;return(j=this.castPlayer)==null?void 0:j.isMediaLoaded},g=new WeakSet,y=function(){de(t,e)===this&&(Object.entries(de(this,h)).forEach(([j,J])=>{de(this,o).controller.removeEventListener(j,J)}),Ve(t,e,void 0),this.muted=de(this,o).isMuted,this.currentTime=de(this,o).savedPlayerState.currentTime,de(this,o).savedPlayerState.isPaused===!1&&this.play())},M=new WeakSet,D=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:de(t,L,b).getCastState()}))},P=new WeakSet,B=async function(){var j,J;let{SESSION_RESUMED:ee}=cast.framework.SessionState;if(de(t,L,b).getSessionState()===ee&&this.castSrc===((j=de(t,_,A))==null?void 0:j.media.contentId)){Ve(t,e,this),Object.entries(de(this,h)).forEach(([te,le])=>{de(this,o).controller.addEventListener(te,le)});try{await et(J=t,i,d).call(J,new chrome.cast.media.GetStatusRequest)}catch(te){console.error(te)}de(this,h)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),de(this,h)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},N=new WeakSet,F=function(){var j;!de(t,C,O)||this.castEnabled||(this.castEnabled=!0,et(j=t,p,T).call(j),this.textTracks.addEventListener("change",et(this,X,$).bind(this)),et(this,M,D).call(this),Ve(this,o,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(de(this,o)),Ve(this,h,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:J})=>{J===!1&&et(this,g,y).call(this),this.dispatchEvent(new Event(J?"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]:()=>{!de(this,v,f)||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 J,ee;((J=this.castPlayer)==null?void 0:J.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"}[(ee=this.castPlayer)==null?void 0:ee.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!de(this,v,f)||(await Promise.resolve(),et(this,H,V).call(this))}}))},H=new WeakSet,V=function(){et(this,X,$).call(this)},X=new WeakSet,$=async function(){var j,J,ee,te,le,ue;if(!this.castPlayer)return;let ie=((J=(j=de(this,o).mediaInfo)==null?void 0:j.tracks)!=null?J:[]).filter(({type:_e})=>_e===chrome.cast.media.TrackType.TEXT),he=[...this.textTracks].filter(({kind:_e})=>_e==="subtitles"||_e==="captions"),ve=ie.map(({language:_e,name:we,trackId:Ze})=>{var He;let{mode:tt}=(He=he.find(Ke=>Ke.language===_e&&Ke.label===we))!=null?He:{};return tt?{mode:tt,trackId:Ze}:!1}).filter(Boolean),ae=ve.filter(({mode:_e})=>_e!=="showing").map(({trackId:_e})=>_e),Re=ve.find(({mode:_e})=>_e==="showing"),Le=(le=(te=(ee=de(t,x,I))==null?void 0:ee.getSessionObj().media[0])==null?void 0:te.activeTrackIds)!=null?le:[],De=Le;if(Le.length&&(De=De.filter(_e=>!ae.includes(_e))),Re!=null&&Re.trackId&&(De=[...De,Re.trackId]),De=[...new Set(De)],!((_e,we)=>_e.length===we.length&&_e.every(Ze=>we.includes(Ze)))(Le,De))try{let _e=new chrome.cast.media.EditTracksInfoRequest(De);await et(ue=t,S,m).call(ue,_e)}catch(_e){console.error(_e)}},Ce(t,u),Ce(t,C),Ce(t,L),Ce(t,x),Ce(t,_),Ce(t,S),Ce(t,i),Ce(t,p),Cn(t,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Cn(t,"instances",new Set),Ce(t,e,void 0),Ce(t,a,!1),Cn(t,"initCast",()=>{var j;de(t,u,R)?de(t,C,O)?de(j=t,s).call(j,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var J;return de(J=t,s).call(J,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var J;return de(J=t,s).call(J,chrome.cast.isAvailable)})}}),Ce(t,s,j=>{if(j){Ve(t,a,!0);let{CAST_STATE_CHANGED:J}=cast.framework.CastContextEventType;de(t,L,b).addEventListener(J,te=>{t.instances.forEach(le=>{var ue;return et(ue=le,M,D).call(ue,te)})});let{SESSION_STATE_CHANGED:ee}=cast.framework.CastContextEventType;de(t,L,b).addEventListener(ee,te=>{t.instances.forEach(le=>{var ue;return et(ue=le,P,B).call(ue,te)})}),t.instances.forEach(te=>{var le;return et(le=te,N,F).call(le)})}}),t};if(globalThis.HTMLVideoElement&&globalThis.customElements){let r=Lf(HTMLVideoElement);globalThis.customElements.get("castable-video")||(globalThis.customElements.define("castable-video",r,{extends:"video"}),globalThis.CastableVideoElement=r),r.initCast()}var ks=["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"],Kl=Fl.createElement("template");Kl.innerHTML=`
755
770
  <style>
756
771
  :host {
757
772
  display: inline-block;
@@ -771,20 +786,20 @@ svg, img, ::slotted(svg), ::slotted(img) {
771
786
  </style>
772
787
  <video is="castable-video" part="video" crossorigin></video>
773
788
  <slot></slot>
774
- `;var Rn,Ui,Cn,On,Ts,ti=class extends fr.HTMLElement{constructor(){super(),Be(this,Ui),Be(this,On),Be(this,Rn,void 0),this.attachShadow({mode:"open"}),this.isConnected&&it(this,Ui,Cn).call(this)}static get observedAttributes(){let r=[],t=s=>s.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(s=>{let a=!1;try{typeof this.prototype[s]=="function"&&(a=!0)}catch{}!a&&s!==s.toUpperCase()&&r.push(s.toLowerCase(),t(s))});let e=Object.getPrototypeOf(this).observedAttributes;return e&&(r=r.concat(e)),r}attributeChangedCallback(r,t,e){it(this,Ui,Cn).call(this),it(this,On,Ts).call(this,r,t,e)}connectedCallback(){it(this,Ui,Cn).call(this)}};Rn=new WeakMap,Ui=new WeakSet,Cn=function(){if(fe(this,Rn))return;gt(this,Rn,!0),this.shadowRoot.append(Cl.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),Ss.forEach(t=>{this.nativeEl.addEventListener(t,e=>{this.dispatchEvent(new CustomEvent(e.type,{detail:e.detail}))})});let r=this.shadowRoot.querySelector("slot");r.addEventListener("slotchange",()=>{r.assignedElements().forEach(t=>{!["track","source"].includes(t.localName)||this.nativeEl.append(t)})}),Array.prototype.forEach.call(this.attributes,t=>{it(this,On,Ts).call(this,t.name,null,t.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},On=new WeakSet,Ts=function(r,t,e){let s=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),a=Ef(s,r),u=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;a&&!u?typeof this[a]=="boolean"?e===null?this[a]=!1:this[a]=!0:this[a]=e:e===null?this.nativeEl.removeAttribute(r):["id","class"].indexOf(r)===-1&&this.nativeEl.setAttribute(r,e)};var Ol=[],Pl=Rl.createElement("video",{is:"castable-video"}),pf=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let r=Object.getPrototypeOf(Pl);r&&r!==fr.HTMLElement.prototype;r=Object.getPrototypeOf(r))Object.getOwnPropertyNames(r).forEach(t=>{pf.indexOf(t)===-1&&Ol.push(t)});Ol.forEach(r=>{if(!(r in ti.prototype))if(typeof Pl[r]=="function")ti.prototype[r]=function(){return this.nativeEl[r].apply(this.nativeEl,arguments)};else{let t={get(){return this.nativeEl[r]}};r!==r.toUpperCase()&&(t.set=function(e){this.nativeEl[r]=e}),Object.defineProperty(ti.prototype,r,t)}});function Ef(r,t){let e=null;return r.forEach(s=>{s.toLowerCase()==t.toLowerCase()&&(e=s)}),e}fr.customElements.get("custom-video")||(fr.customElements.define("custom-video",ti),fr.CustomVideoElement=ti);var Dl=ti,le={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",METADATA_VIDEO_ID:"metadata-video-id",METADATA_VIDEO_TITLE:"metadata-video-title",METADATA_VIEWER_USER_ID:"metadata-viewer-user-id",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DISABLE_COOKIES:"disable-cookies",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time",EXPERIMENTAL_CMCD:"experimental-cmcd"},yf=Object.values(le),Tf=mf(),bf="mux-video",bs=class extends Dl{constructor(){super(),this.__metadata={},this.__playerInitTime=El()}static get observedAttributes(){var r;return[...yf,...(r=Dl.observedAttributes)!=null?r:[]]}get experimentalCmcd(){return this.hasAttribute(le.EXPERIMENTAL_CMCD)}set experimentalCmcd(r){!!r!==this.experimentalCmcd&&(r?this.setAttribute(le.EXPERIMENTAL_CMCD,""):this.removeAttribute(le.EXPERIMENTAL_CMCD))}get playerInitTime(){return this.__playerInitTime}get playerSoftwareName(){var r;return(r=this.__playerSoftwareName)!=null?r:bf}set playerSoftwareName(r){this.__playerSoftwareName=r}get playerSoftwareVersion(){var r;return(r=this.__playerSoftwareVersion)!=null?r:Tf}set playerSoftwareVersion(r){this.__playerSoftwareVersion=r}get _hls(){var r;return(r=this.__core)==null?void 0:r.engine}get mux(){return this.nativeEl.mux}get error(){var r;return(r=bl(this.nativeEl))!=null?r:null}get errorTranslator(){return this.__errorTranslator}set errorTranslator(r){this.__errorTranslator=r}get src(){return this.getAttribute("src")}set src(r){r!==this.src&&(r==null?this.removeAttribute("src"):this.setAttribute("src",r))}get type(){var r;return(r=this.getAttribute(le.TYPE))!=null?r:void 0}set type(r){r!==this.type&&(r?this.setAttribute(le.TYPE,r):this.removeAttribute(le.TYPE))}get autoplay(){let r=this.getAttribute("autoplay");return r===null?!1:r===""?!0:r}set autoplay(r){let t=this.autoplay;r!==t&&(r?this.setAttribute("autoplay",typeof r=="string"?r:""):this.removeAttribute("autoplay"))}get preload(){let r=this.getAttribute("preload");return r===""?"auto":["none","metadata","auto"].includes(r)?r:super.preload}set preload(r){r!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(r)?this.setAttribute("preload",r):this.removeAttribute("preload"))}get debug(){return this.getAttribute(le.DEBUG)!=null}set debug(r){r!==this.debug&&(r?this.setAttribute(le.DEBUG,""):this.removeAttribute(le.DEBUG))}get disableCookies(){return this.hasAttribute(le.DISABLE_COOKIES)}set disableCookies(r){r!==this.disableCookies&&(r?this.setAttribute(le.DISABLE_COOKIES,""):this.removeAttribute(le.DISABLE_COOKIES))}get startTime(){let r=this.getAttribute(le.START_TIME);if(r==null)return;let t=+r;return Number.isNaN(t)?void 0:t}set startTime(r){r!==this.startTime&&(r==null?this.removeAttribute(le.START_TIME):this.setAttribute(le.START_TIME,`${r}`))}get playbackId(){var r;return(r=this.getAttribute(le.PLAYBACK_ID))!=null?r:void 0}set playbackId(r){r!==this.playbackId&&(r?this.setAttribute(le.PLAYBACK_ID,r):this.removeAttribute(le.PLAYBACK_ID))}get customDomain(){var r;return(r=this.getAttribute(le.CUSTOM_DOMAIN))!=null?r:void 0}set customDomain(r){r!==this.customDomain&&(r?this.setAttribute(le.CUSTOM_DOMAIN,r):this.removeAttribute(le.CUSTOM_DOMAIN))}get envKey(){var r;return(r=this.getAttribute(le.ENV_KEY))!=null?r:void 0}set envKey(r){r!==this.envKey&&(r?this.setAttribute(le.ENV_KEY,r):this.removeAttribute(le.ENV_KEY))}get beaconCollectionDomain(){var r;return(r=this.getAttribute(le.BEACON_COLLECTION_DOMAIN))!=null?r:void 0}set beaconCollectionDomain(r){r!==this.beaconCollectionDomain&&(r?this.setAttribute(le.BEACON_COLLECTION_DOMAIN,r):this.removeAttribute(le.BEACON_COLLECTION_DOMAIN))}get streamType(){var r;return(r=this.getAttribute(le.STREAM_TYPE))!=null?r:void 0}set streamType(r){r!==this.streamType&&(r?this.setAttribute(le.STREAM_TYPE,r):this.removeAttribute(le.STREAM_TYPE))}get preferPlayback(){let r=this.getAttribute(le.PREFER_PLAYBACK);if(r===Ct.MSE||r===Ct.NATIVE)return r}set preferPlayback(r){r!==this.preferPlayback&&(r===Ct.MSE||r===Ct.NATIVE?this.setAttribute(le.PREFER_PLAYBACK,r):this.removeAttribute(le.PREFER_PLAYBACK))}get metadata(){let r=this.getAttribute(le.METADATA_VIDEO_ID),t=this.getAttribute(le.METADATA_VIDEO_TITLE),e=this.getAttribute(le.METADATA_VIEWER_USER_ID);return{...this.__metadata,...r!=null?{video_id:r}:{},...t!=null?{video_title:t}:{},...e!=null?{viewer_user_id:e}:{}}}set metadata(r){this.__metadata=r!=null?r:{},this.mux&&this.mux.emit("hb",this.__metadata)}load(){this.__core=Al(this,this.nativeEl,this.__core)}unload(){ys(this.nativeEl,this.__core),this.__core=void 0}attributeChangedCallback(r,t,e){var s,a;switch(super.attributeChangedCallback(r,t,e),r){case le.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=e!=null?e:void 0;break;case le.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=e!=null?e:void 0;break;case"src":{let u=!!t,R=!!e;!u&&R?this.load():u&&!R?this.unload():u&&R&&(this.unload(),this.load());break}case"autoplay":if(e===t)break;(s=this.__core)==null||s.setAutoplay(this.autoplay);break;case"preload":if(e===t)break;(a=this.__core)==null||a.setPreload(e);break;case le.PLAYBACK_ID:this.src=Tl(e!=null?e:void 0,{domain:this.customDomain});break;case le.DEBUG:{let u=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=u);break}case le.METADATA_URL:e&&fetch(e).then(u=>u.json()).then(u=>this.metadata=u).catch(u=>console.error(`Unable to load or parse metadata JSON from metadata-url ${e}!`));break;default:break}}disconnectedCallback(){this.unload()}};fr.customElements.get("mux-video")||(fr.customElements.define("mux-video",bs),fr.MuxVideoElement=bs);var kl=bs;var Af="en",Dr={code:Af};var wl="en";function Ce(r,t=!0){var a,u;let e=t&&(u=(a=Dr)==null?void 0:a[r])!=null?u:r,s=t?Dr.code:wl;return new xs(e,s)}var xs=class{constructor(t,e=(s=>(s=Dr.code)!=null?s:wl)()){this.message=t,this.locale=e}format(t){return this.message.replace(/\{(\w+)\}/g,(e,s)=>{var a;return(a=t[s])!=null?a:""})}toString(){return this.message}};function Ul(r){let t="";return Object.entries(r).forEach(([e,s])=>{s!=null&&(t+=`${_f(e)}: ${s}; `)}),t?t.trim():void 0}function _f(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Nl(r){return r.replace(/[-_]([a-z])/g,(t,e)=>e.toUpperCase())}function rr(r){if(r==null)return;let t=+r;return Number.isNaN(t)?void 0:t}function kn(r){let t=Sf(r).toString();return t?"?"+t:""}function Sf(r){let t={};for(let e in r)r[e]!=null&&(t[e]=r[e]);return new URLSearchParams(t)}function hr(r){let t=(r!=null?r:"").split(".")[1];if(!t)return{};let e=t.replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(atob(e).split("").map(function(a){return"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(s)}var Ls=(r,t)=>!r||!t?!1:r.contains(t)?!0:Ls(r,t.getRootNode().host);var Ds="mux.com",xf=()=>{try{return"1.3.0"}catch{}return"UNKNOWN"},Lf=xf(),Un=()=>Lf,Is=(r,{token:t,domain:e=Ds}={})=>`https://stream.${e}/${r}.m3u8${kn(!!t?{token:t}:{redundant_streams:!0})}`,Kl=(r,{token:t,thumbnailTime:e,domain:s=Ds}={})=>{let a=t==null?e:void 0,{aud:u}=hr(t);if(!(t&&u!=="t"))return`https://image.${s}/${r}/thumbnail.jpg${kn({token:t,time:a})}`},Wl=(r,{token:t,domain:e=Ds}={})=>{let{aud:s}=hr(t);if(!(t&&s!=="s"))return`https://image.${e}/${r}/storyboard.vtt${kn({token:t})}`};function Ms(r){if(r&&/^media-theme-[\w-]+$/.test(r))return r}var Df={crossorigin:"crossOrigin",playsinline:"playsInline"};function Hl(r){var t;return(t=Df[r])!=null?t:Nl(r)}var Gl=r=>{var e,s;let{media:t}=r;return(s=(e=t==null?void 0:t._hls)==null?void 0:e.liveSyncPosition)!=null?s:t!=null&&t.seekable.length?t==null?void 0:t.seekable.end(t.seekable.length-1):void 0},Rs=r=>{let t=Gl(r);if(t==null){console.warn("attempting to seek to live but cannot determine live edge time!");return}r.currentTime=t},If=1,Mf=5,Bl=3,Fl=.5,jl=r=>{var u;let{streamType:t}=r,e=Gl(r),s=(u=r.media)==null?void 0:u.currentTime;if(e==null||s==null)return!1;let a=e-s;return t===be.LL_LIVE||t===be.LL_DVR?a<=If*(Bl+Fl):t===be.LIVE||t===be.DVR?a<=Mf*(Bl+Fl):!1},Ir,Mr,pt,wn=class{constructor(t,e){Ne(this,Ir,void 0);Ne(this,Mr,void 0);Ne(this,pt,[]);mt(this,Ir,t),mt(this,Mr,e)}[Symbol.iterator](){return xe(this,pt).values()}get length(){return xe(this,pt).length}get value(){var t;return(t=xe(this,pt).join(" "))!=null?t:""}set value(t){var e;t!==this.value&&(mt(this,pt,[]),this.add(...(e=t==null?void 0:t.split(" "))!=null?e:[]))}toString(){return this.value}item(t){return xe(this,pt)[t]}values(){return xe(this,pt).values()}keys(){return xe(this,pt).keys()}forEach(t){xe(this,pt).forEach(t)}add(...t){var e,s;t.forEach(a=>{this.contains(a)||xe(this,pt).push(a)}),!(this.value===""&&!((e=xe(this,Ir))!=null&&e.hasAttribute(`${xe(this,Mr)}`)))&&((s=xe(this,Ir))==null||s.setAttribute(`${xe(this,Mr)}`,`${this.value}`))}remove(...t){var e;t.forEach(s=>{xe(this,pt).splice(xe(this,pt).indexOf(s),1)}),(e=xe(this,Ir))==null||e.setAttribute(`${xe(this,Mr)}`,`${this.value}`)}contains(t){return xe(this,pt).includes(t)}toggle(t,e){return typeof e!="undefined"?e?(this.add(t),!0):(this.remove(t),!1):this.contains(t)?(this.remove(t),!1):(this.add(t),!0)}replace(t,e){this.remove(t),this.add(e)}};Ir=new WeakMap,Mr=new WeakMap,pt=new WeakMap;var Vl=`[mux-player ${Un()}]`;function Rr(...r){console.warn(Vl,...r)}function Xt(...r){console.error(Vl,...r)}function Nn(r){var e;let t=(e=r.message)!=null?e:"";if(r.file){let s="https://github.com/muxinc/elements/blob/main/errors/";t+=` ${Ce("Read more: ")}
775
- ${s}${r.file}`}Rr(t)}var ut={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},Cr={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},Yl=Object.freeze({length:0,start(r){let t=r>>>0;if(t>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${t}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(r){let t=r>>>0;if(t>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${t}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),Rf=Ss.filter(r=>r!=="error"),Cf=Object.values(ut).filter(r=>![ut.PLAYSINLINE].includes(r)),Of=Object.values(Cr);function zl(r){r.querySelectorAll(":scope > track").forEach(t=>{var e;(e=r.media)==null||e.append(t.cloneNode())}),Rf.forEach(t=>{var e;(e=r.media)==null||e.addEventListener(t,s=>{r.dispatchEvent(new Event(s.type))})})}var Cs=class extends je.HTMLElement{static get observedAttributes(){return[...Cf,...Of]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(s=>{var a;(a=this.media)==null||a.append(s.cloneNode())});let t=s=>{for(let a of s)a.type==="childList"&&(a.removedNodes.forEach(u=>{var C,O;let R=(C=this.media)==null?void 0:C.querySelector(`track[src="${u.src}"]`);R&&((O=this.media)==null||O.removeChild(R))}),a.addedNodes.forEach(u=>{var R;(R=this.media)==null||R.append(u.cloneNode())}))};new MutationObserver(t).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(t,e,s){var a,u;switch(t){case Cr.MUTED:{this.media&&(this.media.muted=s!=null,this.media.defaultMuted=s!=null);return}case Cr.VOLUME:{let R=(a=rr(s))!=null?a:1;this.media&&(this.media.volume=R);return}case Cr.PLAYBACKRATE:{let R=(u=rr(s))!=null?u:1;this.media&&(this.media.playbackRate=R,this.media.defaultPlaybackRate=R);return}}}play(){var t,e;return(e=(t=this.media)==null?void 0:t.play())!=null?e:Promise.reject()}pause(){var t;(t=this.media)==null||t.pause()}requestCast(t){var e;return(e=this.media)==null?void 0:e.requestCast(t)}get media(){var t;return(t=this.shadowRoot)==null?void 0:t.querySelector("mux-video")}get paused(){var t,e;return(e=(t=this.media)==null?void 0:t.paused)!=null?e:!0}get duration(){var t,e;return(e=(t=this.media)==null?void 0:t.duration)!=null?e:NaN}get ended(){var t,e;return(e=(t=this.media)==null?void 0:t.ended)!=null?e:!1}get buffered(){var t,e;return(e=(t=this.media)==null?void 0:t.buffered)!=null?e:Yl}get seekable(){var t,e;return(e=(t=this.media)==null?void 0:t.seekable)!=null?e:Yl}get readyState(){var t,e;return(e=(t=this.media)==null?void 0:t.readyState)!=null?e:0}get videoWidth(){var t,e;return(e=(t=this.media)==null?void 0:t.videoWidth)!=null?e:0}get videoHeight(){var t,e;return(e=(t=this.media)==null?void 0:t.videoHeight)!=null?e:0}get currentTime(){var t,e;return(e=(t=this.media)==null?void 0:t.currentTime)!=null?e:0}set currentTime(t){this.media&&(this.media.currentTime=Number(t))}get volume(){var t,e;return(e=(t=this.media)==null?void 0:t.volume)!=null?e:1}set volume(t){this.media&&(this.media.volume=Number(t))}get playbackRate(){var t,e;return(e=(t=this.media)==null?void 0:t.playbackRate)!=null?e:1}set playbackRate(t){this.media&&(this.media.playbackRate=Number(t))}get defaultPlaybackRate(){var t;return(t=rr(this.getAttribute(Cr.PLAYBACKRATE)))!=null?t:1}set defaultPlaybackRate(t){t!=null?this.setAttribute(Cr.PLAYBACKRATE,`${t}`):this.removeAttribute(Cr.PLAYBACKRATE)}get crossOrigin(){return Ni(this,ut.CROSSORIGIN)}set crossOrigin(t){this.setAttribute(ut.CROSSORIGIN,`${t}`)}get autoplay(){return Ni(this,ut.AUTOPLAY)!=null}set autoplay(t){t?this.setAttribute(ut.AUTOPLAY,typeof t=="string"?t:""):this.removeAttribute(ut.AUTOPLAY)}get loop(){return Ni(this,ut.LOOP)!=null}set loop(t){t?this.setAttribute(ut.LOOP,""):this.removeAttribute(ut.LOOP)}get muted(){var t,e;return(e=(t=this.media)==null?void 0:t.muted)!=null?e:!1}set muted(t){this.media&&(this.media.muted=Boolean(t))}get defaultMuted(){return Ni(this,ut.MUTED)!=null}set defaultMuted(t){t?this.setAttribute(ut.MUTED,""):this.removeAttribute(ut.MUTED)}get playsInline(){return Ni(this,ut.PLAYSINLINE)!=null}set playsInline(t){Xt("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(t){["","none","metadata","auto"].includes(t)?this.setAttribute(ut.PRELOAD,t):this.removeAttribute(ut.PRELOAD)}};function Ni(r,t){return r.media?r.media.getAttribute(t):r.getAttribute(t)}var Os=Cs;var Bn=new Map;function Fn(r){if(Bn.has(r))return Bn.get(r);let t=r.length,e=0,s=0,a=0,u=[];for(let R=0;R<t;R+=1){let C=r[R],O=r[R+1],L=r[R-1];C==="{"&&O==="{"&&L!=="\\"?(a+=1,a===1&&(s=R),R+=1):C==="}"&&O==="}"&&L!=="\\"&&a&&(a-=1,a===0&&(s>e&&(u.push(Object.freeze({type:"string",start:e,end:s,value:r.slice(e,s)})),e=s),u.push(Object.freeze({type:"part",start:s,end:R+2,value:r.slice(e+2,R).trim()})),R+=1,e=R+1))}return e<t&&u.push(Object.freeze({type:"string",start:e,end:t,value:r.slice(e,t)})),Bn.set(r,Object.freeze(u)),Bn.get(r)}var Or=new WeakMap,Xl=new WeakMap,Kt=class{constructor(t,e){this.expression=e,Or.set(this,t),t.updateParent("")}get attributeName(){return Or.get(this).attr.name}get attributeNamespace(){return Or.get(this).attr.namespaceURI}get value(){return Xl.get(this)}set value(t){Xl.set(this,t||""),Or.get(this).updateParent(t)}get element(){return Or.get(this).element}get booleanValue(){return Or.get(this).booleanValue}set booleanValue(t){Or.get(this).booleanValue=t}},Bi=class{constructor(t,e){this.element=t,this.attr=e,this.partList=[]}get booleanValue(){return this.element.hasAttributeNS(this.attr.namespaceURI,this.attr.name)}set booleanValue(t){if(this.partList.length!==1)throw new DOMException("Operation not supported","NotSupportedError");this.partList[0].value=t?"":null}append(t){this.partList.push(t)}updateParent(t){if(this.partList.length===1&&t===null)this.element.removeAttributeNS(this.attr.namespaceURI,this.attr.name);else{let e=this.partList.map(s=>typeof s=="string"?s:s.value).join("");this.element.setAttributeNS(this.attr.namespaceURI,this.attr.name,e)}}};var vr=new WeakMap,Qt=class{constructor(t,e){this.expression=e,vr.set(this,[t]),t.textContent=""}get value(){return vr.get(this).map(t=>t.textContent).join("")}set value(t){this.replace(t)}get previousSibling(){return vr.get(this)[0].previousSibling}get nextSibling(){return vr.get(this)[vr.get(this).length-1].nextSibling}replace(...t){let e=t.map(s=>typeof s=="string"?new Text(s):s);e.length||e.push(new Text("")),vr.get(this)[0].before(...e);for(let s of vr.get(this))s.remove();vr.set(this,e)}};function Fi(r){return{processCallback(t,e,s){var a;if(!(typeof s!="object"||!s)){for(let u of e)if(u.expression in s){let R=(a=s[u.expression])!==null&&a!==void 0?a:"";r(u,R)}}}}}function Ps(r,t){r.value=String(t)}function Ql(r,t){return typeof t=="boolean"&&r instanceof Kt&&typeof r.element[r.attributeName]=="boolean"?(r.booleanValue=t,!0):!1}var ks=Fi(Ps),Pf=Fi((r,t)=>{Ql(r,t)||Ps(r,t)});function*kf(r){let t=r.ownerDocument.createTreeWalker(r,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,null,!1),e;for(;e=t.nextNode();)if(e instanceof Element&&e.hasAttributes())for(let s=0;s<e.attributes.length;s+=1){let a=e.attributes.item(s);if(a&&a.value.includes("{{")){let u=new Bi(e,a);for(let R of Fn(a.value))if(R.type==="string")u.append(R.value);else{let C=new Kt(u,R.value);u.append(C),yield C}}}else if(e instanceof Text&&e.textContent&&e.textContent.includes("{{")){let s=Fn(e.textContent);for(let a=0;a<s.length;a+=1){let u=s[a];u.end<e.textContent.length&&e.splitText(u.end),u.type==="part"&&(yield new Qt(e,u.value));break}}}var Kn=new WeakMap,Wn=new WeakMap,ir=class extends DocumentFragment{constructor(t,e,s=ks){var a,u;super(),Object.getPrototypeOf(this)!==ir.prototype&&Object.setPrototypeOf(this,ir.prototype),this.appendChild(t.content.cloneNode(!0)),Wn.set(this,Array.from(kf(this))),Kn.set(this,s),(u=(a=Kn.get(this)).createCallback)===null||u===void 0||u.call(a,this,Wn.get(this),e),Kn.get(this).processCallback(this,Wn.get(this),e)}update(t){Kn.get(this).processCallback(this,Wn.get(this),t)}};var Ki=new WeakMap,Wi=class{constructor(t,e){this.element=t;this.type=e;this.element.addEventListener(this.type,this);let s=Ki.get(this.element);s&&s.set(this.type,this)}set(t){if(typeof t=="function")this.handleEvent=t.bind(this.element);else if(typeof t=="object"&&typeof t.handleEvent=="function")this.handleEvent=t.handleEvent.bind(t);else{this.element.removeEventListener(this.type,this);let e=Ki.get(this.element);e&&e.delete(this.type)}}static for(t){Ki.has(t.element)||Ki.set(t.element,new Map);let e=t.attributeName.slice(2),s=Ki.get(t.element);return s&&s.has(e)?s.get(e):new Wi(t.element,e)}};function wf(r,t){return r instanceof Kt&&r.attributeName.startsWith("on")?(Wi.for(r).set(t),r.element.removeAttributeNS(r.attributeNamespace,r.attributeName),!0):!1}function Uf(r,t){return t instanceof Hi&&r instanceof Qt?(t.renderInto(r),!0):!1}function Nf(r,t){return t instanceof DocumentFragment&&r instanceof Qt?(t.childNodes.length&&r.replace(...t.childNodes),!0):!1}function Bf(r,t){if(r instanceof Kt){let e=r.attributeNamespace,s=r.element.getAttributeNS(e,r.attributeName);return String(t)!==s&&(r.value=String(t)),!0}return r.value=String(t),!0}function Ff(r,t){if(typeof t=="boolean"&&r instanceof Kt){let e=r.attributeNamespace,s=r.element.hasAttributeNS(e,r.attributeName);return t!==s&&(r.booleanValue=t),!0}return!1}function Kf(r,t){return t===!1&&r instanceof Qt?(r.replace(""),!0):!1}function Wf(r,t){Ff(r,t)||wf(r,t)||Kf(r,t)||Uf(r,t)||Nf(r,t)||Bf(r,t)}var ws=new WeakMap,Zl=new WeakMap,Jl=new WeakMap,Hi=class{constructor(t,e,s){this.strings=t;this.values=e;this.processor=s}get template(){if(ws.has(this.strings))return ws.get(this.strings);{let t=document.createElement("template"),e=this.strings.length-1;return t.innerHTML=this.strings.reduce((s,a,u)=>s+a+(u<e?`{{ ${u} }}`:""),""),ws.set(this.strings,t),t}}renderInto(t){let e=this.template;if(Zl.get(t)!==e){Zl.set(t,e);let a=new ir(e,this.values,this.processor);Jl.set(t,a),t instanceof Qt?t.replace(...a.children):t.appendChild(a);return}let s=Jl.get(t);s&&s.update(this.values)}},ql=new Map,Hf=Fi(Wf);function Te(r,...t){let e=[""],s=[],a,u=!1,R=(C,O=[])=>{e[e.length-1]=e[e.length-1]+C[0],O.forEach((L,b)=>{(a=L==null?void 0:L.$static$)!==void 0?(a.forEach(x=>{R(x.strings,x.values)}),e[e.length-1]=e[e.length-1]+C[b+1],u=!0):(s.push(L),e.push(C[b+1]))})};if(R(r,t),u){let C=e.join("$$html$$");r=ql.get(C),r===void 0&&(e.raw=e,ql.set(C,r=e)),t=s}return new Hi(r,t,Hf)}function Hn(r,t){r.renderInto(t)}function nt(r,t){let e=document.createElement("template");return e.innerHTML=r,new ir(e,t)}var Us=(...r)=>({$static$:r.map(t=>t instanceof Hi?t:/\w-/.test(t)?{strings:[t]}:{strings:[]})});var tu=`
789
+ `;var Pn,Bi,kn,Kn,Ms,ii=class extends vr.HTMLElement{constructor(){super(),Ce(this,Bi),Ce(this,Kn),Ce(this,Pn,void 0),this.attachShadow({mode:"open"}),this.isConnected&&et(this,Bi,kn).call(this)}static get observedAttributes(){let r=[],t=a=>a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(a=>{let s=!1;try{typeof this.prototype[a]=="function"&&(s=!0)}catch{}!s&&a!==a.toUpperCase()&&r.push(a.toLowerCase(),t(a))});let e=Object.getPrototypeOf(this).observedAttributes;return e&&(r=r.concat(e)),r}attributeChangedCallback(r,t,e){et(this,Bi,kn).call(this),et(this,Kn,Ms).call(this,r,t,e)}connectedCallback(){et(this,Bi,kn).call(this)}};Pn=new WeakMap,Bi=new WeakSet,kn=function(){if(de(this,Pn))return;Ve(this,Pn,!0),this.shadowRoot.append(Kl.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),ks.forEach(t=>{this.nativeEl.addEventListener(t,e=>{this.dispatchEvent(new CustomEvent(e.type,{detail:e.detail}))})});let r=this.shadowRoot.querySelector("slot");r.addEventListener("slotchange",()=>{r.assignedElements().forEach(t=>{!["track","source"].includes(t.localName)||this.nativeEl.append(t)})}),Array.prototype.forEach.call(this.attributes,t=>{et(this,Kn,Ms).call(this,t.name,null,t.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},Kn=new WeakSet,Ms=function(r,t,e){let a=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),s=If(a,r),u=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;s&&!u?typeof this[s]=="boolean"?e===null?this[s]=!1:this[s]=!0:this[s]=e:e===null?this.nativeEl.removeAttribute(r):["id","class"].indexOf(r)===-1&&this.nativeEl.setAttribute(r,e)};var Wl=[],Hl=Fl.createElement("video",{is:"castable-video"}),Df=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let r=Object.getPrototypeOf(Hl);r&&r!==vr.HTMLElement.prototype;r=Object.getPrototypeOf(r))Object.getOwnPropertyNames(r).forEach(t=>{Df.indexOf(t)===-1&&Wl.push(t)});Wl.forEach(r=>{if(!(r in ii.prototype))if(typeof Hl[r]=="function")ii.prototype[r]=function(){return this.nativeEl[r].apply(this.nativeEl,arguments)};else{let t={get(){return this.nativeEl[r]}};r!==r.toUpperCase()&&(t.set=function(e){this.nativeEl[r]=e}),Object.defineProperty(ii.prototype,r,t)}});function If(r,t){let e=null;return r.forEach(a=>{a.toLowerCase()==t.toLowerCase()&&(e=a)}),e}vr.customElements.get("custom-video")||(vr.customElements.define("custom-video",ii),vr.CustomVideoElement=ii);var Ul=ii,ne={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",METADATA_VIDEO_ID:"metadata-video-id",METADATA_VIDEO_TITLE:"metadata-video-title",METADATA_VIEWER_USER_ID:"metadata-viewer-user-id",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",EXPERIMENTAL_CMCD:"experimental-cmcd"},Mf=Object.values(ne),Rf=xf(),Cf="mux-video",er,Fi,wn,Ki,Un,Nn,Bn,Fn,Rs,Cs=class extends Ul{constructor(){super(),Ce(this,Fn),Ce(this,er,void 0),Ce(this,Fi,void 0),Ce(this,wn,void 0),Ce(this,Ki,{}),Ce(this,Un,void 0),Ce(this,Nn,void 0),Ce(this,Bn,void 0),Ve(this,wn,Il())}static get observedAttributes(){var r;return[...Mf,...(r=Ul.observedAttributes)!=null?r:[]]}get experimentalCmcd(){return this.hasAttribute(ne.EXPERIMENTAL_CMCD)}set experimentalCmcd(r){!!r!==this.experimentalCmcd&&(r?this.setAttribute(ne.EXPERIMENTAL_CMCD,""):this.removeAttribute(ne.EXPERIMENTAL_CMCD))}get preferCmcd(){var r;return(r=this.getAttribute(ne.PREFER_CMCD))!=null?r:void 0}set preferCmcd(r){r!==this.preferCmcd&&(r?ti.includes(r)?this.setAttribute(ne.PREFER_CMCD,r):console.warn(`Invalid value for preferCmcd. Must be one of ${ti.join()}`):this.removeAttribute(ne.PREFER_CMCD))}get playerInitTime(){return de(this,wn)}get playerSoftwareName(){var r;return(r=de(this,Nn))!=null?r:Cf}set playerSoftwareName(r){Ve(this,Nn,r)}get playerSoftwareVersion(){var r;return(r=de(this,Un))!=null?r:Rf}set playerSoftwareVersion(r){Ve(this,Un,r)}get _hls(){var r;return(r=de(this,er))==null?void 0:r.engine}get mux(){return this.nativeEl.mux}get error(){var r;return(r=Rl(this.nativeEl))!=null?r:null}get errorTranslator(){return de(this,Bn)}set errorTranslator(r){Ve(this,Bn,r)}get src(){return this.getAttribute("src")}set src(r){r!==this.src&&(r==null?this.removeAttribute("src"):this.setAttribute("src",r))}get type(){var r;return(r=this.getAttribute(ne.TYPE))!=null?r:void 0}set type(r){r!==this.type&&(r?this.setAttribute(ne.TYPE,r):this.removeAttribute(ne.TYPE))}get autoplay(){let r=this.getAttribute("autoplay");return r===null?!1:r===""?!0:r}set autoplay(r){let t=this.autoplay;r!==t&&(r?this.setAttribute("autoplay",typeof r=="string"?r:""):this.removeAttribute("autoplay"))}get preload(){let r=this.getAttribute("preload");return r===""?"auto":["none","metadata","auto"].includes(r)?r:super.preload}set preload(r){r!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(r)?this.setAttribute("preload",r):this.removeAttribute("preload"))}get debug(){return this.getAttribute(ne.DEBUG)!=null}set debug(r){r!==this.debug&&(r?this.setAttribute(ne.DEBUG,""):this.removeAttribute(ne.DEBUG))}get disableCookies(){return this.hasAttribute(ne.DISABLE_COOKIES)}set disableCookies(r){r!==this.disableCookies&&(r?this.setAttribute(ne.DISABLE_COOKIES,""):this.removeAttribute(ne.DISABLE_COOKIES))}get startTime(){let r=this.getAttribute(ne.START_TIME);if(r==null)return;let t=+r;return Number.isNaN(t)?void 0:t}set startTime(r){r!==this.startTime&&(r==null?this.removeAttribute(ne.START_TIME):this.setAttribute(ne.START_TIME,`${r}`))}get playbackId(){var r;return(r=this.getAttribute(ne.PLAYBACK_ID))!=null?r:void 0}set playbackId(r){r!==this.playbackId&&(r?this.setAttribute(ne.PLAYBACK_ID,r):this.removeAttribute(ne.PLAYBACK_ID))}get customDomain(){var r;return(r=this.getAttribute(ne.CUSTOM_DOMAIN))!=null?r:void 0}set customDomain(r){r!==this.customDomain&&(r?this.setAttribute(ne.CUSTOM_DOMAIN,r):this.removeAttribute(ne.CUSTOM_DOMAIN))}get envKey(){var r;return(r=this.getAttribute(ne.ENV_KEY))!=null?r:void 0}set envKey(r){r!==this.envKey&&(r?this.setAttribute(ne.ENV_KEY,r):this.removeAttribute(ne.ENV_KEY))}get beaconCollectionDomain(){var r;return(r=this.getAttribute(ne.BEACON_COLLECTION_DOMAIN))!=null?r:void 0}set beaconCollectionDomain(r){r!==this.beaconCollectionDomain&&(r?this.setAttribute(ne.BEACON_COLLECTION_DOMAIN,r):this.removeAttribute(ne.BEACON_COLLECTION_DOMAIN))}get streamType(){var r;return(r=this.getAttribute(ne.STREAM_TYPE))!=null?r:void 0}set streamType(r){r!==this.streamType&&(r?this.setAttribute(ne.STREAM_TYPE,r):this.removeAttribute(ne.STREAM_TYPE))}get preferPlayback(){let r=this.getAttribute(ne.PREFER_PLAYBACK);if(r===Ot.MSE||r===Ot.NATIVE)return r}set preferPlayback(r){r!==this.preferPlayback&&(r===Ot.MSE||r===Ot.NATIVE?this.setAttribute(ne.PREFER_PLAYBACK,r):this.removeAttribute(ne.PREFER_PLAYBACK))}get metadata(){let r=this.getAttribute(ne.METADATA_VIDEO_ID),t=this.getAttribute(ne.METADATA_VIDEO_TITLE),e=this.getAttribute(ne.METADATA_VIEWER_USER_ID);return{...de(this,Ki),...r!=null?{video_id:r}:{},...t!=null?{video_title:t}:{},...e!=null?{viewer_user_id:e}:{}}}set metadata(r){Ve(this,Ki,r!=null?r:{}),this.mux&&this.mux.emit("hb",de(this,Ki))}load(){Ve(this,er,Cl(this,this.nativeEl,de(this,er)))}unload(){Is(this.nativeEl,de(this,er)),Ve(this,er,void 0)}attributeChangedCallback(r,t,e){var a,s;switch(super.attributeChangedCallback(r,t,e),r){case ne.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=e!=null?e:void 0;break;case ne.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=e!=null?e:void 0;break;case"src":{let u=!!t,R=!!e;!u&&R?et(this,Fn,Rs).call(this):u&&!R?this.unload():u&&R&&(this.unload(),et(this,Fn,Rs).call(this));break}case"autoplay":if(e===t)break;(a=de(this,er))==null||a.setAutoplay(this.autoplay);break;case"preload":if(e===t)break;(s=de(this,er))==null||s.setPreload(e);break;case ne.PLAYBACK_ID:this.src=Ml(e!=null?e:void 0,{domain:this.customDomain});break;case ne.DEBUG:{let u=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=u);break}case ne.METADATA_URL:e&&fetch(e).then(u=>u.json()).then(u=>this.metadata=u).catch(u=>console.error(`Unable to load or parse metadata JSON from metadata-url ${e}!`));break;default:break}}disconnectedCallback(){this.unload()}};er=new WeakMap,Fi=new WeakMap,wn=new WeakMap,Ki=new WeakMap,Un=new WeakMap,Nn=new WeakMap,Bn=new WeakMap,Fn=new WeakSet,Rs=async function(){de(this,Fi)||(await Ve(this,Fi,Promise.resolve()),Ve(this,Fi,null),this.load())};vr.customElements.get("mux-video")||(vr.customElements.define("mux-video",Cs),vr.MuxVideoElement=Cs);var Gl=Cs;var Of="en",Or={code:Of};var jl="en";function Oe(r,t=!0){var s,u;let e=t&&(u=(s=Or)==null?void 0:s[r])!=null?u:r,a=t?Or.code:jl;return new ws(e,a)}var ws=class{constructor(t,e=(a=>(a=Or.code)!=null?a:jl)()){this.message=t,this.locale=e}format(t){return this.message.replace(/\{(\w+)\}/g,(e,a)=>{var s;return(s=t[a])!=null?s:""})}toString(){return this.message}};function Vl(r){let t="";return Object.entries(r).forEach(([e,a])=>{a!=null&&(t+=`${Pf(e)}: ${a}; `)}),t?t.trim():void 0}function Pf(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function $l(r){return r.replace(/[-_]([a-z])/g,(t,e)=>e.toUpperCase())}function tr(r){if(r==null)return;let t=+r;return Number.isNaN(t)?void 0:t}function Hn(r){let t=kf(r).toString();return t?"?"+t:""}function kf(r){let t={};for(let e in r)r[e]!=null&&(t[e]=r[e]);return new URLSearchParams(t)}function gr(r){let t=(r!=null?r:"").split(".")[1];if(!t)return{};let e=t.replace(/-/g,"+").replace(/_/g,"/"),a=decodeURIComponent(atob(e).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(a)}var Us=(r,t)=>!r||!t?!1:r.contains(t)?!0:Us(r,t.getRootNode().host);var Ns="mux.com",wf=()=>{try{return"1.4.0"}catch{}return"UNKNOWN"},Uf=wf(),jn=()=>Uf,Bs=(r,{token:t,domain:e=Ns}={})=>`https://stream.${e}/${r}.m3u8${Hn(!!t?{token:t}:{redundant_streams:!0})}`,Xl=(r,{token:t,thumbnailTime:e,domain:a=Ns}={})=>{let s=t==null?e:void 0,{aud:u}=gr(t);if(!(t&&u!=="t"))return`https://image.${a}/${r}/thumbnail.jpg${Hn({token:t,time:s})}`},Ql=(r,{token:t,domain:e=Ns}={})=>{let{aud:a}=gr(t);if(!(t&&a!=="s"))return`https://image.${e}/${r}/storyboard.vtt${Hn({token:t})}`};function Fs(r){if(r&&/^media-theme-[\w-]+$/.test(r))return r}var Nf={crossorigin:"crossOrigin",playsinline:"playsInline"};function Zl(r){var t;return(t=Nf[r])!=null?t:$l(r)}var Jl=r=>{var e,a;let{media:t}=r;return(a=(e=t==null?void 0:t._hls)==null?void 0:e.liveSyncPosition)!=null?a:t!=null&&t.seekable.length?t==null?void 0:t.seekable.end(t.seekable.length-1):void 0},Ks=r=>{let t=Jl(r);if(t==null){console.warn("attempting to seek to live but cannot determine live edge time!");return}r.currentTime=t},Bf=1,Ff=5,Yl=3,zl=.5,ql=r=>{var u;let{streamType:t}=r,e=Jl(r),a=(u=r.media)==null?void 0:u.currentTime;if(e==null||a==null)return!1;let s=e-a;return t===be.LL_LIVE||t===be.LL_DVR?s<=Bf*(Yl+zl):t===be.LIVE||t===be.DVR?s<=Ff*(Yl+zl):!1},Pr,kr,pt,Gn=class{constructor(t,e){Be(this,Pr,void 0);Be(this,kr,void 0);Be(this,pt,[]);gt(this,Pr,t),gt(this,kr,e)}[Symbol.iterator](){return xe(this,pt).values()}get length(){return xe(this,pt).length}get value(){var t;return(t=xe(this,pt).join(" "))!=null?t:""}set value(t){var e;t!==this.value&&(gt(this,pt,[]),this.add(...(e=t==null?void 0:t.split(" "))!=null?e:[]))}toString(){return this.value}item(t){return xe(this,pt)[t]}values(){return xe(this,pt).values()}keys(){return xe(this,pt).keys()}forEach(t){xe(this,pt).forEach(t)}add(...t){var e,a;t.forEach(s=>{this.contains(s)||xe(this,pt).push(s)}),!(this.value===""&&!((e=xe(this,Pr))!=null&&e.hasAttribute(`${xe(this,kr)}`)))&&((a=xe(this,Pr))==null||a.setAttribute(`${xe(this,kr)}`,`${this.value}`))}remove(...t){var e;t.forEach(a=>{xe(this,pt).splice(xe(this,pt).indexOf(a),1)}),(e=xe(this,Pr))==null||e.setAttribute(`${xe(this,kr)}`,`${this.value}`)}contains(t){return xe(this,pt).includes(t)}toggle(t,e){return typeof e!="undefined"?e?(this.add(t),!0):(this.remove(t),!1):this.contains(t)?(this.remove(t),!1):(this.add(t),!0)}replace(t,e){this.remove(t),this.add(e)}};Pr=new WeakMap,kr=new WeakMap,pt=new WeakMap;var eu=`[mux-player ${jn()}]`;function pr(...r){console.warn(eu,...r)}function Qt(...r){console.error(eu,...r)}function Vn(r){var e;let t=(e=r.message)!=null?e:"";if(r.file){let a="https://github.com/muxinc/elements/blob/main/errors/";t+=` ${Oe("Read more: ")}
790
+ ${a}${r.file}`}pr(t)}var dt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},wr={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},ru=Object.freeze({length:0,start(r){let t=r>>>0;if(t>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${t}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(r){let t=r>>>0;if(t>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${t}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),Kf=ks.filter(r=>r!=="error"),Wf=Object.values(dt).filter(r=>![dt.PLAYSINLINE].includes(r)),Hf=Object.values(wr);function iu(r){r.querySelectorAll(":scope > track").forEach(t=>{var e;(e=r.media)==null||e.append(t.cloneNode())}),Kf.forEach(t=>{var e;(e=r.media)==null||e.addEventListener(t,a=>{r.dispatchEvent(new Event(a.type))})})}var Ws=class extends je.HTMLElement{static get observedAttributes(){return[...Wf,...Hf]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(a=>{var s;(s=this.media)==null||s.append(a.cloneNode())});let t=a=>{for(let s of a)s.type==="childList"&&(s.removedNodes.forEach(u=>{var C,O;let R=(C=this.media)==null?void 0:C.querySelector(`track[src="${u.src}"]`);R&&((O=this.media)==null||O.removeChild(R))}),s.addedNodes.forEach(u=>{var R;(R=this.media)==null||R.append(u.cloneNode())}))};new MutationObserver(t).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(t,e,a){var s,u;switch(t){case wr.MUTED:{this.media&&(this.media.muted=a!=null,this.media.defaultMuted=a!=null);return}case wr.VOLUME:{let R=(s=tr(a))!=null?s:1;this.media&&(this.media.volume=R);return}case wr.PLAYBACKRATE:{let R=(u=tr(a))!=null?u:1;this.media&&(this.media.playbackRate=R,this.media.defaultPlaybackRate=R);return}}}play(){var t,e;return(e=(t=this.media)==null?void 0:t.play())!=null?e:Promise.reject()}pause(){var t;(t=this.media)==null||t.pause()}requestCast(t){var e;return(e=this.media)==null?void 0:e.requestCast(t)}get media(){var t;return(t=this.shadowRoot)==null?void 0:t.querySelector("mux-video")}get paused(){var t,e;return(e=(t=this.media)==null?void 0:t.paused)!=null?e:!0}get duration(){var t,e;return(e=(t=this.media)==null?void 0:t.duration)!=null?e:NaN}get ended(){var t,e;return(e=(t=this.media)==null?void 0:t.ended)!=null?e:!1}get buffered(){var t,e;return(e=(t=this.media)==null?void 0:t.buffered)!=null?e:ru}get seekable(){var t,e;return(e=(t=this.media)==null?void 0:t.seekable)!=null?e:ru}get readyState(){var t,e;return(e=(t=this.media)==null?void 0:t.readyState)!=null?e:0}get videoWidth(){var t,e;return(e=(t=this.media)==null?void 0:t.videoWidth)!=null?e:0}get videoHeight(){var t,e;return(e=(t=this.media)==null?void 0:t.videoHeight)!=null?e:0}get currentTime(){var t,e;return(e=(t=this.media)==null?void 0:t.currentTime)!=null?e:0}set currentTime(t){this.media&&(this.media.currentTime=Number(t))}get volume(){var t,e;return(e=(t=this.media)==null?void 0:t.volume)!=null?e:1}set volume(t){this.media&&(this.media.volume=Number(t))}get playbackRate(){var t,e;return(e=(t=this.media)==null?void 0:t.playbackRate)!=null?e:1}set playbackRate(t){this.media&&(this.media.playbackRate=Number(t))}get defaultPlaybackRate(){var t;return(t=tr(this.getAttribute(wr.PLAYBACKRATE)))!=null?t:1}set defaultPlaybackRate(t){t!=null?this.setAttribute(wr.PLAYBACKRATE,`${t}`):this.removeAttribute(wr.PLAYBACKRATE)}get crossOrigin(){return Wi(this,dt.CROSSORIGIN)}set crossOrigin(t){this.setAttribute(dt.CROSSORIGIN,`${t}`)}get autoplay(){return Wi(this,dt.AUTOPLAY)!=null}set autoplay(t){t?this.setAttribute(dt.AUTOPLAY,typeof t=="string"?t:""):this.removeAttribute(dt.AUTOPLAY)}get loop(){return Wi(this,dt.LOOP)!=null}set loop(t){t?this.setAttribute(dt.LOOP,""):this.removeAttribute(dt.LOOP)}get muted(){var t,e;return(e=(t=this.media)==null?void 0:t.muted)!=null?e:!1}set muted(t){this.media&&(this.media.muted=Boolean(t))}get defaultMuted(){return Wi(this,dt.MUTED)!=null}set defaultMuted(t){t?this.setAttribute(dt.MUTED,""):this.removeAttribute(dt.MUTED)}get playsInline(){return Wi(this,dt.PLAYSINLINE)!=null}set playsInline(t){Qt("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(t){["","none","metadata","auto"].includes(t)?this.setAttribute(dt.PRELOAD,t):this.removeAttribute(dt.PRELOAD)}};function Wi(r,t){return r.media?r.media.getAttribute(t):r.getAttribute(t)}var Hs=Ws;var $n=new Map;function Yn(r){if($n.has(r))return $n.get(r);let t=r.length,e=0,a=0,s=0,u=[];for(let R=0;R<t;R+=1){let C=r[R],O=r[R+1],L=r[R-1];C==="{"&&O==="{"&&L!=="\\"?(s+=1,s===1&&(a=R),R+=1):C==="}"&&O==="}"&&L!=="\\"&&s&&(s-=1,s===0&&(a>e&&(u.push(Object.freeze({type:"string",start:e,end:a,value:r.slice(e,a)})),e=a),u.push(Object.freeze({type:"part",start:a,end:R+2,value:r.slice(e+2,R).trim()})),R+=1,e=R+1))}return e<t&&u.push(Object.freeze({type:"string",start:e,end:t,value:r.slice(e,t)})),$n.set(r,Object.freeze(u)),$n.get(r)}var Ur=new WeakMap,nu=new WeakMap,Wt=class{constructor(t,e){this.expression=e,Ur.set(this,t),t.updateParent("")}get attributeName(){return Ur.get(this).attr.name}get attributeNamespace(){return Ur.get(this).attr.namespaceURI}get value(){return nu.get(this)}set value(t){nu.set(this,t||""),Ur.get(this).updateParent(t)}get element(){return Ur.get(this).element}get booleanValue(){return Ur.get(this).booleanValue}set booleanValue(t){Ur.get(this).booleanValue=t}},Hi=class{constructor(t,e){this.element=t,this.attr=e,this.partList=[]}get booleanValue(){return this.element.hasAttributeNS(this.attr.namespaceURI,this.attr.name)}set booleanValue(t){if(this.partList.length!==1)throw new DOMException("Operation not supported","NotSupportedError");this.partList[0].value=t?"":null}append(t){this.partList.push(t)}updateParent(t){if(this.partList.length===1&&t===null)this.element.removeAttributeNS(this.attr.namespaceURI,this.attr.name);else{let e=this.partList.map(a=>typeof a=="string"?a:a.value).join("");this.element.setAttributeNS(this.attr.namespaceURI,this.attr.name,e)}}};var Er=new WeakMap,Zt=class{constructor(t,e){this.expression=e,Er.set(this,[t]),t.textContent=""}get value(){return Er.get(this).map(t=>t.textContent).join("")}set value(t){this.replace(t)}get previousSibling(){return Er.get(this)[0].previousSibling}get nextSibling(){return Er.get(this)[Er.get(this).length-1].nextSibling}replace(...t){let e=t.map(a=>typeof a=="string"?new Text(a):a);e.length||e.push(new Text("")),Er.get(this)[0].before(...e);for(let a of Er.get(this))a.remove();Er.set(this,e)}};function Gi(r){return{processCallback(t,e,a){var s;if(!(typeof a!="object"||!a)){for(let u of e)if(u.expression in a){let R=(s=a[u.expression])!==null&&s!==void 0?s:"";r(u,R)}}}}}function Gs(r,t){r.value=String(t)}function au(r,t){return typeof t=="boolean"&&r instanceof Wt&&typeof r.element[r.attributeName]=="boolean"?(r.booleanValue=t,!0):!1}var js=Gi(Gs),Gf=Gi((r,t)=>{au(r,t)||Gs(r,t)});function*jf(r){let t=r.ownerDocument.createTreeWalker(r,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,null,!1),e;for(;e=t.nextNode();)if(e instanceof Element&&e.hasAttributes())for(let a=0;a<e.attributes.length;a+=1){let s=e.attributes.item(a);if(s&&s.value.includes("{{")){let u=new Hi(e,s);for(let R of Yn(s.value))if(R.type==="string")u.append(R.value);else{let C=new Wt(u,R.value);u.append(C),yield C}}}else if(e instanceof Text&&e.textContent&&e.textContent.includes("{{")){let a=Yn(e.textContent);for(let s=0;s<a.length;s+=1){let u=a[s];u.end<e.textContent.length&&e.splitText(u.end),u.type==="part"&&(yield new Zt(e,u.value));break}}}var zn=new WeakMap,Xn=new WeakMap,rr=class extends DocumentFragment{constructor(t,e,a=js){var s,u;super(),Object.getPrototypeOf(this)!==rr.prototype&&Object.setPrototypeOf(this,rr.prototype),this.appendChild(t.content.cloneNode(!0)),Xn.set(this,Array.from(jf(this))),zn.set(this,a),(u=(s=zn.get(this)).createCallback)===null||u===void 0||u.call(s,this,Xn.get(this),e),zn.get(this).processCallback(this,Xn.get(this),e)}update(t){zn.get(this).processCallback(this,Xn.get(this),t)}};var ji=new WeakMap,Vi=class{constructor(t,e){this.element=t;this.type=e;this.element.addEventListener(this.type,this);let a=ji.get(this.element);a&&a.set(this.type,this)}set(t){if(typeof t=="function")this.handleEvent=t.bind(this.element);else if(typeof t=="object"&&typeof t.handleEvent=="function")this.handleEvent=t.handleEvent.bind(t);else{this.element.removeEventListener(this.type,this);let e=ji.get(this.element);e&&e.delete(this.type)}}static for(t){ji.has(t.element)||ji.set(t.element,new Map);let e=t.attributeName.slice(2),a=ji.get(t.element);return a&&a.has(e)?a.get(e):new Vi(t.element,e)}};function Vf(r,t){return r instanceof Wt&&r.attributeName.startsWith("on")?(Vi.for(r).set(t),r.element.removeAttributeNS(r.attributeNamespace,r.attributeName),!0):!1}function $f(r,t){return t instanceof $i&&r instanceof Zt?(t.renderInto(r),!0):!1}function Yf(r,t){return t instanceof DocumentFragment&&r instanceof Zt?(t.childNodes.length&&r.replace(...t.childNodes),!0):!1}function zf(r,t){if(r instanceof Wt){let e=r.attributeNamespace,a=r.element.getAttributeNS(e,r.attributeName);return String(t)!==a&&(r.value=String(t)),!0}return r.value=String(t),!0}function Xf(r,t){if(typeof t=="boolean"&&r instanceof Wt){let e=r.attributeNamespace,a=r.element.hasAttributeNS(e,r.attributeName);return t!==a&&(r.booleanValue=t),!0}return!1}function Qf(r,t){return t===!1&&r instanceof Zt?(r.replace(""),!0):!1}function Zf(r,t){Xf(r,t)||Vf(r,t)||Qf(r,t)||$f(r,t)||Yf(r,t)||zf(r,t)}var Vs=new WeakMap,su=new WeakMap,ou=new WeakMap,$i=class{constructor(t,e,a){this.strings=t;this.values=e;this.processor=a}get template(){if(Vs.has(this.strings))return Vs.get(this.strings);{let t=document.createElement("template"),e=this.strings.length-1;return t.innerHTML=this.strings.reduce((a,s,u)=>a+s+(u<e?`{{ ${u} }}`:""),""),Vs.set(this.strings,t),t}}renderInto(t){let e=this.template;if(su.get(t)!==e){su.set(t,e);let s=new rr(e,this.values,this.processor);ou.set(t,s),t instanceof Zt?t.replace(...s.children):t.appendChild(s);return}let a=ou.get(t);a&&a.update(this.values)}},lu=new Map,Jf=Gi(Zf);function pe(r,...t){let e=[""],a=[],s,u=!1,R=(C,O=[])=>{e[e.length-1]=e[e.length-1]+C[0],O.forEach((L,b)=>{(s=L==null?void 0:L.$static$)!==void 0?(s.forEach(x=>{R(x.strings,x.values)}),e[e.length-1]=e[e.length-1]+C[b+1],u=!0):(a.push(L),e.push(C[b+1]))})};if(R(r,t),u){let C=e.join("$$html$$");r=lu.get(C),r===void 0&&(e.raw=e,lu.set(C,r=e)),t=a}return new $i(r,t,Jf)}function Qn(r,t){r.renderInto(t)}function at(r,t){let e=document.createElement("template");return e.innerHTML=r,new rr(e,t)}var $s=(...r)=>({$static$:r.map(t=>t instanceof $i?t:/\w-/.test(t)?{strings:[t]}:{strings:[]})});var du=`
776
791
  :host {
777
792
  cursor: pointer;
778
793
  }
779
794
  media-time-display {
780
795
  color: inherit;
781
796
  }
782
- `,ru=Nt.createElement("template");ru.innerHTML=`
797
+ `,cu=Bt.createElement("template");cu.innerHTML=`
783
798
  <style>
784
- ${tu}
799
+ ${du}
785
800
  </style>
786
801
  <media-time-display show-duration></media-time-display>
787
- `;var eu=["Enter"," "],Gi,ii,Gn,ri=class extends je.HTMLElement{constructor(){var e,s;super();Ne(this,ii);Ne(this,Gi,void 0);this.attachShadow({mode:"open"}),(e=this.shadowRoot)==null||e.appendChild(this.constructor.template.content.cloneNode(!0)),this.timeDisplayEl=(s=this.shadowRoot)==null?void 0:s.querySelector("media-time-display")}static get observedAttributes(){return["hide-duration","remaining","disabled","aria-disabled"]}toggleTimeDisplay(){var e,s,a;(e=this.timeDisplayEl)!=null&&e.hasAttribute("remaining")?(s=this.timeDisplayEl)==null||s.removeAttribute("remaining"):(a=this.timeDisplayEl)==null||a.setAttribute("remaining","")}connectedCallback(){let e=s=>{let{key:a}=s;if(!eu.includes(a)){this.removeEventListener("keyup",e);return}this.toggleTimeDisplay()};this.addEventListener("keydown",s=>{let{metaKey:a,altKey:u,key:R}=s;if(a||u||!eu.includes(R)){this.removeEventListener("keyup",e);return}this.addEventListener("keyup",e)}),this.addEventListener("click",this.toggleTimeDisplay),mt(this,Gi,setInterval(Fe(this,ii,Gn).bind(this),200)),requestAnimationFrame(()=>Fe(this,ii,Gn).call(this))}disconnectedCallback(){clearInterval(xe(this,Gi))}attributeChangedCallback(e,s,a){var u,R;e==="hide-duration"&&Fe(this,ii,Gn).call(this),["remaining","disabled","aria-disabled"].includes(e)&&s!==a&&(a==null?(u=this.timeDisplayEl)==null||u.removeAttribute(e):(R=this.timeDisplayEl)==null||R.setAttribute(e,a))}};Gi=new WeakMap,ii=new WeakSet,Gn=function(){var s,a,u,R;getComputedStyle(this).getPropertyValue("--media-duration-display").trim()==="none"||this.getAttribute("hide-duration")!=null?(s=this.timeDisplayEl)!=null&&s.hasAttribute("show-duration")&&((a=this.timeDisplayEl)==null||a.removeAttribute("show-duration")):(u=this.timeDisplayEl)!=null&&u.hasAttribute("show-duration")||(R=this.timeDisplayEl)==null||R.setAttribute("show-duration","")},ri.styles=tu,ri.template=ru;je.customElements.get("mxp-time-display")||(je.customElements.define("mxp-time-display",ri),je.MxpTimeDisplay=ri);var iu=`:host(:not([audio])) {
802
+ `;var uu=["Enter"," "],Yi,ai,Zn,ni=class extends je.HTMLElement{constructor(){var e,a;super();Be(this,ai);Be(this,Yi,void 0);this.attachShadow({mode:"open"}),(e=this.shadowRoot)==null||e.appendChild(this.constructor.template.content.cloneNode(!0)),this.timeDisplayEl=(a=this.shadowRoot)==null?void 0:a.querySelector("media-time-display")}static get observedAttributes(){return["hide-duration","remaining","disabled","aria-disabled"]}toggleTimeDisplay(){var e,a,s;(e=this.timeDisplayEl)!=null&&e.hasAttribute("remaining")?(a=this.timeDisplayEl)==null||a.removeAttribute("remaining"):(s=this.timeDisplayEl)==null||s.setAttribute("remaining","")}connectedCallback(){let e=a=>{let{key:s}=a;if(!uu.includes(s)){this.removeEventListener("keyup",e);return}this.toggleTimeDisplay()};this.addEventListener("keydown",a=>{let{metaKey:s,altKey:u,key:R}=a;if(s||u||!uu.includes(R)){this.removeEventListener("keyup",e);return}this.addEventListener("keyup",e)}),this.addEventListener("click",this.toggleTimeDisplay),gt(this,Yi,setInterval(Fe(this,ai,Zn).bind(this),200)),requestAnimationFrame(()=>Fe(this,ai,Zn).call(this))}disconnectedCallback(){clearInterval(xe(this,Yi))}attributeChangedCallback(e,a,s){var u,R;e==="hide-duration"&&Fe(this,ai,Zn).call(this),["remaining","disabled","aria-disabled"].includes(e)&&a!==s&&(s==null?(u=this.timeDisplayEl)==null||u.removeAttribute(e):(R=this.timeDisplayEl)==null||R.setAttribute(e,s))}};Yi=new WeakMap,ai=new WeakSet,Zn=function(){var a,s,u,R;getComputedStyle(this).getPropertyValue("--media-duration-display").trim()==="none"||this.getAttribute("hide-duration")!=null?(a=this.timeDisplayEl)!=null&&a.hasAttribute("show-duration")&&((s=this.timeDisplayEl)==null||s.removeAttribute("show-duration")):(u=this.timeDisplayEl)!=null&&u.hasAttribute("show-duration")||(R=this.timeDisplayEl)==null||R.setAttribute("show-duration","")},ni.styles=du,ni.template=cu;je.customElements.get("mxp-time-display")||(je.customElements.define("mxp-time-display",ni),je.MxpTimeDisplay=ni);var fu=`:host(:not([audio])) {
788
803
  --secondary-color: transparent;
789
804
  }
790
805
 
@@ -884,57 +899,87 @@ media-controller {
884
899
 
885
900
  :host media-time-range {
886
901
  color: var(--_primary-color);
902
+ --media-range-thumb-opacity: 0;
887
903
  }
888
904
 
889
905
  :host(:not([audio])) media-time-range {
890
906
  --media-range-padding-left: var(--mux-time-range-padding, 10px);
891
907
  --media-range-padding-right: var(--mux-time-range-padding, 10px);
892
- width: 100%;
908
+ --media-range-padding: 0;
893
909
  z-index: 10;
894
910
  height: 10px;
895
- bottom: -2px;
911
+ bottom: -3px;
896
912
  background: linear-gradient(
897
913
  180deg,
898
914
  transparent,
899
915
  transparent 3px,
900
- var(--media-control-background) 3px,
901
- var(--media-control-background) 8px,
902
- transparent 8px,
916
+ var(--media-control-background, rgba(20, 20, 30, 0.7)) 3px,
917
+ var(--media-control-background, rgba(20, 20, 30, 0.7)) 7px,
918
+ transparent 7px,
903
919
  transparent
904
920
  );
921
+ width: 100%;
922
+ }
923
+
924
+ media-control-bar {
925
+ --media-control-padding: 9px 7px;
926
+ }
927
+
928
+ .size-small media-control-bar {
929
+ --media-control-padding: 9px 5px;
930
+ }
931
+
932
+ .size-extra-small media-control-bar {
933
+ --media-control-padding: 4px 3px;
905
934
  }
906
935
 
907
936
  media-control-bar :is([role='button'], [role='switch'], button) {
908
937
  line-height: 0;
909
- --media-control-padding: 10px 7px;
910
938
  }
911
939
 
912
- .size-extra-small media-control-bar [role='button'],
913
- .size-extra-small media-control-bar [role='switch'] {
914
- height: auto;
915
- padding: 4.4% 3.2%;
940
+ media-control-bar :is(media-text-display, mxp-time-display):first-child {
941
+ --media-control-padding: 9px 5px 9px 10px;
916
942
  }
917
943
 
918
944
  .spacer {
919
945
  flex-grow: 1;
920
- height: 100%;
921
946
  background-color: var(--media-control-background, rgba(20, 20, 30, 0.7));
922
947
  }
923
948
 
924
949
  /* Add a small space on the right to have the play button and
925
950
  * fullscreen button aligned in relation to the progress bar. */
926
- .size-large .padding-2 {
951
+ media-control-bar:not([slot])::after {
952
+ content: '';
927
953
  width: 2px;
928
954
  height: 100%;
929
955
  background-color: var(--media-control-background, rgba(20, 20, 30, 0.7));
930
956
  }
931
957
 
958
+ media-control-bar[slot='top-chrome'] {
959
+ min-height: 42px;
960
+ pointer-events: none;
961
+ }
962
+
963
+ :host([title]) media-control-bar[slot='top-chrome']::before {
964
+ content: '';
965
+ position: absolute;
966
+ width: 100%;
967
+ padding-bottom: min(160px, 25%);
968
+ background: linear-gradient(rgb(0 0 0 / 0.4), transparent);
969
+ }
970
+
971
+ media-control-bar[slot='top-chrome'] > * {
972
+ --media-control-background: transparent;
973
+ --media-control-hover-background: transparent;
974
+ position: relative;
975
+ }
976
+
932
977
  media-controller::part(vertical-layer) {
933
978
  transition: background-color 1s;
934
979
  }
935
980
 
936
981
  media-controller:is([media-paused], :not([user-inactive]))::part(vertical-layer) {
937
- background-color: var(--controls-backdrop-color, var(--controls, rgba(0, 0, 0, 0.6)));
982
+ background-color: var(--controls-backdrop-color, var(--controls, transparent));
938
983
  transition: background-color 0.25s;
939
984
  }
940
985
 
@@ -947,13 +992,18 @@ media-controller:is([media-paused], :not([user-inactive]))::part(vertical-layer)
947
992
  flex-flow: row;
948
993
  align-items: center;
949
994
  justify-content: center;
995
+ filter: drop-shadow(0 0 2px rgb(0 0 0 / 0.25)) drop-shadow(0 0 6px rgb(0 0 0 / 0.25));
996
+ paint-order: stroke;
997
+ stroke: rgba(102, 102, 102, 1);
998
+ stroke-width: 0.3px;
999
+ text-shadow: 0 0 2px rgb(0 0 0 / 0.25), 0 0 6px rgb(0 0 0 / 0.25);
950
1000
  }
951
1001
 
952
1002
  .center-controls media-play-button {
953
1003
  --media-control-background: transparent;
954
1004
  --media-control-hover-background: transparent;
955
1005
  padding: 0;
956
- width: max(30px, min(11%, 100px));
1006
+ width: max(43px, min(10%, 55px));
957
1007
  }
958
1008
 
959
1009
  .center-controls media-seek-backward-button,
@@ -961,8 +1011,16 @@ media-controller:is([media-paused], :not([user-inactive]))::part(vertical-layer)
961
1011
  --media-control-background: transparent;
962
1012
  --media-control-hover-background: transparent;
963
1013
  padding: 0;
964
- margin: 0 4%;
965
- width: min(7%, 70px);
1014
+ margin: 0 2%;
1015
+ width: max(33px, min(8%, 40px));
1016
+ }
1017
+
1018
+ media-control-bar:not([slot]) media-seek-backward-button {
1019
+ padding-right: 5px;
1020
+ }
1021
+
1022
+ media-control-bar:not([slot]) media-seek-forward-button {
1023
+ padding-left: 5px;
966
1024
  }
967
1025
 
968
1026
  media-loading-indicator {
@@ -1004,52 +1062,53 @@ media-time-display {
1004
1062
 
1005
1063
  .title-display {
1006
1064
  font-size: 16px;
1065
+ text-shadow: 0 0 2px rgb(0 0 0 / 0.6);
1007
1066
  }
1008
1067
 
1009
1068
  :host([audio]) .title-display {
1010
1069
  flex-grow: 1;
1011
1070
  font-size: 21px;
1012
1071
  }
1013
- `;var nu=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="airplay">
1072
+ `;var hu=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="airplay">
1014
1073
  <path d="M13.19 14.22a.25.25 0 0 0-.38 0l-5.46 6.37a.25.25 0 0 0 .19.41h10.92a.25.25 0 0 0 .19-.41l-5.46-6.37Z"/>
1015
1074
  <path d="M22 3H4a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h2.94L8 16.75H4.25V4.25h17.5v12.5H18L19.06 18H22a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Z"/>
1016
1075
  </svg>
1017
- `;var au=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="off">
1076
+ `;var mu=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="off">
1018
1077
  <path d="M22.832 5.68a2.58 2.58 0 0 0-2.3-2.5c-1.81-.12-4.67-.18-7.53-.18-2.86 0-5.72.06-7.53.18a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c1.81.12 4.67.18 7.53.18 2.86 0 5.72-.06 7.53-.18a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.137-.21-8.283 0-12.42a1.11 1.11 0 0 1 .91-1.11c1.67-.11 4.43-.18 7.43-.18s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.137.21 8.283 0 12.42ZM10.843 14a1.55 1.55 0 0 1-.76.18 1.57 1.57 0 0 1-.71-.18 1.69 1.69 0 0 1-.57-.42 2.099 2.099 0 0 1-.38-.58 2.47 2.47 0 0 1 0-1.64 2 2 0 0 1 .39-.66 1.73 1.73 0 0 1 .58-.42c.23-.103.479-.158.73-.16.241-.004.48.044.7.14.199.088.373.222.51.39l1.08-.89a2.179 2.179 0 0 0-.47-.44 2.81 2.81 0 0 0-.54-.32 2.91 2.91 0 0 0-.58-.15 2.71 2.71 0 0 0-.56 0 4.08 4.08 0 0 0-1.38.15 3.27 3.27 0 0 0-1.09.67 3.14 3.14 0 0 0-.71 1.06 3.62 3.62 0 0 0-.26 1.39 3.57 3.57 0 0 0 .26 1.38 3 3 0 0 0 .71 1.06c.316.293.687.52 1.09.67.443.16.91.238 1.38.23a3.2 3.2 0 0 0 1.28-.27c.401-.183.747-.47 1-.83l-1.17-.88a1.42 1.42 0 0 1-.53.52Zm6.62 0a1.58 1.58 0 0 1-.76.18 1.54 1.54 0 0 1-.7-.18 1.69 1.69 0 0 1-.57-.42 2.12 2.12 0 0 1-.43-.58 2.29 2.29 0 0 1 .39-2.3 1.84 1.84 0 0 1 1.32-.58c.241-.003.48.045.7.14.199.088.373.222.51.39l1.08-.92a2.43 2.43 0 0 0-.47-.44 3.22 3.22 0 0 0-.53-.29 2.999 2.999 0 0 0-.57-.15 2.87 2.87 0 0 0-.57 0 4.06 4.06 0 0 0-1.36.15 3.17 3.17 0 0 0-1.09.67 3 3 0 0 0-.72 1.06 3.62 3.62 0 0 0-.25 1.39 3.57 3.57 0 0 0 .25 1.38c.16.402.405.764.72 1.06a3.17 3.17 0 0 0 1.09.67c.44.16.904.237 1.37.23.441 0 .877-.092 1.28-.27a2.45 2.45 0 0 0 1-.83l-1.15-.85a1.49 1.49 0 0 1-.54.49Z"/>
1019
1078
  </svg>
1020
- `;var su=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="on">
1079
+ `;var vu=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="on">
1021
1080
  <path d="M22.832 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.41 10.1a3.63 3.63 0 0 1-1.51.32 4.76 4.76 0 0 1-1.63-.27 4 4 0 0 1-1.28-.83 3.67 3.67 0 0 1-.84-1.26 4.23 4.23 0 0 1-.3-1.63 4.28 4.28 0 0 1 .3-1.64 3.53 3.53 0 0 1 .84-1.21 3.89 3.89 0 0 1 1.29-.8 4.76 4.76 0 0 1 1.63-.27 4.06 4.06 0 0 1 1.35.24c.225.091.44.205.64.34a2.7 2.7 0 0 1 .55.52l-1.27 1a1.79 1.79 0 0 0-.6-.46 2 2 0 0 0-.83-.16 2 2 0 0 0-1.56.69 2.35 2.35 0 0 0-.46.77 2.78 2.78 0 0 0-.16 1c-.009.34.046.68.16 1 .104.283.26.545.46.77.188.21.415.38.67.5a2 2 0 0 0 .84.18 1.87 1.87 0 0 0 .9-.21 1.78 1.78 0 0 0 .65-.6l1.38 1a2.88 2.88 0 0 1-1.22 1.01Zm7.52 0a3.63 3.63 0 0 1-1.51.32 4.76 4.76 0 0 1-1.63-.27 3.89 3.89 0 0 1-1.28-.83 3.55 3.55 0 0 1-.85-1.26 4.23 4.23 0 0 1-.3-1.63 4.28 4.28 0 0 1 .3-1.64 3.43 3.43 0 0 1 .85-1.25 3.75 3.75 0 0 1 1.28-.8 4.76 4.76 0 0 1 1.63-.27 4 4 0 0 1 1.35.24c.225.091.44.205.64.34.21.144.395.32.55.52l-1.27 1a1.79 1.79 0 0 0-.6-.46 2 2 0 0 0-.83-.16 2 2 0 0 0-1.56.69 2.352 2.352 0 0 0-.46.77 3.01 3.01 0 0 0-.16 1c-.003.34.05.678.16 1 .108.282.263.542.46.77.188.21.416.38.67.5a2 2 0 0 0 .84.18 1.87 1.87 0 0 0 .9-.21 1.78 1.78 0 0 0 .65-.6l1.38 1a2.82 2.82 0 0 1-1.21 1.05Z"/>
1022
1081
  </svg>
1023
- `;var ou=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="enter">
1082
+ `;var gu=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="enter">
1024
1083
  <path d="M3 15.5V17c2.206 0 4 1.794 4 4h1.5A5.5 5.5 0 0 0 3 15.5Zm0 3V21h2.5A2.5 2.5 0 0 0 3 18.5Z"/>
1025
1084
  <path d="M3 12.5V14c3.86 0 7 3.14 7 7h1.5A8.5 8.5 0 0 0 3 12.5Z"/>
1026
1085
  <path d="M22 3H4a1 1 0 0 0-1 1v6.984c.424 0 .84.035 1.25.086V4.25h17.5v15.5h-8.82c.051.41.086.826.086 1.25H22a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Z"/>
1027
1086
  </svg>
1028
- `;var lu=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="exit">
1087
+ `;var pu=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="exit">
1029
1088
  <path d="M3 15.5V17c2.206 0 4 1.794 4 4h1.5A5.5 5.5 0 0 0 3 15.5Zm0 3V21h2.5A2.5 2.5 0 0 0 3 18.5Z"/>
1030
1089
  <path d="M3 12.5V14c3.86 0 7 3.14 7 7h1.5A8.5 8.5 0 0 0 3 12.5Z"/>
1031
1090
  <path d="M22 3H4a1 1 0 0 0-1 1v6.984c.424 0 .84.035 1.25.086V4.25h17.5v15.5h-8.82c.051.41.086.826.086 1.25H22a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Z"/>
1032
1091
  <path d="M20.5 5.5h-15v5.811c3.52.906 6.283 3.67 7.189 7.19H20.5V5.5Z"/>
1033
1092
  </svg>
1034
- `;var uu=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="enter">
1093
+ `;var Eu=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="enter">
1035
1094
  <path d="M20.25 14.5a.76.76 0 0 0-.75.75v4.25h-4.25a.75.75 0 1 0 0 1.5h5a.76.76 0 0 0 .75-.75v-5a.76.76 0 0 0-.75-.75Zm0-11.5h-5a.76.76 0 0 0-.75.75.76.76 0 0 0 .75.75h4.25v4.25a.75.75 0 1 0 1.5 0v-5a.76.76 0 0 0-.75-.75ZM8.75 19.5H4.5v-4.25a.76.76 0 0 0-.75-.75.76.76 0 0 0-.75.75v5a.76.76 0 0 0 .75.75h5a.75.75 0 1 0 0-1.5Zm0-16.5h-5a.76.76 0 0 0-.75.75v5a.76.76 0 0 0 .75.75.76.76 0 0 0 .75-.75V4.5h4.25a.76.76 0 0 0 .75-.75.76.76 0 0 0-.75-.75Z"/>
1036
1095
  </svg>
1037
- `;var du=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="exit">
1096
+ `;var yu=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="exit">
1038
1097
  <path d="M20.25 14.5h-5a.76.76 0 0 0-.75.75v5a.75.75 0 1 0 1.5 0V16h4.25a.75.75 0 1 0 0-1.5Zm-5-5h5a.75.75 0 1 0 0-1.5H16V3.75a.75.75 0 1 0-1.5 0v5a.76.76 0 0 0 .75.75Zm-6.5 5h-5a.75.75 0 1 0 0 1.5H8v4.25a.75.75 0 1 0 1.5 0v-5a.76.76 0 0 0-.75-.75Zm0-11.5a.76.76 0 0 0-.75.75V8H3.75a.75.75 0 0 0 0 1.5h5a.76.76 0 0 0 .75-.75v-5A.76.76 0 0 0 8.75 3Z"/>
1039
1098
  </svg>
1040
- `;var cu=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="pause">
1099
+ `;var Tu=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="pause">
1041
1100
  <path d="M6 19.5a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-15a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5v15ZM14.5 4a.5.5 0 0 0-.5.5v15a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-15a.5.5 0 0 0-.5-.5h-3Z"/>
1042
1101
  </svg>
1043
- `;var fu=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="enter">
1102
+ `;var bu=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="enter">
1044
1103
  <path d="M22 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h6.75v-1.25h-6.5V4.25h17.5v6.5H23V4a1 1 0 0 0-1-1Zm0 10h-8a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-6a1 1 0 0 0-1-1Zm-.5 6.5h-7v-5h7v5Z"/>
1045
1104
  </svg>
1046
- `;var hu=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="exit">
1105
+ `;var Au=`<svg aria-hidden="true" viewBox="0 0 26 24" slot="exit">
1047
1106
  <path d="M22 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h6.75v-1.25h-6.5V4.25h17.5v6.5H23V4a1 1 0 0 0-1-1Zm0 10h-8a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-6a1 1 0 0 0-1-1Zm-.5 6.5h-7v-5h7v5Z"/>
1048
1107
  </svg>
1049
- `;var vu=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="play">
1108
+ `;var _u=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="play">
1050
1109
  <path d="m6.73 20.93 14.05-8.54a.46.46 0 0 0 0-.78L6.73 3.07a.48.48 0 0 0-.73.39v17.07a.48.48 0 0 0 .73.4Z"/>
1051
1110
  </svg>
1052
- `;var mu=`<svg aria-hidden="true" viewBox="0 0 22 24" slot="backward">
1111
+ `;var Su=`<svg aria-hidden="true" viewBox="0 0 22 24" slot="backward">
1053
1112
  <path d="M11 6V3L5.37 7 11 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 11 6Z"/>
1054
1113
  <text
1055
1114
  class="value"
@@ -1059,7 +1118,7 @@ media-time-display {
1059
1118
  {{value}}
1060
1119
  </text>
1061
1120
  </svg>
1062
- `;var gu=`<svg aria-hidden="true" viewBox="0 0 22 24" slot="forward">
1121
+ `;var xu=`<svg aria-hidden="true" viewBox="0 0 22 24" slot="forward">
1063
1122
  <path d="M11 6V3l5.61 4L11 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 11 6Z"/>
1064
1123
  <text
1065
1124
  class="value"
@@ -1069,21 +1128,21 @@ media-time-display {
1069
1128
  {{value}}
1070
1129
  </text>
1071
1130
  </svg>
1072
- `;var pu=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="high">
1131
+ `;var Lu=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="high">
1073
1132
  <path d="m11.14 4.86-4 4a.49.49 0 0 1-.35.14H3.25a.25.25 0 0 0-.25.25v5.5a.25.25 0 0 0 .25.25h3.54a.49.49 0 0 1 .36.15l4 4a.5.5 0 0 0 .85-.36V5.21a.5.5 0 0 0-.86-.35Zm2.74-1.56v1.52A7.52 7.52 0 0 1 19.47 12a7.52 7.52 0 0 1-5.59 7.18v1.52A9 9 0 0 0 21 12a9 9 0 0 0-7.12-8.7Zm3.56 8.7a5.49 5.49 0 0 0-3.56-5.1v1.66a3.93 3.93 0 0 1 0 6.88v1.66a5.49 5.49 0 0 0 3.56-5.1Z"/>
1074
1133
  </svg>
1075
- `;var Eu=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="low">
1134
+ `;var Du=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="low">
1076
1135
  <path d="m11.14 4.853-4 4a.49.49 0 0 1-.35.14H3.25a.25.25 0 0 0-.25.25v5.5a.25.25 0 0 0 .25.25h3.54a.49.49 0 0 1 .36.15l4 4a.5.5 0 0 0 .85-.36V5.203a.5.5 0 0 0-.86-.35Zm6.3 7.14a5.49 5.49 0 0 0-3.56-5.1v1.66a3.93 3.93 0 0 1 0 6.88v1.66a5.49 5.49 0 0 0 3.56-5.1Z"/>
1077
1136
  </svg>
1078
- `;var yu=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="medium">
1137
+ `;var Iu=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="medium">
1079
1138
  <path d="m11.14 4.853-4 4a.49.49 0 0 1-.35.14H3.25a.25.25 0 0 0-.25.25v5.5a.25.25 0 0 0 .25.25h3.54a.49.49 0 0 1 .36.15l4 4a.5.5 0 0 0 .85-.36V5.203a.5.5 0 0 0-.86-.35Zm6.3 7.14a5.49 5.49 0 0 0-3.56-5.1v1.66a3.93 3.93 0 0 1 0 6.88v1.66a5.49 5.49 0 0 0 3.56-5.1Z"/>
1080
1139
  </svg>
1081
- `;var Tu=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="off">
1140
+ `;var Mu=`<svg aria-hidden="true" viewBox="0 0 24 24" slot="off">
1082
1141
  <path d="m3 4.05 4.48 4.47-.33.33a.49.49 0 0 1-.36.15H3.25a.25.25 0 0 0-.25.25v5.5a.25.25 0 0 0 .25.25h3.54a.49.49 0 0 1 .36.15l4 4a.48.48 0 0 0 .36.15.5.5 0 0 0 .5-.5v-5.75l4.67 4.66a7.71 7.71 0 0 1-2.79 1.47v1.52a9.32 9.32 0 0 0 3.87-1.91L20 21l1-1L4.06 3 3 4.05Zm5.36 5.36 2.39 2.39V17L8 14.26a1.74 1.74 0 0 0-1.24-.51H4.25v-3.5h2.54A1.74 1.74 0 0 0 8 9.74l.36-.33ZM19.47 12a7.19 7.19 0 0 1-.89 3.47l1.11 1.1A8.64 8.64 0 0 0 21 12a9 9 0 0 0-7.12-8.7v1.52A7.52 7.52 0 0 1 19.47 12ZM12 8.88V5.21a.5.5 0 0 0-.5-.5.48.48 0 0 0-.36.15L9.56 6.44 12 8.88ZM15.91 12a4.284 4.284 0 0 1-.07.72l1.22 1.22a5.2 5.2 0 0 0 .38-1.94 5.49 5.49 0 0 0-3.56-5.1v1.66A4 4 0 0 1 15.91 12Z"/>
1083
1142
  </svg>
1084
- `;var bu=()=>nt(nu),Au=()=>nt(au),_u=()=>nt(su),Su=()=>nt(ou),xu=()=>nt(lu),Lu=()=>nt(uu),Du=()=>nt(du),Iu=()=>nt(cu),Mu=()=>nt(fu),Ru=()=>nt(hu),Cu=()=>nt(vu),Ou=r=>nt(mu,r),Pu=r=>nt(gu,r),ku=()=>nt(pu),wu=()=>nt(Eu),Uu=()=>nt(yu),Nu=()=>nt(Tu);var nr={LG:"large",SM:"small",XS:"extra-small"},Vn,Bu,jn=class extends ls{constructor(){super();Ne(this,Vn);Fe(this,Vn,Bu).call(this)}static get observedAttributes(){return["audio","has-open-dialog","has-src","nohotkeys","hotkeys","stream-type","player-size","default-hidden-captions","forward-seek-offset","backward-seek-offset","playbackrates","default-show-remaining-time","poster","placeholder","title"]}attributeChangedCallback(){this.render()}render(){var s,a,u;let e={hasSrc:this.hasAttribute("has-src"),isDialogOpen:this.hasAttribute("has-open-dialog"),audio:this.hasAttribute("audio"),nohotkeys:this.hasAttribute("nohotkeys"),hotkeys:this.getAttribute("hotkeys"),streamType:this.getAttribute("stream-type"),playerSize:this.getAttribute("player-size"),defaultHiddenCaptions:this.hasAttribute("default-hidden-captions"),forwardSeekOffset:this.getAttribute("forward-seek-offset"),backwardSeekOffset:this.getAttribute("backward-seek-offset"),playbackRates:this.getAttribute("playbackrates"),defaultShowRemainingTime:this.hasAttribute("default-show-remaining-time"),poster:this.getAttribute("poster"),placeholder:this.getAttribute("placeholder"),title:this.getAttribute("title")};e.nohotkeys=e.nohotkeys||!e.hasSrc||e.isDialogOpen,[be.LIVE,be.LL_LIVE,be.DVR,be.LL_DVR].includes(e.streamType)&&(e.hotkeys=e.hotkeys||"",e.hotkeys+=" noarrowleft noarrowright"),Hn(Te`
1143
+ `;var Ru=()=>at(hu),Cu=()=>at(mu),Ou=()=>at(vu),Pu=()=>at(gu),ku=()=>at(pu),wu=()=>at(Eu),Uu=()=>at(yu),Nu=()=>at(Tu),Bu=()=>at(bu),Fu=()=>at(Au),Ku=()=>at(_u),Wu=r=>at(Su,r),Hu=r=>at(xu,r),Gu=()=>at(Lu),ju=()=>at(Du),Vu=()=>at(Iu),$u=()=>at(Mu);var ir={LG:"large",SM:"small",XS:"extra-small"},qn,Yu,Jn=class extends ps{constructor(){super();Be(this,qn);Fe(this,qn,Yu).call(this)}static get observedAttributes(){return["audio","has-open-dialog","has-src","nohotkeys","hotkeys","stream-type","player-size","default-hidden-captions","forward-seek-offset","backward-seek-offset","playbackrates","default-show-remaining-time","poster","placeholder","title"]}attributeChangedCallback(){this.render()}render(){var a,s,u;let e={hasSrc:this.hasAttribute("has-src"),isDialogOpen:this.hasAttribute("has-open-dialog"),audio:this.hasAttribute("audio"),nohotkeys:this.hasAttribute("nohotkeys"),hotkeys:this.getAttribute("hotkeys"),streamType:this.getAttribute("stream-type"),playerSize:this.getAttribute("player-size"),defaultHiddenCaptions:this.hasAttribute("default-hidden-captions"),forwardSeekOffset:this.getAttribute("forward-seek-offset"),backwardSeekOffset:this.getAttribute("backward-seek-offset"),playbackRates:this.getAttribute("playbackrates"),defaultShowRemainingTime:this.hasAttribute("default-show-remaining-time"),poster:this.getAttribute("poster"),placeholder:this.getAttribute("placeholder"),title:this.getAttribute("title")};e.nohotkeys=e.nohotkeys||!e.hasSrc||e.isDialogOpen,[be.LIVE,be.LL_LIVE,be.DVR,be.LL_DVR].includes(e.streamType)&&(e.hotkeys=e.hotkeys||"",e.hotkeys+=" noarrowleft noarrowright"),Qn(pe`
1085
1144
  <style>
1086
- ${iu}
1145
+ ${fu}
1087
1146
  </style>
1088
1147
  <media-controller
1089
1148
  gestures-disabled="${!e.hasSrc||e.isDialogOpen}"
@@ -1097,244 +1156,255 @@ media-time-display {
1097
1156
  <media-poster-image
1098
1157
  slot="poster"
1099
1158
  part="poster"
1100
- src="${(s=e.poster)!=null?s:!1}"
1101
- placeholder-src="${(a=e.placeholder)!=null?a:!1}"
1159
+ src="${(a=e.poster)!=null?a:!1}"
1160
+ placeholder-src="${(s=e.placeholder)!=null?s:!1}"
1102
1161
  ></media-poster-image>
1103
1162
  <media-loading-indicator slot="centered-chrome" no-auto-hide></media-loading-indicator>
1104
- ${lh(e)}
1163
+ ${Eh(e)}
1105
1164
  <slot></slot>
1106
1165
  </media-controller>
1107
- `,this.shadowRoot),(u=this.shadowRoot)==null||u.querySelectorAll("*").forEach(R=>{if(!R.localName.includes("-"))return;let C=R.localName.match(/^([^-]+)-(.*)-(button|range|display)$/);if(!C)return;let[,,O,L]=C;O==="text"&&R.classList.contains("title-display")&&(O="title");let b=R.closest('[slot="top-chrome"]')?"top":R.closest('[slot="centered-chrome"]')?"center":"bottom";R.setAttribute("part",`${b} ${O} ${L}`)})}};Vn=new WeakSet,Bu=function(){var e,s;try{(e=window==null?void 0:window.CSS)==null||e.registerProperty({name:"--primary-color",syntax:"<color>",inherits:!0,initialValue:"white"}),(s=window==null?void 0:window.CSS)==null||s.registerProperty({name:"--secondary-color",syntax:"<color>",inherits:!0,initialValue:"transparent"})}catch{}};je.customElements.get("media-theme-mux")||je.customElements.define("media-theme-mux",jn);var lh=r=>{let{streamType:t,playerSize:e,audio:s}=r;if(s)switch(t){case be.LIVE:case be.LL_LIVE:return ch(r);case be.DVR:case be.LL_DVR:return dh(r);case be.ON_DEMAND:default:return uh(r)}switch(t){case be.LIVE:case be.LL_LIVE:switch(e){case nr.LG:return gh(r);case nr.SM:return mh(r);case nr.XS:return vh(r)}case be.DVR:case be.LL_DVR:switch(e){case nr.LG:return yh(r);case nr.SM:return Eh(r);case nr.XS:return ph(r)}case be.ON_DEMAND:default:switch(e){case nr.LG:return hh(r);case nr.SM:return fh(r);case nr.XS:return Ns(r)}}},Ot=r=>Te`
1166
+ `,this.shadowRoot),(u=this.shadowRoot)==null||u.querySelectorAll("*").forEach(R=>{if(!R.localName.includes("-"))return;let C=R.localName.match(/^([^-]+)-(.*)-(button|range|display)$/);if(!C)return;let[,,O,L]=C;O==="text"&&R.classList.contains("title-display")&&(O="title");let b=R.closest('[slot="top-chrome"]')?"top":R.closest('[slot="centered-chrome"]')?"center":"bottom";R.setAttribute("part",`${b} ${O} ${L}`)})}};qn=new WeakSet,Yu=function(){var e,a;try{(e=window==null?void 0:window.CSS)==null||e.registerProperty({name:"--primary-color",syntax:"<color>",inherits:!0,initialValue:"white"}),(a=window==null?void 0:window.CSS)==null||a.registerProperty({name:"--secondary-color",syntax:"<color>",inherits:!0,initialValue:"transparent"})}catch{}};je.customElements.get("media-theme-mux")||je.customElements.define("media-theme-mux",Jn);var Eh=r=>{let{streamType:t,playerSize:e,audio:a}=r;if(a)switch(t){case be.LIVE:case be.LL_LIVE:return bh(r);case be.DVR:case be.LL_DVR:return Th(r);case be.ON_DEMAND:default:return yh(r)}switch(t){case be.LIVE:case be.LL_LIVE:switch(e){case ir.LG:return Dh(r);case ir.SM:return Lh(r);case ir.XS:return xh(r)}case be.DVR:case be.LL_DVR:switch(e){case ir.LG:return Rh(r);case ir.SM:return Mh(r);case ir.XS:return Ih(r)}case be.ON_DEMAND:default:switch(e){case ir.LG:return Sh(r);case ir.SM:return _h(r);case ir.XS:return Ah(r)}}},Et=r=>pe`
1108
1167
  <media-play-button disabled="${!r.hasSrc||r.isDialogOpen}" aria-disabled="${!r.hasSrc||r.isDialogOpen&&"true"}">
1109
- ${Cu()}
1110
- ${Iu()}
1111
- </media-play-button>`,ni=({backwardSeekOffset:r,hasSrc:t,isDialogOpen:e})=>Te`
1168
+ ${Ku()}
1169
+ ${Nu()}
1170
+ </media-play-button>`,si=({backwardSeekOffset:r,hasSrc:t,isDialogOpen:e})=>pe`
1112
1171
  <media-seek-backward-button seek-offset="${r}" disabled="${!t||e}" aria-disabled="${!t||e&&"true"}">
1113
- ${Ou({value:r})}
1114
- </media-seek-backward-button>`,ai=({forwardSeekOffset:r,hasSrc:t,isDialogOpen:e})=>Te`
1172
+ ${Wu({value:r})}
1173
+ </media-seek-backward-button>`,oi=({forwardSeekOffset:r,hasSrc:t,isDialogOpen:e})=>pe`
1115
1174
  <media-seek-forward-button seek-offset="${r}" disabled="${!t||e}" aria-disabled="${!t||e&&"true"}">
1116
- ${Pu({value:r})}
1117
- </media-seek-forward-button>`,Zt=({isDialogOpen:r})=>Te`
1175
+ ${Hu({value:r})}
1176
+ </media-seek-forward-button>`,Pt=({isDialogOpen:r})=>pe`
1118
1177
  <media-mute-button disabled="${r}" aria-disabled="${r&&"true"}">
1119
- ${ku()}
1120
- ${Uu()}
1121
- ${wu()}
1122
- ${Nu()}
1123
- </media-mute-button>`,Pr=({defaultHiddenCaptions:r,isDialogOpen:t})=>Te`
1178
+ ${Gu()}
1179
+ ${Vu()}
1180
+ ${ju()}
1181
+ ${$u()}
1182
+ </media-mute-button>`,nr=({defaultHiddenCaptions:r,isDialogOpen:t})=>pe`
1124
1183
  <media-captions-button default-showing="${!r}" disabled="${t}" aria-disabled="${t&&"true"}">
1125
- ${Au()}
1126
- ${_u()}
1127
- </media-captions-button>`,Jt=r=>Te`
1184
+ ${Cu()}
1185
+ ${Ou()}
1186
+ </media-captions-button>`,ar=r=>pe`
1128
1187
  <media-airplay-button disabled="${!r.hasSrc||r.isDialogOpen}" aria-disabled="${!r.hasSrc||r.isDialogOpen&&"true"}">
1129
- ${bu()}
1130
- </media-airplay-button>`,kr=r=>Te`
1131
- <media-pip-button disabled="${!r.hasSrc||r.isDialogOpen}" aria-disabled="${!r.hasSrc||r.isDialogOpen&&"true"}">
1132
- ${Mu()}
1133
1188
  ${Ru()}
1134
- </media-pip-button>`,wr=r=>Te`
1189
+ </media-airplay-button>`,li=r=>pe`
1190
+ <media-pip-button disabled="${!r.hasSrc||r.isDialogOpen}" aria-disabled="${!r.hasSrc||r.isDialogOpen&&"true"}">
1191
+ ${Bu()}
1192
+ ${Fu()}
1193
+ </media-pip-button>`,sr=r=>pe`
1135
1194
  <media-fullscreen-button disabled="${!r.hasSrc||r.isDialogOpen}" aria-disabled="${!r.hasSrc||r.isDialogOpen&&"true"}">
1136
- ${Lu()}
1137
- ${Du()}
1138
- </media-fullscreen-button>`,qt=r=>Te`
1195
+ ${wu()}
1196
+ ${Uu()}
1197
+ </media-fullscreen-button>`,or=r=>pe`
1139
1198
  <media-cast-button disabled="${!r.hasSrc||r.isDialogOpen}" aria-disabled="${!r.hasSrc||r.isDialogOpen&&"true"}">
1140
- ${Su()}
1141
- ${xu()}
1142
- </media-cast-button>`,$n=({playbackRates:r,isDialogOpen:t})=>Te`
1199
+ ${Pu()}
1200
+ ${ku()}
1201
+ </media-cast-button>`,ea=({playbackRates:r,isDialogOpen:t})=>pe`
1143
1202
  <media-playback-rate-button rates="${r!=null?r:!1}" disabled="${t}" aria-disabled="${t&&"true"}">
1144
- </media-playback-rate-button>`,ar=({isDialogOpen:r})=>Te`
1203
+ </media-playback-rate-button>`,lr=({isDialogOpen:r})=>pe`
1145
1204
  <media-volume-range disabled="${r}" aria-disabled="${r&&"true"}">
1146
- </media-volume-range>`,si=r=>Te`
1205
+ </media-volume-range>`,yr=r=>pe`
1147
1206
  <media-time-range disabled="${!r.hasSrc||r.isDialogOpen}" aria-disabled="${!r.hasSrc||r.isDialogOpen&&"true"}">
1148
- </media-time-range>`,Yn=({defaultShowRemainingTime:r,hasSrc:t,isDialogOpen:e})=>Te`
1207
+ </media-time-range>`,ta=({defaultShowRemainingTime:r,hasSrc:t,isDialogOpen:e})=>pe`
1149
1208
  <mxp-time-display remaining="${r}" disabled="${!t||e}" aria-disabled="${!t||e&&"true"}">
1150
- </mxp-time-display>`,sr=({title:r})=>Te`
1151
- <media-text-display part="title" class="title-display">${r}</media-text-display>`,uh=r=>Te`
1152
- ${r.title?`<media-control-bar>${sr(r)}</media-control-bar>`:Te``}
1209
+ </mxp-time-display>`,ur=({title:r})=>pe`
1210
+ <media-text-display part="title" class="title-display">${r}</media-text-display>`,yh=r=>pe`
1211
+ ${r.title?pe`<media-control-bar>${ur(r)}</media-control-bar>`:pe``}
1153
1212
  <media-control-bar>
1154
- ${Ot(r)}
1155
- ${ni(r)}
1156
- ${ai(r)}
1157
- ${Yn(r)}
1213
+ ${Et(r)}
1158
1214
  ${si(r)}
1159
- ${Zt(r)}
1215
+ ${oi(r)}
1216
+ ${ta(r)}
1217
+ ${yr(r)}
1218
+ ${Pt(r)}
1219
+ ${lr(r)}
1220
+ ${ea(r)}
1160
1221
  ${ar(r)}
1161
- ${$n(r)}
1162
- ${Jt(r)}
1163
- ${qt(r)}
1222
+ ${or(r)}
1164
1223
  </media-control-bar>
1165
- `,dh=r=>Te`
1166
- ${r.title?`<media-control-bar>${sr(r)}</media-control-bar>`:Te``}
1224
+ `,Th=r=>pe`
1225
+ ${r.title?pe`<media-control-bar>${ur(r)}</media-control-bar>`:pe``}
1167
1226
  <media-control-bar>
1168
- ${Ot(r)}
1227
+ ${Et(r)}
1169
1228
  <slot name="seek-live"></slot>
1170
- ${ni(r)}
1171
- ${ai(r)}
1172
- ${Yn(r)}
1173
1229
  ${si(r)}
1174
- ${Zt(r)}
1230
+ ${oi(r)}
1231
+ ${ta(r)}
1232
+ ${yr(r)}
1233
+ ${Pt(r)}
1234
+ ${lr(r)}
1235
+ ${ea(r)}
1175
1236
  ${ar(r)}
1176
- ${$n(r)}
1177
- ${Jt(r)}
1178
- ${qt(r)}
1237
+ ${or(r)}
1179
1238
  </media-control-bar>
1180
- `,ch=r=>Te`
1181
- ${r.title?`<media-control-bar>${sr(r)}</media-control-bar>`:Te``}
1239
+ `,bh=r=>pe`
1240
+ ${r.title?pe`<media-control-bar>${ur(r)}</media-control-bar>`:pe``}
1182
1241
  <media-control-bar>
1183
- ${Ot(r)}
1242
+ ${Et(r)}
1184
1243
  <slot name="seek-live"></slot>
1185
- ${Zt(r)}
1244
+ ${Pt(r)}
1245
+ ${lr(r)}
1246
+ <div class="spacer"></div>
1186
1247
  ${ar(r)}
1187
- ${Jt(r)}
1188
- ${qt(r)}
1248
+ ${or(r)}
1189
1249
  </media-control-bar>
1190
- `,Ns=r=>Te`
1191
- <media-control-bar slot="top-chrome">
1192
- ${Pr(r)}
1250
+ `,Ah=r=>pe`
1251
+ ${yr(r)}
1252
+ <media-control-bar>
1253
+ ${Et(r)}
1254
+ ${Pt(r)}
1193
1255
  <div class="spacer"></div>
1194
- ${Jt(r)}
1195
- ${qt(r)}
1196
- ${kr(r)}
1256
+ ${nr(r)}
1257
+ ${sr(r)}
1258
+ </media-control-bar>
1259
+ `,_h=r=>pe`
1260
+ <media-control-bar slot="top-chrome">
1261
+ ${r.title?ur(r):pe``}
1197
1262
  </media-control-bar>
1198
1263
  <div slot="centered-chrome" class="center-controls">
1199
- ${Ot(r)}
1264
+ ${si(r)}
1265
+ ${Et(r)}
1266
+ ${oi(r)}
1200
1267
  </div>
1268
+ ${yr(r)}
1201
1269
  <media-control-bar>
1202
- ${Zt(r)}
1270
+ ${ta(r)}
1271
+ ${Pt(r)}
1272
+ ${lr(r)}
1203
1273
  <div class="spacer"></div>
1204
- ${wr(r)}
1274
+ ${ea(r)}
1275
+ ${nr(r)}
1276
+ ${ar(r)}
1277
+ ${or(r)}
1278
+ ${li(r)}
1279
+ ${sr(r)}
1205
1280
  </media-control-bar>
1206
- `,fh=r=>Te`
1281
+ `,Sh=r=>pe`
1207
1282
  <media-control-bar slot="top-chrome">
1208
- ${r.title?sr(r):Te``}
1209
- <div class="spacer"></div>
1210
- ${Pr(r)}
1211
- ${Jt(r)}
1212
- ${qt(r)}
1213
- ${kr(r)}
1283
+ ${r.title?ur(r):pe``}
1214
1284
  </media-control-bar>
1215
1285
  <div slot="centered-chrome" class="center-controls">
1216
- ${ni(r)}
1217
- ${Ot(r)}
1218
- ${ai(r)}
1286
+ ${Et(r)}
1219
1287
  </div>
1220
- ${si(r)}
1288
+ ${yr(r)}
1221
1289
  <media-control-bar>
1222
- ${Yn(r)}
1223
- ${Zt(r)}
1224
- ${ar(r)}
1290
+ ${Et(r)}
1291
+ ${si(r)}
1292
+ ${oi(r)}
1293
+ ${ta(r)}
1294
+ ${Pt(r)}
1295
+ ${lr(r)}
1225
1296
  <div class="spacer"></div>
1226
- ${$n(r)}
1227
- ${wr(r)}
1228
- <div class="padding-2"></div>
1297
+ ${ea(r)}
1298
+ ${nr(r)}
1299
+ ${ar(r)}
1300
+ ${or(r)}
1301
+ ${li(r)}
1302
+ ${sr(r)}
1229
1303
  </media-control-bar>
1230
- `,hh=r=>Te`
1304
+ `,xh=r=>pe`
1231
1305
  <media-control-bar slot="top-chrome">
1232
- ${r.title?sr(r):Te``}
1306
+ <slot name="seek-live"></slot>
1233
1307
  </media-control-bar>
1234
- <div slot="centered-chrome" class="center-controls">
1235
- ${Ot(r)}
1236
- </div>
1237
- ${si(r)}
1238
1308
  <media-control-bar>
1239
- ${Ot(r)}
1240
- ${ni(r)}
1241
- ${ai(r)}
1242
- ${Yn(r)}
1243
- ${Zt(r)}
1244
- ${ar(r)}
1309
+ ${Et(r)}
1310
+ ${Pt(r)}
1245
1311
  <div class="spacer"></div>
1246
- ${$n(r)}
1247
- ${Pr(r)}
1248
- ${Jt(r)}
1249
- ${qt(r)}
1250
- ${kr(r)}
1251
- ${wr(r)}
1252
- <div class="padding-2"></div>
1312
+ ${nr(r)}
1313
+ ${sr(r)}
1253
1314
  </media-control-bar>
1254
- `,vh=Ns,mh=r=>Te`
1315
+ `,Lh=r=>pe`
1255
1316
  <media-control-bar slot="top-chrome">
1256
- ${r.title?sr(r):Te``}
1257
- <div class="spacer"></div>
1258
- ${Pr(r)}
1259
- ${Jt(r)}
1260
- ${qt(r)}
1261
- ${kr(r)}
1317
+ <slot name="seek-live"></slot>
1318
+ ${r.title?ur(r):pe``}
1262
1319
  </media-control-bar>
1263
1320
  <div slot="centered-chrome" class="center-controls">
1264
- ${Ot(r)}
1321
+ ${Et(r)}
1265
1322
  </div>
1266
1323
  <media-control-bar>
1267
- ${Zt(r)}
1268
- ${ar(r)}
1269
- <slot name="seek-live"></slot>
1324
+ ${Pt(r)}
1325
+ ${lr(r)}
1270
1326
  <div class="spacer"></div>
1271
- ${wr(r)}
1327
+ ${nr(r)}
1328
+ ${ar(r)}
1329
+ ${or(r)}
1330
+ ${li(r)}
1331
+ ${sr(r)}
1272
1332
  </media-control-bar>
1273
- `,gh=r=>Te`
1333
+ `,Dh=r=>pe`
1274
1334
  <media-control-bar slot="top-chrome">
1275
- ${r.title?sr(r):Te``}
1335
+ <slot name="seek-live"></slot>
1336
+ ${r.title?ur(r):pe``}
1276
1337
  </media-control-bar>
1277
1338
  <div slot="centered-chrome" class="center-controls">
1278
- ${Ot(r)}
1339
+ ${Et(r)}
1279
1340
  </div>
1280
1341
  <media-control-bar>
1281
- ${Zt(r)}
1342
+ ${Et(r)}
1343
+ ${Pt(r)}
1344
+ ${lr(r)}
1345
+ <div class="spacer"></div>
1346
+ ${nr(r)}
1282
1347
  ${ar(r)}
1348
+ ${or(r)}
1349
+ ${li(r)}
1350
+ ${sr(r)}
1351
+ </media-control-bar>
1352
+ `,Ih=r=>pe`
1353
+ <media-control-bar slot="top-chrome">
1283
1354
  <slot name="seek-live"></slot>
1355
+ </media-control-bar>
1356
+ ${yr(r)}
1357
+ <media-control-bar>
1358
+ ${Et(r)}
1359
+ ${Pt(r)}
1284
1360
  <div class="spacer"></div>
1285
- ${Pr(r)}
1286
- ${Jt(r)}
1287
- ${qt(r)}
1288
- ${kr(r)}
1289
- ${wr(r)}
1361
+ ${nr(r)}
1362
+ ${sr(r)}
1290
1363
  </media-control-bar>
1291
- `,ph=Ns,Eh=r=>Te`
1364
+ `,Mh=r=>pe`
1292
1365
  <media-control-bar slot="top-chrome">
1293
- ${r.title?sr(r):Te``}
1294
- <div class="spacer"></div>
1295
- ${Pr(r)}
1296
- ${Jt(r)}
1297
- ${qt(r)}
1298
- ${kr(r)}
1366
+ <slot name="seek-live"></slot>
1367
+ ${r.title?ur(r):pe``}
1299
1368
  </media-control-bar>
1300
1369
  <div slot="centered-chrome" class="center-controls">
1301
- ${ni(r)}
1302
- ${Ot(r)}
1303
- ${ai(r)}
1370
+ ${si(r)}
1371
+ ${Et(r)}
1372
+ ${oi(r)}
1304
1373
  </div>
1305
- ${si(r)}
1374
+ ${yr(r)}
1306
1375
  <media-control-bar>
1307
- ${Zt(r)}
1308
- ${ar(r)}
1309
- <slot name="seek-live"></slot>
1376
+ ${Pt(r)}
1377
+ ${lr(r)}
1310
1378
  <div class="spacer"></div>
1311
- ${wr(r)}
1312
- <div class="padding-2"></div>
1379
+ ${nr(r)}
1380
+ ${ar(r)}
1381
+ ${or(r)}
1382
+ ${li(r)}
1383
+ ${sr(r)}
1313
1384
  </media-control-bar>
1314
- `,yh=r=>Te`
1385
+ `,Rh=r=>pe`
1315
1386
  <media-control-bar slot="top-chrome">
1316
- ${r.title?sr(r):Te``}
1387
+ <slot name="seek-live"></slot>
1388
+ ${r.title?ur(r):pe``}
1317
1389
  </media-control-bar>
1318
1390
  <div slot="centered-chrome" class="center-controls">
1319
- ${Ot(r)}
1391
+ ${Et(r)}
1320
1392
  </div>
1321
- ${si(r)}
1393
+ ${yr(r)}
1322
1394
  <media-control-bar>
1323
- ${Ot(r)}
1324
- ${ni(r)}
1325
- ${ai(r)}
1326
- ${Zt(r)}
1327
- ${ar(r)}
1328
- <slot name="seek-live"></slot>
1395
+ ${Et(r)}
1396
+ ${si(r)}
1397
+ ${oi(r)}
1398
+ ${Pt(r)}
1399
+ ${lr(r)}
1329
1400
  <div class="spacer"></div>
1330
- ${Pr(r)}
1331
- ${Jt(r)}
1332
- ${qt(r)}
1333
- ${kr(r)}
1334
- ${wr(r)}
1335
- <div class="padding-2"></div>
1401
+ ${nr(r)}
1402
+ ${ar(r)}
1403
+ ${or(r)}
1404
+ ${li(r)}
1405
+ ${sr(r)}
1336
1406
  </media-control-bar>
1337
- `;var Ku=`
1407
+ `;var Xu=`
1338
1408
  :host {
1339
1409
  z-index: 100;
1340
1410
  display: flex;
@@ -1386,17 +1456,17 @@ media-time-display {
1386
1456
  text-align: center;
1387
1457
  line-height: 1.4;
1388
1458
  }
1389
- `,Wu=Nt.createElement("template");Wu.innerHTML=`
1459
+ `,Qu=Bt.createElement("template");Qu.innerHTML=`
1390
1460
  <style>
1391
- ${Ku}
1461
+ ${Xu}
1392
1462
  </style>
1393
1463
 
1394
1464
  <div class="dialog">
1395
1465
  <slot></slot>
1396
1466
  </div>
1397
- `;var mr=class extends je.HTMLElement{constructor(){var e;super();this.attachShadow({mode:"open"}),(e=this.shadowRoot)==null||e.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),Fu(this)}close(){!this.hasAttribute("open")||(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),Th(this))}attributeChangedCallback(e,s,a){e==="open"&&s!==a&&(a!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&Fu(this)}};mr.styles=Ku,mr.template=Wu,mr.observedAttributes=["open"];function Fu(r){let t=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(r.dispatchEvent(t),t.defaultPrevented)return;let e=r.querySelector("[autofocus]:not([disabled])");!e&&r.tabIndex>=0&&(e=r),e||(e=Hu(r.shadowRoot)),r._previouslyFocusedElement=Nt.activeElement,Nt.activeElement instanceof HTMLElement&&Nt.activeElement.blur(),r.addEventListener("transitionend",()=>{e instanceof HTMLElement&&e.focus({preventScroll:!0})},{once:!0})}function Hu(r){let e=["button","input","keygen","select","textarea"].map(function(a){return a+":not([disabled])"});e.push('[tabindex]:not([disabled]):not([tabindex=""])');let s=r==null?void 0:r.querySelector(e.join(", "));if(!s&&"attachShadow"in Element.prototype){let a=(r==null?void 0:r.querySelectorAll("*"))||[];for(let u=0;u<a.length&&!(a[u].tagName&&a[u].shadowRoot&&(s=Hu(a[u].shadowRoot),s));u++);}return s}function Th(r){r._previouslyFocusedElement instanceof HTMLElement&&r._previouslyFocusedElement.focus()}je.customElements.get("media-dialog")||(je.customElements.define("media-dialog",mr),je.MediaDialog=mr);var Bs=mr;var Gu=Nt.createElement("template");Gu.innerHTML=`
1467
+ `;var Tr=class extends je.HTMLElement{constructor(){var e;super();this.attachShadow({mode:"open"}),(e=this.shadowRoot)==null||e.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),zu(this)}close(){!this.hasAttribute("open")||(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),Ch(this))}attributeChangedCallback(e,a,s){e==="open"&&a!==s&&(s!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&zu(this)}};Tr.styles=Xu,Tr.template=Qu,Tr.observedAttributes=["open"];function zu(r){let t=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(r.dispatchEvent(t),t.defaultPrevented)return;let e=r.querySelector("[autofocus]:not([disabled])");!e&&r.tabIndex>=0&&(e=r),e||(e=Zu(r.shadowRoot)),r._previouslyFocusedElement=Bt.activeElement,Bt.activeElement instanceof HTMLElement&&Bt.activeElement.blur(),r.addEventListener("transitionend",()=>{e instanceof HTMLElement&&e.focus({preventScroll:!0})},{once:!0})}function Zu(r){let e=["button","input","keygen","select","textarea"].map(function(s){return s+":not([disabled])"});e.push('[tabindex]:not([disabled]):not([tabindex=""])');let a=r==null?void 0:r.querySelector(e.join(", "));if(!a&&"attachShadow"in Element.prototype){let s=(r==null?void 0:r.querySelectorAll("*"))||[];for(let u=0;u<s.length&&!(s[u].tagName&&s[u].shadowRoot&&(a=Zu(s[u].shadowRoot),a));u++);}return a}function Ch(r){r._previouslyFocusedElement instanceof HTMLElement&&r._previouslyFocusedElement.focus()}je.customElements.get("media-dialog")||(je.customElements.define("media-dialog",Tr),je.MediaDialog=Tr);var Ys=Tr;var Ju=Bt.createElement("template");Ju.innerHTML=`
1398
1468
  <style>
1399
- ${Bs.styles}
1469
+ ${Ys.styles}
1400
1470
 
1401
1471
  .close {
1402
1472
  background: none;
@@ -1425,7 +1495,7 @@ media-time-display {
1425
1495
  </svg>
1426
1496
  </button>
1427
1497
  </slot>
1428
- `;var ji=class extends Bs{constructor(){var t,e;super(),(e=(t=this.shadowRoot)==null?void 0:t.querySelector(".close"))==null||e.addEventListener("click",()=>{this.close()})}};ji.template=Gu;je.customElements.get("mxp-dialog")||(je.customElements.define("mxp-dialog",ji),je.MxpDialog=ji);var ju=`:host {
1498
+ `;var zi=class extends Ys{constructor(){var t,e;super(),(e=(t=this.shadowRoot)==null?void 0:t.querySelector(".close"))==null||e.addEventListener("click",()=>{this.close()})}};zi.template=Ju;je.customElements.get("mxp-dialog")||(je.customElements.define("mxp-dialog",zi),je.MxpDialog=zi);var qu=`:host {
1429
1499
  display: inline-block;
1430
1500
  width: 100%;
1431
1501
  }
@@ -1440,21 +1510,36 @@ a {
1440
1510
  font-size: 0.9em;
1441
1511
  text-decoration: underline;
1442
1512
  }
1443
- [part~='seek-live'] {
1444
- height: 44px;
1513
+
1514
+ [audio] [part~='seek-live'] {
1515
+ margin: 0;
1516
+ height: 42px;
1517
+ border-radius: 0;
1445
1518
  background-color: var(--media-control-background, rgba(20, 20, 30, 0.7));
1446
- color: white;
1519
+ }
1520
+
1521
+ [part~='seek-live'] {
1522
+ margin-left: 10px;
1523
+ margin-right: 5px;
1524
+ align-self: center;
1525
+ position: relative;
1526
+ box-sizing: border-box;
1527
+ padding: 4px 6px;
1528
+ border-radius: 12px;
1529
+ background-color: rgba(20, 20, 30, 0.7);
1530
+ font-size: 0.75rem;
1531
+ line-height: 1;
1532
+ color: #fff;
1447
1533
  border: none;
1448
1534
  cursor: pointer;
1449
1535
  }
1450
1536
 
1451
- [part~='seek-live']::before {
1452
- content: '\u25CF ';
1453
- color: rgb(118, 118, 118);
1454
- padding-right: 5px;
1537
+ [part~='seek-live'] svg {
1538
+ width: 8px;
1539
+ fill: rgb(118, 118, 118);
1455
1540
  }
1456
- [part~='seek-live'][in-live-window]::before {
1457
- color: #fb3c4d;
1541
+ [part~='seek-live'][in-live-window] svg {
1542
+ fill: #fb3c4d;
1458
1543
  }
1459
1544
 
1460
1545
  [part~='seek-live'][disabled] {
@@ -1576,18 +1661,18 @@ a {
1576
1661
  ::part(title display) {
1577
1662
  display: var(--media-controls, var(--media-title-display));
1578
1663
  }
1579
- `;var $u=r=>Te`
1664
+ `;var td=r=>pe`
1580
1665
  <style>
1581
- ${ju}
1666
+ ${qu}
1582
1667
  </style>
1583
- ${_h(r)}
1584
- `,Vu=r=>[be.LIVE,be.LL_LIVE].includes(r.streamType),Ah=r=>[be.LIVE,be.LL_LIVE,be.DVR,be.LL_DVR].includes(r.streamType),_h=r=>{var t,e,s,a,u,R,C,O,L,b,x,I,_,A,S,v,i,d,p,T,l,o,h,E,n,c,m,f,g,y,M,D,P,B,N,F,H,V,X,$,j,J,ee;return Te`
1585
- <${Us((t=Ms(r.theme))!=null?t:"media-theme-mux")}
1668
+ ${kh(r)}
1669
+ `,ed=r=>[be.LIVE,be.LL_LIVE].includes(r.streamType),Ph=r=>[be.LIVE,be.LL_LIVE,be.DVR,be.LL_DVR].includes(r.streamType),kh=r=>{var t,e,a,s,u,R,C,O,L,b,x,I,_,A,S,m,i,d,p,T,l,o,h,E,n,c,v,f,g,y,M,D,P,B,N,F,H,V,X,$,j,J,ee,te;return pe`
1670
+ <${$s((t=Fs(r.theme))!=null?t:"media-theme-mux")}
1586
1671
  has-src="${(e=r.hasSrc)!=null?e:!1}"
1587
- has-open-dialog="${(s=r.isDialogOpen)!=null?s:!1}"
1588
- nohotkeys="${(a=r.noHotKeys)!=null?a:!1}"
1672
+ has-open-dialog="${(a=r.isDialogOpen)!=null?a:!1}"
1673
+ nohotkeys="${(s=r.noHotKeys)!=null?s:!1}"
1589
1674
  audio="${(u=r.audio)!=null?u:!1}"
1590
- style="${(R=Ul({"--primary-color":r.primaryColor,"--secondary-color":r.secondaryColor}))!=null?R:!1}"
1675
+ style="${(R=Vl({"--primary-color":r.primaryColor,"--secondary-color":r.secondaryColor}))!=null?R:!1}"
1591
1676
  class="size-${r.playerSize}${r.secondaryColor?" two-tone":""}"
1592
1677
  stream-type="${(C=r.streamType)!=null?C:!1}"
1593
1678
  player-size="${(O=r.playerSize)!=null?O:!1}"
@@ -1598,7 +1683,7 @@ a {
1598
1683
  default-show-remaining-time="${(_=r.defaultShowRemainingTime)!=null?_:!1}"
1599
1684
  title="${(A=r.title)!=null?A:!1}"
1600
1685
  hotkeys="${(S=r.hotKeys)!=null?S:!1}"
1601
- poster="${r.poster===""?!1:(v=r.poster)!=null?v:!1}"
1686
+ poster="${r.poster===""?!1:(m=r.poster)!=null?m:!1}"
1602
1687
  placeholder="${(i=r.placeholder)!=null?i:!1}"
1603
1688
  exportparts="top, center, bottom, layer, media-layer, poster-layer, vertical-layer, centered-layer, gesture-layer, poster, seek-live, play, button, seek-backward, seek-forward, mute, captions, airplay, pip, fullscreen, cast, playback-rate, volume, range, time, display"
1604
1689
  >
@@ -1612,56 +1697,58 @@ a {
1612
1697
  preload="${(o=r.preload)!=null?o:!1}"
1613
1698
  debug="${(h=r.debug)!=null?h:!1}"
1614
1699
  experimental-cmcd="${(E=r.experimentalCmcd)!=null?E:!1}"
1615
- disable-cookies="${(n=r.disableCookies)!=null?n:!1}"
1616
- prefer-playback="${(c=r.preferPlayback)!=null?c:!1}"
1700
+ prefer-cmcd="${(n=r.preferCmcd)!=null?n:!1}"
1701
+ disable-cookies="${(c=r.disableCookies)!=null?c:!1}"
1702
+ prefer-playback="${(v=r.preferPlayback)!=null?v:!1}"
1617
1703
  start-time="${r.startTime!=null?r.startTime:!1}"
1618
- metadata-video-id="${(m=r.metadataVideoId)!=null?m:!1}"
1619
- metadata-video-title="${(g=(f=r.metadataVideoTitle)!=null?f:r.title)!=null?g:!1}"
1620
- metadata-viewer-user-id="${(y=r.metadataViewerUserId)!=null?y:!1}"
1621
- beacon-collection-domain="${(M=r.beaconCollectionDomain)!=null?M:!1}"
1622
- player-software-name="${(D=r.playerSoftwareName)!=null?D:!1}"
1623
- player-software-version="${(P=r.playerSoftwareVersion)!=null?P:!1}"
1624
- env-key="${(B=r.envKey)!=null?B:!1}"
1625
- stream-type="${(N=r.streamType)!=null?N:!1}"
1626
- custom-domain="${(F=r.customDomain)!=null?F:!1}"
1627
- src="${r.src?r.src:r.playbackId?Is(r.playbackId,{domain:r.customDomain,token:r.tokens.playback}):!1}"
1628
- cast-src="${r.src?r.src:r.playbackId?Is(r.playbackId,{domain:r.customDomain,token:r.tokens.playback}):!1}"
1629
- cast-stream-type="${Vu(r)?"live":!1}"
1704
+ metadata-video-id="${(f=r.metadataVideoId)!=null?f:!1}"
1705
+ metadata-video-title="${(y=(g=r.metadataVideoTitle)!=null?g:r.title)!=null?y:!1}"
1706
+ metadata-viewer-user-id="${(M=r.metadataViewerUserId)!=null?M:!1}"
1707
+ beacon-collection-domain="${(D=r.beaconCollectionDomain)!=null?D:!1}"
1708
+ player-software-name="${(P=r.playerSoftwareName)!=null?P:!1}"
1709
+ player-software-version="${(B=r.playerSoftwareVersion)!=null?B:!1}"
1710
+ env-key="${(N=r.envKey)!=null?N:!1}"
1711
+ stream-type="${(F=r.streamType)!=null?F:!1}"
1712
+ custom-domain="${(H=r.customDomain)!=null?H:!1}"
1713
+ src="${r.src?r.src:r.playbackId?Bs(r.playbackId,{domain:r.customDomain,token:r.tokens.playback}):!1}"
1714
+ cast-src="${r.src?r.src:r.playbackId?Bs(r.playbackId,{domain:r.customDomain,token:r.tokens.playback}):!1}"
1715
+ cast-stream-type="${ed(r)?"live":!1}"
1630
1716
  exportparts="video"
1631
1717
  >
1632
- ${r.storyboard?Te`<track label="thumbnails" default kind="metadata" src="${r.storyboard}" />`:Te``}
1718
+ ${r.storyboard?pe`<track label="thumbnails" default kind="metadata" src="${r.storyboard}" />`:pe``}
1633
1719
  </mux-video>
1634
- ${Ah(r)?Te`<button
1720
+ ${Ph(r)?pe`<button
1635
1721
  slot="seek-live"
1636
- part="${Vu(r)?"top":"bottom"} seek-live button"
1722
+ part="${ed(r)?"top":"bottom"} seek-live button"
1637
1723
  disabled="${r.inLiveWindow||!r.hasSrc||r.isDialogOpen}"
1638
1724
  aria-disabled="${(r.inLiveWindow||!r.hasSrc||r.isDialogOpen)&&"true"}"
1639
1725
  in-live-window="${r.inLiveWindow}"
1640
- onclick="${function(te){var se;if((se=r.onSeekToLive)==null||se.call(r,te),r.paused){let ue=new CustomEvent("mediaplayrequest",{composed:!0,bubbles:!0});this.dispatchEvent(ue)}}}"
1726
+ onclick="${function(le){var ue;if((ue=r.onSeekToLive)==null||ue.call(r,le),r.paused){let ie=new CustomEvent("mediaplayrequest",{composed:!0,bubbles:!0});this.dispatchEvent(ie)}}}"
1641
1727
  >
1728
+ <svg viewBox="0 0 8 8"><circle cx="4" cy="4" r="4"></circle></svg>
1642
1729
  Live
1643
- </button>`:Te``}
1730
+ </button>`:pe``}
1644
1731
  <mxp-dialog
1645
1732
  no-auto-hide
1646
- open="${(H=r.isDialogOpen)!=null?H:!1}"
1733
+ open="${(V=r.isDialogOpen)!=null?V:!1}"
1647
1734
  onclose="${r.onCloseErrorDialog}"
1648
1735
  oninitfocus="${r.onInitFocusDialog}"
1649
1736
  >
1650
- ${(V=r.dialog)!=null&&V.title?Te`<h3>${r.dialog.title}</h3>`:Te``}
1737
+ ${(X=r.dialog)!=null&&X.title?pe`<h3>${r.dialog.title}</h3>`:pe``}
1651
1738
  <p>
1652
- ${(X=r.dialog)==null?void 0:X.message}
1653
- ${($=r.dialog)!=null&&$.linkUrl?Te`<a
1739
+ ${($=r.dialog)==null?void 0:$.message}
1740
+ ${(j=r.dialog)!=null&&j.linkUrl?pe`<a
1654
1741
  href="${r.dialog.linkUrl}"
1655
1742
  target="_blank"
1656
1743
  rel="external noopener"
1657
- aria-label="${(j=r.dialog.linkText)!=null?j:""} ${Ce("(opens in a new window)")}"
1658
- >${(J=r.dialog.linkText)!=null?J:r.dialog.linkUrl}</a
1659
- >`:Te``}
1744
+ aria-label="${(J=r.dialog.linkText)!=null?J:""} ${Oe("(opens in a new window)")}"
1745
+ >${(ee=r.dialog.linkText)!=null?ee:r.dialog.linkUrl}</a
1746
+ >`:pe``}
1660
1747
  </p>
1661
1748
  </mxp-dialog>
1662
- </${Us((ee=Ms(r.theme))!=null?ee:"media-theme-mux")}>
1663
- `};function zn(r,t,e,s,a){var C,O,L;let u={},R={};switch(r.code){case Ve.MEDIA_ERR_NETWORK:{switch(u.title=Ce("Network Error",a),u.message=r.message,(C=r.data)==null?void 0:C.response.code){case 412:{u.title=Ce("Video is not currently available",a),u.message=Ce("The live stream or video file are not yet ready.",a),R.message=Ce("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",a),R.file="412-not-playable.md";break}case 404:{u.title=Ce("Video does not exist",a),u.message="",R.message=Ce("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",a),R.file="404-not-found.md";break}case 403:{if(u.title=Ce("Invalid playback URL",a),u.message=Ce("The video URL or playback-token are formatted with incorrect or incomplete information.",a),R.message=Ce("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",a),R.file="missing-signed-tokens.md",!s)break;let{exp:b,aud:x,sub:I}=hr(s),_=Date.now()>b*1e3,A=I!==e,S=x!=="v",v={timeStyle:"medium",dateStyle:"medium"};if(_){u.title=Ce("Video URL has expired",a),u.message=Ce("The video\u2019s secured playback-token has expired.",a),R.message=Ce("This playback is using signed URLs and the playback-token has expired. Expired at: {expiredDate}. Current time: {currentDate}.",a).format({expiredDate:new Intl.DateTimeFormat(Dr.code,v).format(b*1e3),currentDate:new Intl.DateTimeFormat(Dr.code,v).format(Date.now())}),R.file="403-expired-token.md";break}if(A){u.title=Ce("Video URL is formatted incorrectly",a),u.message=Ce("The video\u2019s playback ID does not match the one encoded in the playback-token.",a),R.message=Ce("The specified playback ID {playbackId} and the playback ID encoded in the playback-token {tokenPlaybackId} do not match.",a).format({playbackId:e,tokenPlaybackId:I}),R.file="403-playback-id-mismatch.md";break}if(S){u.title=Ce("Video URL is formatted incorrectly",a),u.message=Ce("The playback-token is formatted with incorrect information.",a),R.message=Ce("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",a).format({tokenType:x}),R.file="403-incorrect-aud-value.md";break}R.message=Ce("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",a),R.file="403-malformatted-token.md";break}}break}case Ve.MEDIA_ERR_DECODE:{let{message:b}=r;u={title:Ce("Media Error",a),message:b},R.file="media-decode-error.md";break}case Ve.MEDIA_ERR_SRC_NOT_SUPPORTED:{let b=(L=(O=r.data)==null?void 0:O.response)==null?void 0:L.code;if(b>=400&&b<500){r.code=Ve.MEDIA_ERR_NETWORK,r.data={response:{code:b}},{dialog:u,devlog:R}=zn(r,t,e,s);break}u={title:Ce("Source Not Supported",a),message:r.message},R.file="media-src-not-supported.md";break}default:u={title:Ce("Error",a),message:r.message};break}return t&&(u={title:Ce("Your device appears to be offline",a),message:Ce("Check your internet connection and try reloading this video.",a)}),{dialog:u,devlog:R}}var Sh=Object.values(be),xh=700,Lh=300,Fs={LG:"large",SM:"small",XS:"extra-small"};function Xn(r){let t=r.getBoundingClientRect();return t.width<Lh?Fs.XS:t.width<xh?Fs.SM:Fs.LG}var or={SRC:"src",POSTER:"poster"},pe={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",TITLE:"title",PLACEHOLDER:"placeholder"};function Dh(r,t){var s,a;return{src:!r.playbackId&&r.src,playbackId:r.playbackId,hasSrc:!!r.playbackId||!!r.src,poster:r.poster,storyboard:r.storyboard,placeholder:r.getAttribute("placeholder"),theme:r.getAttribute("theme"),thumbnailTime:!r.tokens.thumbnail&&r.thumbnailTime,autoplay:r.autoplay,crossOrigin:r.crossOrigin,loop:r.loop,noHotKeys:r.hasAttribute(pe.NOHOTKEYS),hotKeys:r.getAttribute(pe.HOTKEYS),muted:r.muted,paused:r.paused,preload:r.preload,envKey:r.envKey,experimentalCmcd:r.experimentalCmcd,debug:r.debug,disableCookies:r.disableCookies,tokens:r.tokens,beaconCollectionDomain:r.beaconCollectionDomain,metadata:r.metadata,playerSoftwareName:r.playerSoftwareName,playerSoftwareVersion:r.playerSoftwareVersion,startTime:r.startTime,preferPlayback:r.preferPlayback,audio:r.audio,streamType:r.streamType,primaryColor:r.primaryColor,secondaryColor:r.secondaryColor,forwardSeekOffset:r.forwardSeekOffset,backwardSeekOffset:r.backwardSeekOffset,defaultHiddenCaptions:r.defaultHiddenCaptions,defaultShowRemainingTime:r.defaultShowRemainingTime,playbackRates:r.getAttribute(pe.PLAYBACK_RATES),customDomain:(s=r.getAttribute(le.CUSTOM_DOMAIN))!=null?s:void 0,playerSize:Xn((a=r.mediaController)!=null?a:r),metadataVideoId:r.getAttribute(le.METADATA_VIDEO_ID),metadataVideoTitle:r.getAttribute(le.METADATA_VIDEO_TITLE),metadataViewerUserId:r.getAttribute(le.METADATA_VIEWER_USER_ID),title:r.getAttribute(pe.TITLE),...t}}var Ih=Object.values(le),Mh=Object.values(or),Rh=Object.values(pe),Ch=Un(),Oh="mux-player",Yu={dialog:void 0,isDialogOpen:!1,inLiveWindow:!1},Nr,$i,lr,Yi,li,er,ui,Qn,gr,oi,di,Zn,zi,Ks,Jn,zu,qn,Xu,ea,Qu,ta,Zu,ra,Ju,ia,qu,Vi=class extends Os{constructor(){super();Ne(this,ui);Ne(this,gr);Ne(this,di);Ne(this,zi);Ne(this,Jn);Ne(this,qn);Ne(this,ea);Ne(this,ta);Ne(this,ra);Ne(this,ia);Ne(this,Nr,!1);Ne(this,$i,{});Ne(this,lr,!0);Ne(this,Yi,new wn(this,"hotkeys"));Ne(this,li,void 0);Ne(this,er,{...Yu,onCloseErrorDialog:()=>Fe(this,gr,oi).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:e=>{Ls(this,Nt.activeElement)||e.preventDefault()},onSeekToLive:()=>Rs(this)});this.attachShadow({mode:"open"}),this.isConnected&&Fe(this,ui,Qn).call(this)}static get observedAttributes(){var e;return[...(e=Os.observedAttributes)!=null?e:[],...Mh,...Ih,...Rh]}get theme(){var e,s;return Array.from((s=(e=this.shadowRoot)==null?void 0:e.children)!=null?s:[]).find(({localName:a})=>a.startsWith("media-theme-"))}get mediaController(){var e,s;return(s=(e=this.theme)==null?void 0:e.shadowRoot)==null?void 0:s.querySelector("media-controller")}connectedCallback(){Fe(this,zi,Ks).call(this),Fe(this,Jn,zu).call(this)}disconnectedCallback(){Fe(this,qn,Xu).call(this)}attributeChangedCallback(e,s,a){switch(xe(this,Nr)||Fe(this,ui,Qn).call(this),super.attributeChangedCallback(e,s,a),e){case pe.HOTKEYS:xe(this,Yi).value=a;break;case pe.THUMBNAIL_TIME:{a!=null&&this.tokens.thumbnail&&Rr(Ce("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case pe.THUMBNAIL_TOKEN:{let{aud:R}=hr(a);a&&R!=="t"&&Rr(Ce("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:R}));break}case pe.STORYBOARD_TOKEN:{let{aud:R}=hr(a);a&&R!=="s"&&Rr(Ce("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:R}));break}case le.PLAYBACK_ID:{a!=null&&a.includes("?token")&&Xt(Ce("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:a})),this.streamType?this.streamType!=null&&!Sh.includes(this.streamType)&&Nn({file:"invalid-stream-type.md",message:Ce("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand`, `live`, `ll-live`, `live:dvr`, or `ll-live:dvr`").format({streamType:this.streamType})}):Nn({file:"invalid-stream-type.md",message:String(Ce("No stream-type value supplied. Defaulting to `on-demand`. Please provide stream-type as either: `on-demand`, `live`, `ll-live`, `live:dvr`, or `ll-live:dvr`"))});break}}[le.PLAYBACK_ID,or.SRC,pe.PLAYBACK_TOKEN].includes(e)&&s!==a&&mt(this,er,{...xe(this,er),...Yu}),Fe(this,di,Zn).call(this,{[Hl(e)]:a})}get experimentalCmcd(){return this.hasAttribute(le.EXPERIMENTAL_CMCD)}set experimentalCmcd(e){!!e!==this.experimentalCmcd&&(e?this.setAttribute(le.EXPERIMENTAL_CMCD,""):this.removeAttribute(le.EXPERIMENTAL_CMCD))}get hasPlayed(){var e,s;return(s=(e=this.mediaController)==null?void 0:e.hasAttribute("media-has-played"))!=null?s:!1}get inLiveWindow(){return xe(this,er).inLiveWindow}get _hls(){var e;return(e=this.media)==null?void 0:e._hls}get mux(){var e;return(e=this.media)==null?void 0:e.mux}get playbackId(){var e;return(e=this.getAttribute(le.PLAYBACK_ID))!=null?e:void 0}set playbackId(e){e?this.setAttribute(le.PLAYBACK_ID,e):this.removeAttribute(le.PLAYBACK_ID)}get src(){var e,s;return this.playbackId?(e=Ur(this,or.SRC))!=null?e:void 0:(s=this.getAttribute(or.SRC))!=null?s:void 0}set src(e){e?this.setAttribute(or.SRC,e):this.removeAttribute(or.SRC)}get poster(){var s;let e=this.getAttribute(or.POSTER);if(e!=null)return e;if(this.playbackId&&!this.audio)return Kl(this.playbackId,{domain:this.customDomain,thumbnailTime:(s=this.thumbnailTime)!=null?s:this.startTime,token:this.tokens.thumbnail})}set poster(e){e||e===""?this.setAttribute(or.POSTER,e):this.removeAttribute(or.POSTER)}get storyboard(){if(this.playbackId&&!this.audio&&(!this.streamType||![be.LIVE,be.LL_LIVE,be.DVR,be.LL_DVR].includes(this.streamType)))return Wl(this.playbackId,{domain:this.customDomain,token:this.tokens.storyboard})}get audio(){return this.hasAttribute(pe.AUDIO)}set audio(e){if(!e){this.removeAttribute(pe.AUDIO);return}this.setAttribute(pe.AUDIO,"")}get hotkeys(){return xe(this,Yi)}get nohotkeys(){return this.hasAttribute(pe.NOHOTKEYS)}set nohotkeys(e){if(!e){this.removeAttribute(pe.NOHOTKEYS);return}this.setAttribute(pe.NOHOTKEYS,"")}get thumbnailTime(){return rr(this.getAttribute(pe.THUMBNAIL_TIME))}set thumbnailTime(e){this.setAttribute(pe.THUMBNAIL_TIME,`${e}`)}get title(){var e;return(e=this.getAttribute(pe.TITLE))!=null?e:""}set title(e){e!==this.title&&(e?this.setAttribute(pe.TITLE,e):this.removeAttribute("title"),super.title=e)}get placeholder(){var e;return(e=Ur(this,pe.PLACEHOLDER))!=null?e:""}set placeholder(e){this.setAttribute(pe.PLACEHOLDER,`${e}`)}get primaryColor(){var e;return(e=this.getAttribute(pe.PRIMARY_COLOR))!=null?e:void 0}set primaryColor(e){this.setAttribute(pe.PRIMARY_COLOR,`${e}`)}get secondaryColor(){var e;return(e=this.getAttribute(pe.SECONDARY_COLOR))!=null?e:void 0}set secondaryColor(e){this.setAttribute(pe.SECONDARY_COLOR,`${e}`)}get defaultShowRemainingTime(){return this.hasAttribute(pe.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(e){e?this.setAttribute(pe.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(pe.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(!!this.hasAttribute(pe.PLAYBACK_RATES))return this.getAttribute(pe.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(e=>Number(e)).filter(e=>!Number.isNaN(e)).sort((e,s)=>e-s)}set playbackRates(e){if(!e){this.removeAttribute(pe.PLAYBACK_RATES);return}this.setAttribute(pe.PLAYBACK_RATES,e.join(" "))}get forwardSeekOffset(){var e;return(e=rr(this.getAttribute(pe.FORWARD_SEEK_OFFSET)))!=null?e:10}set forwardSeekOffset(e){this.setAttribute(pe.FORWARD_SEEK_OFFSET,`${e}`)}get backwardSeekOffset(){var e;return(e=rr(this.getAttribute(pe.BACKWARD_SEEK_OFFSET)))!=null?e:10}set backwardSeekOffset(e){this.setAttribute(pe.BACKWARD_SEEK_OFFSET,`${e}`)}get defaultHiddenCaptions(){return this.hasAttribute(pe.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(e){e?this.setAttribute(pe.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(pe.DEFAULT_HIDDEN_CAPTIONS)}get playerSoftwareName(){var e;return(e=this.getAttribute(le.PLAYER_SOFTWARE_NAME))!=null?e:Oh}get playerSoftwareVersion(){var e;return(e=this.getAttribute(le.PLAYER_SOFTWARE_VERSION))!=null?e:Ch}get beaconCollectionDomain(){var e;return(e=this.getAttribute(le.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(le.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(le.BEACON_COLLECTION_DOMAIN))}get customDomain(){var e;return(e=this.getAttribute(le.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(le.CUSTOM_DOMAIN,e):this.removeAttribute(le.CUSTOM_DOMAIN))}get envKey(){var e;return(e=Ur(this,le.ENV_KEY))!=null?e:void 0}set envKey(e){this.setAttribute(le.ENV_KEY,`${e}`)}get debug(){return Ur(this,le.DEBUG)!=null}set debug(e){e?this.setAttribute(le.DEBUG,""):this.removeAttribute(le.DEBUG)}get disableCookies(){return Ur(this,le.DISABLE_COOKIES)!=null}set disableCookies(e){e?this.setAttribute(le.DISABLE_COOKIES,""):this.removeAttribute(le.DISABLE_COOKIES)}get streamType(){return Ur(this,le.STREAM_TYPE)}set streamType(e){this.setAttribute(le.STREAM_TYPE,`${e}`)}get startTime(){return rr(Ur(this,le.START_TIME))}set startTime(e){this.setAttribute(le.START_TIME,`${e}`)}get preferPlayback(){let e=this.getAttribute(le.PREFER_PLAYBACK);if(e===Ct.MSE||e===Ct.NATIVE)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===Ct.MSE||e===Ct.NATIVE?this.setAttribute(le.PREFER_PLAYBACK,e):this.removeAttribute(le.PREFER_PLAYBACK))}get metadata(){var e;return(e=this.media)==null?void 0:e.metadata}set metadata(e){if(xe(this,Nr)||Fe(this,ui,Qn).call(this),!this.media){Xt("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata=e}get tokens(){let e=this.getAttribute(pe.PLAYBACK_TOKEN),s=this.getAttribute(pe.THUMBNAIL_TOKEN),a=this.getAttribute(pe.STORYBOARD_TOKEN);return{...xe(this,$i),...e!=null?{playback:e}:{},...s!=null?{thumbnail:s}:{},...a!=null?{storyboard:a}:{}}}set tokens(e){mt(this,$i,e!=null?e:{})}get playbackToken(){var e;return(e=this.getAttribute(pe.PLAYBACK_TOKEN))!=null?e:void 0}set playbackToken(e){this.setAttribute(pe.PLAYBACK_TOKEN,`${e}`)}get thumbnailToken(){var e;return(e=this.getAttribute(pe.THUMBNAIL_TOKEN))!=null?e:void 0}set thumbnailToken(e){this.setAttribute(pe.THUMBNAIL_TOKEN,`${e}`)}get storyboardToken(){var e;return(e=this.getAttribute(pe.STORYBOARD_TOKEN))!=null?e:void 0}set storyboardToken(e){this.setAttribute(pe.STORYBOARD_TOKEN,`${e}`)}addTextTrack(e,s,a,u){var C;let R=(C=this.media)==null?void 0:C.nativeEl;if(!!R)return Es(R,e,s,a,u)}removeTextTrack(e){var a;let s=(a=this.media)==null?void 0:a.nativeEl;if(!!s)return ml(s,e)}get textTracks(){var e;return(e=this.media)==null?void 0:e.textTracks}};Nr=new WeakMap,$i=new WeakMap,lr=new WeakMap,Yi=new WeakMap,li=new WeakMap,er=new WeakMap,ui=new WeakSet,Qn=function(){var e,s,a;if(!xe(this,Nr)){mt(this,Nr,!0),Fe(this,gr,oi).call(this,{playerSize:Xn(this)});try{if(customElements.upgrade(this.theme),!(this.theme instanceof je.HTMLElement))throw""}catch{Xt(`<${(e=this.theme)==null?void 0:e.localName}> failed to upgrade!`)}try{if(customElements.upgrade(this.media),!(this.media instanceof kl))throw""}catch{Xt("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof Di))throw""}catch{Xt("<media-controller> failed to upgrade!")}zl(this),Fe(this,ta,Zu).call(this),Fe(this,ra,Ju).call(this),Fe(this,ea,Qu).call(this),mt(this,lr,(a=(s=this.mediaController)==null?void 0:s.hasAttribute("user-inactive"))!=null?a:!0),Fe(this,ia,qu).call(this)}},gr=new WeakSet,oi=function(e){Object.assign(xe(this,er),e),Fe(this,di,Zn).call(this)},di=new WeakSet,Zn=function(e={}){Hn($u(Dh(this,{...xe(this,er),...e})),this.shadowRoot)},zi=new WeakSet,Ks=function(){var e,s;xe(this,er).playerSize!=Xn((e=this.mediaController)!=null?e:this)&&Fe(this,gr,oi).call(this,{playerSize:Xn((s=this.mediaController)!=null?s:this)})},Jn=new WeakSet,zu=function(){var e;mt(this,li,new ResizeObserver(()=>Fe(this,zi,Ks).call(this))),xe(this,li).observe((e=this.mediaController)!=null?e:this)},qn=new WeakSet,Xu=function(){var e;(e=xe(this,li))==null||e.disconnect()},ea=new WeakSet,Qu=function(){var s,a,u,R,C;(s=this.mediaController)==null||s.addEventListener("mediaplayrequest",O=>{var L;((L=O.target)==null?void 0:L.localName)==="media-play-button"&&this.streamType&&[be.LIVE,be.LL_LIVE,be.DVR,be.LL_DVR].includes(this.streamType)&&this.hasPlayed&&Rs(this)});let e=()=>{let O=jl(this),L=xe(this,er).inLiveWindow;O!==L&&(Fe(this,gr,oi).call(this,{inLiveWindow:O}),this.dispatchEvent(new CustomEvent("inlivewindowchange",{composed:!0,bubbles:!0,detail:this.inLiveWindow})))};(a=this.media)==null||a.addEventListener("progress",e),(u=this.media)==null||u.addEventListener("waiting",e),(R=this.media)==null||R.addEventListener("timeupdate",e),(C=this.media)==null||C.addEventListener("emptied",e)},ta=new WeakSet,Zu=function(){var s;let e=a=>{let{detail:u}=a;if(u instanceof Ve||(u=new Ve(u.message,u.code,u.fatal)),!(u!=null&&u.fatal)){Rr(u),u.data&&Rr(`${u.name} data:`,u.data);return}let{dialog:R,devlog:C}=zn(u,!window.navigator.onLine,this.playbackId,this.playbackToken);C.message&&Nn(C),Xt(u),u.data&&Xt(`${u.name} data:`,u.data),Fe(this,gr,oi).call(this,{isDialogOpen:!0,dialog:R})};this.addEventListener("error",e),this.media&&(this.media.errorTranslator=(a={})=>{var R,C,O;if(!((R=this.media)!=null&&R.error))return a;let{devlog:u}=zn((C=this.media)==null?void 0:C.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(O=this.media)==null?void 0:O.error.code,player_error_message:u.message?String(u.message):a.player_error_message}}),(s=this.media)==null||s.addEventListener("error",a=>{var R,C;let{detail:u}=a;if(!u){let{message:O,code:L}=(C=(R=this.media)==null?void 0:R.error)!=null?C:{};u=new Ve(O,L)}!(u!=null&&u.fatal)||this.dispatchEvent(new CustomEvent("error",{detail:u}))})},ra=new WeakSet,Ju=function(){var s,a,u,R;let e=()=>Fe(this,di,Zn).call(this);(a=(s=this.media)==null?void 0:s.textTracks)==null||a.addEventListener("addtrack",e),(R=(u=this.media)==null?void 0:u.textTracks)==null||R.addEventListener("removetrack",e)},ia=new WeakSet,qu=function(){var b,x,I;let e=this.mediaController,s=/.*Version\/.*Safari\/.*/.test(navigator.userAgent);if(s)return;let a,u=new WeakMap,R=()=>this.streamType&&[be.LIVE,be.LL_LIVE].includes(this.streamType)&&!this.secondaryColor&&this.offsetWidth>=800,C=(_,A,S=!1)=>{if(R())return;Array.from(_&&_.activeCues||[]).forEach(i=>{if(!(!i.snapToLines||i.line<-5||i.line>=0&&i.line<10))if(!A||this.paused){let d=i.text.split(`
1664
- `).length,p=s?-2:-3;this.streamType&&[be.LIVE,be.LL_LIVE].includes(this.streamType)&&(p=s?-1:-2);let T=p-d;if(i.line===T&&!S)return;u.has(i)||u.set(i,i.line),i.line=T-1,i.line=T}else setTimeout(()=>{i.line=u.get(i)||"auto"},500)})},O=()=>{var _;C(a,(_=e==null?void 0:e.hasAttribute("user-inactive"))!=null?_:!1)},L=()=>{var S;let A=Array.from(((S=e==null?void 0:e.media)==null?void 0:S.textTracks)||[]).filter(v=>["subtitles","captions"].includes(v.kind)&&v.mode==="showing")[0];A!==a&&(a==null||a.removeEventListener("cuechange",O)),a=A,a==null||a.addEventListener("cuechange",O),C(a,xe(this,lr))};if(L(),(b=e==null?void 0:e.media)==null||b.textTracks.addEventListener("change",L),(x=e==null?void 0:e.media)==null||x.textTracks.addEventListener("addtrack",L),navigator.userAgent.includes("Chrome/")){let _=()=>{C(a,xe(this,lr),!0),this.paused||window.requestAnimationFrame(_)};(I=e==null?void 0:e.media)==null||I.addEventListener("playing",()=>{_()})}e==null||e.addEventListener("userinactivechange",()=>{let _=e==null?void 0:e.hasAttribute("user-inactive");xe(this,lr)!==_&&(mt(this,lr,_),C(a,xe(this,lr)))})};function Ur(r,t){return r.media?r.media.getAttribute(t):r.getAttribute(t)}je.customElements.get("mux-player")||(je.customElements.define("mux-player",Vi),je.MuxPlayerElement=Vi);var ey=Vi;export{Ve as MediaError,ey as default,Ur as getVideoAttribute};
1749
+ </${$s((te=Fs(r.theme))!=null?te:"media-theme-mux")}>
1750
+ `};function ra(r,t,e,a,s){var C,O,L;let u={},R={};switch(r.code){case $e.MEDIA_ERR_NETWORK:{switch(u.title=Oe("Network Error",s),u.message=r.message,(C=r.data)==null?void 0:C.response.code){case 412:{u.title=Oe("Video is not currently available",s),u.message=Oe("The live stream or video file are not yet ready.",s),R.message=Oe("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",s),R.file="412-not-playable.md";break}case 404:{u.title=Oe("Video does not exist",s),u.message="",R.message=Oe("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",s),R.file="404-not-found.md";break}case 403:{if(u.title=Oe("Invalid playback URL",s),u.message=Oe("The video URL or playback-token are formatted with incorrect or incomplete information.",s),R.message=Oe("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",s),R.file="missing-signed-tokens.md",!a)break;let{exp:b,aud:x,sub:I}=gr(a),_=Date.now()>b*1e3,A=I!==e,S=x!=="v",m={timeStyle:"medium",dateStyle:"medium"};if(_){u.title=Oe("Video URL has expired",s),u.message=Oe("The video\u2019s secured playback-token has expired.",s),R.message=Oe("This playback is using signed URLs and the playback-token has expired. Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat(Or.code,m).format(b*1e3),currentDate:new Intl.DateTimeFormat(Or.code,m).format(Date.now())}),R.file="403-expired-token.md";break}if(A){u.title=Oe("Video URL is formatted incorrectly",s),u.message=Oe("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),R.message=Oe("The specified playback ID {playbackId} and the playback ID encoded in the playback-token {tokenPlaybackId} do not match.",s).format({playbackId:e,tokenPlaybackId:I}),R.file="403-playback-id-mismatch.md";break}if(S){u.title=Oe("Video URL is formatted incorrectly",s),u.message=Oe("The playback-token is formatted with incorrect information.",s),R.message=Oe("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",s).format({tokenType:x}),R.file="403-incorrect-aud-value.md";break}R.message=Oe("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",s),R.file="403-malformatted-token.md";break}}break}case $e.MEDIA_ERR_DECODE:{let{message:b}=r;u={title:Oe("Media Error",s),message:b},R.file="media-decode-error.md";break}case $e.MEDIA_ERR_SRC_NOT_SUPPORTED:{let b=(L=(O=r.data)==null?void 0:O.response)==null?void 0:L.code;if(b>=400&&b<500){r.code=$e.MEDIA_ERR_NETWORK,r.data={response:{code:b}},{dialog:u,devlog:R}=ra(r,t,e,a);break}u={title:Oe("Source Not Supported",s),message:r.message},R.file="media-src-not-supported.md";break}default:u={title:Oe("Error",s),message:r.message};break}return t&&(u={title:Oe("Your device appears to be offline",s),message:Oe("Check your internet connection and try reloading this video.",s)}),{dialog:u,devlog:R}}var wh=Object.values(be),Uh=700,Nh=300,zs={LG:"large",SM:"small",XS:"extra-small"};function ia(r){let t=r.getBoundingClientRect();return t.width<Nh?zs.XS:t.width<Uh?zs.SM:zs.LG}var dr={SRC:"src",POSTER:"poster"},Ee={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",TITLE:"title",PLACEHOLDER:"placeholder"};function Bh(r,t){var a,s;return{src:!r.playbackId&&r.src,playbackId:r.playbackId,hasSrc:!!r.playbackId||!!r.src,poster:r.poster,storyboard:r.storyboard,placeholder:r.getAttribute("placeholder"),theme:r.getAttribute("theme"),thumbnailTime:!r.tokens.thumbnail&&r.thumbnailTime,autoplay:r.autoplay,crossOrigin:r.crossOrigin,loop:r.loop,noHotKeys:r.hasAttribute(Ee.NOHOTKEYS),hotKeys:r.getAttribute(Ee.HOTKEYS),muted:r.muted,paused:r.paused,preload:r.preload,envKey:r.envKey,experimentalCmcd:r.experimentalCmcd,preferCmcd:r.preferCmcd,debug:r.debug,disableCookies:r.disableCookies,tokens:r.tokens,beaconCollectionDomain:r.beaconCollectionDomain,metadata:r.metadata,playerSoftwareName:r.playerSoftwareName,playerSoftwareVersion:r.playerSoftwareVersion,startTime:r.startTime,preferPlayback:r.preferPlayback,audio:r.audio,streamType:r.streamType,primaryColor:r.primaryColor,secondaryColor:r.secondaryColor,forwardSeekOffset:r.forwardSeekOffset,backwardSeekOffset:r.backwardSeekOffset,defaultHiddenCaptions:r.defaultHiddenCaptions,defaultShowRemainingTime:r.defaultShowRemainingTime,playbackRates:r.getAttribute(Ee.PLAYBACK_RATES),customDomain:(a=r.getAttribute(ne.CUSTOM_DOMAIN))!=null?a:void 0,playerSize:ia((s=r.mediaController)!=null?s:r),metadataVideoId:r.getAttribute(ne.METADATA_VIDEO_ID),metadataVideoTitle:r.getAttribute(ne.METADATA_VIDEO_TITLE),metadataViewerUserId:r.getAttribute(ne.METADATA_VIEWER_USER_ID),title:r.getAttribute(Ee.TITLE),...t}}var Fh=Object.values(ne),Kh=Object.values(dr),Wh=Object.values(Ee),Hh=jn(),Gh="mux-player",rd={dialog:void 0,isDialogOpen:!1,inLiveWindow:!1},Br,Qi,cr,Zi,di,Jt,ci,na,br,ui,fi,aa,Ji,Xs,sa,id,oa,nd,la,ad,ua,sd,da,od,ca,ld,Xi=class extends Hs{constructor(){super();Be(this,ci);Be(this,br);Be(this,fi);Be(this,Ji);Be(this,sa);Be(this,oa);Be(this,la);Be(this,ua);Be(this,da);Be(this,ca);Be(this,Br,!1);Be(this,Qi,{});Be(this,cr,!0);Be(this,Zi,new Gn(this,"hotkeys"));Be(this,di,void 0);Be(this,Jt,{...rd,onCloseErrorDialog:()=>Fe(this,br,ui).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:e=>{Us(this,Bt.activeElement)||e.preventDefault()},onSeekToLive:()=>Ks(this)});this.attachShadow({mode:"open"}),this.isConnected&&Fe(this,ci,na).call(this)}static get observedAttributes(){var e;return[...(e=Hs.observedAttributes)!=null?e:[],...Kh,...Fh,...Wh]}get theme(){var e,a;return Array.from((a=(e=this.shadowRoot)==null?void 0:e.children)!=null?a:[]).find(({localName:s})=>s.startsWith("media-theme-"))}get mediaController(){var e,a;return(a=(e=this.theme)==null?void 0:e.shadowRoot)==null?void 0:a.querySelector("media-controller")}connectedCallback(){Fe(this,Ji,Xs).call(this),Fe(this,sa,id).call(this)}disconnectedCallback(){Fe(this,oa,nd).call(this)}attributeChangedCallback(e,a,s){switch(xe(this,Br)||Fe(this,ci,na).call(this),super.attributeChangedCallback(e,a,s),e){case Ee.HOTKEYS:xe(this,Zi).value=s;break;case Ee.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&pr(Oe("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case Ee.THUMBNAIL_TOKEN:{let{aud:R}=gr(s);s&&R!=="t"&&pr(Oe("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:R}));break}case Ee.STORYBOARD_TOKEN:{let{aud:R}=gr(s);s&&R!=="s"&&pr(Oe("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:R}));break}case ne.PLAYBACK_ID:{s!=null&&s.includes("?token")&&Qt(Oe("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:s})),this.streamType?this.streamType!=null&&!wh.includes(this.streamType)&&Vn({file:"invalid-stream-type.md",message:Oe("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand`, `live`, `ll-live`, `live:dvr`, or `ll-live:dvr`").format({streamType:this.streamType})}):Vn({file:"invalid-stream-type.md",message:String(Oe("No stream-type value supplied. Defaulting to `on-demand`. Please provide stream-type as either: `on-demand`, `live`, `ll-live`, `live:dvr`, or `ll-live:dvr`"))});break}}[ne.PLAYBACK_ID,dr.SRC,Ee.PLAYBACK_TOKEN].includes(e)&&a!==s&&gt(this,Jt,{...xe(this,Jt),...rd}),Fe(this,fi,aa).call(this,{[Zl(e)]:s})}get experimentalCmcd(){return this.hasAttribute(ne.EXPERIMENTAL_CMCD)}set experimentalCmcd(e){!!e!==this.experimentalCmcd&&(e?this.setAttribute(ne.EXPERIMENTAL_CMCD,""):this.removeAttribute(ne.EXPERIMENTAL_CMCD))}get preferCmcd(){var e;return(e=this.getAttribute(ne.PREFER_CMCD))!=null?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?ti.includes(e)?this.setAttribute(ne.PREFER_CMCD,e):pr(`Invalid value for preferCmcd. Must be one of ${ti.join()}`):this.removeAttribute(ne.PREFER_CMCD))}get hasPlayed(){var e,a;return(a=(e=this.mediaController)==null?void 0:e.hasAttribute("media-has-played"))!=null?a:!1}get inLiveWindow(){return xe(this,Jt).inLiveWindow}get _hls(){var e;return(e=this.media)==null?void 0:e._hls}get mux(){var e;return(e=this.media)==null?void 0:e.mux}get playbackId(){var e;return(e=this.getAttribute(ne.PLAYBACK_ID))!=null?e:void 0}set playbackId(e){e?this.setAttribute(ne.PLAYBACK_ID,e):this.removeAttribute(ne.PLAYBACK_ID)}get src(){var e,a;return this.playbackId?(e=Nr(this,dr.SRC))!=null?e:void 0:(a=this.getAttribute(dr.SRC))!=null?a:void 0}set src(e){e?this.setAttribute(dr.SRC,e):this.removeAttribute(dr.SRC)}get poster(){var a;let e=this.getAttribute(dr.POSTER);if(e!=null)return e;if(this.playbackId&&!this.audio)return Xl(this.playbackId,{domain:this.customDomain,thumbnailTime:(a=this.thumbnailTime)!=null?a:this.startTime,token:this.tokens.thumbnail})}set poster(e){e||e===""?this.setAttribute(dr.POSTER,e):this.removeAttribute(dr.POSTER)}get storyboard(){if(this.playbackId&&!this.audio&&(!this.streamType||![be.LIVE,be.LL_LIVE,be.DVR,be.LL_DVR].includes(this.streamType)))return Ql(this.playbackId,{domain:this.customDomain,token:this.tokens.storyboard})}get audio(){return this.hasAttribute(Ee.AUDIO)}set audio(e){if(!e){this.removeAttribute(Ee.AUDIO);return}this.setAttribute(Ee.AUDIO,"")}get hotkeys(){return xe(this,Zi)}get nohotkeys(){return this.hasAttribute(Ee.NOHOTKEYS)}set nohotkeys(e){if(!e){this.removeAttribute(Ee.NOHOTKEYS);return}this.setAttribute(Ee.NOHOTKEYS,"")}get thumbnailTime(){return tr(this.getAttribute(Ee.THUMBNAIL_TIME))}set thumbnailTime(e){this.setAttribute(Ee.THUMBNAIL_TIME,`${e}`)}get title(){var e;return(e=this.getAttribute(Ee.TITLE))!=null?e:""}set title(e){e!==this.title&&(e?this.setAttribute(Ee.TITLE,e):this.removeAttribute("title"),super.title=e)}get placeholder(){var e;return(e=Nr(this,Ee.PLACEHOLDER))!=null?e:""}set placeholder(e){this.setAttribute(Ee.PLACEHOLDER,`${e}`)}get primaryColor(){var e;return(e=this.getAttribute(Ee.PRIMARY_COLOR))!=null?e:void 0}set primaryColor(e){this.setAttribute(Ee.PRIMARY_COLOR,`${e}`)}get secondaryColor(){var e;return(e=this.getAttribute(Ee.SECONDARY_COLOR))!=null?e:"rgb(0 0 0 / .65)"}set secondaryColor(e){this.setAttribute(Ee.SECONDARY_COLOR,`${e}`)}get defaultShowRemainingTime(){return this.hasAttribute(Ee.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(e){e?this.setAttribute(Ee.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(Ee.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(!!this.hasAttribute(Ee.PLAYBACK_RATES))return this.getAttribute(Ee.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(e=>Number(e)).filter(e=>!Number.isNaN(e)).sort((e,a)=>e-a)}set playbackRates(e){if(!e){this.removeAttribute(Ee.PLAYBACK_RATES);return}this.setAttribute(Ee.PLAYBACK_RATES,e.join(" "))}get forwardSeekOffset(){var e;return(e=tr(this.getAttribute(Ee.FORWARD_SEEK_OFFSET)))!=null?e:10}set forwardSeekOffset(e){this.setAttribute(Ee.FORWARD_SEEK_OFFSET,`${e}`)}get backwardSeekOffset(){var e;return(e=tr(this.getAttribute(Ee.BACKWARD_SEEK_OFFSET)))!=null?e:10}set backwardSeekOffset(e){this.setAttribute(Ee.BACKWARD_SEEK_OFFSET,`${e}`)}get defaultHiddenCaptions(){return this.hasAttribute(Ee.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(e){e?this.setAttribute(Ee.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(Ee.DEFAULT_HIDDEN_CAPTIONS)}get playerSoftwareName(){var e;return(e=this.getAttribute(ne.PLAYER_SOFTWARE_NAME))!=null?e:Gh}get playerSoftwareVersion(){var e;return(e=this.getAttribute(ne.PLAYER_SOFTWARE_VERSION))!=null?e:Hh}get beaconCollectionDomain(){var e;return(e=this.getAttribute(ne.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(ne.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(ne.BEACON_COLLECTION_DOMAIN))}get customDomain(){var e;return(e=this.getAttribute(ne.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(ne.CUSTOM_DOMAIN,e):this.removeAttribute(ne.CUSTOM_DOMAIN))}get envKey(){var e;return(e=Nr(this,ne.ENV_KEY))!=null?e:void 0}set envKey(e){this.setAttribute(ne.ENV_KEY,`${e}`)}get debug(){return Nr(this,ne.DEBUG)!=null}set debug(e){e?this.setAttribute(ne.DEBUG,""):this.removeAttribute(ne.DEBUG)}get disableCookies(){return Nr(this,ne.DISABLE_COOKIES)!=null}set disableCookies(e){e?this.setAttribute(ne.DISABLE_COOKIES,""):this.removeAttribute(ne.DISABLE_COOKIES)}get streamType(){return Nr(this,ne.STREAM_TYPE)}set streamType(e){this.setAttribute(ne.STREAM_TYPE,`${e}`)}get startTime(){return tr(Nr(this,ne.START_TIME))}set startTime(e){this.setAttribute(ne.START_TIME,`${e}`)}get preferPlayback(){let e=this.getAttribute(ne.PREFER_PLAYBACK);if(e===Ot.MSE||e===Ot.NATIVE)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===Ot.MSE||e===Ot.NATIVE?this.setAttribute(ne.PREFER_PLAYBACK,e):this.removeAttribute(ne.PREFER_PLAYBACK))}get metadata(){var e;return(e=this.media)==null?void 0:e.metadata}set metadata(e){if(xe(this,Br)||Fe(this,ci,na).call(this),!this.media){Qt("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata=e}get tokens(){let e=this.getAttribute(Ee.PLAYBACK_TOKEN),a=this.getAttribute(Ee.THUMBNAIL_TOKEN),s=this.getAttribute(Ee.STORYBOARD_TOKEN);return{...xe(this,Qi),...e!=null?{playback:e}:{},...a!=null?{thumbnail:a}:{},...s!=null?{storyboard:s}:{}}}set tokens(e){gt(this,Qi,e!=null?e:{})}get playbackToken(){var e;return(e=this.getAttribute(Ee.PLAYBACK_TOKEN))!=null?e:void 0}set playbackToken(e){this.setAttribute(Ee.PLAYBACK_TOKEN,`${e}`)}get thumbnailToken(){var e;return(e=this.getAttribute(Ee.THUMBNAIL_TOKEN))!=null?e:void 0}set thumbnailToken(e){this.setAttribute(Ee.THUMBNAIL_TOKEN,`${e}`)}get storyboardToken(){var e;return(e=this.getAttribute(Ee.STORYBOARD_TOKEN))!=null?e:void 0}set storyboardToken(e){this.setAttribute(Ee.STORYBOARD_TOKEN,`${e}`)}addTextTrack(e,a,s,u){var C;let R=(C=this.media)==null?void 0:C.nativeEl;if(!!R)return Ds(R,e,a,s,u)}removeTextTrack(e){var s;let a=(s=this.media)==null?void 0:s.nativeEl;if(!!a)return xl(a,e)}get textTracks(){var e;return(e=this.media)==null?void 0:e.textTracks}};Br=new WeakMap,Qi=new WeakMap,cr=new WeakMap,Zi=new WeakMap,di=new WeakMap,Jt=new WeakMap,ci=new WeakSet,na=function(){var e,a,s;if(!xe(this,Br)){gt(this,Br,!0),Fe(this,br,ui).call(this,{playerSize:ia(this)});try{if(customElements.upgrade(this.theme),!(this.theme instanceof je.HTMLElement))throw""}catch{Qt(`<${(e=this.theme)==null?void 0:e.localName}> failed to upgrade!`)}try{if(customElements.upgrade(this.media),!(this.media instanceof Gl))throw""}catch{Qt("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof Mi))throw""}catch{Qt("<media-controller> failed to upgrade!")}iu(this),Fe(this,ua,sd).call(this),Fe(this,da,od).call(this),Fe(this,la,ad).call(this),gt(this,cr,(s=(a=this.mediaController)==null?void 0:a.hasAttribute("user-inactive"))!=null?s:!0),Fe(this,ca,ld).call(this)}},br=new WeakSet,ui=function(e){Object.assign(xe(this,Jt),e),Fe(this,fi,aa).call(this)},fi=new WeakSet,aa=function(e={}){Qn(td(Bh(this,{...xe(this,Jt),...e})),this.shadowRoot)},Ji=new WeakSet,Xs=function(){var e,a;xe(this,Jt).playerSize!=ia((e=this.mediaController)!=null?e:this)&&Fe(this,br,ui).call(this,{playerSize:ia((a=this.mediaController)!=null?a:this)})},sa=new WeakSet,id=function(){var e;gt(this,di,new ResizeObserver(()=>Fe(this,Ji,Xs).call(this))),xe(this,di).observe((e=this.mediaController)!=null?e:this)},oa=new WeakSet,nd=function(){var e;(e=xe(this,di))==null||e.disconnect()},la=new WeakSet,ad=function(){var a,s,u,R,C;(a=this.mediaController)==null||a.addEventListener("mediaplayrequest",O=>{var L;((L=O.target)==null?void 0:L.localName)==="media-play-button"&&this.streamType&&[be.LIVE,be.LL_LIVE,be.DVR,be.LL_DVR].includes(this.streamType)&&this.hasPlayed&&Ks(this)});let e=()=>{let O=ql(this),L=xe(this,Jt).inLiveWindow;O!==L&&(Fe(this,br,ui).call(this,{inLiveWindow:O}),this.dispatchEvent(new CustomEvent("inlivewindowchange",{composed:!0,bubbles:!0,detail:this.inLiveWindow})))};(s=this.media)==null||s.addEventListener("progress",e),(u=this.media)==null||u.addEventListener("waiting",e),(R=this.media)==null||R.addEventListener("timeupdate",e),(C=this.media)==null||C.addEventListener("emptied",e)},ua=new WeakSet,sd=function(){var a;let e=s=>{let{detail:u}=s;if(u instanceof $e||(u=new $e(u.message,u.code,u.fatal)),!(u!=null&&u.fatal)){pr(u),u.data&&pr(`${u.name} data:`,u.data);return}let{dialog:R,devlog:C}=ra(u,!window.navigator.onLine,this.playbackId,this.playbackToken);C.message&&Vn(C),Qt(u),u.data&&Qt(`${u.name} data:`,u.data),Fe(this,br,ui).call(this,{isDialogOpen:!0,dialog:R})};this.addEventListener("error",e),this.media&&(this.media.errorTranslator=(s={})=>{var R,C,O;if(!((R=this.media)!=null&&R.error))return s;let{devlog:u}=ra((C=this.media)==null?void 0:C.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(O=this.media)==null?void 0:O.error.code,player_error_message:u.message?String(u.message):s.player_error_message}}),(a=this.media)==null||a.addEventListener("error",s=>{var R,C;let{detail:u}=s;if(!u){let{message:O,code:L}=(C=(R=this.media)==null?void 0:R.error)!=null?C:{};u=new $e(O,L)}!(u!=null&&u.fatal)||this.dispatchEvent(new CustomEvent("error",{detail:u}))})},da=new WeakSet,od=function(){var a,s,u,R;let e=()=>Fe(this,fi,aa).call(this);(s=(a=this.media)==null?void 0:a.textTracks)==null||s.addEventListener("addtrack",e),(R=(u=this.media)==null?void 0:u.textTracks)==null||R.addEventListener("removetrack",e)},ca=new WeakSet,ld=function(){var b,x,I;let e=this.mediaController,a=/.*Version\/.*Safari\/.*/.test(navigator.userAgent);if(a)return;let s,u=new WeakMap,R=()=>this.streamType&&[be.LIVE,be.LL_LIVE].includes(this.streamType)&&!this.secondaryColor&&this.offsetWidth>=800,C=(_,A,S=!1)=>{if(R())return;Array.from(_&&_.activeCues||[]).forEach(i=>{if(!(!i.snapToLines||i.line<-5||i.line>=0&&i.line<10))if(!A||this.paused){let d=i.text.split(`
1751
+ `).length,p=a?-2:-3;this.streamType&&[be.LIVE,be.LL_LIVE].includes(this.streamType)&&(p=a?-1:-2);let T=p-d;if(i.line===T&&!S)return;u.has(i)||u.set(i,i.line),i.line=T-1,i.line=T}else setTimeout(()=>{i.line=u.get(i)||"auto"},500)})},O=()=>{var _;C(s,(_=e==null?void 0:e.hasAttribute("user-inactive"))!=null?_:!1)},L=()=>{var S;let A=Array.from(((S=e==null?void 0:e.media)==null?void 0:S.textTracks)||[]).filter(m=>["subtitles","captions"].includes(m.kind)&&m.mode==="showing")[0];A!==s&&(s==null||s.removeEventListener("cuechange",O)),s=A,s==null||s.addEventListener("cuechange",O),C(s,xe(this,cr))};if(L(),(b=e==null?void 0:e.media)==null||b.textTracks.addEventListener("change",L),(x=e==null?void 0:e.media)==null||x.textTracks.addEventListener("addtrack",L),navigator.userAgent.includes("Chrome/")){let _=()=>{C(s,xe(this,cr),!0),this.paused||window.requestAnimationFrame(_)};(I=e==null?void 0:e.media)==null||I.addEventListener("playing",()=>{_()})}e==null||e.addEventListener("userinactivechange",()=>{let _=e==null?void 0:e.hasAttribute("user-inactive");xe(this,cr)!==_&&(gt(this,cr,_),C(s,xe(this,cr)))})};function Nr(r,t){return r.media?r.media.getAttribute(t):r.getAttribute(t)}je.customElements.get("mux-player")||(je.customElements.define("mux-player",Xi),je.MuxPlayerElement=Xi);var fy=Xi;export{$e as MediaError,fy as default,Nr as getVideoAttribute};
1665
1752
  /*!
1666
1753
  * JavaScript Cookie v2.1.3
1667
1754
  * https://github.com/js-cookie/js-cookie