@mux/mux-player 2.2.0 → 2.3.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,22 +1,22 @@
1
- var Gb=Object.create;var Rm=Object.defineProperty;var Vb=Object.getOwnPropertyDescriptor;var Kb=Object.getOwnPropertyNames;var Wb=Object.getPrototypeOf,qb=Object.prototype.hasOwnProperty;var Yb=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var jb=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Kb(e))!qb.call(i,s)&&s!==t&&Rm(i,s,{get:()=>e[s],enumerable:!(r=Vb(e,s))||r.enumerable});return i};var zb=(i,e,t)=>(t=i!=null?Gb(Wb(i)):{},jb(e||!i||!i.__esModule?Rm(t,"default",{value:i,enumerable:!0}):t,i));var Gd=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var Ne=(i,e,t)=>(Gd(i,e,"read from private field"),t?t.call(i):e.get(i)),ut=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},si=(i,e,t,r)=>(Gd(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t);var Et=(i,e,t)=>(Gd(i,e,"access private method"),t);var Rg=Yb((yl,Lu)=>{(function(){var i,e;i=this,e=function(){return function(){var t={80:function(n,a,o){n.exports=o(728).default},728:function(n,a,o){"use strict";o.d(a,{default:function(){return Fb}});var l=o(48),d=o.n(l),c=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(v){var m=16*Math.random()|0;return(v==="x"?m:3&m|8).toString(16)})},u=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},h=function(v){return v&&v.nodeName!==void 0?(v.muxId||(v.muxId=v.id||u()),v.muxId):v},f=function(v){var m;v&&v.nodeName!==void 0?v=h(m=v):m=document.querySelector(v);var p=m&&m.nodeName?m.nodeName.toLowerCase():"";return[m,v,p]},g=o(640),E=o.n(g),T=E().methodFactory;E().methodFactory=function(v,m,p){var y=T(v,m,p);return function(){for(var _=["[mux]"],I=0;I<arguments.length;I++)_.push(arguments[I]);y.apply(void 0,_)}},E().setLevel(E().getLevel());var A=E();function k(){return(d().doNotTrack||d().navigator&&d().navigator.doNotTrack)==="1"}var L={now:function(){var v=d().performance,m=v&&v.timing,p=m&&m.navigationStart,y=typeof p=="number"&&typeof v.now=="function"?p+v.now():Date.now();return Math.round(y)}},N=function(v){return D(v)[0]},D=function(v){if(typeof v!="string"||v==="")return["localhost"];var m,p=(v.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return p&&(m=(p.match(/[^\.]+\.[^\.]+$/)||[])[0]),[p,m]},$={exists:function(){var v=d().performance;return(v&&v.timing)!==void 0},domContentLoadedEventEnd:function(){var v=d().performance,m=v&&v.timing;return m&&m.domContentLoadedEventEnd},navigationStart:function(){var v=d().performance,m=v&&v.timing;return m&&m.navigationStart}};function O(v,m,p){p=p===void 0?1:p,v[m]=v[m]||0,v[m]+=p}var G=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],Y=["x-cdn","content-type"].concat(G);function P(v){var m={};return(v=v||"").trim().split(/[\r\n]+/).forEach(function(p){if(p){var y=p.split(": "),_=y.shift();_&&(Y.indexOf(_.toLowerCase())>=0||_.toLowerCase().indexOf("x-litix-")===0)&&(m[_]=y.join(": "))}}),m}function X(v){if(v){var m=G.find(function(p){return v[p]!==void 0});return m?v[m]:void 0}}var z=function(v){var m={};for(var p in v){var y=v[p];y["DATA-ID"].search("io.litix.data.")!==-1&&(m[y["DATA-ID"].replace("io.litix.data.","")]=y.VALUE)}return m};function Ae(v,m){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(v);m&&(y=y.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,y)}return p}function Ee(v){for(var m=1;m<arguments.length;m++){var p=arguments[m]!=null?arguments[m]:{};m%2?Ae(Object(p),!0).forEach(function(y){be(v,y,p[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Ae(Object(p)).forEach(function(y){Object.defineProperty(v,y,Object.getOwnPropertyDescriptor(p,y))})}return v}function be(v,m,p){return m in v?Object.defineProperty(v,m,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[m]=p,v}var we=function(v){if(!v)return{};var m=$.navigationStart(),p=v.loading,y=p?p.start:v.trequest,_=p?p.first:v.tfirst,I=p?p.end:v.tload;return{bytesLoaded:v.total,requestStart:Math.round(m+y),responseStart:Math.round(m+_),responseEnd:Math.round(m+I)}},Se=function(v){if(v&&typeof v.getAllResponseHeaders=="function")return P(v.getAllResponseHeaders())};function Z(v,m){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(v);m&&(y=y.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,y)}return p}function ne(v){for(var m=1;m<arguments.length;m++){var p=arguments[m]!=null?arguments[m]:{};m%2?Z(Object(p),!0).forEach(function(y){se(v,y,p[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Z(Object(p)).forEach(function(y){Object.defineProperty(v,y,Object.getOwnPropertyDescriptor(p,y))})}return v}function se(v,m,p){return m in v?Object.defineProperty(v,m,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[m]=p,v}var xe=function(v,m){if(!v||typeof v.getRequests!="function")return{};var p=v.getRequests({state:"executed"});if(p.length===0)return{};var y,_=p[p.length-1],I=N(_.url),x=_.url,R=_.bytesLoaded,U=new Date(_.requestStartDate).getTime(),C=new Date(_.firstByteDate).getTime(),K=new Date(_.requestEndDate).getTime(),ve=isNaN(_.duration)?0:_.duration,de=typeof m.getMetricsFor=="function"?m.getMetricsFor(_.mediaType).HttpList:m.getDashMetrics().getHttpRequests(_.mediaType);return de.length>0&&(y=P(de[de.length-1]._responseHeaders||"")),{requestStart:U,requestResponseStart:C,requestResponseEnd:K,requestBytesLoaded:R,requestResponseHeaders:y,requestMediaDuration:ve,requestHostname:I,requestUrl:x,requestId:y?X(y):void 0}},Ie=function(v,m){var p=m.getQualityFor(v),y=m.getCurrentTrackFor(v).bitrateList;return y?{currentLevel:p,renditionWidth:y[p].width||null,renditionHeight:y[p].height||null,renditionBitrate:y[p].bandwidth}:{}},Ve=function(v){var m;return(m=v.match(/.*codecs\*?="(.*)"/))===null||m===void 0?void 0:m[1]};function ht(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var V=0,ee=function(){function v(){(function(_,I){if(!(_ instanceof I))throw new TypeError("Cannot call a class as a function")})(this,v)}var m,p,y;return m=v,p=[{key:"on",value:function(_,I,x){return I._eventEmitterGuid=I._eventEmitterGuid||++V,this._listeners=this._listeners||{},this._listeners[_]=this._listeners[_]||[],x&&(I=I.bind(x)),this._listeners[_].push(I),I}},{key:"off",value:function(_,I){var x=this._listeners&&this._listeners[_];x&&x.forEach(function(R,U){R._eventEmitterGuid===I._eventEmitterGuid&&x.splice(U,1)})}},{key:"one",value:function(_,I,x){var R=this;I._eventEmitterGuid=I._eventEmitterGuid||++V;var U=function C(){R.off(_,C),I.apply(x||this,arguments)};U._eventEmitterGuid=I._eventEmitterGuid,this.on(_,U)}},{key:"emit",value:function(_,I){var x=this;if(this._listeners){I=I||{};var R=this._listeners["before*"]||[],U=this._listeners[_]||[],C=this._listeners["after"+_]||[],K=function(ve,de){(ve=ve.slice()).forEach(function(he){he.call(x,{type:_},de)})};K(R,I),K(U,I),K(C,I)}}}],p&&ht(m.prototype,p),y&&ht(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}(),ke=ee;function Je(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var _t=function(){function v(_){var I=this;(function(x,R){if(!(x instanceof R))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,_.on("playing",function(){I._playheadShouldBeProgressing=!0}),_.on("play",this._startPlaybackHeartbeatInterval.bind(this)),_.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),_.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),_.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),_.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("seeked",function(){_.data.player_is_paused?I._stopPlaybackHeartbeatInterval():I._startPlaybackHeartbeatInterval()}),_.on("timeupdate",function(){I._playbackHeartbeatInterval!==null&&_.emit("playbackheartbeat")}),_.on("devicesleep",function(x,R){I._playbackHeartbeatInterval!==null&&(d().clearInterval(I._playbackHeartbeatInterval),_.emit("playbackheartbeatend",{viewer_time:R.viewer_time}),I._playbackHeartbeatInterval=null)})}var m,p,y;return m=v,(p=[{key:"_startPlaybackHeartbeatInterval",value:function(){var _=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=d().setInterval(function(){_.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(d().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Je(m.prototype,p),y&&Je(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function jt(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function hr(v,m,p){return m&&jt(v.prototype,m),p&&jt(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var ti=hr(function v(m){var p=this;(function(y,_){if(!(y instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),m.on("viewinit",function(){p.viewErrored=!1}),m.on("error",function(y,_){try{var I=m.errorTranslator({player_error_code:_.player_error_code,player_error_message:_.player_error_message,player_error_context:_.player_error_context});I?(m.data.player_error_code=I.player_error_code||_.player_error_code,m.data.player_error_message=I.player_error_message||_.player_error_message,m.data.player_error_context=I.player_error_context||_.player_error_context,p.viewErrored=!0):(delete m.data.player_error_code,delete m.data.player_error_message,delete m.data.player_error_context)}catch(x){m.mux.log.warn("Exception in error translator callback.",x),p.viewErrored=!0}})});function Li(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var ki=function(){function v(_){(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._watchTimeTrackerLastCheckedTime=null,_.on("playbackheartbeat",this._updateWatchTime.bind(this)),_.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var m,p,y;return m=v,(p=[{key:"_updateWatchTime",value:function(_,I){var x=I.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=x),O(this.pm.data,"view_watch_time",x-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=x}},{key:"_clearWatchTimeState",value:function(_,I){this._updateWatchTime(_,I),this._watchTimeTrackerLastCheckedTime=null}}])&&Li(m.prototype,p),y&&Li(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function _s(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var mn=function(){function v(_){var I=this;(function(U,C){if(!(U instanceof C))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=L.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var x=this._startPlaybackTimeTracking.bind(this);_.on("playing",x),_.on("adplaying",x),_.on("seeked",x);var R=this._stopPlaybackTimeTracking.bind(this);_.on("playbackheartbeatend",R),_.on("seeking",R),_.on("adplaying",function(){I._isAdPlaying=!0}),_.on("adended",function(){I._isAdPlaying=!1}),_.on("adpause",function(){I._isAdPlaying=!1}),_.on("adbreakstart",function(){I._isAdPlaying=!1}),_.on("adbreakend",function(){I._isAdPlaying=!1}),_.on("adplay",function(){I._isAdPlaying=!1}),_.on("viewinit",function(){I._playbackTimeTrackerLastPlayheadPosition=-1,I._lastTime=L.now(),I._isAdPlaying=!1,I._callbackUpdatePlaybackTime=null})}var m,p,y;return m=v,(p=[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var _=this.pm.data.player_playhead_time,I=L.now(),x=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&_>this._playbackTimeTrackerLastPlayheadPosition?x=_-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(x=I-this._lastTime),x>0&&x<=1e3&&O(this.pm.data,"view_content_playback_time",x),this._playbackTimeTrackerLastPlayheadPosition=_,this._lastTime=I}}])&&_s(m.prototype,p),y&&_s(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function hi(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var rt=function(){function v(_){(function(x,R){if(!(x instanceof R))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_;var I=this._updatePlayheadTime.bind(this);_.on("playbackheartbeat",I),_.on("playbackheartbeatend",I),_.on("timeupdate",I),_.on("destroy",function(){_.off("timeupdate",I)})}var m,p,y;return m=v,(p=[{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(_,I){var x=this,R=function(){x.pm.currentFragmentPDT&&x.pm.currentFragmentStart&&(x.pm.data.player_program_time=x.pm.currentFragmentPDT+x.pm.data.player_playhead_time-x.pm.currentFragmentStart)};if(I&&I.player_playhead_time)this.pm.data.player_playhead_time=I.player_playhead_time,R(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var U=this.pm.getPlayheadTime();U!==void 0&&(this.pm.data.player_playhead_time=U,R(),this._updateMaxPlayheadPosition())}}}])&&hi(m.prototype,p),y&&hi(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Or(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function pn(v,m,p){return m&&Or(v.prototype,m),p&&Or(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var gn=3e5,Oa=pn(function v(m){if(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")}(this,v),!m.disableRebufferTracking){var p,y=function(I,x){_(x),p=void 0},_=function(I){if(p){var x=I.viewer_time-p;O(m.data,"view_rebuffer_duration",x),p=I.viewer_time,m.data.view_rebuffer_duration>gn&&(m.emit("viewend"),m.send("viewend"),m.mux.log.warn("Ending view after rebuffering for longer than ".concat(gn,"ms, future events will be ignored unless a programchange or videochange occurs.")))}m.data.view_watch_time>=0&&m.data.view_rebuffer_count>0&&(m.data.view_rebuffer_frequency=m.data.view_rebuffer_count/m.data.view_watch_time,m.data.view_rebuffer_percentage=m.data.view_rebuffer_duration/m.data.view_watch_time)};m.on("playbackheartbeat",function(I,x){return _(x)}),m.on("rebufferstart",function(I,x){p||(O(m.data,"view_rebuffer_count",1),p=x.viewer_time,m.one("rebufferend",y))}),m.on("viewinit",function(){p=void 0,m.off("rebufferend",y)})}});function vn(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var CE=function(){function v(_){var I=this;(function(x,R){if(!(x instanceof R))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.disableRebufferTracking||_.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,_.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),_.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),_.on("seeking",function(){I._cleanupRebufferTracker(null,{viewer_time:L.now()})}))}var m,p,y;return m=v,p=[{key:"_checkIfRebuffering",value:function(_,I){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(_,I);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var x=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&x>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=I.viewer_time}else this._cleanupRebufferTracker(_,I,!0);else this._prepareRebufferTrackerState(I.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(_){this._lastCheckedTime=_,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=_}},{key:"_cleanupRebufferTracker",value:function(_,I){var x=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:I.viewer_time});else{if(this._lastCheckedTime===null)return;var R=this.pm.data.player_playhead_time-this._lastPlayheadTime,U=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&R>0&&U-R>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+U-R}))}x?this._prepareRebufferTrackerState(I.viewer_time):this._clearRebufferTrackerState()}}],p&&vn(m.prototype,p),y&&vn(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}(),ME=CE;function Jf(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var OE=function(){function v(_){var I=this;(function(x,R){if(!(x instanceof R))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){var x=_.data,R=x.view_id;if(!x.view_program_changed){var U=function(C,K){var ve=K.viewer_time;C.type==="playing"&&_.data.view_time_to_first_frame===void 0?I.calculateTimeToFirstFrame(ve||L.now(),R):C.type!=="adplaying"||_.data.view_time_to_first_frame!==void 0&&!I._inPrerollPosition()||I.calculateTimeToFirstFrame(ve||L.now(),R)};_.one("playing",U),_.one("adplaying",U),_.one("viewend",function(){_.off("playing",U),_.off("adplaying",U)})}})}var m,p,y;return m=v,(p=[{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(_,I){I===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:_}),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))}}])&&Jf(m.prototype,p),y&&Jf(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function em(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function PE(v,m,p){return m&&em(v.prototype,m),p&&em(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var NE=PE(function v(m){var p=this;(function(y,_){if(!(y instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),m.on("viewinit",function(){p._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(y){m.on(y,function(){if(p._lastPlayheadPosition>=0&&m.data.player_playhead_time>=0&&p._lastPlayerWidth>=0&&p._lastSourceWidth>0&&p._lastPlayerHeight>=0&&p._lastSourceHeight>0){var _=m.data.player_playhead_time-p._lastPlayheadPosition;if(_<0)return void(p._lastPlayheadPosition=-1);var I=Math.min(p._lastPlayerWidth/p._lastSourceWidth,p._lastPlayerHeight/p._lastSourceHeight),x=Math.max(0,I-1),R=Math.max(0,1-I);m.data.view_max_upscale_percentage=Math.max(m.data.view_max_upscale_percentage||0,x),m.data.view_max_downscale_percentage=Math.max(m.data.view_max_downscale_percentage||0,R),O(m.data,"view_total_content_playback_time",_),O(m.data,"view_total_upscaling",x*_),O(m.data,"view_total_downscaling",R*_)}p._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(y){m.on(y,function(){p._lastPlayheadPosition=m.data.player_playhead_time,p._lastPlayerWidth=m.data.player_width,p._lastPlayerHeight=m.data.player_height,p._lastSourceWidth=m.data.video_source_width,p._lastSourceHeight=m.data.video_source_height})})});function tm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function UE(v,m,p){return m&&tm(v.prototype,m),p&&tm(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var FE=UE(function v(m){var p=this;(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v),this.isSeeking=!1;var y=-1,_=function(){var I=L.now(),x=(m.data.viewer_time||I)-(y||I);O(m.data,"view_seek_duration",x),m.data.view_max_seek_time=Math.max(m.data.view_max_seek_time||0,x),p.isSeeking=!1,y=-1};m.on("seeking",function(I,x){Object.assign(m.data,x),p.isSeeking&&x.viewer_time-y<=2e3?y=x.viewer_time:(p.isSeeking&&_(),p.isSeeking=!0,y=x.viewer_time,O(m.data,"view_seek_count",1),m.send("seeking"))}),m.on("seeked",function(){_()}),m.on("viewend",function(){p.isSeeking&&(_(),m.send("seeked")),p.isSeeking=!1,y=-1})});function im(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,R=[],U=!0,C=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(R.push(I.value),!y||R.length!==y);U=!0);}catch(K){C=!0,x=K}finally{try{U||_.return==null||_.return()}finally{if(C)throw x}}return R}}(v,m)||function(p,y){if(p){if(typeof p=="string")return rm(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?rm(p,y):void 0}}(v,m)||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 rm(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}function sm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var nm=function(v,m){v.push(m),v.sort(function(p,y){return p.viewer_time-y.viewer_time})},BE=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],$E=function(){function v(_){var I=this;(function(R,U){if(!(R instanceof U))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){I.isAdBreak=!1,I._currentAdRequestNumber=0,I._currentAdResponseNumber=0,I._adRequests=[],I._adResponses=[],I._adHasPlayed=!1,I._wouldBeNewAdPlay=!0,I._prerollPlayTime=void 0}),BE.forEach(function(R){return _.on(R,I._updateAdData.bind(I))});var x=function(){I.isAdBreak=!1};_.on("adbreakstart",function(){I.isAdBreak=!0}),_.on("play",x),_.on("playing",x),_.on("viewend",x),_.on("adrequest",function(R,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdRequestNumber++},U),nm(I._adRequests,U),O(_.data,"view_ad_request_count"),I.inPrerollPosition()&&(_.data.view_preroll_requested=!0,I._adHasPlayed||O(_.data,"view_preroll_request_count"))}),_.on("adresponse",function(R,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdResponseNumber++},U),nm(I._adResponses,U);var C=I.findAdRequest(U.ad_request_id);C&&O(_.data,"view_ad_request_time",Math.max(0,U.viewer_time-C.viewer_time))}),_.on("adplay",function(R,U){I._adHasPlayed=!0,I._wouldBeNewAdPlay&&(I._wouldBeNewAdPlay=!1,O(_.data,"view_ad_played_count")),I.inPrerollPosition()&&!_.data.view_preroll_played&&(_.data.view_preroll_played=!0,I._adRequests.length>0&&(_.data.view_preroll_request_time=Math.max(0,U.viewer_time-I._adRequests[0].viewer_time)),_.data.view_start&&(_.data.view_startup_preroll_request_time=Math.max(0,U.viewer_time-_.data.view_start)),I._prerollPlayTime=U.viewer_time)}),_.on("adplaying",function(R,U){I.inPrerollPosition()&&_.data.view_preroll_load_time===void 0&&I._prerollPlayTime!==void 0&&(_.data.view_preroll_load_time=U.viewer_time-I._prerollPlayTime,_.data.view_startup_preroll_load_time=U.viewer_time-I._prerollPlayTime)}),_.on("adclicked",function(R,U){I._wouldBeNewAdPlay||O(_.data,"view_ad_clicked_count")}),_.on("adskipped",function(R,U){I._wouldBeNewAdPlay||O(_.data,"view_ad_skipped_count")}),_.on("adended",function(){I._wouldBeNewAdPlay=!0}),_.on("aderror",function(){I._wouldBeNewAdPlay=!0})}var m,p,y;return m=v,(p=[{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(_){for(var I=0;I<this._adRequests.length;I++)if(this._adRequests[I].ad_request_id===_)return this._adRequests[I]}},{key:"_updateAdData",value:function(_,I){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&I.ad_tag_url){var x=im(D(I.ad_tag_url),2),R=x[0],U=x[1];this.pm.data.view_preroll_ad_tag_domain=U,this.pm.data.view_preroll_ad_tag_hostname=R}if(!this.pm.data.view_preroll_ad_asset_hostname&&I.ad_asset_url){var C=im(D(I.ad_asset_url),2),K=C[0],ve=C[1];this.pm.data.view_preroll_ad_asset_domain=ve,this.pm.data.view_preroll_ad_asset_hostname=K}}this.pm.data.ad_asset_url=I==null?void 0:I.ad_asset_url,this.pm.data.ad_tag_url=I==null?void 0:I.ad_tag_url,this.pm.data.ad_creative_id=I==null?void 0:I.ad_creative_id,this.pm.data.ad_id=I==null?void 0:I.ad_id,this.pm.data.ad_universal_id=I==null?void 0:I.ad_universal_id}}])&&sm(m.prototype,p),y&&sm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function am(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function HE(v,m,p){return m&&am(v.prototype,m),p&&am(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var GE=HE(function v(m){var p,y;(function(R,U){if(!(R instanceof U))throw new TypeError("Cannot call a class as a function")})(this,v);var _=function(){m.disableRebufferTracking||p&&(O(m.data,"view_waiting_rebuffer_duration",L.now()-p),p=!1,d().clearInterval(y))},I=!1,x=function(){I=!1,_()};m.on("waiting",function(){I&&(m.disableRebufferTracking||(O(m.data,"view_waiting_rebuffer_count",1),p=L.now(),y=d().setInterval(function(){if(p){var R=L.now();O(m.data,"view_waiting_rebuffer_duration",R-p),p=R}},250)))}),m.on("playing",function(){_(),I=!0}),m.on("pause",x),m.on("seeking",x)});function om(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function VE(v,m,p){return m&&om(v.prototype,m),p&&om(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var KE=VE(function v(m){var p=this;(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v);var y=function(){p.lastWallClockTime=L.now(),m.on("before*",_)},_=function(I){var x=L.now(),R=p.lastWallClockTime;p.lastWallClockTime=x,x-R>3e4&&(m.emit("devicesleep",{viewer_time:R}),Object.assign(m.data,{viewer_time:R}),m.send("devicesleep"),m.emit("devicewake",{viewer_time:x}),Object.assign(m.data,{viewer_time:x}),m.send("devicewake"))};m.one("playbackheartbeat",y),m.on("playbackheartbeatend",function(){m.off("before*",_),m.one("playbackheartbeat",y)})}),lm=o(375),WE=o(655),dm=o.n(WE),cm="muxData",um=function(){var v;try{v=lm.parse(dm().get(cm)||"")}catch{v={}}return v},hm=function(v){try{dm().set(cm,lm.stringify(v),{expires:365})}catch{}},qE=function(){var v=um();return v.mux_viewer_id=v.mux_viewer_id||c(),v.msn=v.msn||Math.random(),hm(v),{mux_viewer_id:v.mux_viewer_id,mux_sample_number:v.msn}};function YE(v,m){var p=m.beaconCollectionDomain,y=m.beaconDomain;if(p)return"https://"+p;var _=y||"litix.io";return(v=v||"inferred").match(/^[a-z0-9]+$/)?"https://"+v+"."+_:"https://img.litix.io/a.gif"}var fm=function(){var v;switch(mm()){case"cellular":v="cellular";break;case"ethernet":v="wired";break;case"wifi":v="wifi";break;case void 0:break;default:v="other"}return v},mm=function(){var v=d().navigator,m=v&&(v.connection||v.mozConnection||v.webkitConnection);return m&&m.type};fm.getConnectionFromAPI=mm;var jE=fm,zE=gm({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"}),pm=gm({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ck:"clicked",cl:"canceled",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",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",sd:"skipped",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function gm(v){var m={};for(var p in v)v.hasOwnProperty(p)&&(m[v[p]]=p);return m}function Nd(v){var m={},p={};return Object.keys(v).forEach(function(y){var _=!1;if(v.hasOwnProperty(y)&&v[y]!==void 0){var I=y.split("_"),x=I[0],R=zE[x];R||(A.info("Data key word `"+I[0]+"` not expected in "+y),R=x+"_"),I.splice(1).forEach(function(U){U==="url"&&(_=!0),pm[U]?R+=pm[U]:Number(U)&&Math.floor(Number(U))===Number(U)?R+=U:(A.info("Data key word `"+U+"` not expected in "+y),R+="_"+U+"_")}),_?p[R]=v[y]:m[R]=v[y]}}),Object.assign(m,p)}var XE={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},QE=["hb","requestcompleted","requestfailed","requestcanceled"],ZE="https://img.litix.io",Qi=function(v){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=v||ZE,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},XE,m)};Qi.prototype.queueEvent=function(v,m){var p=Object.assign({},m);return(this._eventQueue.length<=this._options.maxQueueLength||v==="eventrateexceeded")&&(this._eventQueue.push(p),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},Qi.prototype.flushEvents=function(){var v=arguments.length>0&&arguments[0]!==void 0&&arguments[0];v&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},Qi.prototype.destroy=function(){var v=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,v?this._clearBeaconQueue():this.flushEvents(),d().clearTimeout(this._sendTimeout)},Qi.prototype._clearBeaconQueue=function(){var v=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,m=this._eventQueue.slice(v);v>0&&Object.assign(m[m.length-1],Nd({mux_view_message:"event queue truncated"}));var p=this._createPayload(m);vm(this._beaconUrl,p,!0,function(){})},Qi.prototype._sendBeaconQueue=function(){var v=this;if(!this._postInFlight){var m=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var p=this._createPayload(m),y=L.now();vm(this._beaconUrl,p,!1,function(_,I){I?(v._eventQueue=m.concat(v._eventQueue),v._failureCount+=1,A.info("Error sending beacon: "+I)):v._failureCount=0,v._roundTripTime=L.now()-y,v._postInFlight=!1})}},Qi.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var v=Math.pow(2,this._failureCount-1);return(1+(v*=Math.random()))*this._options.baseTimeBetweenBeacons},Qi.prototype._startBeaconSending=function(){var v=this;d().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=d().setTimeout(function(){v._eventQueue.length&&v._sendBeaconQueue(),v._startBeaconSending()},this._getNextBeaconTime()))},Qi.prototype._createPayload=function(v){var m,p,y,_=this,I={transmission_timestamp:Math.round(L.now())};this._roundTripTime&&(I.rtt_ms=Math.round(this._roundTripTime));var x=function(){m=JSON.stringify({metadata:I,events:p||v}),y=m.length/1024},R=function(){return y<=_._options.maxPayloadKBSize};return x(),R()||(A.info("Payload size is too big ("+y+" kb). Removing unnecessary events."),p=v.filter(function(U){return QE.indexOf(U.e)===-1}),x()),R()||(A.info("Payload size still too big ("+y+" kb). Cropping fields.."),p.forEach(function(U){for(var C in U){var K=U[C];typeof K=="string"&&K.length>51200&&(U[C]=K.substring(0,51200))}}),x()),m};var JE=function(v){return v.length<=57344},vm=function(v,m,p,y){if(p&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(v,m))y();else if(d().fetch)d().fetch(v,{method:"POST",body:m,headers:{"Content-Type":"text/plain"},keepalive:JE(m)}).then(function(I){return y(null,I.ok?null:"Error")}).catch(function(I){return y(null,I)});else{if(d().XMLHttpRequest){var _=new(d()).XMLHttpRequest;return _.onreadystatechange=function(){if(_.readyState===4)return y(null,_.status!==200?"error":void 0)},_.open("POST",v),_.setRequestHeader("Content-Type","text/plain"),void _.send(m)}y()}},eb=Qi;function tb(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,R=[],U=!0,C=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(R.push(I.value),!y||R.length!==y);U=!0);}catch(K){C=!0,x=K}finally{try{U||_.return==null||_.return()}finally{if(C)throw x}}return R}}(v,m)||function(p,y){if(p){if(typeof p=="string")return Em(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?Em(p,y):void 0}}(v,m)||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 Em(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}function bm(v,m){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(v);m&&(y=y.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,y)}return p}function As(v){for(var m=1;m<arguments.length;m++){var p=arguments[m]!=null?arguments[m]:{};m%2?bm(Object(p),!0).forEach(function(y){Pa(v,y,p[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):bm(Object(p)).forEach(function(y){Object.defineProperty(v,y,Object.getOwnPropertyDescriptor(p,y))})}return v}function En(v){return En=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},En(v)}function ib(v,m){if(!(v instanceof m))throw new TypeError("Cannot call a class as a function")}function ym(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Pa(v,m,p){return m in v?Object.defineProperty(v,m,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[m]=p,v}var rb=["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"],sb=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],nb=["ad_id","ad_creative_id","ad_universal_id"],ab=["viewstart","error","ended","viewend"],ob=function(){function v(_,I){var x,R,U,C,K,ve,de,he,oe,me,Me,At,St,Ut,ri,Ce=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};ib(this,v),Pa(this,"previousBeaconData",null),Pa(this,"lastEventTime",0),Pa(this,"rateLimited",!1),this.mux=_,this.envKey=I,this.options=Ce,this.eventQueue=new eb(YE(this.envKey,this.options)),this.sampleRate=(x=this.options.sampleRate)!==null&&x!==void 0?x:1,this.disableCookies=(R=this.options.disableCookies)!==null&&R!==void 0&&R,this.respectDoNotTrack=(U=this.options.respectDoNotTrack)!==null&&U!==void 0&&U,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(C=this.options.platform)===null||C===void 0?void 0:C.name,viewer_application_version:(K=this.options.platform)===null||K===void 0?void 0:K.version,viewer_application_engine:(ve=this.options.platform)===null||ve===void 0?void 0:ve.layout,viewer_device_name:(de=this.options.platform)===null||de===void 0?void 0:de.product,viewer_device_category:"",viewer_device_manufacturer:(he=this.options.platform)===null||he===void 0?void 0:he.manufacturer,viewer_os_family:(oe=this.options.platform)===null||oe===void 0||(me=oe.os)===null||me===void 0?void 0:me.family,viewer_os_architecture:(Me=this.options.platform)===null||Me===void 0||(At=Me.os)===null||At===void 0?void 0:At.architecture,viewer_os_version:(St=this.options.platform)===null||St===void 0||(Ut=St.os)===null||Ut===void 0?void 0:Ut.version,viewer_connection_type:jE(),page_url:d()===null||d()===void 0||(ri=d().location)===null||ri===void 0?void 0:ri.href},this.viewerData=this.disableCookies?{}:qE()}var m,p,y;return m=v,(p=[{key:"send",value:function(_,I){var x;if(_&&I!=null&&I.view_id){if(this.respectDoNotTrack&&k())return A.info("Not sending `"+_+"` because Do Not Track is enabled");if(!I||En(I)!=="object")return A.error("A data object was expected in send() but was not provided");var R,U,C=this.disableCookies?{}:(R=um(),U=L.now(),R.session_start&&(R.sst=R.session_start,delete R.session_start),R.session_id&&(R.sid=R.session_id,delete R.session_id),R.session_expires&&(R.sex=R.session_expires,delete R.session_expires),(!R.sex||R.sex<U)&&(R.sid=c(),R.sst=U),R.sex=U+15e5,hm(R),{session_id:R.sid,session_start:R.sst,session_expires:R.sex}),K=As(As(As(As(As({},this.pageLevelData),I),C),this.viewerData),{},{event:_,env_key:this.envKey});K.user_id&&(K.viewer_user_id=K.user_id,delete K.user_id);var ve=((x=K.mux_sample_number)!==null&&x!==void 0?x:0)>=this.sampleRate,de=Nd(this._deduplicateBeaconData(_,K));if(this.lastEventTime=this.mux.utils.now(),ve)return A.info("Not sending event due to sample rate restriction",_,K,de);if(this.envKey||A.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",_,K,de),!this.rateLimited){if(A.info("Sending event",_,K,de),this.rateLimited=!this.eventQueue.queueEvent(_,de),this.mux.WINDOW_UNLOADING&&_==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&_==="hb"?this.eventQueue.flushEvents(!0):ab.indexOf(_)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return K.event="eventrateexceeded",de=Nd(K),this.eventQueue.queueEvent(K.event,de),A.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(_,I){var x=this,R={},U=I.view_id;if(U==="-1"||_==="viewstart"||_==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)R=As({},I),U&&(this.previousBeaconData=R),U&&_==="viewend"&&(this.previousBeaconData=null);else{var C=_.indexOf("request")===0;Object.entries(I).forEach(function(K){var ve=tb(K,2),de=ve[0],he=ve[1];x.previousBeaconData&&(he!==x.previousBeaconData[de]||rb.indexOf(de)>-1||x.objectHasChanged(C,de,he,x.previousBeaconData[de])||x.eventRequiresKey(_,de))&&(R[de]=he,x.previousBeaconData[de]=he)})}return R}},{key:"objectHasChanged",value:function(_,I,x,R){return!(!_||I.indexOf("request_")!==0||I!=="request_response_headers"&&En(x)==="object"&&En(R)==="object"&&Object.keys(x||{}).length===Object.keys(R||{}).length)}},{key:"eventRequiresKey",value:function(_,I){return _==="renditionchange"&&I.indexOf("video_source_")===0||!(!nb.includes(I)||!sb.includes(_))}}])&&ym(m.prototype,p),y&&ym(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Tm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function lb(v,m,p){return m&&Tm(v.prototype,m),p&&Tm(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var db=lb(function v(m){(function(C,K){if(!(C instanceof K))throw new TypeError("Cannot call a class as a function")})(this,v);var p=0,y=0,_=0,I=0,x=0,R=0,U=0;m.on("requestcompleted",function(C,K){var ve,de,he=K.request_start,oe=K.request_response_start,me=K.request_response_end,Me=K.request_bytes_loaded;if(I++,oe?(ve=oe-(he!=null?he:0),de=(me!=null?me:0)-oe):de=(me!=null?me:0)-(he!=null?he:0),de>0&&Me&&Me>0){var At=Me/de*8e3;x++,y+=Me,_+=de,m.data.view_min_request_throughput=Math.min(m.data.view_min_request_throughput||1/0,At),m.data.view_average_request_throughput=y/_*8e3,m.data.view_request_count=I,ve>0&&(p+=ve,m.data.view_max_request_latency=Math.max(m.data.view_max_request_latency||0,ve),m.data.view_average_request_latency=p/x)}}),m.on("requestfailed",function(C,K){I++,R++,m.data.view_request_count=I,m.data.view_request_failed_count=R}),m.on("requestcanceled",function(C,K){I++,U++,m.data.view_request_count=I,m.data.view_request_canceled_count=U})});function _m(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function cb(v,m,p){return m&&_m(v.prototype,m),p&&_m(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var ub=cb(function v(m){var p=this;(function(y,_){if(!(y instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),m.on("before*",function(y,_){var I=_.viewer_time,x=L.now(),R=p._lastEventTime;if(p._lastEventTime=x,R&&x-R>36e5){var U=Object.keys(m.data).reduce(function(C,K){return K.indexOf("video_")===0?Object.assign(C,function(ve,de,he){return de in ve?Object.defineProperty(ve,de,{value:he,enumerable:!0,configurable:!0,writable:!0}):ve[de]=he,ve}({},K,m.data[K])):C},{});m.mux.log.info("Received event after at least an hour inactivity, creating a new view"),m.emit("viewinit",Object.assign({viewer_time:I},U)),m.playbackHeartbeat._playheadShouldBeProgressing&&y.type!=="play"&&y.type!=="adbreakstart"&&(m.emit("play",{viewer_time:I}),y.type!=="playing"&&m.emit("playing",{viewer_time:I}))}})});function Ud(v){return Ud=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},Ud(v)}function hb(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,R=[],U=!0,C=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(R.push(I.value),!y||R.length!==y);U=!0);}catch(K){C=!0,x=K}finally{try{U||_.return==null||_.return()}finally{if(C)throw x}}return R}}(v,m)||function(p,y){if(p){if(typeof p=="string")return Am(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?Am(p,y):void 0}}(v,m)||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 Am(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}function Sm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Fd(v,m){return Fd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,y){return p.__proto__=y,p},Fd(v,m)}function fb(v){var m=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 p,y=Na(v);if(m){var _=Na(this).constructor;p=Reflect.construct(y,arguments,_)}else p=y.apply(this,arguments);return mb(this,p)}}function mb(v,m){if(m&&(Ud(m)==="object"||typeof m=="function"))return m;if(m!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return pt(v)}function pt(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function Na(v){return Na=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(m){return m.__proto__||Object.getPrototypeOf(m)},Na(v)}var pb=["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"],gb=function(v){(function(x,R){if(typeof R!="function"&&R!==null)throw new TypeError("Super expression must either be null or a function");x.prototype=Object.create(R&&R.prototype,{constructor:{value:x,writable:!0,configurable:!0}}),Object.defineProperty(x,"prototype",{writable:!1}),R&&Fd(x,R)})(I,v);var m,p,y,_=fb(I);function I(x,R,U){var C;(function(oe,me){if(!(oe instanceof me))throw new TypeError("Cannot call a class as a function")})(this,I),(C=_.call(this)).DOM_CONTENT_LOADED_EVENT_END=$.domContentLoadedEventEnd(),C.NAVIGATION_START=$.navigationStart(),C.mux=x,C.id=R,(U=Object.assign({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(oe){return oe}},U)).data=U.data||{},U.data.property_key&&(U.data.env_key=U.data.property_key,delete U.data.property_key),A.setLevel(U.debug?"debug":"warn"),C.getPlayheadTime=U.getPlayheadTime,C.getStateData=U.getStateData||function(){return{}},C.getAdData=U.getAdData||function(){},C.minimumRebufferDuration=U.minimumRebufferDuration,C.sustainedRebufferThreshold=U.sustainedRebufferThreshold,C.playbackHeartbeatTime=U.playbackHeartbeatTime,C.disableRebufferTracking=U.disableRebufferTracking,C.disableRebufferTracking&&C.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."),C.disablePlayheadRebufferTracking=U.disablePlayheadRebufferTracking,C.errorTranslator=U.errorTranslator,C.playbackEventDispatcher=new ob(x,U.data.env_key,U),C.data={player_instance_id:c(),mux_sample_rate:U.sampleRate,beacon_domain:U.beaconCollectionDomain?U.beaconCollectionDomain:U.beaconDomain},C.data.view_sequence_number=1,C.data.player_sequence_number=1,C.oldEmit=C.emit,C.emit=function(oe,me){me=Object.assign({viewer_time:this.mux.utils.now()},me),this.oldEmit(oe,me)};var K=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(pt(C));C.on("viewinit",function(oe,me){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,me),this._initializeViewData(),this.one("play",K),this.one("adbreakstart",K)});var ve=function(oe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",oe)}.bind(pt(C));if(C.on("videochange",function(oe,me){ve(me)}),C.on("programchange",function(oe,me){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."),ve(Object.assign(me,{view_program_changed:!0})),K(),this.emit("play"),this.emit("playing")}),C.on("fragmentchange",function(oe,me){this.currentFragmentPDT=me.currentFragmentPDT,this.currentFragmentStart=me.currentFragmentStart}),C.on("destroy",C.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var de=function(){var oe=C.data.view_start!==void 0;C.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",oe&&C.mux.WINDOW_HIDDEN&&(C.data.player_is_paused||C.emit("hb"))};window.addEventListener("visibilitychange",de,!1);var he=function(oe){oe.persisted||C.destroy()};window.addEventListener("pagehide",he,!1),C.on("destroy",function(){window.removeEventListener("visibilitychange",de),window.removeEventListener("pagehide",he)})}return C.on("playerready",function(oe,me){Object.assign(this.data,me)}),pb.forEach(function(oe){C.on(oe,function(me,Me){oe.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,Me),this._sanitizeData()}),C.on("after"+oe,function(){(oe!=="error"||this.errorTracker.viewErrored)&&this.send(oe)})}),C.on("viewend",function(oe,me){Object.assign(C.data,me)}),C.one("playerready",function(oe){var me=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=me-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}),C.longResumeTracker=new ub(pt(C)),C.errorTracker=new ti(pt(C)),new KE(pt(C)),C.seekingTracker=new FE(pt(C)),C.playheadTime=new rt(pt(C)),C.playbackHeartbeat=new _t(pt(C)),new NE(pt(C)),C.watchTimeTracker=new ki(pt(C)),new mn(pt(C)),C.adTracker=new $E(pt(C)),new ME(pt(C)),new Oa(pt(C)),new OE(pt(C)),new GE(pt(C)),new db(pt(C)),U.hlsjs&&C.addHLSJS(U),U.dashjs&&C.addDashJS(U),C.emit("viewinit",U.data),C}return m=I,p=[{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(x){if(this.data.view_id){var R=Object.assign({},this.data);if(R.video_source_is_live===void 0&&(R.player_source_duration===1/0||R.video_source_duration===1/0?R.video_source_is_live=!0:(R.player_source_duration>0||R.video_source_duration>0)&&(R.video_source_is_live=!1)),R.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(ve){R[ve]=void 0}),R.video_source_url=R.video_source_url||R.player_source_url,R.video_source_url){var U=hb(D(R.video_source_url),2),C=U[0],K=U[1];R.video_source_domain=K,R.video_source_hostname=C}delete R.ad_request_id,this.playbackEventDispatcher.send(x,R),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),x==="viewend"&&delete this.data.view_id}}},{key:"_updateStateData",value:function(){Object.assign(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var x=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(R){var U=parseInt(x.data[R],10);x.data[R]=isNaN(U)?void 0:U}),["player_source_url","video_source_url"].forEach(function(R){if(x.data[R]){var U=x.data[R].toLowerCase();U.indexOf("data:")!==0&&U.indexOf("blob:")!==0||(x.data[R]="MSE style URL")}})}},{key:"_resetVideoData",value:function(x,R){var U=this;Object.keys(this.data).forEach(function(C){C.indexOf("video_")===0&&delete U.data[C]})}},{key:"_resetViewData",value:function(){var x=this;Object.keys(this.data).forEach(function(R){R.indexOf("view_")===0&&delete x.data[R]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(x,R){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var x=this,R=this.data.view_id=c(),U=function(){R===x.data.view_id&&O(x.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",U):U()}},{key:"_restartHeartBeat",value:function(){var x=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){x.data.player_is_paused||x.emit("hb")},1e4))}},{key:"addHLSJS",value:function(x){x.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=x.hlsjs,function(R,U,C){var K=arguments.length>4?arguments[4]:void 0,ve=R.log,de=R.utils.secondsToMs,he=function(Oe){var Q,fe=parseInt(K.version);return fe===1&&Oe.programDateTime!==null&&(Q=Oe.programDateTime),fe===0&&Oe.pdt!==null&&(Q=Oe.pdt),Q};if($.exists()){var oe=function(Oe,Q){return R.emit(U,Oe,Q)},me=function(Oe,Q){var fe=Q.levels,te=Q.audioTracks,_e=Q.url,De=Q.stats,ct=Q.networkDetails,Ft=Q.sessionData,xt={},Ot={};fe.forEach(function(ft,_n){xt[_n]={width:ft.width,height:ft.height,bitrate:ft.bitrate,attrs:ft.attrs}}),te.forEach(function(ft,_n){Ot[_n]={name:ft.name,language:ft.lang,bitrate:ft.bitrate}});var gt=we(De),vt=gt.bytesLoaded,fr=gt.requestStart,Tn=gt.responseStart,Pr=gt.responseEnd;oe("requestcompleted",Ee(Ee({},z(Ft)),{},{request_event_type:Oe,request_bytes_loaded:vt,request_start:fr,request_response_start:Tn,request_response_end:Pr,request_type:"manifest",request_hostname:N(_e),request_response_headers:Se(ct),request_rendition_lists:{media:xt,audio:Ot,video:{}}}))};C.on(K.Events.MANIFEST_LOADED,me);var Me=function(Oe,Q){var fe=Q.details,te=Q.level,_e=Q.networkDetails,De=Q.stats,ct=we(De),Ft=ct.bytesLoaded,xt=ct.requestStart,Ot=ct.responseStart,gt=ct.responseEnd,vt=fe.fragments[fe.fragments.length-1],fr=he(vt)+de(vt.duration);oe("requestcompleted",{request_event_type:Oe,request_bytes_loaded:Ft,request_start:xt,request_response_start:Ot,request_response_end:gt,request_current_level:te,request_type:"manifest",request_hostname:N(fe.url),request_response_headers:Se(_e),video_holdback:fe.holdBack&&de(fe.holdBack),video_part_holdback:fe.partHoldBack&&de(fe.partHoldBack),video_part_target_duration:fe.partTarget&&de(fe.partTarget),video_target_duration:fe.targetduration&&de(fe.targetduration),video_source_is_live:fe.live,player_manifest_newest_program_time:isNaN(fr)?void 0:fr})};C.on(K.Events.LEVEL_LOADED,Me);var At=function(Oe,Q){var fe=Q.details,te=Q.networkDetails,_e=Q.stats,De=we(_e),ct=De.bytesLoaded,Ft=De.requestStart,xt=De.responseStart,Ot=De.responseEnd;oe("requestcompleted",{request_event_type:Oe,request_bytes_loaded:ct,request_start:Ft,request_response_start:xt,request_response_end:Ot,request_type:"manifest",request_hostname:N(fe.url),request_response_headers:Se(te)})};C.on(K.Events.AUDIO_TRACK_LOADED,At);var St=function(Oe,Q){var fe=Q.stats,te=Q.networkDetails,_e=Q.frag;fe=fe||_e.stats;var De=we(fe),ct=De.bytesLoaded,Ft=De.requestStart,xt=De.responseStart,Ot=De.responseEnd,gt=te?Se(te):void 0,vt={request_event_type:Oe,request_bytes_loaded:ct,request_start:Ft,request_response_start:xt,request_response_end:Ot,request_hostname:te?N(te.responseURL):void 0,request_id:gt?X(gt):void 0,request_response_headers:gt,request_media_duration:_e.duration,request_url:te==null?void 0:te.responseURL};_e.type==="main"?(vt.request_type="media",vt.request_current_level=_e.level,vt.request_video_width=(C.levels[_e.level]||{}).width,vt.request_video_height=(C.levels[_e.level]||{}).height,vt.request_labeled_bitrate=(C.levels[_e.level]||{}).bitrate):vt.request_type=_e.type,oe("requestcompleted",vt)};C.on(K.Events.FRAG_LOADED,St);var Ut=function(Oe,Q){var fe=Q.frag,te=fe.start,_e={currentFragmentPDT:he(fe),currentFragmentStart:de(te)};oe("fragmentchange",_e)};C.on(K.Events.FRAG_CHANGED,Ut);var ri=function(Oe,Q){var fe=Q.type,te=Q.details,_e=Q.response,De=Q.fatal,ct=Q.frag,Ft=Q.networkDetails,xt=(ct==null?void 0:ct.url)||Q.url||"",Ot=Ft?Se(Ft):void 0;if(te!==K.ErrorDetails.MANIFEST_LOAD_ERROR&&te!==K.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&te!==K.ErrorDetails.FRAG_LOAD_ERROR&&te!==K.ErrorDetails.FRAG_LOAD_TIMEOUT&&te!==K.ErrorDetails.LEVEL_LOAD_ERROR&&te!==K.ErrorDetails.LEVEL_LOAD_TIMEOUT&&te!==K.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&te!==K.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&te!==K.ErrorDetails.SUBTITLE_LOAD_ERROR&&te!==K.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&te!==K.ErrorDetails.KEY_LOAD_ERROR&&te!==K.ErrorDetails.KEY_LOAD_TIMEOUT||oe("requestfailed",{request_error:te,request_url:xt,request_hostname:N(xt),request_id:Ot?X(Ot):void 0,request_type:te===K.ErrorDetails.FRAG_LOAD_ERROR||te===K.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":te===K.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||te===K.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":te===K.ErrorDetails.SUBTITLE_LOAD_ERROR||te===K.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":te===K.ErrorDetails.KEY_LOAD_ERROR||te===K.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:_e==null?void 0:_e.code,request_error_text:_e==null?void 0:_e.text}),De){var gt,vt="".concat(xt?"url: ".concat(xt,`
5
- `):"")+"".concat(_e&&(_e.code||_e.text)?"response: ".concat(_e.code,", ").concat(_e.text,`
6
- `):"")+"".concat(Q.reason?"failure reason: ".concat(Q.reason,`
7
- `):"")+"".concat(Q.level?"level: ".concat(Q.level,`
8
- `):"")+"".concat(Q.parent?"parent stream controller: ".concat(Q.parent,`
9
- `):"")+"".concat(Q.buffer?"buffer length: ".concat(Q.buffer,`
10
- `):"")+"".concat(Q.error?"error: ".concat(Q.error,`
11
- `):"")+"".concat(Q.event?"event: ".concat(Q.event,`
12
- `):"")+"".concat(Q.err?"error message: ".concat((gt=Q.err)===null||gt===void 0?void 0:gt.message,`
13
- `):"");oe("error",{player_error_code:fe,player_error_message:te,player_error_context:vt})}};C.on(K.Events.ERROR,ri);var Ce=function(Oe,Q){var fe=Q.frag,te=fe&&fe._url||"";oe("requestcanceled",{request_event_type:Oe,request_url:te,request_type:"media",request_hostname:N(te)})};C.on(K.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ce);var lt=function(Oe,Q){var fe=Q.level,te=C.levels[fe];if(te&&te.attrs&&te.attrs.BANDWIDTH){var _e,De=te.attrs.BANDWIDTH,ct=parseFloat(te.attrs["FRAME-RATE"]);isNaN(ct)||(_e=ct),De?oe("renditionchange",{video_source_fps:_e,video_source_bitrate:De,video_source_width:te.width,video_source_height:te.height,video_source_rendition_name:te.name,video_source_codec:te==null?void 0:te.videoCodec}):ve.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};C.on(K.Events.LEVEL_SWITCHED,lt),C._stopMuxMonitor=function(){C.off(K.Events.MANIFEST_LOADED,me),C.off(K.Events.LEVEL_LOADED,Me),C.off(K.Events.AUDIO_TRACK_LOADED,At),C.off(K.Events.FRAG_LOADED,St),C.off(K.Events.FRAG_CHANGED,Ut),C.off(K.Events.ERROR,ri),C.off(K.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ce),C.off(K.Events.LEVEL_SWITCHED,lt),C.off(K.Events.DESTROYING,C._stopMuxMonitor),delete C._stopMuxMonitor},C.on(K.Events.DESTROYING,C._stopMuxMonitor)}else ve.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,x.hlsjs,{},x.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var x;this.hlsjs&&((x=this.hlsjs)&&typeof x._stopMuxMonitor=="function"&&x._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(x){x.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=x.dashjs,function(R,U,C){var K=R.log;if(C&&C.on){var ve=function(Ce,lt){return R.emit(U,Ce,lt)},de=function(Ce){var lt=Ce.type,Oe=(Ce.data||{}).url;ve("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:N(Oe),request_url:Oe})};C.on("manifestLoaded",de);var he={},oe=function(Ce){var lt=Ce.type,Oe=Ce.fragmentModel,Q=(Ce.chunk||{}).mediaInfo||{},fe=Q.type,te=Q.bitrateList,_e={};(te=te||[]).forEach(function(Pr,ft){_e[ft]={},_e[ft].width=Pr.width,_e[ft].height=Pr.height,_e[ft].bitrate=Pr.bandwidth,_e[ft].attrs={}}),fe==="video"?he.video=_e:fe==="audio"?he.audio=_e:he.media=_e;var De=xe(Oe,C),ct=De.requestStart,Ft=De.requestResponseStart,xt=De.requestResponseEnd,Ot=De.requestResponseHeaders,gt=De.requestMediaDuration,vt=De.requestHostname,fr=De.requestUrl,Tn=De.requestId;ve("requestcompleted",{request_event_type:lt,request_start:ct,request_response_start:Ft,request_response_end:xt,request_bytes_loaded:-1,request_type:fe+"_init",request_response_headers:Ot,request_hostname:vt,request_id:Tn,request_url:fr,request_media_duration:gt,request_rendition_lists:he})};C.on("initFragmentLoaded",oe);var me=function(Ce){var lt=Ce.type,Oe=Ce.fragmentModel,Q=Ce.chunk||{},fe=Q.mediaInfo,te=Q.start,_e=(fe||{}).type,De=xe(Oe,C),ct=De.requestStart,Ft=De.requestResponseStart,xt=De.requestResponseEnd,Ot=De.requestBytesLoaded,gt=De.requestResponseHeaders,vt=De.requestMediaDuration,fr=De.requestHostname,Tn=De.requestUrl,Pr=De.requestId,ft=Ie(_e,C),_n=ft.currentLevel,Bb=ft.renditionWidth,$b=ft.renditionHeight,Hb=ft.renditionBitrate;ve("requestcompleted",{request_event_type:lt,request_start:ct,request_response_start:Ft,request_response_end:xt,request_bytes_loaded:Ot,request_type:_e,request_response_headers:gt,request_hostname:fr,request_id:Pr,request_url:Tn,request_media_start_time:te,request_media_duration:vt,request_current_level:_n,request_labeled_bitrate:Hb,request_video_width:Bb,request_video_height:$b})};C.on("mediaFragmentLoaded",me);var Me={video:void 0,audio:void 0,totalBitrate:void 0},At=function(){if(Me.video&&typeof Me.video.bitrate=="number"){if(Me.video.width&&Me.video.height){var Ce=Me.video.bitrate;return Me.audio&&typeof Me.audio.bitrate=="number"&&(Ce+=Me.audio.bitrate),Ce!==Me.totalBitrate?(Me.totalBitrate=Ce,{video_source_bitrate:Ce,video_source_height:Me.video.height,video_source_width:Me.video.width,video_source_codec:Ve(Me.video.codec)}):void 0}K.warn("have bitrate info for video but missing width/height")}},St=function(Ce,lt,Oe){if(typeof Ce.newQuality=="number"){var Q=Ce.mediaType;if(Q==="audio"||Q==="video"){var fe=C.getBitrateInfoListFor(Q).find(function(_e){return _e.qualityIndex===Ce.newQuality});if(fe&&typeof fe.bitrate=="number"){Me[Q]=ne(ne({},fe),{},{codec:C.getCurrentTrackFor(Q).codec});var te=At();te&&ve("renditionchange",te)}else K.warn("missing bitrate info for ".concat(Q))}}else K.warn("missing evt.newQuality in qualityChangeRendered event",Ce)};C.on("qualityChangeRendered",St);var Ut=function(Ce){var lt=Ce.request,Oe=Ce.mediaType;ve("requestcanceled",{request_event_type:(lt=lt||{}).type+"_"+lt.action,request_url:lt.url,request_type:Oe,request_hostname:N(lt.url)})};C.on("fragmentLoadingAbandoned",Ut);var ri=function(Ce){var lt,Oe,Q=Ce.error,fe=(Q==null||(lt=Q.data)===null||lt===void 0?void 0:lt.request)||{},te=(Q==null||(Oe=Q.data)===null||Oe===void 0?void 0:Oe.response)||{};(Q==null?void 0:Q.code)===27&&ve("requestfailed",{request_error:fe.type+"_"+fe.action,request_url:fe.url,request_hostname:N(fe.url),request_type:fe.mediaType,request_error_code:te.status,request_error_text:te.statusText});var _e="".concat(fe!=null&&fe.url?"url: ".concat(fe.url,`
14
- `):"")+"".concat(te!=null&&te.status||te!=null&&te.statusText?"response: ".concat(te==null?void 0:te.status,", ").concat(te==null?void 0:te.statusText,`
15
- `):"");ve("error",{player_error_code:Q==null?void 0:Q.code,player_error_message:Q==null?void 0:Q.message,player_error_context:_e})};C.on("error",ri),C._stopMuxMonitor=function(){C.off("manifestLoaded",de),C.off("initFragmentLoaded",oe),C.off("mediaFragmentLoaded",me),C.off("qualityChangeRendered",St),C.off("error",ri),C.off("fragmentLoadingAbandoned",Ut),delete C._stopMuxMonitor}}else K.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,x.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var x;this.dashjs&&((x=this.dashjs)&&typeof x._stopMuxMonitor=="function"&&x._stopMuxMonitor(),this.dashjs=void 0)}}],p&&Sm(m.prototype,p),y&&Sm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),I}(ke),vb=gb,Eb=o(153),bn=o.n(Eb);function Bd(v){return Bd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},Bd(v)}function xm(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,R=[],U=!0,C=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(R.push(I.value),!y||R.length!==y);U=!0);}catch(K){C=!0,x=K}finally{try{U||_.return==null||_.return()}finally{if(C)throw x}}return R}}(v,m)||function(p,y){if(p){if(typeof p=="string")return Im(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?Im(p,y):void 0}}(v,m)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
16
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Im(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}var Ss,bb=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],yb={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};d()&&d().WeakMap&&(Ss=new WeakMap);var Tb="#EXT-X-TARGETDURATION",_b="#EXT-X-PART-INF",Ab="#EXT-X-SERVER-CONTROL",Sb="#EXTINF",xb="#EXT-X-PROGRAM-DATE-TIME",Ib="#EXT-X-VERSION",Lb="#EXT-X-SESSION-DATA",Ua=function(v){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(v),this.manifest};Ua.prototype.process=function(v){var m;for(this.buffer+=v,m=this.buffer.indexOf(`
1
+ var Xy=Object.create;var pp=Object.defineProperty;var Qy=Object.getOwnPropertyDescriptor;var Zy=Object.getOwnPropertyNames;var Jy=Object.getPrototypeOf,eT=Object.prototype.hasOwnProperty;var tT=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var iT=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Zy(e))!eT.call(i,s)&&s!==t&&pp(i,s,{get:()=>e[s],enumerable:!(r=Qy(e,s))||r.enumerable});return i};var rT=(i,e,t)=>(t=i!=null?Xy(Jy(i)):{},iT(e||!i||!i.__esModule?pp(t,"default",{value:i,enumerable:!0}):t,i));var sc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var Pe=(i,e,t)=>(sc(i,e,"read from private field"),t?t.call(i):e.get(i)),nt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ti=(i,e,t,r)=>(sc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t);var ot=(i,e,t)=>(sc(i,e,"access private method"),t);var T0=tT((kl,Yu)=>{(function(){var i,e;i=this,e=function(){return function(){var t={80:function(n,a,o){n.exports=o(728).default},728:function(n,a,o){"use strict";o.d(a,{default:function(){return qy}});var l=o(48),d=o.n(l),c=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(v){var m=16*Math.random()|0;return(v==="x"?m:3&m|8).toString(16)})},u=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},h=function(v){return v&&v.nodeName!==void 0?(v.muxId||(v.muxId=v.id||u()),v.muxId):v},f=function(v){var m;v&&v.nodeName!==void 0?v=h(m=v):m=document.querySelector(v);var p=m&&m.nodeName?m.nodeName.toLowerCase():"";return[m,v,p]},g=o(640),E=o.n(g),T=E().methodFactory;E().methodFactory=function(v,m,p){var y=T(v,m,p);return function(){for(var _=["[mux]"],I=0;I<arguments.length;I++)_.push(arguments[I]);y.apply(void 0,_)}},E().setLevel(E().getLevel());var A=E();function R(){return(d().doNotTrack||d().navigator&&d().navigator.doNotTrack)==="1"}var L={now:function(){var v=d().performance,m=v&&v.timing,p=m&&m.navigationStart,y=typeof p=="number"&&typeof v.now=="function"?p+v.now():Date.now();return Math.round(y)}},N=function(v){return M(v)[0]},M=function(v){if(typeof v!="string"||v==="")return["localhost"];var m,p=(v.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return p&&(m=(p.match(/[^\.]+\.[^\.]+$/)||[])[0]),[p,m]},$={exists:function(){var v=d().performance;return(v&&v.timing)!==void 0},domContentLoadedEventEnd:function(){var v=d().performance,m=v&&v.timing;return m&&m.domContentLoadedEventEnd},navigationStart:function(){var v=d().performance,m=v&&v.timing;return m&&m.navigationStart}};function U(v,m,p){p=p===void 0?1:p,v[m]=v[m]||0,v[m]+=p}var H=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],W=["x-cdn","content-type"].concat(H);function O(v){var m={};return(v=v||"").trim().split(/[\r\n]+/).forEach(function(p){if(p){var y=p.split(": "),_=y.shift();_&&(W.indexOf(_.toLowerCase())>=0||_.toLowerCase().indexOf("x-litix-")===0)&&(m[_]=y.join(": "))}}),m}function z(v){if(v){var m=H.find(function(p){return v[p]!==void 0});return m?v[m]:void 0}}var Y=function(v){var m={};for(var p in v){var y=v[p];y["DATA-ID"].search("io.litix.data.")!==-1&&(m[y["DATA-ID"].replace("io.litix.data.","")]=y.VALUE)}return m};function ye(v,m){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(v);m&&(y=y.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,y)}return p}function Ee(v){for(var m=1;m<arguments.length;m++){var p=arguments[m]!=null?arguments[m]:{};m%2?ye(Object(p),!0).forEach(function(y){be(v,y,p[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):ye(Object(p)).forEach(function(y){Object.defineProperty(v,y,Object.getOwnPropertyDescriptor(p,y))})}return v}function be(v,m,p){return m in v?Object.defineProperty(v,m,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[m]=p,v}var ke=function(v){if(!v)return{};var m=$.navigationStart(),p=v.loading,y=p?p.start:v.trequest,_=p?p.first:v.tfirst,I=p?p.end:v.tload;return{bytesLoaded:v.total,requestStart:Math.round(m+y),responseStart:Math.round(m+_),responseEnd:Math.round(m+I)}},Se=function(v){if(v&&typeof v.getAllResponseHeaders=="function")return O(v.getAllResponseHeaders())};function Z(v,m){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(v);m&&(y=y.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,y)}return p}function te(v){for(var m=1;m<arguments.length;m++){var p=arguments[m]!=null?arguments[m]:{};m%2?Z(Object(p),!0).forEach(function(y){re(v,y,p[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Z(Object(p)).forEach(function(y){Object.defineProperty(v,y,Object.getOwnPropertyDescriptor(p,y))})}return v}function re(v,m,p){return m in v?Object.defineProperty(v,m,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[m]=p,v}var xe=function(v,m){if(!v||typeof v.getRequests!="function")return{};var p=v.getRequests({state:"executed"});if(p.length===0)return{};var y,_=p[p.length-1],I=N(_.url),x=_.url,k=_.bytesLoaded,F=new Date(_.requestStartDate).getTime(),D=new Date(_.firstByteDate).getTime(),G=new Date(_.requestEndDate).getTime(),me=isNaN(_.duration)?0:_.duration,ne=typeof m.getMetricsFor=="function"?m.getMetricsFor(_.mediaType).HttpList:m.getDashMetrics().getHttpRequests(_.mediaType);return ne.length>0&&(y=O(ne[ne.length-1]._responseHeaders||"")),{requestStart:F,requestResponseStart:D,requestResponseEnd:G,requestBytesLoaded:k,requestResponseHeaders:y,requestMediaDuration:me,requestHostname:I,requestUrl:x,requestId:y?z(y):void 0}},Ie=function(v,m){var p=m.getQualityFor(v),y=m.getCurrentTrackFor(v).bitrateList;return y?{currentLevel:p,renditionWidth:y[p].width||null,renditionHeight:y[p].height||null,renditionBitrate:y[p].bandwidth}:{}},ze=function(v){var m;return(m=v.match(/.*codecs\*?="(.*)"/))===null||m===void 0?void 0:m[1]};function kt(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Pt=0,Ot=function(){function v(){(function(_,I){if(!(_ instanceof I))throw new TypeError("Cannot call a class as a function")})(this,v)}var m,p,y;return m=v,p=[{key:"on",value:function(_,I,x){return I._eventEmitterGuid=I._eventEmitterGuid||++Pt,this._listeners=this._listeners||{},this._listeners[_]=this._listeners[_]||[],x&&(I=I.bind(x)),this._listeners[_].push(I),I}},{key:"off",value:function(_,I){var x=this._listeners&&this._listeners[_];x&&x.forEach(function(k,F){k._eventEmitterGuid===I._eventEmitterGuid&&x.splice(F,1)})}},{key:"one",value:function(_,I,x){var k=this;I._eventEmitterGuid=I._eventEmitterGuid||++Pt;var F=function D(){k.off(_,D),I.apply(x||this,arguments)};F._eventEmitterGuid=I._eventEmitterGuid,this.on(_,F)}},{key:"emit",value:function(_,I){var x=this;if(this._listeners){I=I||{};var k=this._listeners["before*"]||[],F=this._listeners[_]||[],D=this._listeners["after"+_]||[],G=function(me,ne){(me=me.slice()).forEach(function(le){le.call(x,{type:_},ne)})};G(k,I),G(F,I),G(D,I)}}}],p&&kt(m.prototype,p),y&&kt(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}(),Wi=Ot;function As(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Cb=function(){function v(_){var I=this;(function(x,k){if(!(x instanceof k))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,_.on("playing",function(){I._playheadShouldBeProgressing=!0}),_.on("play",this._startPlaybackHeartbeatInterval.bind(this)),_.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),_.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),_.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),_.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("seeked",function(){_.data.player_is_paused?I._stopPlaybackHeartbeatInterval():I._startPlaybackHeartbeatInterval()}),_.on("timeupdate",function(){I._playbackHeartbeatInterval!==null&&_.emit("playbackheartbeat")}),_.on("devicesleep",function(x,k){I._playbackHeartbeatInterval!==null&&(d().clearInterval(I._playbackHeartbeatInterval),_.emit("playbackheartbeatend",{viewer_time:k.viewer_time}),I._playbackHeartbeatInterval=null)})}var m,p,y;return m=v,(p=[{key:"_startPlaybackHeartbeatInterval",value:function(){var _=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=d().setInterval(function(){_.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(d().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&As(m.prototype,p),y&&As(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Cm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Mb(v,m,p){return m&&Cm(v.prototype,m),p&&Cm(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Pb=Mb(function v(m){var p=this;(function(y,_){if(!(y instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),m.on("viewinit",function(){p.viewErrored=!1}),m.on("error",function(y,_){try{var I=m.errorTranslator({player_error_code:_.player_error_code,player_error_message:_.player_error_message,player_error_context:_.player_error_context});I?(m.data.player_error_code=I.player_error_code||_.player_error_code,m.data.player_error_message=I.player_error_message||_.player_error_message,m.data.player_error_context=I.player_error_context||_.player_error_context,p.viewErrored=!0):(delete m.data.player_error_code,delete m.data.player_error_message,delete m.data.player_error_context)}catch(x){m.mux.log.warn("Exception in error translator callback.",x),p.viewErrored=!0}})});function Mm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Ob=function(){function v(_){(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._watchTimeTrackerLastCheckedTime=null,_.on("playbackheartbeat",this._updateWatchTime.bind(this)),_.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var m,p,y;return m=v,(p=[{key:"_updateWatchTime",value:function(_,I){var x=I.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=x),U(this.pm.data,"view_watch_time",x-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=x}},{key:"_clearWatchTimeState",value:function(_,I){this._updateWatchTime(_,I),this._watchTimeTrackerLastCheckedTime=null}}])&&Mm(m.prototype,p),y&&Mm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Pm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Nb=function(){function v(_){var I=this;(function(F,D){if(!(F instanceof D))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=L.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var x=this._startPlaybackTimeTracking.bind(this);_.on("playing",x),_.on("adplaying",x),_.on("seeked",x);var k=this._stopPlaybackTimeTracking.bind(this);_.on("playbackheartbeatend",k),_.on("seeking",k),_.on("adplaying",function(){I._isAdPlaying=!0}),_.on("adended",function(){I._isAdPlaying=!1}),_.on("adpause",function(){I._isAdPlaying=!1}),_.on("adbreakstart",function(){I._isAdPlaying=!1}),_.on("adbreakend",function(){I._isAdPlaying=!1}),_.on("adplay",function(){I._isAdPlaying=!1}),_.on("viewinit",function(){I._playbackTimeTrackerLastPlayheadPosition=-1,I._lastTime=L.now(),I._isAdPlaying=!1,I._callbackUpdatePlaybackTime=null})}var m,p,y;return m=v,(p=[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var _=this.pm.data.player_playhead_time,I=L.now(),x=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&_>this._playbackTimeTrackerLastPlayheadPosition?x=_-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(x=I-this._lastTime),x>0&&x<=1e3&&U(this.pm.data,"view_content_playback_time",x),this._playbackTimeTrackerLastPlayheadPosition=_,this._lastTime=I}}])&&Pm(m.prototype,p),y&&Pm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Om(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Ub=function(){function v(_){(function(x,k){if(!(x instanceof k))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_;var I=this._updatePlayheadTime.bind(this);_.on("playbackheartbeat",I),_.on("playbackheartbeatend",I),_.on("timeupdate",I),_.on("destroy",function(){_.off("timeupdate",I)})}var m,p,y;return m=v,(p=[{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(_,I){var x=this,k=function(){x.pm.currentFragmentPDT&&x.pm.currentFragmentStart&&(x.pm.data.player_program_time=x.pm.currentFragmentPDT+x.pm.data.player_playhead_time-x.pm.currentFragmentStart)};if(I&&I.player_playhead_time)this.pm.data.player_playhead_time=I.player_playhead_time,k(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var F=this.pm.getPlayheadTime();F!==void 0&&(this.pm.data.player_playhead_time=F,k(),this._updateMaxPlayheadPosition())}}}])&&Om(m.prototype,p),y&&Om(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Nm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Fb(v,m,p){return m&&Nm(v.prototype,m),p&&Nm(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Um=3e5,Bb=Fb(function v(m){if(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")}(this,v),!m.disableRebufferTracking){var p,y=function(I,x){_(x),p=void 0},_=function(I){if(p){var x=I.viewer_time-p;U(m.data,"view_rebuffer_duration",x),p=I.viewer_time,m.data.view_rebuffer_duration>Um&&(m.emit("viewend"),m.send("viewend"),m.mux.log.warn("Ending view after rebuffering for longer than ".concat(Um,"ms, future events will be ignored unless a programchange or videochange occurs.")))}m.data.view_watch_time>=0&&m.data.view_rebuffer_count>0&&(m.data.view_rebuffer_frequency=m.data.view_rebuffer_count/m.data.view_watch_time,m.data.view_rebuffer_percentage=m.data.view_rebuffer_duration/m.data.view_watch_time)};m.on("playbackheartbeat",function(I,x){return _(x)}),m.on("rebufferstart",function(I,x){p||(U(m.data,"view_rebuffer_count",1),p=x.viewer_time,m.one("rebufferend",y))}),m.on("viewinit",function(){p=void 0,m.off("rebufferend",y)})}});function Fm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var $b=function(){function v(_){var I=this;(function(x,k){if(!(x instanceof k))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.disableRebufferTracking||_.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,_.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),_.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),_.on("seeking",function(){I._cleanupRebufferTracker(null,{viewer_time:L.now()})}))}var m,p,y;return m=v,p=[{key:"_checkIfRebuffering",value:function(_,I){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(_,I);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var x=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&x>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=I.viewer_time}else this._cleanupRebufferTracker(_,I,!0);else this._prepareRebufferTrackerState(I.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(_){this._lastCheckedTime=_,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=_}},{key:"_cleanupRebufferTracker",value:function(_,I){var x=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:I.viewer_time});else{if(this._lastCheckedTime===null)return;var k=this.pm.data.player_playhead_time-this._lastPlayheadTime,F=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&k>0&&F-k>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+F-k}))}x?this._prepareRebufferTrackerState(I.viewer_time):this._clearRebufferTrackerState()}}],p&&Fm(m.prototype,p),y&&Fm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}(),Hb=$b;function Bm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Gb=function(){function v(_){var I=this;(function(x,k){if(!(x instanceof k))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){var x=_.data,k=x.view_id;if(!x.view_program_changed){var F=function(D,G){var me=G.viewer_time;D.type==="playing"&&_.data.view_time_to_first_frame===void 0?I.calculateTimeToFirstFrame(me||L.now(),k):D.type!=="adplaying"||_.data.view_time_to_first_frame!==void 0&&!I._inPrerollPosition()||I.calculateTimeToFirstFrame(me||L.now(),k)};_.one("playing",F),_.one("adplaying",F),_.one("viewend",function(){_.off("playing",F),_.off("adplaying",F)})}})}var m,p,y;return m=v,(p=[{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(_,I){I===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:_}),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))}}])&&Bm(m.prototype,p),y&&Bm(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function $m(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Vb(v,m,p){return m&&$m(v.prototype,m),p&&$m(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Kb=Vb(function v(m){var p=this;(function(y,_){if(!(y instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),m.on("viewinit",function(){p._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(y){m.on(y,function(){if(p._lastPlayheadPosition>=0&&m.data.player_playhead_time>=0&&p._lastPlayerWidth>=0&&p._lastSourceWidth>0&&p._lastPlayerHeight>=0&&p._lastSourceHeight>0){var _=m.data.player_playhead_time-p._lastPlayheadPosition;if(_<0)return void(p._lastPlayheadPosition=-1);var I=Math.min(p._lastPlayerWidth/p._lastSourceWidth,p._lastPlayerHeight/p._lastSourceHeight),x=Math.max(0,I-1),k=Math.max(0,1-I);m.data.view_max_upscale_percentage=Math.max(m.data.view_max_upscale_percentage||0,x),m.data.view_max_downscale_percentage=Math.max(m.data.view_max_downscale_percentage||0,k),U(m.data,"view_total_content_playback_time",_),U(m.data,"view_total_upscaling",x*_),U(m.data,"view_total_downscaling",k*_)}p._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(y){m.on(y,function(){p._lastPlayheadPosition=m.data.player_playhead_time,p._lastPlayerWidth=m.data.player_width,p._lastPlayerHeight=m.data.player_height,p._lastSourceWidth=m.data.video_source_width,p._lastSourceHeight=m.data.video_source_height})})});function Hm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Wb(v,m,p){return m&&Hm(v.prototype,m),p&&Hm(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var qb=Wb(function v(m){var p=this;(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v),this.isSeeking=!1;var y=-1,_=function(){var I=L.now(),x=(m.data.viewer_time||I)-(y||I);U(m.data,"view_seek_duration",x),m.data.view_max_seek_time=Math.max(m.data.view_max_seek_time||0,x),p.isSeeking=!1,y=-1};m.on("seeking",function(I,x){Object.assign(m.data,x),p.isSeeking&&x.viewer_time-y<=2e3?y=x.viewer_time:(p.isSeeking&&_(),p.isSeeking=!0,y=x.viewer_time,U(m.data,"view_seek_count",1),m.send("seeking"))}),m.on("seeked",function(){_()}),m.on("viewend",function(){p.isSeeking&&(_(),m.send("seeked")),p.isSeeking=!1,y=-1})});function Gm(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,k=[],F=!0,D=!1;try{for(_=_.call(p);!(F=(I=_.next()).done)&&(k.push(I.value),!y||k.length!==y);F=!0);}catch(G){D=!0,x=G}finally{try{F||_.return==null||_.return()}finally{if(D)throw x}}return k}}(v,m)||function(p,y){if(p){if(typeof p=="string")return Vm(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?Vm(p,y):void 0}}(v,m)||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 Vm(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}function Km(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}var Wm=function(v,m){v.push(m),v.sort(function(p,y){return p.viewer_time-y.viewer_time})},Yb=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],jb=function(){function v(_){var I=this;(function(k,F){if(!(k instanceof F))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){I.isAdBreak=!1,I._currentAdRequestNumber=0,I._currentAdResponseNumber=0,I._adRequests=[],I._adResponses=[],I._adHasPlayed=!1,I._wouldBeNewAdPlay=!0,I._prerollPlayTime=void 0}),Yb.forEach(function(k){return _.on(k,I._updateAdData.bind(I))});var x=function(){I.isAdBreak=!1};_.on("adbreakstart",function(){I.isAdBreak=!0}),_.on("play",x),_.on("playing",x),_.on("viewend",x),_.on("adrequest",function(k,F){F=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdRequestNumber++},F),Wm(I._adRequests,F),U(_.data,"view_ad_request_count"),I.inPrerollPosition()&&(_.data.view_preroll_requested=!0,I._adHasPlayed||U(_.data,"view_preroll_request_count"))}),_.on("adresponse",function(k,F){F=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdResponseNumber++},F),Wm(I._adResponses,F);var D=I.findAdRequest(F.ad_request_id);D&&U(_.data,"view_ad_request_time",Math.max(0,F.viewer_time-D.viewer_time))}),_.on("adplay",function(k,F){I._adHasPlayed=!0,I._wouldBeNewAdPlay&&(I._wouldBeNewAdPlay=!1,U(_.data,"view_ad_played_count")),I.inPrerollPosition()&&!_.data.view_preroll_played&&(_.data.view_preroll_played=!0,I._adRequests.length>0&&(_.data.view_preroll_request_time=Math.max(0,F.viewer_time-I._adRequests[0].viewer_time)),_.data.view_start&&(_.data.view_startup_preroll_request_time=Math.max(0,F.viewer_time-_.data.view_start)),I._prerollPlayTime=F.viewer_time)}),_.on("adplaying",function(k,F){I.inPrerollPosition()&&_.data.view_preroll_load_time===void 0&&I._prerollPlayTime!==void 0&&(_.data.view_preroll_load_time=F.viewer_time-I._prerollPlayTime,_.data.view_startup_preroll_load_time=F.viewer_time-I._prerollPlayTime)}),_.on("adclicked",function(k,F){I._wouldBeNewAdPlay||U(_.data,"view_ad_clicked_count")}),_.on("adskipped",function(k,F){I._wouldBeNewAdPlay||U(_.data,"view_ad_skipped_count")}),_.on("adended",function(){I._wouldBeNewAdPlay=!0}),_.on("aderror",function(){I._wouldBeNewAdPlay=!0})}var m,p,y;return m=v,(p=[{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(_){for(var I=0;I<this._adRequests.length;I++)if(this._adRequests[I].ad_request_id===_)return this._adRequests[I]}},{key:"_updateAdData",value:function(_,I){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&I.ad_tag_url){var x=Gm(M(I.ad_tag_url),2),k=x[0],F=x[1];this.pm.data.view_preroll_ad_tag_domain=F,this.pm.data.view_preroll_ad_tag_hostname=k}if(!this.pm.data.view_preroll_ad_asset_hostname&&I.ad_asset_url){var D=Gm(M(I.ad_asset_url),2),G=D[0],me=D[1];this.pm.data.view_preroll_ad_asset_domain=me,this.pm.data.view_preroll_ad_asset_hostname=G}}this.pm.data.ad_asset_url=I==null?void 0:I.ad_asset_url,this.pm.data.ad_tag_url=I==null?void 0:I.ad_tag_url,this.pm.data.ad_creative_id=I==null?void 0:I.ad_creative_id,this.pm.data.ad_id=I==null?void 0:I.ad_id,this.pm.data.ad_universal_id=I==null?void 0:I.ad_universal_id}}])&&Km(m.prototype,p),y&&Km(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function qm(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function zb(v,m,p){return m&&qm(v.prototype,m),p&&qm(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Xb=zb(function v(m){var p,y;(function(k,F){if(!(k instanceof F))throw new TypeError("Cannot call a class as a function")})(this,v);var _=function(){m.disableRebufferTracking||p&&(U(m.data,"view_waiting_rebuffer_duration",L.now()-p),p=!1,d().clearInterval(y))},I=!1,x=function(){I=!1,_()};m.on("waiting",function(){I&&(m.disableRebufferTracking||(U(m.data,"view_waiting_rebuffer_count",1),p=L.now(),y=d().setInterval(function(){if(p){var k=L.now();U(m.data,"view_waiting_rebuffer_duration",k-p),p=k}},250)))}),m.on("playing",function(){_(),I=!0}),m.on("pause",x),m.on("seeking",x)});function Ym(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Qb(v,m,p){return m&&Ym(v.prototype,m),p&&Ym(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Zb=Qb(function v(m){var p=this;(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v);var y=function(){p.lastWallClockTime=L.now(),m.on("before*",_)},_=function(I){var x=L.now(),k=p.lastWallClockTime;p.lastWallClockTime=x,x-k>3e4&&(m.emit("devicesleep",{viewer_time:k}),Object.assign(m.data,{viewer_time:k}),m.send("devicesleep"),m.emit("devicewake",{viewer_time:x}),Object.assign(m.data,{viewer_time:x}),m.send("devicewake"))};m.one("playbackheartbeat",y),m.on("playbackheartbeatend",function(){m.off("before*",_),m.one("playbackheartbeat",y)})}),jm=o(375),Jb=o(655),zm=o.n(Jb),Xm="muxData",Qm=function(){var v;try{v=jm.parse(zm().get(Xm)||"")}catch{v={}}return v},Zm=function(v){try{zm().set(Xm,jm.stringify(v),{expires:365})}catch{}},ey=function(){var v=Qm();return v.mux_viewer_id=v.mux_viewer_id||c(),v.msn=v.msn||Math.random(),Zm(v),{mux_viewer_id:v.mux_viewer_id,mux_sample_number:v.msn}};function ty(v,m){var p=m.beaconCollectionDomain,y=m.beaconDomain;if(p)return"https://"+p;var _=y||"litix.io";return(v=v||"inferred").match(/^[a-z0-9]+$/)?"https://"+v+"."+_:"https://img.litix.io/a.gif"}var Jm=function(){var v;switch(ep()){case"cellular":v="cellular";break;case"ethernet":v="wired";break;case"wifi":v="wifi";break;case void 0:break;default:v="other"}return v},ep=function(){var v=d().navigator,m=v&&(v.connection||v.mozConnection||v.webkitConnection);return m&&m.type};Jm.getConnectionFromAPI=ep;var iy=Jm,ry=ip({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"}),tp=ip({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ck:"clicked",cl:"canceled",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",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",sd:"skipped",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function ip(v){var m={};for(var p in v)v.hasOwnProperty(p)&&(m[v[p]]=p);return m}function Zd(v){var m={},p={};return Object.keys(v).forEach(function(y){var _=!1;if(v.hasOwnProperty(y)&&v[y]!==void 0){var I=y.split("_"),x=I[0],k=ry[x];k||(A.info("Data key word `"+I[0]+"` not expected in "+y),k=x+"_"),I.splice(1).forEach(function(F){F==="url"&&(_=!0),tp[F]?k+=tp[F]:Number(F)&&Math.floor(Number(F))===Number(F)?k+=F:(A.info("Data key word `"+F+"` not expected in "+y),k+="_"+F+"_")}),_?p[k]=v[y]:m[k]=v[y]}}),Object.assign(m,p)}var sy={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},ny=["hb","requestcompleted","requestfailed","requestcanceled"],ay="https://img.litix.io",qi=function(v){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=v||ay,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},sy,m)};qi.prototype.queueEvent=function(v,m){var p=Object.assign({},m);return(this._eventQueue.length<=this._options.maxQueueLength||v==="eventrateexceeded")&&(this._eventQueue.push(p),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},qi.prototype.flushEvents=function(){var v=arguments.length>0&&arguments[0]!==void 0&&arguments[0];v&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},qi.prototype.destroy=function(){var v=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,v?this._clearBeaconQueue():this.flushEvents(),d().clearTimeout(this._sendTimeout)},qi.prototype._clearBeaconQueue=function(){var v=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,m=this._eventQueue.slice(v);v>0&&Object.assign(m[m.length-1],Zd({mux_view_message:"event queue truncated"}));var p=this._createPayload(m);rp(this._beaconUrl,p,!0,function(){})},qi.prototype._sendBeaconQueue=function(){var v=this;if(!this._postInFlight){var m=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var p=this._createPayload(m),y=L.now();rp(this._beaconUrl,p,!1,function(_,I){I?(v._eventQueue=m.concat(v._eventQueue),v._failureCount+=1,A.info("Error sending beacon: "+I)):v._failureCount=0,v._roundTripTime=L.now()-y,v._postInFlight=!1})}},qi.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var v=Math.pow(2,this._failureCount-1);return(1+(v*=Math.random()))*this._options.baseTimeBetweenBeacons},qi.prototype._startBeaconSending=function(){var v=this;d().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=d().setTimeout(function(){v._eventQueue.length&&v._sendBeaconQueue(),v._startBeaconSending()},this._getNextBeaconTime()))},qi.prototype._createPayload=function(v){var m,p,y,_=this,I={transmission_timestamp:Math.round(L.now())};this._roundTripTime&&(I.rtt_ms=Math.round(this._roundTripTime));var x=function(){m=JSON.stringify({metadata:I,events:p||v}),y=m.length/1024},k=function(){return y<=_._options.maxPayloadKBSize};return x(),k()||(A.info("Payload size is too big ("+y+" kb). Removing unnecessary events."),p=v.filter(function(F){return ny.indexOf(F.e)===-1}),x()),k()||(A.info("Payload size still too big ("+y+" kb). Cropping fields.."),p.forEach(function(F){for(var D in F){var G=F[D];typeof G=="string"&&G.length>51200&&(F[D]=G.substring(0,51200))}}),x()),m};var oy=function(v){return v.length<=57344},rp=function(v,m,p,y){if(p&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(v,m))y();else if(d().fetch)d().fetch(v,{method:"POST",body:m,headers:{"Content-Type":"text/plain"},keepalive:oy(m)}).then(function(I){return y(null,I.ok?null:"Error")}).catch(function(I){return y(null,I)});else{if(d().XMLHttpRequest){var _=new(d()).XMLHttpRequest;return _.onreadystatechange=function(){if(_.readyState===4)return y(null,_.status!==200?"error":void 0)},_.open("POST",v),_.setRequestHeader("Content-Type","text/plain"),void _.send(m)}y()}},ly=qi;function dy(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,k=[],F=!0,D=!1;try{for(_=_.call(p);!(F=(I=_.next()).done)&&(k.push(I.value),!y||k.length!==y);F=!0);}catch(G){D=!0,x=G}finally{try{F||_.return==null||_.return()}finally{if(D)throw x}}return k}}(v,m)||function(p,y){if(p){if(typeof p=="string")return sp(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?sp(p,y):void 0}}(v,m)||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 sp(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}function np(v,m){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(v);m&&(y=y.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,y)}return p}function Ss(v){for(var m=1;m<arguments.length;m++){var p=arguments[m]!=null?arguments[m]:{};m%2?np(Object(p),!0).forEach(function(y){Ha(v,y,p[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):np(Object(p)).forEach(function(y){Object.defineProperty(v,y,Object.getOwnPropertyDescriptor(p,y))})}return v}function bn(v){return bn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},bn(v)}function cy(v,m){if(!(v instanceof m))throw new TypeError("Cannot call a class as a function")}function ap(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Ha(v,m,p){return m in v?Object.defineProperty(v,m,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[m]=p,v}var uy=["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"],hy=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],fy=["ad_id","ad_creative_id","ad_universal_id"],my=["viewstart","error","ended","viewend"],py=function(){function v(_,I){var x,k,F,D,G,me,ne,le,se,ue,we,vt,Et,Nt,ei,Re=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};cy(this,v),Ha(this,"previousBeaconData",null),Ha(this,"lastEventTime",0),Ha(this,"rateLimited",!1),this.mux=_,this.envKey=I,this.options=Re,this.eventQueue=new ly(ty(this.envKey,this.options)),this.sampleRate=(x=this.options.sampleRate)!==null&&x!==void 0?x:1,this.disableCookies=(k=this.options.disableCookies)!==null&&k!==void 0&&k,this.respectDoNotTrack=(F=this.options.respectDoNotTrack)!==null&&F!==void 0&&F,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(D=this.options.platform)===null||D===void 0?void 0:D.name,viewer_application_version:(G=this.options.platform)===null||G===void 0?void 0:G.version,viewer_application_engine:(me=this.options.platform)===null||me===void 0?void 0:me.layout,viewer_device_name:(ne=this.options.platform)===null||ne===void 0?void 0:ne.product,viewer_device_category:"",viewer_device_manufacturer:(le=this.options.platform)===null||le===void 0?void 0:le.manufacturer,viewer_os_family:(se=this.options.platform)===null||se===void 0||(ue=se.os)===null||ue===void 0?void 0:ue.family,viewer_os_architecture:(we=this.options.platform)===null||we===void 0||(vt=we.os)===null||vt===void 0?void 0:vt.architecture,viewer_os_version:(Et=this.options.platform)===null||Et===void 0||(Nt=Et.os)===null||Nt===void 0?void 0:Nt.version,viewer_connection_type:iy(),page_url:d()===null||d()===void 0||(ei=d().location)===null||ei===void 0?void 0:ei.href},this.viewerData=this.disableCookies?{}:ey()}var m,p,y;return m=v,(p=[{key:"send",value:function(_,I){var x;if(_&&I!=null&&I.view_id){if(this.respectDoNotTrack&&R())return A.info("Not sending `"+_+"` because Do Not Track is enabled");if(!I||bn(I)!=="object")return A.error("A data object was expected in send() but was not provided");var k,F,D=this.disableCookies?{}:(k=Qm(),F=L.now(),k.session_start&&(k.sst=k.session_start,delete k.session_start),k.session_id&&(k.sid=k.session_id,delete k.session_id),k.session_expires&&(k.sex=k.session_expires,delete k.session_expires),(!k.sex||k.sex<F)&&(k.sid=c(),k.sst=F),k.sex=F+15e5,Zm(k),{session_id:k.sid,session_start:k.sst,session_expires:k.sex}),G=Ss(Ss(Ss(Ss(Ss({},this.pageLevelData),I),D),this.viewerData),{},{event:_,env_key:this.envKey});G.user_id&&(G.viewer_user_id=G.user_id,delete G.user_id);var me=((x=G.mux_sample_number)!==null&&x!==void 0?x:0)>=this.sampleRate,ne=Zd(this._deduplicateBeaconData(_,G));if(this.lastEventTime=this.mux.utils.now(),me)return A.info("Not sending event due to sample rate restriction",_,G,ne);if(this.envKey||A.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",_,G,ne),!this.rateLimited){if(A.info("Sending event",_,G,ne),this.rateLimited=!this.eventQueue.queueEvent(_,ne),this.mux.WINDOW_UNLOADING&&_==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&_==="hb"?this.eventQueue.flushEvents(!0):my.indexOf(_)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return G.event="eventrateexceeded",ne=Zd(G),this.eventQueue.queueEvent(G.event,ne),A.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(_,I){var x=this,k={},F=I.view_id;if(F==="-1"||_==="viewstart"||_==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)k=Ss({},I),F&&(this.previousBeaconData=k),F&&_==="viewend"&&(this.previousBeaconData=null);else{var D=_.indexOf("request")===0;Object.entries(I).forEach(function(G){var me=dy(G,2),ne=me[0],le=me[1];x.previousBeaconData&&(le!==x.previousBeaconData[ne]||uy.indexOf(ne)>-1||x.objectHasChanged(D,ne,le,x.previousBeaconData[ne])||x.eventRequiresKey(_,ne))&&(k[ne]=le,x.previousBeaconData[ne]=le)})}return k}},{key:"objectHasChanged",value:function(_,I,x,k){return!(!_||I.indexOf("request_")!==0||I!=="request_response_headers"&&bn(x)==="object"&&bn(k)==="object"&&Object.keys(x||{}).length===Object.keys(k||{}).length)}},{key:"eventRequiresKey",value:function(_,I){return _==="renditionchange"&&I.indexOf("video_source_")===0||!(!fy.includes(I)||!hy.includes(_))}}])&&ap(m.prototype,p),y&&ap(m,y),Object.defineProperty(m,"prototype",{writable:!1}),v}();function op(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function gy(v,m,p){return m&&op(v.prototype,m),p&&op(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var vy=gy(function v(m){(function(D,G){if(!(D instanceof G))throw new TypeError("Cannot call a class as a function")})(this,v);var p=0,y=0,_=0,I=0,x=0,k=0,F=0;m.on("requestcompleted",function(D,G){var me,ne,le=G.request_start,se=G.request_response_start,ue=G.request_response_end,we=G.request_bytes_loaded;if(I++,se?(me=se-(le!=null?le:0),ne=(ue!=null?ue:0)-se):ne=(ue!=null?ue:0)-(le!=null?le:0),ne>0&&we&&we>0){var vt=we/ne*8e3;x++,y+=we,_+=ne,m.data.view_min_request_throughput=Math.min(m.data.view_min_request_throughput||1/0,vt),m.data.view_average_request_throughput=y/_*8e3,m.data.view_request_count=I,me>0&&(p+=me,m.data.view_max_request_latency=Math.max(m.data.view_max_request_latency||0,me),m.data.view_average_request_latency=p/x)}}),m.on("requestfailed",function(D,G){I++,k++,m.data.view_request_count=I,m.data.view_request_failed_count=k}),m.on("requestcanceled",function(D,G){I++,F++,m.data.view_request_count=I,m.data.view_request_canceled_count=F})});function lp(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function Ey(v,m,p){return m&&lp(v.prototype,m),p&&lp(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var by=Ey(function v(m){var p=this;(function(y,_){if(!(y instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),m.on("before*",function(y,_){var I=_.viewer_time,x=L.now(),k=p._lastEventTime;if(p._lastEventTime=x,k&&x-k>36e5){var F=Object.keys(m.data).reduce(function(D,G){return G.indexOf("video_")===0?Object.assign(D,function(me,ne,le){return ne in me?Object.defineProperty(me,ne,{value:le,enumerable:!0,configurable:!0,writable:!0}):me[ne]=le,me}({},G,m.data[G])):D},{});m.mux.log.info("Received event after at least an hour inactivity, creating a new view"),m.emit("viewinit",Object.assign({viewer_time:I},F)),m.playbackHeartbeat._playheadShouldBeProgressing&&y.type!=="play"&&y.type!=="adbreakstart"&&(m.emit("play",{viewer_time:I}),y.type!=="playing"&&m.emit("playing",{viewer_time:I}))}})});function Jd(v){return Jd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},Jd(v)}function yy(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,k=[],F=!0,D=!1;try{for(_=_.call(p);!(F=(I=_.next()).done)&&(k.push(I.value),!y||k.length!==y);F=!0);}catch(G){D=!0,x=G}finally{try{F||_.return==null||_.return()}finally{if(D)throw x}}return k}}(v,m)||function(p,y){if(p){if(typeof p=="string")return dp(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?dp(p,y):void 0}}(v,m)||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 dp(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}function cp(v,m){for(var p=0;p<m.length;p++){var y=m[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}function ec(v,m){return ec=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,y){return p.__proto__=y,p},ec(v,m)}function Ty(v){var m=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 p,y=Ga(v);if(m){var _=Ga(this).constructor;p=Reflect.construct(y,arguments,_)}else p=y.apply(this,arguments);return _y(this,p)}}function _y(v,m){if(m&&(Jd(m)==="object"||typeof m=="function"))return m;if(m!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ut(v)}function ut(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function Ga(v){return Ga=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(m){return m.__proto__||Object.getPrototypeOf(m)},Ga(v)}var Ay=["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"],Sy=function(v){(function(x,k){if(typeof k!="function"&&k!==null)throw new TypeError("Super expression must either be null or a function");x.prototype=Object.create(k&&k.prototype,{constructor:{value:x,writable:!0,configurable:!0}}),Object.defineProperty(x,"prototype",{writable:!1}),k&&ec(x,k)})(I,v);var m,p,y,_=Ty(I);function I(x,k,F){var D;(function(se,ue){if(!(se instanceof ue))throw new TypeError("Cannot call a class as a function")})(this,I),(D=_.call(this)).DOM_CONTENT_LOADED_EVENT_END=$.domContentLoadedEventEnd(),D.NAVIGATION_START=$.navigationStart(),D.mux=x,D.id=k,(F=Object.assign({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(se){return se}},F)).data=F.data||{},F.data.property_key&&(F.data.env_key=F.data.property_key,delete F.data.property_key),A.setLevel(F.debug?"debug":"warn"),D.getPlayheadTime=F.getPlayheadTime,D.getStateData=F.getStateData||function(){return{}},D.getAdData=F.getAdData||function(){},D.minimumRebufferDuration=F.minimumRebufferDuration,D.sustainedRebufferThreshold=F.sustainedRebufferThreshold,D.playbackHeartbeatTime=F.playbackHeartbeatTime,D.disableRebufferTracking=F.disableRebufferTracking,D.disableRebufferTracking&&D.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."),D.disablePlayheadRebufferTracking=F.disablePlayheadRebufferTracking,D.errorTranslator=F.errorTranslator,D.playbackEventDispatcher=new py(x,F.data.env_key,F),D.data={player_instance_id:c(),mux_sample_rate:F.sampleRate,beacon_domain:F.beaconCollectionDomain?F.beaconCollectionDomain:F.beaconDomain},D.data.view_sequence_number=1,D.data.player_sequence_number=1,D.oldEmit=D.emit,D.emit=function(se,ue){ue=Object.assign({viewer_time:this.mux.utils.now()},ue),this.oldEmit(se,ue)};var G=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(ut(D));D.on("viewinit",function(se,ue){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,ue),this._initializeViewData(),this.one("play",G),this.one("adbreakstart",G)});var me=function(se){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",se)}.bind(ut(D));if(D.on("videochange",function(se,ue){me(ue)}),D.on("programchange",function(se,ue){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),me(Object.assign(ue,{view_program_changed:!0})),G(),this.emit("play"),this.emit("playing")}),D.on("fragmentchange",function(se,ue){this.currentFragmentPDT=ue.currentFragmentPDT,this.currentFragmentStart=ue.currentFragmentStart}),D.on("destroy",D.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ne=function(){var se=D.data.view_start!==void 0;D.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",se&&D.mux.WINDOW_HIDDEN&&(D.data.player_is_paused||D.emit("hb"))};window.addEventListener("visibilitychange",ne,!1);var le=function(se){se.persisted||D.destroy()};window.addEventListener("pagehide",le,!1),D.on("destroy",function(){window.removeEventListener("visibilitychange",ne),window.removeEventListener("pagehide",le)})}return D.on("playerready",function(se,ue){Object.assign(this.data,ue)}),Ay.forEach(function(se){D.on(se,function(ue,we){se.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,we),this._sanitizeData()}),D.on("after"+se,function(){(se!=="error"||this.errorTracker.viewErrored)&&this.send(se)})}),D.on("viewend",function(se,ue){Object.assign(D.data,ue)}),D.one("playerready",function(se){var ue=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=ue-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}),D.longResumeTracker=new by(ut(D)),D.errorTracker=new Pb(ut(D)),new Zb(ut(D)),D.seekingTracker=new qb(ut(D)),D.playheadTime=new Ub(ut(D)),D.playbackHeartbeat=new Cb(ut(D)),new Kb(ut(D)),D.watchTimeTracker=new Ob(ut(D)),new Nb(ut(D)),D.adTracker=new jb(ut(D)),new Hb(ut(D)),new Bb(ut(D)),new Gb(ut(D)),new Xb(ut(D)),new vy(ut(D)),F.hlsjs&&D.addHLSJS(F),F.dashjs&&D.addDashJS(F),D.emit("viewinit",F.data),D}return m=I,p=[{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(x){if(this.data.view_id){var k=Object.assign({},this.data);if(k.video_source_is_live===void 0&&(k.player_source_duration===1/0||k.video_source_duration===1/0?k.video_source_is_live=!0:(k.player_source_duration>0||k.video_source_duration>0)&&(k.video_source_is_live=!1)),k.video_source_is_live||["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"].forEach(function(me){k[me]=void 0}),k.video_source_url=k.video_source_url||k.player_source_url,k.video_source_url){var F=yy(M(k.video_source_url),2),D=F[0],G=F[1];k.video_source_domain=G,k.video_source_hostname=D}delete k.ad_request_id,this.playbackEventDispatcher.send(x,k),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),x==="viewend"&&delete this.data.view_id}}},{key:"_updateStateData",value:function(){Object.assign(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var x=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(k){var F=parseInt(x.data[k],10);x.data[k]=isNaN(F)?void 0:F}),["player_source_url","video_source_url"].forEach(function(k){if(x.data[k]){var F=x.data[k].toLowerCase();F.indexOf("data:")!==0&&F.indexOf("blob:")!==0||(x.data[k]="MSE style URL")}})}},{key:"_resetVideoData",value:function(x,k){var F=this;Object.keys(this.data).forEach(function(D){D.indexOf("video_")===0&&delete F.data[D]})}},{key:"_resetViewData",value:function(){var x=this;Object.keys(this.data).forEach(function(k){k.indexOf("view_")===0&&delete x.data[k]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(x,k){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var x=this,k=this.data.view_id=c(),F=function(){k===x.data.view_id&&U(x.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",F):F()}},{key:"_restartHeartBeat",value:function(){var x=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){x.data.player_is_paused||x.emit("hb")},1e4))}},{key:"addHLSJS",value:function(x){x.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=x.hlsjs,function(k,F,D){var G=arguments.length>4?arguments[4]:void 0,me=k.log,ne=k.utils.secondsToMs,le=function(De){var X,de=parseInt(G.version);return de===1&&De.programDateTime!==null&&(X=De.programDateTime),de===0&&De.pdt!==null&&(X=De.pdt),X};if($.exists()){var se=function(De,X){return k.emit(F,De,X)},ue=function(De,X){var de=X.levels,Q=X.audioTracks,ve=X.url,Ae=X.stats,st=X.networkDetails,Ut=X.sessionData,bt={},wt={};de.forEach(function(at,An){bt[An]={width:at.width,height:at.height,bitrate:at.bitrate,attrs:at.attrs}}),Q.forEach(function(at,An){wt[An]={name:at.name,language:at.lang,bitrate:at.bitrate}});var ht=ke(Ae),ft=ht.bytesLoaded,sr=ht.requestStart,_n=ht.responseStart,Dr=ht.responseEnd;se("requestcompleted",Ee(Ee({},Y(Ut)),{},{request_event_type:De,request_bytes_loaded:ft,request_start:sr,request_response_start:_n,request_response_end:Dr,request_type:"manifest",request_hostname:N(ve),request_response_headers:Se(st),request_rendition_lists:{media:bt,audio:wt,video:{}}}))};D.on(G.Events.MANIFEST_LOADED,ue);var we=function(De,X){var de=X.details,Q=X.level,ve=X.networkDetails,Ae=X.stats,st=ke(Ae),Ut=st.bytesLoaded,bt=st.requestStart,wt=st.responseStart,ht=st.responseEnd,ft=de.fragments[de.fragments.length-1],sr=le(ft)+ne(ft.duration);se("requestcompleted",{request_event_type:De,request_bytes_loaded:Ut,request_start:bt,request_response_start:wt,request_response_end:ht,request_current_level:Q,request_type:"manifest",request_hostname:N(de.url),request_response_headers:Se(ve),video_holdback:de.holdBack&&ne(de.holdBack),video_part_holdback:de.partHoldBack&&ne(de.partHoldBack),video_part_target_duration:de.partTarget&&ne(de.partTarget),video_target_duration:de.targetduration&&ne(de.targetduration),video_source_is_live:de.live,player_manifest_newest_program_time:isNaN(sr)?void 0:sr})};D.on(G.Events.LEVEL_LOADED,we);var vt=function(De,X){var de=X.details,Q=X.networkDetails,ve=X.stats,Ae=ke(ve),st=Ae.bytesLoaded,Ut=Ae.requestStart,bt=Ae.responseStart,wt=Ae.responseEnd;se("requestcompleted",{request_event_type:De,request_bytes_loaded:st,request_start:Ut,request_response_start:bt,request_response_end:wt,request_type:"manifest",request_hostname:N(de.url),request_response_headers:Se(Q)})};D.on(G.Events.AUDIO_TRACK_LOADED,vt);var Et=function(De,X){var de=X.stats,Q=X.networkDetails,ve=X.frag;de=de||ve.stats;var Ae=ke(de),st=Ae.bytesLoaded,Ut=Ae.requestStart,bt=Ae.responseStart,wt=Ae.responseEnd,ht=Q?Se(Q):void 0,ft={request_event_type:De,request_bytes_loaded:st,request_start:Ut,request_response_start:bt,request_response_end:wt,request_hostname:Q?N(Q.responseURL):void 0,request_id:ht?z(ht):void 0,request_response_headers:ht,request_media_duration:ve.duration,request_url:Q==null?void 0:Q.responseURL};ve.type==="main"?(ft.request_type="media",ft.request_current_level=ve.level,ft.request_video_width=(D.levels[ve.level]||{}).width,ft.request_video_height=(D.levels[ve.level]||{}).height,ft.request_labeled_bitrate=(D.levels[ve.level]||{}).bitrate):ft.request_type=ve.type,se("requestcompleted",ft)};D.on(G.Events.FRAG_LOADED,Et);var Nt=function(De,X){var de=X.frag,Q=de.start,ve={currentFragmentPDT:le(de),currentFragmentStart:ne(Q)};se("fragmentchange",ve)};D.on(G.Events.FRAG_CHANGED,Nt);var ei=function(De,X){var de=X.type,Q=X.details,ve=X.response,Ae=X.fatal,st=X.frag,Ut=X.networkDetails,bt=(st==null?void 0:st.url)||X.url||"",wt=Ut?Se(Ut):void 0;if(Q!==G.ErrorDetails.MANIFEST_LOAD_ERROR&&Q!==G.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&Q!==G.ErrorDetails.FRAG_LOAD_ERROR&&Q!==G.ErrorDetails.FRAG_LOAD_TIMEOUT&&Q!==G.ErrorDetails.LEVEL_LOAD_ERROR&&Q!==G.ErrorDetails.LEVEL_LOAD_TIMEOUT&&Q!==G.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&Q!==G.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&Q!==G.ErrorDetails.SUBTITLE_LOAD_ERROR&&Q!==G.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&Q!==G.ErrorDetails.KEY_LOAD_ERROR&&Q!==G.ErrorDetails.KEY_LOAD_TIMEOUT||se("requestfailed",{request_error:Q,request_url:bt,request_hostname:N(bt),request_id:wt?z(wt):void 0,request_type:Q===G.ErrorDetails.FRAG_LOAD_ERROR||Q===G.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":Q===G.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||Q===G.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":Q===G.ErrorDetails.SUBTITLE_LOAD_ERROR||Q===G.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":Q===G.ErrorDetails.KEY_LOAD_ERROR||Q===G.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:ve==null?void 0:ve.code,request_error_text:ve==null?void 0:ve.text}),Ae){var ht,ft="".concat(bt?"url: ".concat(bt,`
5
+ `):"")+"".concat(ve&&(ve.code||ve.text)?"response: ".concat(ve.code,", ").concat(ve.text,`
6
+ `):"")+"".concat(X.reason?"failure reason: ".concat(X.reason,`
7
+ `):"")+"".concat(X.level?"level: ".concat(X.level,`
8
+ `):"")+"".concat(X.parent?"parent stream controller: ".concat(X.parent,`
9
+ `):"")+"".concat(X.buffer?"buffer length: ".concat(X.buffer,`
10
+ `):"")+"".concat(X.error?"error: ".concat(X.error,`
11
+ `):"")+"".concat(X.event?"event: ".concat(X.event,`
12
+ `):"")+"".concat(X.err?"error message: ".concat((ht=X.err)===null||ht===void 0?void 0:ht.message,`
13
+ `):"");se("error",{player_error_code:de,player_error_message:Q,player_error_context:ft})}};D.on(G.Events.ERROR,ei);var Re=function(De,X){var de=X.frag,Q=de&&de._url||"";se("requestcanceled",{request_event_type:De,request_url:Q,request_type:"media",request_hostname:N(Q)})};D.on(G.Events.FRAG_LOAD_EMERGENCY_ABORTED,Re);var tt=function(De,X){var de=X.level,Q=D.levels[de];if(Q&&Q.attrs&&Q.attrs.BANDWIDTH){var ve,Ae=Q.attrs.BANDWIDTH,st=parseFloat(Q.attrs["FRAME-RATE"]);isNaN(st)||(ve=st),Ae?se("renditionchange",{video_source_fps:ve,video_source_bitrate:Ae,video_source_width:Q.width,video_source_height:Q.height,video_source_rendition_name:Q.name,video_source_codec:Q==null?void 0:Q.videoCodec}):me.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};D.on(G.Events.LEVEL_SWITCHED,tt),D._stopMuxMonitor=function(){D.off(G.Events.MANIFEST_LOADED,ue),D.off(G.Events.LEVEL_LOADED,we),D.off(G.Events.AUDIO_TRACK_LOADED,vt),D.off(G.Events.FRAG_LOADED,Et),D.off(G.Events.FRAG_CHANGED,Nt),D.off(G.Events.ERROR,ei),D.off(G.Events.FRAG_LOAD_EMERGENCY_ABORTED,Re),D.off(G.Events.LEVEL_SWITCHED,tt),D.off(G.Events.DESTROYING,D._stopMuxMonitor),delete D._stopMuxMonitor},D.on(G.Events.DESTROYING,D._stopMuxMonitor)}else me.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,x.hlsjs,{},x.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var x;this.hlsjs&&((x=this.hlsjs)&&typeof x._stopMuxMonitor=="function"&&x._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(x){x.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=x.dashjs,function(k,F,D){var G=k.log;if(D&&D.on){var me=function(Re,tt){return k.emit(F,Re,tt)},ne=function(Re){var tt=Re.type,De=(Re.data||{}).url;me("requestcompleted",{request_event_type:tt,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:N(De),request_url:De})};D.on("manifestLoaded",ne);var le={},se=function(Re){var tt=Re.type,De=Re.fragmentModel,X=(Re.chunk||{}).mediaInfo||{},de=X.type,Q=X.bitrateList,ve={};(Q=Q||[]).forEach(function(Dr,at){ve[at]={},ve[at].width=Dr.width,ve[at].height=Dr.height,ve[at].bitrate=Dr.bandwidth,ve[at].attrs={}}),de==="video"?le.video=ve:de==="audio"?le.audio=ve:le.media=ve;var Ae=xe(De,D),st=Ae.requestStart,Ut=Ae.requestResponseStart,bt=Ae.requestResponseEnd,wt=Ae.requestResponseHeaders,ht=Ae.requestMediaDuration,ft=Ae.requestHostname,sr=Ae.requestUrl,_n=Ae.requestId;me("requestcompleted",{request_event_type:tt,request_start:st,request_response_start:Ut,request_response_end:bt,request_bytes_loaded:-1,request_type:de+"_init",request_response_headers:wt,request_hostname:ft,request_id:_n,request_url:sr,request_media_duration:ht,request_rendition_lists:le})};D.on("initFragmentLoaded",se);var ue=function(Re){var tt=Re.type,De=Re.fragmentModel,X=Re.chunk||{},de=X.mediaInfo,Q=X.start,ve=(de||{}).type,Ae=xe(De,D),st=Ae.requestStart,Ut=Ae.requestResponseStart,bt=Ae.requestResponseEnd,wt=Ae.requestBytesLoaded,ht=Ae.requestResponseHeaders,ft=Ae.requestMediaDuration,sr=Ae.requestHostname,_n=Ae.requestUrl,Dr=Ae.requestId,at=Ie(ve,D),An=at.currentLevel,Yy=at.renditionWidth,jy=at.renditionHeight,zy=at.renditionBitrate;me("requestcompleted",{request_event_type:tt,request_start:st,request_response_start:Ut,request_response_end:bt,request_bytes_loaded:wt,request_type:ve,request_response_headers:ht,request_hostname:sr,request_id:Dr,request_url:_n,request_media_start_time:Q,request_media_duration:ft,request_current_level:An,request_labeled_bitrate:zy,request_video_width:Yy,request_video_height:jy})};D.on("mediaFragmentLoaded",ue);var we={video:void 0,audio:void 0,totalBitrate:void 0},vt=function(){if(we.video&&typeof we.video.bitrate=="number"){if(we.video.width&&we.video.height){var Re=we.video.bitrate;return we.audio&&typeof we.audio.bitrate=="number"&&(Re+=we.audio.bitrate),Re!==we.totalBitrate?(we.totalBitrate=Re,{video_source_bitrate:Re,video_source_height:we.video.height,video_source_width:we.video.width,video_source_codec:ze(we.video.codec)}):void 0}G.warn("have bitrate info for video but missing width/height")}},Et=function(Re,tt,De){if(typeof Re.newQuality=="number"){var X=Re.mediaType;if(X==="audio"||X==="video"){var de=D.getBitrateInfoListFor(X).find(function(ve){return ve.qualityIndex===Re.newQuality});if(de&&typeof de.bitrate=="number"){we[X]=te(te({},de),{},{codec:D.getCurrentTrackFor(X).codec});var Q=vt();Q&&me("renditionchange",Q)}else G.warn("missing bitrate info for ".concat(X))}}else G.warn("missing evt.newQuality in qualityChangeRendered event",Re)};D.on("qualityChangeRendered",Et);var Nt=function(Re){var tt=Re.request,De=Re.mediaType;me("requestcanceled",{request_event_type:(tt=tt||{}).type+"_"+tt.action,request_url:tt.url,request_type:De,request_hostname:N(tt.url)})};D.on("fragmentLoadingAbandoned",Nt);var ei=function(Re){var tt,De,X=Re.error,de=(X==null||(tt=X.data)===null||tt===void 0?void 0:tt.request)||{},Q=(X==null||(De=X.data)===null||De===void 0?void 0:De.response)||{};(X==null?void 0:X.code)===27&&me("requestfailed",{request_error:de.type+"_"+de.action,request_url:de.url,request_hostname:N(de.url),request_type:de.mediaType,request_error_code:Q.status,request_error_text:Q.statusText});var ve="".concat(de!=null&&de.url?"url: ".concat(de.url,`
14
+ `):"")+"".concat(Q!=null&&Q.status||Q!=null&&Q.statusText?"response: ".concat(Q==null?void 0:Q.status,", ").concat(Q==null?void 0:Q.statusText,`
15
+ `):"");me("error",{player_error_code:X==null?void 0:X.code,player_error_message:X==null?void 0:X.message,player_error_context:ve})};D.on("error",ei),D._stopMuxMonitor=function(){D.off("manifestLoaded",ne),D.off("initFragmentLoaded",se),D.off("mediaFragmentLoaded",ue),D.off("qualityChangeRendered",Et),D.off("error",ei),D.off("fragmentLoadingAbandoned",Nt),delete D._stopMuxMonitor}}else G.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,x.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var x;this.dashjs&&((x=this.dashjs)&&typeof x._stopMuxMonitor=="function"&&x._stopMuxMonitor(),this.dashjs=void 0)}}],p&&cp(m.prototype,p),y&&cp(m,y),Object.defineProperty(m,"prototype",{writable:!1}),I}(Wi),xy=Sy,Iy=o(153),yn=o.n(Iy);function tc(v){return tc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},tc(v)}function up(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,k=[],F=!0,D=!1;try{for(_=_.call(p);!(F=(I=_.next()).done)&&(k.push(I.value),!y||k.length!==y);F=!0);}catch(G){D=!0,x=G}finally{try{F||_.return==null||_.return()}finally{if(D)throw x}}return k}}(v,m)||function(p,y){if(p){if(typeof p=="string")return hp(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?hp(p,y):void 0}}(v,m)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
16
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function hp(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}var xs,Ly=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Ry={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};d()&&d().WeakMap&&(xs=new WeakMap);var ky="#EXT-X-TARGETDURATION",wy="#EXT-X-PART-INF",Dy="#EXT-X-SERVER-CONTROL",Cy="#EXTINF",My="#EXT-X-PROGRAM-DATE-TIME",Py="#EXT-X-VERSION",Oy="#EXT-X-SESSION-DATA",Va=function(v){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(v),this.manifest};Va.prototype.process=function(v){var m;for(this.buffer+=v,m=this.buffer.indexOf(`
17
17
  `);m>-1;m=this.buffer.indexOf(`
18
- `))this.processLine(this.buffer.substring(0,m)),this.buffer=this.buffer.substring(m+1)},Ua.prototype.processLine=function(v){var m=v.indexOf(":"),p=Db(v,m),y=p[0],_=p.length===2?Hd(p[1]):void 0;if(y[0]!=="#")this.currentUri.uri=y,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(y){case Tb:if(!isFinite(_)||_<0)return;this.manifest.targetDuration=_,this.setHoldBack();break;case _b:$d(this.manifest,p),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Ab:$d(this.manifest,p),this.setHoldBack();break;case Sb:_===0?this.currentUri.duration=.01:_>0&&(this.currentUri.duration=_);break;case xb:var I=_,x=new Date(I);this.manifest.dateTimeString||(this.manifest.dateTimeString=I,this.manifest.dateTimeObject=x),this.currentUri.dateTimeString=I,this.currentUri.dateTimeObject=x;break;case Ib:$d(this.manifest,p);break;case Lb:var R=Cb(p[1]),U=z(R);Object.assign(this.manifest.sessionData,U)}},Ua.prototype.setHoldBack=function(){var v=this.manifest,m=v.serverControl,p=v.targetDuration,y=v.partTargetDuration;if(m){var _="holdBack",I="partHoldBack",x=p&&3*p,R=y&&2*y;p&&!m.hasOwnProperty(_)&&(m[_]=x),x&&m[_]<x&&(m[_]=x),y&&!m.hasOwnProperty(I)&&(m[I]=3*y),y&&m[I]<R&&(m[I]=R)}};var $d=function(v,m){var p,y=Lm(m[0].replace("#EXT-X-",""));wb(m[1])?(p={},p=Object.assign(Rb(m[1]),p)):p=Hd(m[1]),v[y]=p},Lm=function(v){return v.toLowerCase().replace(/-(\w)/g,function(m){return m[1].toUpperCase()})},Hd=function(v){if(v.toLowerCase()==="yes"||v.toLowerCase()==="no")return v.toLowerCase()==="yes";var m=v.indexOf(":")!==-1?v:parseFloat(v);return isNaN(m)?v:m},kb=function(v){var m={},p=v.split("=");return p.length>1&&(m[Lm(p[0])]=Hd(p[1])),m},Rb=function(v){for(var m=v.split(","),p={},y=0;m.length>y;y++){var _=m[y],I=kb(_);p=Object.assign(I,p)}return p},wb=function(v){return v.indexOf("=")>-1},Db=function(v,m){return m===-1?[v]:[v.substring(0,m),v.substring(m+1)]},Cb=function(v){var m={};if(v){var p=v.search(",");return[v.slice(0,p),v.slice(p+1)].forEach(function(y,_){for(var I=y.replace(/['"]+/g,"").split("="),x=0;x<I.length;x++)I[x]==="DATA-ID"&&(m["DATA-ID"]=I[1-x]),I[x]==="VALUE"&&(m.VALUE=I[1-x])}),{data:m}}},Mb=Ua,Ob={safeCall:function(v,m,p,y){var _=y;if(v&&typeof v[m]=="function")try{_=v[m].apply(v,p)}catch(I){A.info("safeCall error",I)}return _},safeIncrement:O,getComputedStyle:function(v,m){var p;if(v&&m&&d()&&typeof d().getComputedStyle=="function")return Ss&&Ss.has(v)&&(p=Ss.get(v)),p||(p=d().getComputedStyle(v,null),Ss&&Ss.set(v,p)),p.getPropertyValue(m)},secondsToMs:function(v){return Math.floor(1e3*v)},assign:Object.assign,headersStringToObject:P,cdnHeadersToRequestId:X,extractHostnameAndDomain:D,extractHostname:N,manifestParser:Mb,generateShortID:u,generateUUID:c,now:L.now},Pb={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 Nb(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,R=[],U=!0,C=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(R.push(I.value),!y||R.length!==y);U=!0);}catch(K){C=!0,x=K}finally{try{U||_.return==null||_.return()}finally{if(C)throw x}}return R}}(v,m)||function(p,y){if(p){if(typeof p=="string")return km(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?km(p,y):void 0}}(v,m)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
19
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function km(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}var ii={},yn=function v(m){var p=arguments;typeof m=="string"?v.hasOwnProperty(m)?d().setTimeout(function(){p=Array.prototype.splice.call(p,1),v[m].apply(null,p)},0):A.warn("`"+m+"` is an unknown task"):typeof m=="function"?d().setTimeout(function(){m(v)},0):A.warn("`"+m+"` is invalid.")},Ub={loaded:L.now(),NAME:"mux-embed",VERSION:"4.27.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(v,m){return function(p,y,_){var I=xm(f(y),3),x=I[0],R=I[1],U=I[2],C=p.log,K=p.utils.getComputedStyle,ve=p.utils.secondsToMs;if(!x)return C.error("No element was found with the `"+R+"` query selector.");if(U!=="video"&&U!=="audio")return C.error("The element of `"+R+"` was not a media element.");x.mux&&(x.mux.destroy(),delete x.mux,C.warn("Already monitoring this video element, replacing existing event listeners")),(_=Object.assign({automaticErrorTracking:!0},_)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:p.VERSION},_.data),_.getPlayheadTime=function(){return ve(x.currentTime)},_.getStateData=function(){var he,oe,me=this.hlsjs&&this.hlsjs.url,Me=this.dashjs&&Bd(this.dashjs.getSource==="function")&&this.dashjs.getSource(),At={player_is_paused:x.paused,player_playhead_time:ve(x.currentTime),player_width:parseInt(K(x,"width")),player_height:parseInt(K(x,"height")),player_autoplay_on:x.autoplay,player_preload_on:x.preload,player_language_code:x.lang,player_is_fullscreen:bn()&&!!(bn().fullscreenElement||bn().webkitFullscreenElement||bn().mozFullScreenElement||bn().msFullscreenElement),video_poster_url:x.poster,video_source_url:me||Me||x.currentSrc,video_source_duration:ve(x.duration),video_source_height:x.videoHeight,video_source_width:x.videoWidth,view_dropped_frame_count:(he=x)===null||he===void 0||(oe=he.getVideoPlaybackQuality)===null||oe===void 0?void 0:oe.call(he).droppedVideoFrames},St=_.getPlayheadTime();if(x.getStartDate&&St>0){var Ut=x.getStartDate();if(Ut&&typeof Ut.getTime=="function"&&Ut.getTime()){var ri=Ut.getTime();if(At.player_program_time=ri+St,x.seekable.length>0){var Ce=ri+x.seekable.end(x.seekable.length-1);At.player_live_edge_program_time=Ce}}}return At},x.mux=x.mux||{},x.mux.deleted=!1,x.mux.emit=function(he,oe){p.emit(R,he,oe)};var de=function(){C.error("The monitor for this video element has already been destroyed.")};x.mux.destroy=function(){Object.keys(x.mux.listeners).forEach(function(he){x.removeEventListener(he,x.mux.listeners[he],!1)}),delete x.mux.listeners,x.mux.destroy=de,x.mux.swapElement=de,x.mux.emit=de,x.mux.addHLSJS=de,x.mux.addDashJS=de,x.mux.removeHLSJS=de,x.mux.removeDashJS=de,x.mux.deleted=!0,p.emit(R,"destroy")},x.mux.swapElement=function(he){var oe=xm(f(he),3),me=oe[0],Me=oe[1],At=oe[2];return me?At!=="video"&&At!=="audio"?p.log.error("The element of `"+Me+"` was not a media element."):(me.muxId=x.muxId,delete x.muxId,me.mux=me.mux||{},me.mux.listeners=Object.assign({},x.mux.listeners),delete x.mux.listeners,Object.keys(me.mux.listeners).forEach(function(St){x.removeEventListener(St,me.mux.listeners[St],!1),me.addEventListener(St,me.mux.listeners[St],!1)}),me.mux.swapElement=x.mux.swapElement,me.mux.destroy=x.mux.destroy,delete x.mux,void(x=me)):p.log.error("No element was found with the `"+Me+"` query selector.")},x.mux.addHLSJS=function(he){p.addHLSJS(R,he)},x.mux.addDashJS=function(he){p.addDashJS(R,he)},x.mux.removeHLSJS=function(){p.removeHLSJS(R)},x.mux.removeDashJS=function(){p.removeDashJS(R)},p.init(R,_),p.emit(R,"playerready"),x.paused||(p.emit(R,"play"),x.readyState>2&&p.emit(R,"playing")),x.mux.listeners={},bb.forEach(function(he){(he!=="error"||_.automaticErrorTracking)&&(x.mux.listeners[he]=function(){var oe={};if(he==="error"){if(!x.error||x.error.code===1)return;oe.player_error_code=x.error.code,oe.player_error_message=yb[x.error.code]||x.error.message}p.emit(R,he,oe)},x.addEventListener(he,x.mux.listeners[he],!1))})}(yn,v,m)},destroyMonitor:function(v){var m=Nb(f(v),1)[0];m&&m.mux&&typeof m.mux.destroy=="function"?m.mux.destroy():A.error("A video element monitor for `"+v+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(v,m){var p=h(v);ii[p]?ii[p].addHLSJS(m):A.error("A monitor for `"+p+"` has not been initialized.")},addDashJS:function(v,m){var p=h(v);ii[p]?ii[p].addDashJS(m):A.error("A monitor for `"+p+"` has not been initialized.")},removeHLSJS:function(v){var m=h(v);ii[m]?ii[m].removeHLSJS():A.error("A monitor for `"+m+"` has not been initialized.")},removeDashJS:function(v){var m=h(v);ii[m]?ii[m].removeDashJS():A.error("A monitor for `"+m+"` has not been initialized.")},init:function(v,m){k()&&m&&m.respectDoNotTrack&&A.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var p=h(v);ii[p]=new vb(yn,p,m)},emit:function(v,m,p){var y=h(v);ii[y]?(ii[y].emit(m,p),m==="destroy"&&delete ii[y]):A.error("A monitor for `"+y+"` has not been initialized.")},checkDoNotTrack:k,log:A,utils:Ob,events:Pb,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(yn,Ub),d()!==void 0&&typeof d().addEventListener=="function"&&d().addEventListener("pagehide",function(v){v.persisted||(yn.WINDOW_UNLOADING=!0)},!1);var Fb=yn},655:function(n,a,o){var l,d;function c(u){return c=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},c(u);}(function(u){var h=!1;if((d=typeof(l=u)=="function"?l.call(a,o,a,n):l)===void 0||(n.exports=d),h=!0,c(a)==="object"&&(n.exports=u(),h=!0),!h){var f=window.Cookies,g=window.Cookies=u();g.noConflict=function(){return window.Cookies=f,g}}})(function(){var u=function(){for(var h=0,f={};h<arguments.length;h++){var g=arguments[h];for(var E in g)f[E]=g[E]}return f};return function h(f){function g(E,T,A){var k;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(A=u({path:"/"},g.defaults,A)).expires=="number"){var L=new Date;L.setMilliseconds(L.getMilliseconds()+864e5*A.expires),A.expires=L}try{k=JSON.stringify(T),/^[\{\[]/.test(k)&&(T=k)}catch{}return T=f.write?f.write(T,E):encodeURIComponent(String(T)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),E=(E=(E=encodeURIComponent(String(E))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[E,"=",T,A.expires?"; expires="+A.expires.toUTCString():"",A.path?"; path="+A.path:"",A.domain?"; domain="+A.domain:"",A.secure?"; secure":""].join("")}E||(k={});for(var N=document.cookie?document.cookie.split("; "):[],D=/(%[0-9A-Z]{2})+/g,$=0;$<N.length;$++){var O=N[$].split("="),G=O.slice(1).join("=");G.charAt(0)==='"'&&(G=G.slice(1,-1));try{var Y=O[0].replace(D,decodeURIComponent);if(G=f.read?f.read(G,Y):f(G,Y)||G.replace(D,decodeURIComponent),this.json)try{G=JSON.parse(G)}catch{}if(E===Y){k=G;break}E||(k[Y]=G)}catch{}}return k}}return g.set=g,g.get=function(E){return g.call(g,E)},g.getJSON=function(){return g.apply({json:!0},[].slice.call(arguments))},g.defaults={},g.remove=function(E,T){g(E,"",u(T,{expires:-1}))},g.withConverter=h,g}(function(){})})},153:function(n,a,o){var l,d=o.g!==void 0?o.g:typeof window!="undefined"?window:{},c=o(558);typeof document!="undefined"?l=document:(l=d["__GLOBAL_DOCUMENT_CACHE@4"])||(l=d["__GLOBAL_DOCUMENT_CACHE@4"]=c),n.exports=l},48:function(n,a,o){var l;l=typeof window!="undefined"?window:o.g!==void 0?o.g:typeof self!="undefined"?self:{},n.exports=l},640:function(n,a,o){var l,d;(function(c,u){"use strict";l=function(){var h=function(){},f="undefined",g=typeof window!==f&&typeof window.navigator!==f&&/Trident\/|MSIE /.test(window.navigator.userAgent),E=["trace","debug","info","warn","error"];function T(P,X){var z=P[X];if(typeof z.bind=="function")return z.bind(P);try{return Function.prototype.bind.call(z,P)}catch{return function(){return Function.prototype.apply.apply(z,[P,arguments])}}}function A(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function k(P){return P==="debug"&&(P="log"),typeof console!==f&&(P==="trace"&&g?A:console[P]!==void 0?T(console,P):console.log!==void 0?T(console,"log"):h)}function L(P,X){for(var z=0;z<E.length;z++){var Ae=E[z];this[Ae]=z<P?h:this.methodFactory(Ae,P,X)}this.log=this.debug}function N(P,X,z){return function(){typeof console!==f&&(L.call(this,X,z),this[P].apply(this,arguments))}}function D(P,X,z){return k(P)||N.apply(this,arguments)}function $(P,X,z){var Ae,Ee=this;X=X==null?"WARN":X;var be="loglevel";function we(se){var xe=(E[se]||"silent").toUpperCase();if(typeof window!==f&&be){try{return void(window.localStorage[be]=xe)}catch{}try{window.document.cookie=encodeURIComponent(be)+"="+xe+";"}catch{}}}function Se(){var se;if(typeof window!==f&&be){try{se=window.localStorage[be]}catch{}if(typeof se===f)try{var xe=window.document.cookie,Ie=xe.indexOf(encodeURIComponent(be)+"=");Ie!==-1&&(se=/^([^;]+)/.exec(xe.slice(Ie))[1])}catch{}return Ee.levels[se]===void 0&&(se=void 0),se}}function Z(){if(typeof window!==f&&be){try{return void window.localStorage.removeItem(be)}catch{}try{window.document.cookie=encodeURIComponent(be)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof P=="string"?be+=":"+P:typeof P=="symbol"&&(be=void 0),Ee.name=P,Ee.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Ee.methodFactory=z||D,Ee.getLevel=function(){return Ae},Ee.setLevel=function(se,xe){if(typeof se=="string"&&Ee.levels[se.toUpperCase()]!==void 0&&(se=Ee.levels[se.toUpperCase()]),!(typeof se=="number"&&se>=0&&se<=Ee.levels.SILENT))throw"log.setLevel() called with invalid level: "+se;if(Ae=se,xe!==!1&&we(se),L.call(Ee,se,P),typeof console===f&&se<Ee.levels.SILENT)return"No console available for logging"},Ee.setDefaultLevel=function(se){X=se,Se()||Ee.setLevel(se,!1)},Ee.resetLevel=function(){Ee.setLevel(X,!1),Z()},Ee.enableAll=function(se){Ee.setLevel(Ee.levels.TRACE,se)},Ee.disableAll=function(se){Ee.setLevel(Ee.levels.SILENT,se)};var ne=Se();ne==null&&(ne=X),Ee.setLevel(ne,!1)}var O=new $,G={};O.getLogger=function(P){if(typeof P!="symbol"&&typeof P!="string"||P==="")throw new TypeError("You must supply a name when creating a logger.");var X=G[P];return X||(X=G[P]=new $(P,O.getLevel(),O.methodFactory)),X};var Y=typeof window!==f?window.log:void 0;return O.noConflict=function(){return typeof window!==f&&window.log===O&&(window.log=Y),O},O.getLoggers=function(){return G},O.default=O,O},(d=typeof l=="function"?l.call(a,o,a,n):l)===void 0||(n.exports=d)})()},375:function(n,a){"use strict";var o=Object.prototype.hasOwnProperty;function l(c){try{return decodeURIComponent(c.replace(/\+/g," "))}catch{return null}}function d(c){try{return encodeURIComponent(c)}catch{return null}}a.stringify=function(c,u){u=u||"";var h,f,g=[];for(f in typeof u!="string"&&(u="?"),c)if(o.call(c,f)){if((h=c[f])||h!=null&&!isNaN(h)||(h=""),f=d(f),h=d(h),f===null||h===null)continue;g.push(f+"="+h)}return g.length?u+g.join("&"):""},a.parse=function(c){for(var u,h=/([^=?#&]+)=?([^&]*)/g,f={};u=h.exec(c);){var g=l(u[1]),E=l(u[2]);g===null||E===null||g in f||(f[g]=E)}return f}},558:function(){}},r={};function s(n){var a=r[n];if(a!==void 0)return a.exports;var o=r[n]={exports:{}};return t[n].call(o.exports,o,o.exports,s),o.exports}return s.n=function(n){var a=n&&n.__esModule?function(){return n.default}:function(){return n};return s.d(a,{a}),a},s.d=function(n,a){for(var o in a)s.o(a,o)&&!s.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:a[o]})},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(n,a){return Object.prototype.hasOwnProperty.call(n,a)},s(80)}()},typeof yl=="object"&&typeof Lu=="object"?Lu.exports=e():typeof yl=="object"?yl.mux=e():i.mux=e()})()});var xs=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class i extends xs{}globalThis.DocumentFragment=i}var An=class extends xs{},Vd=class extends xs{},Xb={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(An)}},Sn,Kd=class{constructor(e,t={}){ut(this,Sn,void 0);si(this,Sn,t==null?void 0:t.detail)}get detail(){return Ne(this,Sn)}initCustomEvent(){}};Sn=new WeakMap;function Qb(i,e){return new An}var wm={document:{createElement:Qb},DocumentFragment,customElements:Xb,CustomEvent:Kd,EventTarget:xs,HTMLElement:An,HTMLVideoElement:Vd},Dm=typeof window=="undefined"||typeof globalThis.customElements=="undefined",st=Dm?wm:globalThis,zt=Dm?wm.document:globalThis.document;var re={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_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},ye={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},Nr={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_PAUSED:"mediaPaused",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_ENDED:"mediaEnded",MEDIA_MUTED:"mediaMuted",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_IS_PIP:"mediaIsPip",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_LOADING:"mediaLoading",MEDIA_BUFFERED:"mediaBuffered",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled"},Cm=Object.entries(Nr),S=Cm.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{}),Zi=Cm.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"}),rx=Object.entries(Zi).reduce((i,[e,t])=>{let r=S[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"}),Mm=Object.entries(S).reduce((i,[e,t])=>{let r=Zi[e];return r&&(i[t]=r),i},{userinactive:"userinactivechange"}),Is={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},Fa={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var Wd={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Xt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},fi={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var Rt={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:i=1}={})=>`current playback rate ${i}`,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:i=30}={})=>`seek forward ${i} seconds`,SEEK_BACK_N_SECS:({seekOffset:i=30}={})=>`seek back ${i} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"},Jb={...Rt,...Xe};function Om(i){return i==null?void 0:i.map(ey).join(" ")}function Pm(i){return i==null?void 0:i.split(/\s+/).map(ty)}function ey(i){if(i){let{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function ty(i){if(i){let[e,t,r]=i.split(":");return{id:e,width:t,height:r}}}function Nm(i){return i==null?void 0:i.map(iy).join(" ")}function Um(i){return i==null?void 0:i.split(/\s+/).map(ry)}function iy(i){if(i){let{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function ry(i){if(i){let[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function Ba(i,e=!1){return i.split("_").map(function(t,r){return(r||e?t[0].toUpperCase():t[0].toLowerCase())+t.slice(1).toLowerCase()}).join("")}function Fm(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Bm(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function $a(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}var Ha=i=>new Promise(e=>setTimeout(e,i));var $m=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],sy=(i,e)=>{let t=i===1?$m[e].singular:$m[e].plural;return`${i} ${t}`},Ur=i=>{if(!Bm(i))return"";let e=Math.abs(i),t=e!==i,r=new Date(0,0,0,0,0,e,0);return`${[r.getHours(),r.getMinutes(),r.getSeconds()].map((o,l)=>o&&sy(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function Ri(i,e){let t=!1;i<0&&(t=!0,i=0-i),i=i<0?0:i;let r=Math.floor(i%60),s=Math.floor(i/60%60),n=Math.floor(i/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(n=s=r="0"),n=n>0||o>0?n+":":"",s=((n||a>=10)&&s<10?"0"+s:s)+":",r=r<10?"0"+r:r,(t?"-":"")+n+s+r}var ox=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}});var Ga=(i,e,t=".value")=>{let r=i.querySelector(t);!r||(r.textContent=e)},ay=(i,e)=>{let t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},Va=(i,e)=>ay(i,e)[0],Fr=(i,e)=>!i||!e?!1:i.contains(e)?!0:Fr(i,e.getRootNode().host),mr=(i,e)=>{if(!i)return null;let t=i.closest(e);return t||mr(i.getRootNode().host,e)};function qd(i=document){var e;let t=i==null?void 0:i.activeElement;return t?(e=qd(t.shadowRoot))!=null?e:t:null}function Hm(i){return i.checkVisibility?i.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}):getComputedStyle(i).opacity!="0"&&getComputedStyle(i.parentElement).opacity!="0"}function et(i,e){var t;let r;for(r of i.querySelectorAll("style")){let s;try{s=(t=r.sheet)==null?void 0:t.cssRules}catch{continue}for(let n of s!=null?s:[])if(n.selectorText===e)return n}return r!=null&&r.sheet?(r.sheet.insertRule(`${e}{}`,r.sheet.cssRules.length),r.sheet.cssRules[r.sheet.cssRules.length-1]):{style:{setProperty:()=>{},removeProperty:()=>{}}}}function Fe(i,e,t=Number.NaN){let r=i.getAttribute(e);return r!=null?+r:t}function ze(i,e,t){let r=+t;if(t==null||Number.isNaN(r)){i.hasAttribute(e)&&i.removeAttribute(e);return}Fe(i,e,void 0)!==r&&i.setAttribute(e,`${r}`)}function Ye(i,e){return i.hasAttribute(e)}function Ke(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}Ye(i,e)!=t&&i.toggleAttribute(e,t)}function We(i,e,t=null){var r;return(r=i.getAttribute(e))!=null?r:t}function Be(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}let r=`${t}`;We(i,e,void 0)!==r&&i.setAttribute(e,r)}var Ka=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},Yd=class{observe(){}unobserve(){}disconnect(){}},Gm={createElement:function(){return new jd.HTMLElement},addEventListener(){},removeEventListener(){}},jd={ResizeObserver:Yd,document:Gm,HTMLElement:class extends Ka{},DocumentFragment:class extends Ka{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},CustomEvent:function(){},getComputedStyle:function(){}},Vm=typeof window=="undefined"||typeof window.customElements=="undefined",Km=Object.keys(jd).every(i=>i in globalThis),w=Vm&&!Km?jd:globalThis,j=Vm&&!Km?Gm:globalThis.document;var oy=Object.defineProperty,ly=(i,e,t)=>e in i?oy(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,dy=(i,e,t)=>(ly(i,typeof e!="symbol"?e+"":e,t),t),Wm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ni=(i,e,t)=>(Wm(i,e,"read from private field"),t?t.call(i):e.get(i)),Wa=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},qa=(i,e,t,r)=>(Wm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),wi,Ya,Ls,ja,qm=j.createElement("template");qm.innerHTML=`
18
+ `))this.processLine(this.buffer.substring(0,m)),this.buffer=this.buffer.substring(m+1)},Va.prototype.processLine=function(v){var m=v.indexOf(":"),p=By(v,m),y=p[0],_=p.length===2?rc(p[1]):void 0;if(y[0]!=="#")this.currentUri.uri=y,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(y){case ky:if(!isFinite(_)||_<0)return;this.manifest.targetDuration=_,this.setHoldBack();break;case wy:ic(this.manifest,p),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Dy:ic(this.manifest,p),this.setHoldBack();break;case Cy:_===0?this.currentUri.duration=.01:_>0&&(this.currentUri.duration=_);break;case My:var I=_,x=new Date(I);this.manifest.dateTimeString||(this.manifest.dateTimeString=I,this.manifest.dateTimeObject=x),this.currentUri.dateTimeString=I,this.currentUri.dateTimeObject=x;break;case Py:ic(this.manifest,p);break;case Oy:var k=$y(p[1]),F=Y(k);Object.assign(this.manifest.sessionData,F)}},Va.prototype.setHoldBack=function(){var v=this.manifest,m=v.serverControl,p=v.targetDuration,y=v.partTargetDuration;if(m){var _="holdBack",I="partHoldBack",x=p&&3*p,k=y&&2*y;p&&!m.hasOwnProperty(_)&&(m[_]=x),x&&m[_]<x&&(m[_]=x),y&&!m.hasOwnProperty(I)&&(m[I]=3*y),y&&m[I]<k&&(m[I]=k)}};var ic=function(v,m){var p,y=fp(m[0].replace("#EXT-X-",""));Fy(m[1])?(p={},p=Object.assign(Uy(m[1]),p)):p=rc(m[1]),v[y]=p},fp=function(v){return v.toLowerCase().replace(/-(\w)/g,function(m){return m[1].toUpperCase()})},rc=function(v){if(v.toLowerCase()==="yes"||v.toLowerCase()==="no")return v.toLowerCase()==="yes";var m=v.indexOf(":")!==-1?v:parseFloat(v);return isNaN(m)?v:m},Ny=function(v){var m={},p=v.split("=");return p.length>1&&(m[fp(p[0])]=rc(p[1])),m},Uy=function(v){for(var m=v.split(","),p={},y=0;m.length>y;y++){var _=m[y],I=Ny(_);p=Object.assign(I,p)}return p},Fy=function(v){return v.indexOf("=")>-1},By=function(v,m){return m===-1?[v]:[v.substring(0,m),v.substring(m+1)]},$y=function(v){var m={};if(v){var p=v.search(",");return[v.slice(0,p),v.slice(p+1)].forEach(function(y,_){for(var I=y.replace(/['"]+/g,"").split("="),x=0;x<I.length;x++)I[x]==="DATA-ID"&&(m["DATA-ID"]=I[1-x]),I[x]==="VALUE"&&(m.VALUE=I[1-x])}),{data:m}}},Hy=Va,Gy={safeCall:function(v,m,p,y){var _=y;if(v&&typeof v[m]=="function")try{_=v[m].apply(v,p)}catch(I){A.info("safeCall error",I)}return _},safeIncrement:U,getComputedStyle:function(v,m){var p;if(v&&m&&d()&&typeof d().getComputedStyle=="function")return xs&&xs.has(v)&&(p=xs.get(v)),p||(p=d().getComputedStyle(v,null),xs&&xs.set(v,p)),p.getPropertyValue(m)},secondsToMs:function(v){return Math.floor(1e3*v)},assign:Object.assign,headersStringToObject:O,cdnHeadersToRequestId:z,extractHostnameAndDomain:M,extractHostname:N,manifestParser:Hy,generateShortID:u,generateUUID:c,now:L.now},Vy={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 Ky(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,y){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var I,x,k=[],F=!0,D=!1;try{for(_=_.call(p);!(F=(I=_.next()).done)&&(k.push(I.value),!y||k.length!==y);F=!0);}catch(G){D=!0,x=G}finally{try{F||_.return==null||_.return()}finally{if(D)throw x}}return k}}(v,m)||function(p,y){if(p){if(typeof p=="string")return mp(p,y);var _=Object.prototype.toString.call(p).slice(8,-1);return _==="Object"&&p.constructor&&(_=p.constructor.name),_==="Map"||_==="Set"?Array.from(p):_==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?mp(p,y):void 0}}(v,m)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
19
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function mp(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,y=new Array(m);p<m;p++)y[p]=v[p];return y}var Jt={},Tn=function v(m){var p=arguments;typeof m=="string"?v.hasOwnProperty(m)?d().setTimeout(function(){p=Array.prototype.splice.call(p,1),v[m].apply(null,p)},0):A.warn("`"+m+"` is an unknown task"):typeof m=="function"?d().setTimeout(function(){m(v)},0):A.warn("`"+m+"` is invalid.")},Wy={loaded:L.now(),NAME:"mux-embed",VERSION:"4.27.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(v,m){return function(p,y,_){var I=up(f(y),3),x=I[0],k=I[1],F=I[2],D=p.log,G=p.utils.getComputedStyle,me=p.utils.secondsToMs;if(!x)return D.error("No element was found with the `"+k+"` query selector.");if(F!=="video"&&F!=="audio")return D.error("The element of `"+k+"` was not a media element.");x.mux&&(x.mux.destroy(),delete x.mux,D.warn("Already monitoring this video element, replacing existing event listeners")),(_=Object.assign({automaticErrorTracking:!0},_)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:p.VERSION},_.data),_.getPlayheadTime=function(){return me(x.currentTime)},_.getStateData=function(){var le,se,ue=this.hlsjs&&this.hlsjs.url,we=this.dashjs&&tc(this.dashjs.getSource==="function")&&this.dashjs.getSource(),vt={player_is_paused:x.paused,player_playhead_time:me(x.currentTime),player_width:parseInt(G(x,"width")),player_height:parseInt(G(x,"height")),player_autoplay_on:x.autoplay,player_preload_on:x.preload,player_language_code:x.lang,player_is_fullscreen:yn()&&!!(yn().fullscreenElement||yn().webkitFullscreenElement||yn().mozFullScreenElement||yn().msFullscreenElement),video_poster_url:x.poster,video_source_url:ue||we||x.currentSrc,video_source_duration:me(x.duration),video_source_height:x.videoHeight,video_source_width:x.videoWidth,view_dropped_frame_count:(le=x)===null||le===void 0||(se=le.getVideoPlaybackQuality)===null||se===void 0?void 0:se.call(le).droppedVideoFrames},Et=_.getPlayheadTime();if(x.getStartDate&&Et>0){var Nt=x.getStartDate();if(Nt&&typeof Nt.getTime=="function"&&Nt.getTime()){var ei=Nt.getTime();if(vt.player_program_time=ei+Et,x.seekable.length>0){var Re=ei+x.seekable.end(x.seekable.length-1);vt.player_live_edge_program_time=Re}}}return vt},x.mux=x.mux||{},x.mux.deleted=!1,x.mux.emit=function(le,se){p.emit(k,le,se)};var ne=function(){D.error("The monitor for this video element has already been destroyed.")};x.mux.destroy=function(){Object.keys(x.mux.listeners).forEach(function(le){x.removeEventListener(le,x.mux.listeners[le],!1)}),delete x.mux.listeners,x.mux.destroy=ne,x.mux.swapElement=ne,x.mux.emit=ne,x.mux.addHLSJS=ne,x.mux.addDashJS=ne,x.mux.removeHLSJS=ne,x.mux.removeDashJS=ne,x.mux.deleted=!0,p.emit(k,"destroy")},x.mux.swapElement=function(le){var se=up(f(le),3),ue=se[0],we=se[1],vt=se[2];return ue?vt!=="video"&&vt!=="audio"?p.log.error("The element of `"+we+"` was not a media element."):(ue.muxId=x.muxId,delete x.muxId,ue.mux=ue.mux||{},ue.mux.listeners=Object.assign({},x.mux.listeners),delete x.mux.listeners,Object.keys(ue.mux.listeners).forEach(function(Et){x.removeEventListener(Et,ue.mux.listeners[Et],!1),ue.addEventListener(Et,ue.mux.listeners[Et],!1)}),ue.mux.swapElement=x.mux.swapElement,ue.mux.destroy=x.mux.destroy,delete x.mux,void(x=ue)):p.log.error("No element was found with the `"+we+"` query selector.")},x.mux.addHLSJS=function(le){p.addHLSJS(k,le)},x.mux.addDashJS=function(le){p.addDashJS(k,le)},x.mux.removeHLSJS=function(){p.removeHLSJS(k)},x.mux.removeDashJS=function(){p.removeDashJS(k)},p.init(k,_),p.emit(k,"playerready"),x.paused||(p.emit(k,"play"),x.readyState>2&&p.emit(k,"playing")),x.mux.listeners={},Ly.forEach(function(le){(le!=="error"||_.automaticErrorTracking)&&(x.mux.listeners[le]=function(){var se={};if(le==="error"){if(!x.error||x.error.code===1)return;se.player_error_code=x.error.code,se.player_error_message=Ry[x.error.code]||x.error.message}p.emit(k,le,se)},x.addEventListener(le,x.mux.listeners[le],!1))})}(Tn,v,m)},destroyMonitor:function(v){var m=Ky(f(v),1)[0];m&&m.mux&&typeof m.mux.destroy=="function"?m.mux.destroy():A.error("A video element monitor for `"+v+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(v,m){var p=h(v);Jt[p]?Jt[p].addHLSJS(m):A.error("A monitor for `"+p+"` has not been initialized.")},addDashJS:function(v,m){var p=h(v);Jt[p]?Jt[p].addDashJS(m):A.error("A monitor for `"+p+"` has not been initialized.")},removeHLSJS:function(v){var m=h(v);Jt[m]?Jt[m].removeHLSJS():A.error("A monitor for `"+m+"` has not been initialized.")},removeDashJS:function(v){var m=h(v);Jt[m]?Jt[m].removeDashJS():A.error("A monitor for `"+m+"` has not been initialized.")},init:function(v,m){R()&&m&&m.respectDoNotTrack&&A.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var p=h(v);Jt[p]=new xy(Tn,p,m)},emit:function(v,m,p){var y=h(v);Jt[y]?(Jt[y].emit(m,p),m==="destroy"&&delete Jt[y]):A.error("A monitor for `"+y+"` has not been initialized.")},checkDoNotTrack:R,log:A,utils:Gy,events:Vy,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Tn,Wy),d()!==void 0&&typeof d().addEventListener=="function"&&d().addEventListener("pagehide",function(v){v.persisted||(Tn.WINDOW_UNLOADING=!0)},!1);var qy=Tn},655:function(n,a,o){var l,d;function c(u){return c=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},c(u);}(function(u){var h=!1;if((d=typeof(l=u)=="function"?l.call(a,o,a,n):l)===void 0||(n.exports=d),h=!0,c(a)==="object"&&(n.exports=u(),h=!0),!h){var f=window.Cookies,g=window.Cookies=u();g.noConflict=function(){return window.Cookies=f,g}}})(function(){var u=function(){for(var h=0,f={};h<arguments.length;h++){var g=arguments[h];for(var E in g)f[E]=g[E]}return f};return function h(f){function g(E,T,A){var R;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(A=u({path:"/"},g.defaults,A)).expires=="number"){var L=new Date;L.setMilliseconds(L.getMilliseconds()+864e5*A.expires),A.expires=L}try{R=JSON.stringify(T),/^[\{\[]/.test(R)&&(T=R)}catch{}return T=f.write?f.write(T,E):encodeURIComponent(String(T)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),E=(E=(E=encodeURIComponent(String(E))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[E,"=",T,A.expires?"; expires="+A.expires.toUTCString():"",A.path?"; path="+A.path:"",A.domain?"; domain="+A.domain:"",A.secure?"; secure":""].join("")}E||(R={});for(var N=document.cookie?document.cookie.split("; "):[],M=/(%[0-9A-Z]{2})+/g,$=0;$<N.length;$++){var U=N[$].split("="),H=U.slice(1).join("=");H.charAt(0)==='"'&&(H=H.slice(1,-1));try{var W=U[0].replace(M,decodeURIComponent);if(H=f.read?f.read(H,W):f(H,W)||H.replace(M,decodeURIComponent),this.json)try{H=JSON.parse(H)}catch{}if(E===W){R=H;break}E||(R[W]=H)}catch{}}return R}}return g.set=g,g.get=function(E){return g.call(g,E)},g.getJSON=function(){return g.apply({json:!0},[].slice.call(arguments))},g.defaults={},g.remove=function(E,T){g(E,"",u(T,{expires:-1}))},g.withConverter=h,g}(function(){})})},153:function(n,a,o){var l,d=o.g!==void 0?o.g:typeof window!="undefined"?window:{},c=o(558);typeof document!="undefined"?l=document:(l=d["__GLOBAL_DOCUMENT_CACHE@4"])||(l=d["__GLOBAL_DOCUMENT_CACHE@4"]=c),n.exports=l},48:function(n,a,o){var l;l=typeof window!="undefined"?window:o.g!==void 0?o.g:typeof self!="undefined"?self:{},n.exports=l},640:function(n,a,o){var l,d;(function(c,u){"use strict";l=function(){var h=function(){},f="undefined",g=typeof window!==f&&typeof window.navigator!==f&&/Trident\/|MSIE /.test(window.navigator.userAgent),E=["trace","debug","info","warn","error"];function T(O,z){var Y=O[z];if(typeof Y.bind=="function")return Y.bind(O);try{return Function.prototype.bind.call(Y,O)}catch{return function(){return Function.prototype.apply.apply(Y,[O,arguments])}}}function A(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function R(O){return O==="debug"&&(O="log"),typeof console!==f&&(O==="trace"&&g?A:console[O]!==void 0?T(console,O):console.log!==void 0?T(console,"log"):h)}function L(O,z){for(var Y=0;Y<E.length;Y++){var ye=E[Y];this[ye]=Y<O?h:this.methodFactory(ye,O,z)}this.log=this.debug}function N(O,z,Y){return function(){typeof console!==f&&(L.call(this,z,Y),this[O].apply(this,arguments))}}function M(O,z,Y){return R(O)||N.apply(this,arguments)}function $(O,z,Y){var ye,Ee=this;z=z==null?"WARN":z;var be="loglevel";function ke(re){var xe=(E[re]||"silent").toUpperCase();if(typeof window!==f&&be){try{return void(window.localStorage[be]=xe)}catch{}try{window.document.cookie=encodeURIComponent(be)+"="+xe+";"}catch{}}}function Se(){var re;if(typeof window!==f&&be){try{re=window.localStorage[be]}catch{}if(typeof re===f)try{var xe=window.document.cookie,Ie=xe.indexOf(encodeURIComponent(be)+"=");Ie!==-1&&(re=/^([^;]+)/.exec(xe.slice(Ie))[1])}catch{}return Ee.levels[re]===void 0&&(re=void 0),re}}function Z(){if(typeof window!==f&&be){try{return void window.localStorage.removeItem(be)}catch{}try{window.document.cookie=encodeURIComponent(be)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof O=="string"?be+=":"+O:typeof O=="symbol"&&(be=void 0),Ee.name=O,Ee.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Ee.methodFactory=Y||M,Ee.getLevel=function(){return ye},Ee.setLevel=function(re,xe){if(typeof re=="string"&&Ee.levels[re.toUpperCase()]!==void 0&&(re=Ee.levels[re.toUpperCase()]),!(typeof re=="number"&&re>=0&&re<=Ee.levels.SILENT))throw"log.setLevel() called with invalid level: "+re;if(ye=re,xe!==!1&&ke(re),L.call(Ee,re,O),typeof console===f&&re<Ee.levels.SILENT)return"No console available for logging"},Ee.setDefaultLevel=function(re){z=re,Se()||Ee.setLevel(re,!1)},Ee.resetLevel=function(){Ee.setLevel(z,!1),Z()},Ee.enableAll=function(re){Ee.setLevel(Ee.levels.TRACE,re)},Ee.disableAll=function(re){Ee.setLevel(Ee.levels.SILENT,re)};var te=Se();te==null&&(te=z),Ee.setLevel(te,!1)}var U=new $,H={};U.getLogger=function(O){if(typeof O!="symbol"&&typeof O!="string"||O==="")throw new TypeError("You must supply a name when creating a logger.");var z=H[O];return z||(z=H[O]=new $(O,U.getLevel(),U.methodFactory)),z};var W=typeof window!==f?window.log:void 0;return U.noConflict=function(){return typeof window!==f&&window.log===U&&(window.log=W),U},U.getLoggers=function(){return H},U.default=U,U},(d=typeof l=="function"?l.call(a,o,a,n):l)===void 0||(n.exports=d)})()},375:function(n,a){"use strict";var o=Object.prototype.hasOwnProperty;function l(c){try{return decodeURIComponent(c.replace(/\+/g," "))}catch{return null}}function d(c){try{return encodeURIComponent(c)}catch{return null}}a.stringify=function(c,u){u=u||"";var h,f,g=[];for(f in typeof u!="string"&&(u="?"),c)if(o.call(c,f)){if((h=c[f])||h!=null&&!isNaN(h)||(h=""),f=d(f),h=d(h),f===null||h===null)continue;g.push(f+"="+h)}return g.length?u+g.join("&"):""},a.parse=function(c){for(var u,h=/([^=?#&]+)=?([^&]*)/g,f={};u=h.exec(c);){var g=l(u[1]),E=l(u[2]);g===null||E===null||g in f||(f[g]=E)}return f}},558:function(){}},r={};function s(n){var a=r[n];if(a!==void 0)return a.exports;var o=r[n]={exports:{}};return t[n].call(o.exports,o,o.exports,s),o.exports}return s.n=function(n){var a=n&&n.__esModule?function(){return n.default}:function(){return n};return s.d(a,{a}),a},s.d=function(n,a){for(var o in a)s.o(a,o)&&!s.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:a[o]})},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(n,a){return Object.prototype.hasOwnProperty.call(n,a)},s(80)}()},typeof kl=="object"&&typeof Yu=="object"?Yu.exports=e():typeof kl=="object"?kl.mux=e():i.mux=e()})()});var Is=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class i extends Is{}globalThis.DocumentFragment=i}var Sn=class extends Is{},nc=class extends Is{},sT={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(Sn)}},xn,ac=class{constructor(e,t={}){nt(this,xn,void 0);ti(this,xn,t==null?void 0:t.detail)}get detail(){return Pe(this,xn)}initCustomEvent(){}};xn=new WeakMap;function nT(i,e){return new Sn}var gp={document:{createElement:nT},DocumentFragment,customElements:sT,CustomEvent:ac,EventTarget:Is,HTMLElement:Sn,HTMLVideoElement:nc},vp=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Xe=vp?gp:globalThis,Yt=vp?gp.document:globalThis.document;var ee={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_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},pe={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},Cr={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_PAUSED:"mediaPaused",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_ENDED:"mediaEnded",MEDIA_MUTED:"mediaMuted",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_IS_PIP:"mediaIsPip",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_LOADING:"mediaLoading",MEDIA_BUFFERED:"mediaBuffered",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled"},Ep=Object.entries(Cr),S=Ep.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{}),Yi=Ep.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"}),SI=Object.entries(Yi).reduce((i,[e,t])=>{let r=S[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"}),bp=Object.entries(S).reduce((i,[e,t])=>{let r=Yi[e];return r&&(i[t]=r),i},{userinactive:"userinactivechange"}),Ls={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},Rs={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var oc={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},jt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},ui={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var St={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:i=1}={})=>`current playback rate ${i}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading"},Ve={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",ENTER_AIRPLAY:()=>"start airplay",EXIT_AIRPLAY:()=>"stop airplay",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:i=30}={})=>`seek forward ${i} seconds`,SEEK_BACK_N_SECS:({seekOffset:i=30}={})=>`seek back ${i} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"},oT={...St,...Ve};function yp(i){return i==null?void 0:i.map(lT).join(" ")}function Tp(i){return i==null?void 0:i.split(/\s+/).map(dT)}function lT(i){if(i){let{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function dT(i){if(i){let[e,t,r]=i.split(":");return{id:e,width:t,height:r}}}function _p(i){return i==null?void 0:i.map(cT).join(" ")}function Ap(i){return i==null?void 0:i.split(/\s+/).map(uT)}function cT(i){if(i){let{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function uT(i){if(i){let[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function Ka(i,e=!1){return i.split("_").map(function(t,r){return(r||e?t[0].toUpperCase():t[0].toLowerCase())+t.slice(1).toLowerCase()}).join("")}function Sp(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function xp(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function Wa(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}var qa=i=>new Promise(e=>setTimeout(e,i));var Ip=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],hT=(i,e)=>{let t=i===1?Ip[e].singular:Ip[e].plural;return`${i} ${t}`},Mr=i=>{if(!xp(i))return"";let e=Math.abs(i),t=e!==i,r=new Date(0,0,0,0,0,e,0);return`${[r.getHours(),r.getMinutes(),r.getSeconds()].map((o,l)=>o&&hT(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function Si(i,e){let t=!1;i<0&&(t=!0,i=0-i),i=i<0?0:i;let r=Math.floor(i%60),s=Math.floor(i/60%60),n=Math.floor(i/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(n=s=r="0"),n=n>0||o>0?n+":":"",s=((n||a>=10)&&s<10?"0"+s:s)+":",r=r<10?"0"+r:r,(t?"-":"")+n+s+r}var RI=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}});var Ya=(i,e,t=".value")=>{let r=i.querySelector(t);r&&(r.textContent=e)},mT=(i,e)=>{let t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},ja=(i,e)=>mT(i,e)[0],nr=(i,e)=>!i||!e?!1:i.contains(e)?!0:nr(i,e.getRootNode().host),ar=(i,e)=>{if(!i)return null;let t=i.closest(e);return t||ar(i.getRootNode().host,e)};function dc(i=document){var e;let t=i==null?void 0:i.activeElement;return t?(e=dc(t.shadowRoot))!=null?e:t:null}function Lp(i){var e;let t=(e=i==null?void 0:i.getRootNode)==null?void 0:e.call(i);return t instanceof ShadowRoot||t instanceof Document?t:null}function Rp(i,e=3){if(i.checkVisibility)return i.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0});let t=i;for(;t&&e>0;){let r=getComputedStyle(t);if(r.opacity==="0"||r.visibility==="hidden"||r.display==="none")return!1;t=t.parentElement,e--}return!0}function kp(i,e,t,r){let s=lc(t,r),n=lc(t,{x:i,y:e}),a=lc(r,{x:i,y:e});return n>s||a>s?n>a?1:0:n/s}function lc(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function Ye(i,e){var t;let r;for(r of i.querySelectorAll("style")){let s;try{s=(t=r.sheet)==null?void 0:t.cssRules}catch{continue}for(let n of s!=null?s:[])if(n.selectorText===e)return n}return r!=null&&r.sheet?(r.sheet.insertRule(`${e}{}`,r.sheet.cssRules.length),r.sheet.cssRules[r.sheet.cssRules.length-1]):{style:{setProperty:()=>{},removeProperty:()=>{}}}}function Ue(i,e,t=Number.NaN){let r=i.getAttribute(e);return r!=null?+r:t}function Ke(i,e,t){let r=+t;if(t==null||Number.isNaN(r)){i.hasAttribute(e)&&i.removeAttribute(e);return}Ue(i,e,void 0)!==r&&i.setAttribute(e,`${r}`)}function Fe(i,e){return i.hasAttribute(e)}function Oe(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}Fe(i,e)!=t&&i.toggleAttribute(e,t)}function He(i,e,t=null){var r;return(r=i.getAttribute(e))!=null?r:t}function Be(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}let r=`${t}`;He(i,e,void 0)!==r&&i.setAttribute(e,r)}var za=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},cc=class{observe(){}unobserve(){}disconnect(){}},wp={createElement:function(){return new uc.HTMLElement},addEventListener(){},removeEventListener(){}},uc={ResizeObserver:cc,document:wp,HTMLElement:class extends za{},DocumentFragment:class extends za{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[]}},Dp=typeof window=="undefined"||typeof window.customElements=="undefined",Cp=Object.keys(uc).every(i=>i in globalThis),w=Dp&&!Cp?uc:globalThis,q=Dp&&!Cp?wp:globalThis.document;var pT=Object.defineProperty,gT=(i,e,t)=>e in i?pT(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,vT=(i,e,t)=>(gT(i,typeof e!="symbol"?e+"":e,t),t),Mp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ii=(i,e,t)=>(Mp(i,e,"read from private field"),t?t.call(i):e.get(i)),Xa=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Qa=(i,e,t,r)=>(Mp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),xi,Za,ks,Ja,Pp=q.createElement("template");Pp.innerHTML=`
20
20
  <style>
21
21
  :host {
22
22
  font: var(--media-font,
@@ -65,12 +65,26 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
65
65
  min-width: 100%;
66
66
  }
67
67
  </style>
68
- `;var $e=class extends w.HTMLElement{constructor(e={}){if(super(),Wa(this,wi,void 0),dy(this,"preventClick",!1),Wa(this,Ya,r=>{this.preventClick||this.handleClick(r)}),Wa(this,Ls,r=>{let{key:s}=r;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",ni(this,Ls));return}this.preventClick||this.handleClick(r)}),Wa(this,ja,r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",ni(this,Ls));return}this.addEventListener("keyup",ni(this,Ls),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});let r=qm.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=j.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),this.shadowRoot.appendChild(r)}let{style:t}=et(this.shadowRoot,":host");t.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`)}static get observedAttributes(){return["disabled",ye.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",ni(this,Ya)),this.addEventListener("keydown",ni(this,ja)),this.tabIndex=0}disable(){this.removeEventListener("click",ni(this,Ya)),this.removeEventListener("keydown",ni(this,ja)),this.removeEventListener("keyup",ni(this,Ls)),this.tabIndex=-1}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ye.MEDIA_CONTROLLER?(t&&((n=(s=ni(this,wi))==null?void 0:s.unassociateElement)==null||n.call(s,this),qa(this,wi,null)),r&&this.isConnected&&(qa(this,wi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ni(this,wi))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");let s=this.getAttribute(ye.MEDIA_CONTROLLER);s&&(qa(this,wi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=ni(this,wi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=ni(this,wi))==null?void 0:e.unassociateElement)==null||t.call(e,this),qa(this,wi,null)}get keysUsed(){return["Enter"," "]}handleClick(e){}};wi=new WeakMap;Ya=new WeakMap;Ls=new WeakMap;ja=new WeakMap;w.customElements.get("media-chrome-button")||w.customElements.define("media-chrome-button",$e);var cy=`<svg aria-hidden="true" viewBox="0 0 26 24">
68
+ `;var $e=class extends w.HTMLElement{constructor(e={}){if(super(),Xa(this,xi,void 0),vT(this,"preventClick",!1),Xa(this,Za,r=>{this.preventClick||this.handleClick(r)}),Xa(this,ks,r=>{let{key:s}=r;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",ii(this,ks));return}this.preventClick||this.handleClick(r)}),Xa(this,Ja,r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",ii(this,ks));return}this.addEventListener("keyup",ii(this,ks),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});let r=Pp.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=q.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),this.shadowRoot.appendChild(r)}let{style:t}=Ye(this.shadowRoot,":host");t.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`)}static get observedAttributes(){return["disabled",pe.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",ii(this,Za)),this.addEventListener("keydown",ii(this,Ja)),this.tabIndex=0}disable(){this.removeEventListener("click",ii(this,Za)),this.removeEventListener("keydown",ii(this,Ja)),this.removeEventListener("keyup",ii(this,ks)),this.tabIndex=-1}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===pe.MEDIA_CONTROLLER?(t&&((n=(s=ii(this,xi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Qa(this,xi,null)),r&&this.isConnected&&(Qa(this,xi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ii(this,xi))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");let s=this.getAttribute(pe.MEDIA_CONTROLLER);s&&(Qa(this,xi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=ii(this,xi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=ii(this,xi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Qa(this,xi,null)}get keysUsed(){return["Enter"," "]}handleClick(e){}};xi=new WeakMap;Za=new WeakMap;ks=new WeakMap;Ja=new WeakMap;w.customElements.get("media-chrome-button")||w.customElements.define("media-chrome-button",$e);var Op=`<svg aria-hidden="true" viewBox="0 0 26 24">
69
69
  <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"/>
70
70
  </svg>
71
- `,Ym=j.createElement("template");Ym.innerHTML=`
72
- <slot name="icon">${cy}</slot>
73
- `;var zd=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Ym,...e})}connectedCallback(){this.setAttribute("aria-label",Xe.AIRPLAY()),super.connectedCallback()}get mediaAirplayUnavailable(){return We(this,S.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){Be(this,S.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new w.CustomEvent(re.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};w.customElements.get("media-airplay-button")||w.customElements.define("media-airplay-button",zd);var uy='<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>',hy='<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>',zm=j.createElement("template");zm.innerHTML=`
71
+ `,Up=q.createElement("template");Up.innerHTML=`
72
+ <style>
73
+ :host([${S.MEDIA_IS_AIRPLAYING}]) slot:not([name=exit]):not([name=icon]) {
74
+ display: none !important;
75
+ }
76
+
77
+
78
+ :host(:not([${S.MEDIA_IS_AIRPLAYING}])) slot:not([name=enter]):not([name=icon]) {
79
+ display: none !important;
80
+ }
81
+ </style>
82
+
83
+ <slot name="icon">
84
+ <slot name="enter">${Op}</slot>
85
+ <slot name="exit">${Op}</slot>
86
+ </slot>
87
+ `;var Np=i=>{let e=i.mediaIsAirplaying?Ve.EXIT_AIRPLAY():Ve.ENTER_AIRPLAY();i.setAttribute("aria-label",e)},hc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_AIRPLAYING,S.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Up,...e})}connectedCallback(){super.connectedCallback(),Np(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_IS_AIRPLAYING&&Np(this)}get mediaIsAirplaying(){return Fe(this,S.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){Oe(this,S.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return He(this,S.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){Be(this,S.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new w.CustomEvent(ee.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};w.customElements.get("media-airplay-button")||w.customElements.define("media-airplay-button",hc);var ET='<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>',bT='<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>',Bp=q.createElement("template");Bp.innerHTML=`
74
88
  <style>
75
89
  :host([${S.MEDIA_IS_CASTING}]) slot:not([name=exit]):not([name=icon]) {
76
90
  display: none !important;
@@ -83,17 +97,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
83
97
  </style>
84
98
 
85
99
  <slot name="icon">
86
- <slot name="enter">${uy}</slot>
87
- <slot name="exit">${hy}</slot>
100
+ <slot name="enter">${ET}</slot>
101
+ <slot name="exit">${bT}</slot>
88
102
  </slot>
89
- `;var jm=i=>{let t=i.getAttribute(S.MEDIA_IS_CASTING)!=null?Xe.EXIT_CAST():Xe.ENTER_CAST();i.setAttribute("aria-label",t)},Xd=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_CASTING,S.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:zm,...e})}connectedCallback(){jm(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===S.MEDIA_IS_CASTING&&jm(this),super.attributeChangedCallback(e,t,r)}get mediaIsCasting(){return Ye(this,S.MEDIA_IS_CASTING)}set mediaIsCasting(e){Ke(this,S.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return We(this,S.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){Be(this,S.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?re.MEDIA_EXIT_CAST_REQUEST:re.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-cast-button")||w.customElements.define("media-cast-button",Xd);var Xm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},pr=(i,e,t)=>(Xm(i,e,"read from private field"),t?t.call(i):e.get(i)),fy=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},za=(i,e,t,r)=>(Xm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Bt,Qm=j.createElement("template");Qm.innerHTML=`
103
+ `;var Fp=i=>{let e=i.mediaIsCasting?Ve.EXIT_CAST():Ve.ENTER_CAST();i.setAttribute("aria-label",e)},fc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_CASTING,S.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Bp,...e})}connectedCallback(){super.connectedCallback(),Fp(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_IS_CASTING&&Fp(this)}get mediaIsCasting(){return Fe(this,S.MEDIA_IS_CASTING)}set mediaIsCasting(e){Oe(this,S.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return He(this,S.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){Be(this,S.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?ee.MEDIA_EXIT_CAST_REQUEST:ee.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-cast-button")||w.customElements.define("media-cast-button",fc);var $p=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},or=(i,e,t)=>($p(i,e,"read from private field"),t?t.call(i):e.get(i)),yT=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},eo=(i,e,t,r)=>($p(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ft,Hp=q.createElement("template");Hp.innerHTML=`
90
104
  <style>
91
105
  :host {
92
106
  display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
93
107
  box-sizing: border-box;
94
108
  }
95
109
  </style>
96
- `;var Qd=class extends w.HTMLElement{constructor(e={}){if(super(),fy(this,Bt,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),r=Qm.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=j.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),t.appendChild(r)}}static get observedAttributes(){return[ye.MEDIA_CONTROLLER,S.MEDIA_PAUSED]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ye.MEDIA_CONTROLLER&&(t&&((n=(s=pr(this,Bt))==null?void 0:s.unassociateElement)==null||n.call(s,this),za(this,Bt,null)),r&&this.isConnected&&(za(this,Bt,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=pr(this,Bt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),za(this,Bt,my(this)),this.getAttribute(ye.MEDIA_CONTROLLER)&&((t=(e=pr(this,Bt))==null?void 0:e.associateElement)==null||t.call(e,this)),(r=pr(this,Bt))==null||r.addEventListener("pointerdown",this),(s=pr(this,Bt))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,r,s;this.getAttribute(ye.MEDIA_CONTROLLER)&&((t=(e=pr(this,Bt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(r=pr(this,Bt))==null||r.removeEventListener("pointerdown",this),(s=pr(this,Bt))==null||s.removeEventListener("click",this),za(this,Bt,null)}handleEvent(e){var t;let r=(t=e.composedPath())==null?void 0:t[0];if(!!["video","media-controller"].includes(r==null?void 0:r.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){let{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:c}=this.getBoundingClientRect(),u=n-o,h=a-l;if(u<0||h<0||u>d||h>c||d===0&&c===0)return;let{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===Wd.TOUCH){this.handleTap(e);return}else if(f===Wd.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return Ye(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ke(this,S.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?re.MEDIA_PLAY_REQUEST:re.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new w.CustomEvent(t,{composed:!0,bubbles:!0}))}};Bt=new WeakMap;function my(i){var e;let t=i.getAttribute(ye.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):mr(i,"media-controller")}w.customElements.get("media-gesture-receiver")||w.customElements.define("media-gesture-receiver",Qd);var py=Object.defineProperty,gy=(i,e,t)=>e in i?py(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,vy=(i,e,t)=>(gy(i,typeof e!="symbol"?e+"":e,t),t),He={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},Zm=j.createElement("template");Zm.innerHTML=`
110
+ `;var mc=class extends w.HTMLElement{constructor(e={}){if(super(),yT(this,Ft,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),r=Hp.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=q.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),t.appendChild(r)}}static get observedAttributes(){return[pe.MEDIA_CONTROLLER,S.MEDIA_PAUSED]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===pe.MEDIA_CONTROLLER&&(t&&((n=(s=or(this,Ft))==null?void 0:s.unassociateElement)==null||n.call(s,this),eo(this,Ft,null)),r&&this.isConnected&&(eo(this,Ft,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=or(this,Ft))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),eo(this,Ft,TT(this)),this.getAttribute(pe.MEDIA_CONTROLLER)&&((t=(e=or(this,Ft))==null?void 0:e.associateElement)==null||t.call(e,this)),(r=or(this,Ft))==null||r.addEventListener("pointerdown",this),(s=or(this,Ft))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,r,s;this.getAttribute(pe.MEDIA_CONTROLLER)&&((t=(e=or(this,Ft))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(r=or(this,Ft))==null||r.removeEventListener("pointerdown",this),(s=or(this,Ft))==null||s.removeEventListener("click",this),eo(this,Ft,null)}handleEvent(e){var t;let r=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(r==null?void 0:r.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){let{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:c}=this.getBoundingClientRect(),u=n-o,h=a-l;if(u<0||h<0||u>d||h>c||d===0&&c===0)return;let{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===oc.TOUCH){this.handleTap(e);return}else if(f===oc.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return Fe(this,S.MEDIA_PAUSED)}set mediaPaused(e){Oe(this,S.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?ee.MEDIA_PLAY_REQUEST:ee.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new w.CustomEvent(t,{composed:!0,bubbles:!0}))}};Ft=new WeakMap;function TT(i){var e;let t=i.getAttribute(pe.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):ar(i,"media-controller")}w.customElements.get("media-gesture-receiver")||w.customElements.define("media-gesture-receiver",mc);var Gp=new WeakMap,pc=i=>{let e=Gp.get(i);return e||Gp.set(i,e=new Set),e},Vp=new w.ResizeObserver(i=>{for(let e of i)for(let t of pc(e.target))t(e)});function In(i,e){pc(i).add(e),Vp.observe(i)}function gc(i,e){let t=pc(i);t.delete(e),t.size||Vp.unobserve(i)}var _T=Object.defineProperty,AT=(i,e,t)=>e in i?_T(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ST=(i,e,t)=>(AT(i,typeof e!="symbol"?e+"":e,t),t),yc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ln=(i,e,t)=>(yc(i,e,"read from private field"),t?t.call(i):e.get(i)),Pr=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},vc=(i,e,t,r)=>(yc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),hi=(i,e,t)=>(yc(i,e,"access private method"),t),to,lr,Ec,Kp,bc,Wp,Rn,ro,so,Tc,ws,kn,Le={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},qp=q.createElement("template");qp.innerHTML=`
97
111
  <style>
98
112
 
99
113
  :host([${S.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
@@ -108,7 +122,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
108
122
  background-color: var(--media-background-color, #000);
109
123
  }
110
124
 
111
- :host(:not([${He.AUDIO}])) [part~=layer]:not([part~=media-layer]) {
125
+ :host(:not([${Le.AUDIO}])) [part~=layer]:not([part~=media-layer]) {
112
126
  position: absolute;
113
127
  top: 0;
114
128
  left: 0;
@@ -126,19 +140,19 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
126
140
  }
127
141
 
128
142
 
129
- :host([${He.AUDIO}]) slot[name=media] {
143
+ :host([${Le.AUDIO}]) slot[name=media] {
130
144
  display: var(--media-slot-display, none);
131
145
  }
132
146
 
133
147
 
134
- :host([${He.AUDIO}]) [part~=layer][part~=gesture-layer] {
148
+ :host([${Le.AUDIO}]) [part~=layer][part~=gesture-layer] {
135
149
  height: 0;
136
150
  display: block;
137
151
  }
138
152
 
139
153
 
140
- :host(:not([${He.AUDIO}])[${He.GESTURES_DISABLED}]) ::slotted([slot=gestures-chrome]),
141
- :host(:not([${He.AUDIO}])[${He.GESTURES_DISABLED}]) media-gesture-receiver[slot=gestures-chrome] {
154
+ :host(:not([${Le.AUDIO}])[${Le.GESTURES_DISABLED}]) ::slotted([slot=gestures-chrome]),
155
+ :host(:not([${Le.AUDIO}])[${Le.GESTURES_DISABLED}]) media-gesture-receiver[slot=gestures-chrome] {
142
156
  display: none;
143
157
  }
144
158
 
@@ -147,13 +161,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
147
161
  pointer-events: auto;
148
162
  }
149
163
 
150
- :host(:not([${He.AUDIO}])) *[part~=layer][part~=centered-layer] {
164
+ :host(:not([${Le.AUDIO}])) *[part~=layer][part~=centered-layer] {
151
165
  align-items: center;
152
166
  justify-content: center;
153
167
  }
154
168
 
155
- :host(:not([${He.AUDIO}])) ::slotted(media-gesture-receiver[slot=gestures-chrome]),
156
- :host(:not([${He.AUDIO}])) media-gesture-receiver[slot=gestures-chrome] {
169
+ :host(:not([${Le.AUDIO}])) ::slotted(media-gesture-receiver[slot=gestures-chrome]),
170
+ :host(:not([${Le.AUDIO}])) media-gesture-receiver[slot=gestures-chrome] {
157
171
  align-self: stretch;
158
172
  flex-grow: 1;
159
173
  }
@@ -173,7 +187,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
173
187
  }
174
188
 
175
189
 
176
- :host(:not([${He.AUDIO}])) .spacer {
190
+ :host(:not([${Le.AUDIO}])) .spacer {
177
191
  flex-grow: 1;
178
192
  }
179
193
 
@@ -185,23 +199,27 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
185
199
  }
186
200
 
187
201
 
188
- ::slotted(:not([slot=media]):not([${He.NO_AUTOHIDE}])) {
202
+ ::slotted(:not([slot=media]):not([${Le.NO_AUTOHIDE}])) {
189
203
  opacity: 1;
190
204
  transition: opacity 0.25s;
191
205
  }
192
206
 
193
207
 
194
- :host([${He.USER_INACTIVE}]:not([${S.MEDIA_PAUSED}]):not([${S.MEDIA_IS_CASTING}]):not([${He.AUDIO}])) ::slotted(:not([slot=media]):not([${He.NO_AUTOHIDE}])) {
208
+ :host([${Le.USER_INACTIVE}]:not([${S.MEDIA_PAUSED}]):not([${S.MEDIA_IS_AIRPLAYING}]):not([${S.MEDIA_IS_CASTING}]):not([${Le.AUDIO}])) ::slotted(:not([slot=media]):not([${Le.NO_AUTOHIDE}])) {
195
209
  opacity: 0;
196
210
  transition: opacity 1s;
197
211
  }
198
212
 
213
+ :host([${Le.USER_INACTIVE}]:not([${S.MEDIA_PAUSED}]):not([${S.MEDIA_IS_CASTING}]):not([${Le.AUDIO}])) ::slotted([slot=media]) {
214
+ cursor: none;
215
+ }
216
+
199
217
  ::slotted(media-control-bar) {
200
218
  align-self: stretch;
201
219
  }
202
220
 
203
221
 
204
- :host(:not([${He.AUDIO}])[${S.MEDIA_HAS_PLAYED}]) slot[name=poster] {
222
+ :host(:not([${Le.AUDIO}])[${S.MEDIA_HAS_PLAYED}]) slot[name=poster] {
205
223
  display: none;
206
224
  }
207
225
  </style>
@@ -218,7 +236,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
218
236
 
219
237
  <slot part="bottom chrome"></slot>
220
238
  </span>
221
- `;var Ey=Object.values(S),by="sm:384 md:576 lg:768 xl:960";function yy(i){for(let e of i)Ty(e.target,e.contentRect.width)}function Ty(i,e){var t;if(!i.isConnected)return;let r=(t=i.getAttribute(He.BREAKPOINTS))!=null?t:by,s=_y(r),n=Ay(s,e),a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){let o=new CustomEvent(Zi.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}}function _y(i){let e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function Ay(i,e){return Object.keys(i).filter(t=>e>=i[t])}var Xa=class extends w.HTMLElement{constructor(){super(),vy(this,"breakpointsComputed",!1),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Zm.content.cloneNode(!0)));let e=l=>{let d=this.media;for(let c of l)c.type==="childList"&&(c.removedNodes.forEach(u=>{if(u.slot=="media"&&c.target==this){let h=c.previousSibling&&c.previousSibling.previousElementSibling;if(!h||!d)this.mediaUnsetCallback(u);else{let f=h.slot!=="media";for(;(h=h.previousSibling)!==null;)h.slot=="media"&&(f=!1);f&&this.mediaUnsetCallback(u)}}}),d&&c.addedNodes.forEach(u=>{u==d&&this.handleMediaUpdated(d).then(h=>this.mediaSetCallback(h))}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let r=!1,s=l=>{r||(setTimeout(()=>{yy(l),r=!1,this.breakpointsComputed||(this.breakpointsComputed=!0,this.dispatchEvent(new CustomEvent(Zi.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))},0),r=!0)},n=new ResizeObserver(s);this.resizeObserver=n,n.observe(this);let a=this.media,o=this.querySelector(":scope > slot[slot=media]");o&&o.addEventListener("slotchange",()=>{if(!o.assignedElements({flatten:!0}).length){this.mediaUnsetCallback(a);return}this.media&&(a=this.media,this.handleMediaUpdated(this.media).then(d=>this.mediaSetCallback(d)))})}static get observedAttributes(){return[He.AUTOHIDE,He.GESTURES_DISABLED].concat(Ey).filter(e=>![S.MEDIA_RENDITION_LIST,S.MEDIA_AUDIO_TRACK_LIST].includes(e))}attributeChangedCallback(e,t,r){e.toLowerCase()==He.AUTOHIDE&&(this.autohide=r)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}mediaSetCallback(e){this._mediaClickPlayToggle=()=>{let t=e.paused?re.MEDIA_PLAY_REQUEST:re.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new w.CustomEvent(t,{composed:!0,bubbles:!0}))}}handleMediaUpdated(e){let t=n=>Promise.resolve(n),r=n=>(console.error('<media-chrome>: Media element set with slot="media" does not appear to be compatible.',n),Promise.reject(n));if(!e)return r(e);let s=e.nodeName.toLowerCase();return s.includes("-")?w.customElements.whenDefined(s).then(()=>t(e)):t(e)}mediaUnsetCallback(e){}connectedCallback(){var e;let r=this.getAttribute(He.AUDIO)!=null?Rt.AUDIO_PLAYER():Rt.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",r),this.media&&this.handleMediaUpdated(this.media).then(o=>this.mediaSetCallback(o)),this.setAttribute(He.USER_INACTIVE,"");let s=()=>{if(this.autohide<0||this.hasAttribute(He.USER_INACTIVE))return;this.setAttribute(He.USER_INACTIVE,"");let o=new w.CustomEvent(Zi.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(o)},n=()=>{if(!this.hasAttribute(He.USER_INACTIVE))return;this.removeAttribute(He.USER_INACTIVE);let o=new w.CustomEvent(Zi.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(o)},a=()=>{n(),clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=setTimeout(()=>{s()},this.autohide*1e3))};this.addEventListener("keyup",()=>{a()}),this.addEventListener("pointerup",o=>{o.pointerType==="touch"?[this,this.media].includes(o.target)&&!this.hasAttribute(He.USER_INACTIVE)?s():a():o.composedPath().some(l=>{var d;return["media-play-button","media-fullscreen-button"].includes((d=l==null?void 0:l.nodeName)==null?void 0:d.toLowerCase())})&&a()}),this.addEventListener("pointermove",o=>{n(),clearTimeout(this._inactiveTimeout),[this,this.media].includes(o.target)&&a()}),this.addEventListener("mouseleave",()=>{s()}),this.addEventListener("keyup",()=>{this.setAttribute(He.KEYBOARD_CONTROL,"")}),(e=w.window)==null||e.addEventListener("mouseup",()=>{this.removeAttribute(He.KEYBOARD_CONTROL)})}set autohide(e){e=Number(e),this._autohide=isNaN(e)?0:e}get autohide(){return this._autohide===void 0?2:this._autohide}};var Jm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},bt=(i,e,t)=>(Jm(i,e,"read from private field"),t?t.call(i):e.get(i)),xn=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Qa=(i,e,t,r)=>(Jm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ks,Rs,Za,Br,Ji,gr,vr=class{constructor(e,t,{defaultValue:r}={defaultValue:void 0}){xn(this,Ji),xn(this,ks,void 0),xn(this,Rs,void 0),xn(this,Za,void 0),xn(this,Br,new Set),Qa(this,ks,e),Qa(this,Rs,t),Qa(this,Za,new Set(r))}[Symbol.iterator](){return bt(this,Ji,gr).values()}get length(){return bt(this,Ji,gr).size}get value(){var e;return(e=[...bt(this,Ji,gr)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Qa(this,Br,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...bt(this,Ji,gr)][e]}values(){return bt(this,Ji,gr).values()}forEach(e){bt(this,Ji,gr).forEach(e)}add(...e){var t,r;e.forEach(s=>bt(this,Br).add(s)),!(this.value===""&&!((t=bt(this,ks))!=null&&t.hasAttribute(`${bt(this,Rs)}`)))&&((r=bt(this,ks))==null||r.setAttribute(`${bt(this,Rs)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>bt(this,Br).delete(r)),(t=bt(this,ks))==null||t.setAttribute(`${bt(this,Rs)}`,`${this.value}`)}contains(e){return bt(this,Ji,gr).has(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}};ks=new WeakMap;Rs=new WeakMap;Za=new WeakMap;Br=new WeakMap;Ji=new WeakSet;gr=function(){return bt(this,Br).size?bt(this,Br):bt(this,Za)};var ep=(i="")=>i.split(/\s+/),tp=(i="")=>{let[e,t,r]=i.split(":"),s=r?decodeURIComponent(r):void 0;return e=e==="cc"?"captions":"subtitles",{kind:e,language:t,label:s}},In=(i="",e={})=>ep(i).map(t=>{let r=tp(t);return{...e,...r}}),Sy=i=>Array.isArray(i)?i.map(e=>typeof e=="string"?tp(e):e):typeof i=="string"?In(i):[i],Ja=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,$r=(i=[])=>Array.prototype.map.call(i,Ja).join(" "),xy=(i,e)=>t=>t[i]===e,ip=i=>{let e=Object.entries(i).map(([t,r])=>xy(t,r));return t=>e.every(r=>r(t))},Zd=(i,e=[],t=[])=>{let r=Sy(t).map(ip),s=n=>r.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=i})},eo=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];let t=typeof e=="function"?e:ip(e);return Array.from(i.textTracks).filter(t)},Jd=i=>!!i.getAttribute(S.MEDIA_SUBTITLES_SHOWING),er=(i,e)=>{var t,r;let s=Jd(i);if(s||e===!1){let n=i.getAttribute(S.MEDIA_SUBTITLES_SHOWING);if(n){let a=new w.CustomEvent(re.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:n});i.dispatchEvent(a)}}else if(!s||e===!0){let[n]=(r=ep((t=i.getAttribute(S.MEDIA_SUBTITLES_LIST))!=null?t:""))!=null?r:[];if(n){let a=new w.CustomEvent(re.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:n});i.dispatchEvent(a)}}else console.error("Attempting to enable captions or subtitles but none are available! Please verify your media content if this is unexpected.")};var at={enter:"requestFullscreen",exit:"exitFullscreen",rootEvents:["fullscreenchange"],mediaEvents:[],element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};j.fullscreenElement===void 0&&(at.enter="webkitRequestFullScreen",at.exit=j.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",at.rootEvents=["webkitfullscreenchange"],at.mediaEvents=["webkitbeginfullscreen","webkitendfullscreen"],at.element="webkitFullscreenElement",at.error="webkitfullscreenerror",at.enabled="webkitFullscreenEnabled");var to,ec=()=>{var i,e;return to||(to=(e=(i=j)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),to)},rp=async(i=ec())=>{if(!i)return!1;let e=i.volume;return i.volume=e/2+.1,await Ha(0),i.volume!==e},Iy=(i=ec())=>typeof(i==null?void 0:i.requestPictureInPicture)=="function",Ly=(i=ec())=>{let e=j[at.enabled];return!e&&i&&(e="webkitSupportsFullscreen"in i),e},tc=Ly(),sp=Iy(),np=!!w.WebKitPlaybackTargetAvailabilityEvent,ap=!!w.chrome;var io,op=rp().then(i=>(io=i,io)),ky=Object.values(fi),ic=i=>eo(i.media,e=>[Is.SUBTITLES,Is.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),Ry=i=>eo(i.media,e=>e.mode===Fa.SHOWING&&[Is.SUBTITLES,Is.CAPTIONS].includes(e.kind)),$t={MEDIA_PAUSED:{get:function(i){let{media:e}=i;return e?e.paused:!0},mediaEvents:["play","playing","pause","emptied"]},MEDIA_HAS_PLAYED:{get:function(i){let{media:e}=i;return e?!e.paused:!1},mediaEvents:["playing","emptied"]},MEDIA_ENDED:{get:function(i){let{media:e}=i;return e?e.ended:!1},mediaEvents:["seeked","ended","emptied"]},MEDIA_PLAYBACK_RATE:{get:function(i){let{media:e}=i;return!e||typeof e.playbackRate=="undefined"?1:e.playbackRate},mediaEvents:["ratechange","loadstart"]},MEDIA_MUTED:{get:function(i){let{media:e}=i;return!e||typeof e.muted=="undefined"?!1:e.muted},mediaEvents:["volumechange"]},MEDIA_VOLUME:{get:function(i){let{media:e}=i;return!e||typeof e.volume=="undefined"?1:Number(e.volume)},mediaEvents:["volumechange"]},MEDIA_VOLUME_LEVEL:{get:function(i){let{media:e}=i,t="high";if(!e||typeof e.volume=="undefined")return t;let{muted:r,volume:s}=e;return s===0||r?t="off":s<.5?t="low":s<.75&&(t="medium"),t},mediaEvents:["volumechange"]},MEDIA_CURRENT_TIME:{get:function(i){let{media:e}=i;return!e||typeof e.currentTime=="undefined"?0:e.currentTime},mediaEvents:["playing","pause","timeupdate","loadedmetadata"]},MEDIA_DURATION:{get:function(i){let{media:e}=i;return!e||!Number.isFinite(e.duration)?NaN:e.duration},mediaEvents:["durationchange","loadedmetadata","emptied"]},MEDIA_SEEKABLE:{get:function(i){var e;let{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;let r=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!r&&!s))return[Number(r.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress"]},MEDIA_LOADING:{get:function(i){var e;return((e=i.media)==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},MEDIA_BUFFERED:{get:function(i){var e,t,r;let s=(e=i.media)==null?void 0:e.buffered;return Array.from((r=(t=i.media)==null?void 0:t.buffered)!=null?r:[]).map((n,a)=>[Number(s.start(a)).toFixed(3),Number(s.end(a)).toFixed(3)])},mediaEvents:["progress","emptied"]},MEDIA_STREAM_TYPE:{get:function(i){let{media:e}=i;if(!e)return;let{streamType:t}=e;if(ky.includes(t)){if(t===fi.UNKNOWN){let s=i.getAttribute("defaultstreamtype");return[fi.LIVE,fi.ON_DEMAND].includes(s)?s:void 0}return t}let r=e.duration;if(r===1/0)return fi.LIVE;if(Number.isFinite(r))return fi.ON_DEMAND;{let s=i.getAttribute("defaultstreamtype");if([fi.LIVE,fi.ON_DEMAND].includes(s))return s}},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},MEDIA_TARGET_LIVE_WINDOW:{get:function(i){let{media:e}=i;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,r=$t.MEDIA_STREAM_TYPE.get(i);return(t==null||Number.isNaN(t))&&r===fi.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},MEDIA_TIME_IS_LIVE:{get:function(i){let{media:e}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!($t.MEDIA_STREAM_TYPE.get(i)==="live"))return!1;let r=e.seekable;if(!r)return!0;if(!r.length)return!1;let s=i.hasAttribute("liveedgeoffset")?Number(i.getAttribute("liveedgeoffset")):10,n=r.end(r.length-1)-s;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},MEDIA_IS_FULLSCREEN:{get:function(i,e){var t;let r=i.media;if(r&&j[at.element]===void 0&&"webkitDisplayingFullscreen"in r)return r.webkitDisplayingFullscreen&&r.webkitPresentationMode==="fullscreen";let s;return e?s=j[at.element]?e.target:null:s=(t=i.getRootNode().fullscreenElement)!=null?t:j[at.element],Fr(i.fullscreenElement,s)},rootEvents:at.rootEvents,mediaEvents:at.mediaEvents},MEDIA_IS_PIP:{get:function(i,e){var t;let r=i.media;if(!r)return!1;if(e)return e.type=="enterpictureinpicture";{let s=(t=i.getRootNode().pictureInPictureElement)!=null?t:j.pictureInPictureElement;return Fr(r,s)}},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},MEDIA_IS_CASTING:{get:function(i,e){var t;let{media:r}=i;if(!r)return!1;let s=(t=w.CastableVideoElement)==null?void 0:t.castElement,n=Fr(r,s);return(e==null?void 0:e.type)==="castchange"&&(e==null?void 0:e.detail)==="CONNECTING"&&(n="connecting"),n},mediaEvents:["entercast","leavecast","castchange"]},MEDIA_AIRPLAY_UNAVAILABLE:{get:function(i,e){if(!np)return Xt.UNSUPPORTED;if(!!e&&e.availability!=="available"&&e.availability==="not-available")return Xt.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"]},MEDIA_CAST_UNAVAILABLE:{get:function(){var i;let e=(i=w.CastableVideoElement)==null?void 0:i.castState;if(!ap||!e)return Xt.UNSUPPORTED;if(!e.includes("CONNECT"))return Xt.UNAVAILABLE},mediaEvents:["castchange"]},MEDIA_FULLSCREEN_UNAVAILABLE:{get:function(){return tc?void 0:Xt.UNAVAILABLE}},MEDIA_PIP_UNAVAILABLE:{get:function(){return sp?void 0:Xt.UNSUPPORTED}},MEDIA_RENDITION_UNAVAILABLE:{get:function(i){var e;let{media:t}=i;if(!(t!=null&&t.videoRenditions))return Xt.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return Xt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_AUDIO_TRACK_UNAVAILABLE:{get:function(i){var e,t;let{media:r}=i;if(!(r!=null&&r.audioTracks))return Xt.UNSUPPORTED;if(((t=(e=r.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return Xt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},MEDIA_VOLUME_UNAVAILABLE:{get:function(i){if(io!==void 0&&!io)return Xt.UNSUPPORTED;let{media:e}=i;if(e&&typeof e.volume=="undefined")return Xt.UNAVAILABLE},mediaEvents:["loadstart"]},MEDIA_SUBTITLES_LIST:{get:function(i){return ic(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},MEDIA_SUBTITLES_SHOWING:{get:function(i){return i.hasAttribute("defaultsubtitles")&&!i.hasAttribute(S.MEDIA_HAS_PLAYED)&&!i.hasAttribute(S.MEDIA_SUBTITLES_SHOWING)&&er(i,!0),Ry(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"]},MEDIA_RENDITION_LIST:{get:function(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]]},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_RENDITION_SELECTED:{get:function(i){var e,t,r;let{media:s}=i;return(r=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:r.id},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},MEDIA_AUDIO_TRACK_LIST:{get:function(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},MEDIA_AUDIO_TRACK_ENABLED:{get:function(i){var e,t;let{media:r}=i;return(t=[...(e=r==null?void 0:r.audioTracks)!=null?e:[]].find(s=>s.enabled))==null?void 0:t.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]}},ro={MEDIA_PLAY_REQUEST:(i,e,t)=>{var r;let s=$t.MEDIA_STREAM_TYPE.get(t),n=t.getAttribute("noautoseektolive")===null;s==fi.LIVE&&n&&ro.MEDIA_SEEK_TO_LIVE_REQUEST(i),(r=i.play())==null||r.catch(()=>{})},MEDIA_PAUSE_REQUEST:i=>i.pause(),MEDIA_MUTE_REQUEST:i=>i.muted=!0,MEDIA_UNMUTE_REQUEST:i=>{i.muted=!1,i.volume===0&&(i.volume=.25)},MEDIA_VOLUME_REQUEST:(i,e,t)=>{let r=e.detail;if(i.volume=r,r>0&&i.muted&&(i.muted=!1),!t.hasAttribute("novolumepref"))try{w.localStorage.setItem("media-chrome-pref-volume",r.toString())}catch{}},MEDIA_ENTER_FULLSCREEN_REQUEST:(i,e,t)=>{if(!tc){console.warn("Fullscreen support is unavailable; not entering fullscreen");return}j.pictureInPictureElement&&j.exitPictureInPicture(),t[at.enter]?t.fullscreenElement[at.enter]():i.webkitEnterFullscreen?i.webkitEnterFullscreen():i.requestFullscreen?i.requestFullscreen():console.warn("MediaChrome: Fullscreen not supported")},MEDIA_EXIT_FULLSCREEN_REQUEST:()=>{j[at.exit]()},MEDIA_ENTER_PIP_REQUEST:i=>{if(!j.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!i.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}j[at.element]&&j[at.exit]();let e=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};i.requestPictureInPicture().catch(t=>{if(t.code===11)if(i.readyState===0&&i.preload==="none"){let r=()=>{i.removeEventListener("loadedmetadata",s),i.preload="none"},s=()=>{i.requestPictureInPicture().catch(e),r()};i.addEventListener("loadedmetadata",s),i.preload="metadata",setTimeout(()=>{i.readyState===0&&e(),r()},1e3)}else throw t;else throw t})},MEDIA_EXIT_PIP_REQUEST:()=>{j.pictureInPictureElement&&j.exitPictureInPicture()},MEDIA_ENTER_CAST_REQUEST:i=>{var e;!((e=w.CastableVideoElement)!=null&&e.castEnabled)||(j[at.element]&&j[at.exit](),i.requestCast())},MEDIA_EXIT_CAST_REQUEST:async()=>{var i;(i=w.CastableVideoElement)!=null&&i.castElement&&w.CastableVideoElement.exitCast()},MEDIA_SEEK_REQUEST:(i,e)=>{let t=e.detail;(i.readyState>0||i.readyState===void 0)&&(i.currentTime=t)},MEDIA_PLAYBACK_RATE_REQUEST:(i,e)=>{i.playbackRate=e.detail},MEDIA_PREVIEW_REQUEST:(i,e,t)=>{var r;if(!i)return;let s=e.detail;s===null&&t.propagateMediaState(S.MEDIA_PREVIEW_TIME,void 0),t.propagateMediaState(S.MEDIA_PREVIEW_TIME,s);let[n]=eo(i,{kind:Is.METADATA,label:"thumbnails"});if(!(n&&n.cues))return;if(s===null){t.propagateMediaState(S.MEDIA_PREVIEW_IMAGE,void 0),t.propagateMediaState(S.MEDIA_PREVIEW_COORDS,void 0);return}let a=Array.prototype.find.call(n.cues,c=>c.startTime>=s);if(!a)return;let o=/'^(?:[a-z]+:)?\/\//i.test(a.text)||(r=i.querySelector('track[label="thumbnails"]'))==null?void 0:r.src,l=new URL(a.text,o),d=new URLSearchParams(l.hash).get("#xywh");t.propagateMediaState(S.MEDIA_PREVIEW_IMAGE,l.href),t.propagateMediaState(S.MEDIA_PREVIEW_COORDS,d.split(","))},MEDIA_SHOW_SUBTITLES_REQUEST:(i,e,t)=>{let r=ic(t),{detail:s=[]}=e;Zd(Fa.SHOWING,r,s)},MEDIA_DISABLE_SUBTITLES_REQUEST:(i,e,t)=>{let r=ic(t),{detail:s=[]}=e;Zd(Fa.DISABLED,r,s)},MEDIA_AIRPLAY_REQUEST:i=>{if(!!i){if(!(i.webkitShowPlaybackTargetPicker&&w.WebKitPlaybackTargetAvailabilityEvent)){console.warn("received a request to select AirPlay but AirPlay is not supported in this environment");return}i.webkitShowPlaybackTargetPicker()}},MEDIA_SEEK_TO_LIVE_REQUEST:i=>{let e=i.seekable;if(!e){console.warn("MediaController: Media element does not support seeking to live.");return}if(!e.length){console.warn("MediaController: Media is unable to seek to live.");return}i.currentTime=e.end(e.length-1)},MEDIA_RENDITION_REQUEST:(i,e)=>{if(!(i!=null&&i.videoRenditions)){console.warn("MediaController: Rendition selection not supported by this media.");return}let t=e.detail,r=[...i.videoRenditions].findIndex(s=>s.id==t);i.videoRenditions.selectedIndex!=r&&(i.videoRenditions.selectedIndex=r)},MEDIA_AUDIO_TRACK_REQUEST:(i,e)=>{if(!(i!=null&&i.audioTracks)){console.warn("MediaController: Audio track selection not supported by this media.");return}let t=e.detail;for(let r of i.audioTracks)r.enabled=t==r.id}};var nc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Gr=(i,e,t)=>(nc(i,e,"read from private field"),t?t.call(i):e.get(i)),so=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},lp=(i,e,t,r)=>(nc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ws=(i,e,t)=>(nc(i,e,"access private method"),t),Er,Ln,Ds,kn,no,rc,mp=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],wy=10,dp=0,Ht={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys"},ao=class extends Xa{constructor(){super(),so(this,Ds),so(this,no),so(this,Er,new vr(this,Ht.HOTKEYS)),so(this,Ln,void 0),$t.MEDIA_VOLUME_UNAVAILABLE.get(this)===void 0&&op.then(()=>{this.propagateMediaState(S.MEDIA_VOLUME_UNAVAILABLE,$t.MEDIA_VOLUME_UNAVAILABLE.get(this))}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this),Object.keys(ro).forEach(e=>{let t=`_handle${Ba(e,!0)}`;this[t]=r=>{if(r.stopPropagation(),!this.media){console.warn("MediaController: No media available.");return}ro[e](this.media,r,this)},this.addEventListener(re[e],this[t])}),this._mediaStatePropagators={},Object.keys($t).forEach(e=>{this._mediaStatePropagators[e]=t=>{this.propagateMediaState(Nr[e],$t[e].get(this,t))}}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(Ht.NO_HOTKEYS,Ht.HOTKEYS,Ht.DEFAULT_STREAM_TYPE,Ht.DEFAULT_SUBTITLES)}get fullscreenElement(){var e;return(e=Gr(this,Ln))!=null?e:this}set fullscreenElement(e){this.hasAttribute(Ht.FULLSCREEN_ELEMENT)&&this.removeAttribute(Ht.FULLSCREEN_ELEMENT),lp(this,Ln,e)}attributeChangedCallback(e,t,r){var s;if(e===Ht.NO_HOTKEYS)r!==t&&r===""?(this.hasAttribute(Ht.HOTKEYS)&&console.warn("Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):r!==t&&r===null&&this.enableHotkeys();else if(e===Ht.HOTKEYS)Gr(this,Er).value=r;else if(e===Ht.DEFAULT_SUBTITLES&&r!==t&&r==="")er(this,!0);else if(e===Ht.DEFAULT_STREAM_TYPE)this.propagateMediaState(Nr.MEDIA_STREAM_TYPE);else if(e===Ht.FULLSCREEN_ELEMENT){let n=r?(s=this.getRootNode())==null?void 0:s.getElementById(r):void 0;lp(this,Ln,n)}super.attributeChangedCallback(e,t,r)}mediaSetCallback(e){if(super.mediaSetCallback(e),e.hasAttribute("tabindex")||(e.tabIndex=-1),Object.keys($t).forEach(t=>{let{mediaEvents:r,rootEvents:s,textTracksEvents:n,videoRenditionsEvents:a,audioTracksEvents:o}=$t[t],l=this._mediaStatePropagators[t];r==null||r.forEach(d=>{e.addEventListener(d,l),l()}),s==null||s.forEach(d=>{this.getRootNode().addEventListener(d,l),l()}),n==null||n.forEach(d=>{var c;(c=e.textTracks)==null||c.addEventListener(d,l),l()}),a==null||a.forEach(d=>{var c;(c=e.videoRenditions)==null||c.addEventListener(d,l),l()}),o==null||o.forEach(d=>{var c;(c=e.audioTracks)==null||c.addEventListener(d,l),l()})}),!this.hasAttribute("novolumepref"))try{let t=w.localStorage.getItem("media-chrome-pref-volume");t!==null&&(e.volume=t)}catch(t){console.debug("Error getting volume pref",t)}}mediaUnsetCallback(e){super.mediaUnsetCallback(e),Object.keys($t).forEach(t=>{let{mediaEvents:r,rootEvents:s,textTracksEvents:n,videoRenditionsEvents:a,audioTracksEvents:o}=$t[t],l=this._mediaStatePropagators[t];r==null||r.forEach(d=>{e.removeEventListener(d,l)}),s==null||s.forEach(d=>{this.getRootNode().removeEventListener(d,l)}),n==null||n.forEach(d=>{var c;(c=e.textTracks)==null||c.removeEventListener(d,l)}),a==null||a.forEach(d=>{var c;(c=e.videoRenditions)==null||c.removeEventListener(d,l),l()}),o==null||o.forEach(d=>{var c;(c=e.audioTracks)==null||c.removeEventListener(d,l),l()})}),this.propagateMediaState(Nr.MEDIA_PAUSED,!0)}propagateMediaState(e,t){let r=fp(this.mediaStateReceivers,e);if(hp(this.mediaStateReceivers,e,t),r===fp(this.mediaStateReceivers,e))return;let s=e.toLowerCase(),n=new w.CustomEvent(Mm[s],{composed:!0,bubbles:!0,detail:t});this.dispatchEvent(n)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let r=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=Ny(e,r,s);Object.keys(re).forEach(a=>{e.addEventListener(re[a],this[`_handle${Ba(a,!0)}`])}),t.set(e,n)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.keys(re).forEach(s=>{e.removeEventListener(re[s],this[`_handle${Ba(s,!0)}`])})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),Object.keys($t).forEach(s=>{let n=$t[s];hp([e],Nr[s],n.get(this))}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,r=t.indexOf(e);r<0||t.splice(r,1)}enableHotkeys(){this.addEventListener("keydown",ws(this,no,rc))}disableHotkeys(){this.removeEventListener("keydown",ws(this,no,rc)),this.removeEventListener("keyup",ws(this,Ds,kn))}get hotkeys(){return Gr(this,Er)}keyboardShortcutHandler(e){var t,r,s,n;if(((n=(s=(t=e.target.getAttribute(Ht.KEYS_USED))==null?void 0:t.split(" "))!=null?s:(r=e.target)==null?void 0:r.keysUsed)!=null?n:[]).map(f=>f==="Space"?" ":f).filter(Boolean).includes(e.key))return;let o,l,d,c,u,h=wy;if(!Gr(this,Er).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&Gr(this,Er).contains("nospace")))switch(e.key){case" ":case"k":o=this.getAttribute(S.MEDIA_PAUSED)!=null?re.MEDIA_PLAY_REQUEST:re.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new w.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"m":o=this.getAttribute(S.MEDIA_VOLUME_LEVEL)==="off"?re.MEDIA_UNMUTE_REQUEST:re.MEDIA_MUTE_REQUEST,this.dispatchEvent(new w.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"f":o=this.getAttribute(S.MEDIA_IS_FULLSCREEN)!=null?re.MEDIA_EXIT_FULLSCREEN_REQUEST:re.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new w.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"c":er(this);break;case"ArrowLeft":l=this.getAttribute(S.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:dp,c=Math.max(d-h,0),u=new w.CustomEvent(re.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break;case"ArrowRight":l=this.getAttribute(S.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:dp,c=Math.max(d+h,0),u=new w.CustomEvent(re.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break;default:break}}};Er=new WeakMap;Ln=new WeakMap;Ds=new WeakSet;kn=function(i){let{key:e}=i;if(!mp.includes(e)){this.removeEventListener("keyup",ws(this,Ds,kn));return}this.keyboardShortcutHandler(i)};no=new WeakSet;rc=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!mp.includes(r)){this.removeEventListener("keyup",ws(this,Ds,kn));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(Gr(this,Er).contains(`no${r.toLowerCase()}`)||r===" "&&Gr(this,Er).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",ws(this,Ds,kn),{once:!0})};var Dy=Object.values(S),Cy=Object.values(Nr),ac=i=>{var e,t,r,s;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)==null?void 0:e.includes("-"))&&(w.customElements.upgrade(i),{observedAttributes:n}=i.constructor);let a=(s=(r=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,ye.MEDIA_CHROME_ATTRIBUTES))==null?void 0:r.split)==null?void 0:s.call(r,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>Dy.includes(o)):[]},My=i=>{var e,t;return((e=i.nodeName)==null?void 0:e.includes("-"))&&!!w.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof w.customElements.get(i.nodeName.toLowerCase()))&&w.customElements.upgrade(i),Cy.some(r=>r in i)},sc=i=>My(i)||!!ac(i).length,cp=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},up={[S.MEDIA_SUBTITLES_LIST]:$r,[S.MEDIA_SUBTITLES_SHOWING]:$r,[S.MEDIA_SEEKABLE]:cp,[S.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(cp).join(" "),[S.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[S.MEDIA_RENDITION_LIST]:Om,[S.MEDIA_AUDIO_TRACK_LIST]:Nm},Oy=async(i,e,t)=>{var r,s;if(i.isConnected||await Ha(0),typeof t=="boolean"||t==null)return Ke(i,e,t);if(typeof t=="number")return ze(i,e,t);if(typeof t=="string")return Be(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);let n=(s=(r=up[e])==null?void 0:r.call(up,t))!=null?s:t;return i.setAttribute(e,n)},Py=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Hr=(i,e)=>{if(Py(i))return;let t=(s,n)=>{var a,o;sc(s)&&n(s);let{children:l=[]}=s!=null?s:{},d=(o=(a=s==null?void 0:s.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(u=>Hr(u,n))},r=i==null?void 0:i.nodeName.toLowerCase();if(r.includes("-")&&!sc(i)){w.customElements.whenDefined(r).then(()=>{t(i,e)});return}t(i,e)},hp=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}let s=ac(r),n=e.toLowerCase();!s.includes(n)||Oy(r,n,t)})},fp=(i,e)=>{for(let t of i){if(e in t)return t[e];let r=ac(t),s=e.toLowerCase();if(!!r.includes(s))return t.getAttribute(s)}},Ny=(i,e,t)=>{Hr(i,e);let r=c=>{var u;let h=(u=c==null?void 0:c.composedPath()[0])!=null?u:c.target;e(h)},s=c=>{var u;let h=(u=c==null?void 0:c.composedPath()[0])!=null?u:c.target;t(h)};i.addEventListener(re.REGISTER_MEDIA_STATE_RECEIVER,r),i.addEventListener(re.UNREGISTER_MEDIA_STATE_RECEIVER,s);let n=c=>{c.forEach(u=>{let{addedNodes:h=[],removedNodes:f=[],type:g,target:E,attributeName:T}=u;g==="childList"?(Array.prototype.forEach.call(h,A=>Hr(A,e)),Array.prototype.forEach.call(f,A=>Hr(A,t))):g==="attributes"&&T===ye.MEDIA_CHROME_ATTRIBUTES&&(sc(E)?e(E):t(E))})},a=[],o=c=>{let u=c.target;u.name!=="media"&&(a.forEach(h=>Hr(h,t)),a=[...u.assignedElements({flatten:!0})],a.forEach(h=>Hr(h,e)))};i.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{Hr(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener(re.REGISTER_MEDIA_STATE_RECEIVER,r),i.removeEventListener(re.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};w.customElements.get("media-controller")||w.customElements.define("media-controller",ao);var oc=ao;var mc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},tr=(i,e,t)=>(mc(i,e,"read from private field"),t?t.call(i):e.get(i)),mi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Rn=(i,e,t,r)=>(mc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Di=(i,e,t)=>(mc(i,e,"access private method"),t),Ci,fo,oo,lo,co,lc,uo,dc,ho,pc,cc,pp,uc,gp,hc,vp,fc,Ep,bp=j.createElement("template");bp.innerHTML=`
239
+ `;var xT=Object.values(S),IT="sm:384 md:576 lg:768 xl:960";function LT(i){RT(i.target,i.contentRect.width)}function RT(i,e){var t;if(!i.isConnected)return;let r=(t=i.getAttribute(Le.BREAKPOINTS))!=null?t:IT,s=kT(r),n=wT(s,e),a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){let o=new CustomEvent(Yi.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}}function kT(i){let e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function wT(i,e){return Object.keys(i).filter(t=>e>=i[t])}var io=class extends w.HTMLElement{constructor(){super(),Pr(this,Ec),Pr(this,bc),Pr(this,Rn),Pr(this,so),Pr(this,ws),Pr(this,to,0),Pr(this,lr,void 0),ST(this,"breakpointsComputed",!1),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(qp.content.cloneNode(!0)));let e=a=>{let o=this.media;for(let l of a)l.type==="childList"&&(l.removedNodes.forEach(d=>{if(d.slot=="media"&&l.target==this){let c=l.previousSibling&&l.previousSibling.previousElementSibling;if(!c||!o)this.mediaUnsetCallback(d);else{let u=c.slot!=="media";for(;(c=c.previousSibling)!==null;)c.slot=="media"&&(u=!1);u&&this.mediaUnsetCallback(d)}}}),o&&l.addedNodes.forEach(d=>{d===o&&o!==Ln(this,lr)&&this.handleMediaUpdated(o).then(c=>this.mediaSetCallback(c))}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let r=!1;In(this,a=>{r||(setTimeout(()=>{LT(a),r=!1,this.breakpointsComputed||(this.breakpointsComputed=!0,this.dispatchEvent(new CustomEvent(Yi.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))},0),r=!0)});let n=this.querySelector(":scope > slot[slot=media]");n&&n.addEventListener("slotchange",()=>{if(!n.assignedElements({flatten:!0}).length){this.mediaUnsetCallback(Ln(this,lr));return}this.media&&this.media!==Ln(this,lr)&&this.handleMediaUpdated(this.media).then(o=>this.mediaSetCallback(o))})}static get observedAttributes(){return[Le.AUTOHIDE,Le.GESTURES_DISABLED].concat(xT).filter(e=>![S.MEDIA_RENDITION_LIST,S.MEDIA_AUDIO_TRACK_LIST].includes(e))}attributeChangedCallback(e,t,r){e.toLowerCase()==Le.AUTOHIDE&&(this.autohide=r)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){vc(this,lr,e);let t=r=>(vc(this,lr,null),console.error('Media Chrome: Media element set with slot="media" does not appear to be compatible.',r),Promise.reject(r));return e?(e.localName.includes("-")&&await w.customElements.whenDefined(e.localName),e):t(e)}connectedCallback(){var e;let r=this.getAttribute(Le.AUDIO)!=null?St.AUDIO_PLAYER():St.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",r),this.media&&this.media!==Ln(this,lr)&&this.handleMediaUpdated(this.media).then(s=>this.mediaSetCallback(s)),this.setAttribute(Le.USER_INACTIVE,""),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=w.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;this.media&&this.mediaUnsetCallback(this.media),(e=w.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){}handleEvent(e){switch(e.type){case"pointerdown":vc(this,to,e.timeStamp);break;case"pointermove":hi(this,Ec,Kp).call(this,e);break;case"pointerup":hi(this,bc,Wp).call(this,e);break;case"mouseleave":hi(this,Rn,ro).call(this);break;case"mouseup":this.removeAttribute(Le.KEYBOARD_CONTROL);break;case"keyup":hi(this,ws,kn).call(this),this.setAttribute(Le.KEYBOARD_CONTROL,"");break}}set autohide(e){e=Number(e),this._autohide=isNaN(e)?0:e}get autohide(){return this._autohide===void 0?2:this._autohide}};to=new WeakMap;lr=new WeakMap;Ec=new WeakSet;Kp=function(i){i.pointerType!=="mouse"&&i.timeStamp-Ln(this,to)<250||(hi(this,so,Tc).call(this),clearTimeout(this._inactiveTimeout),[this,this.media].includes(i.target)&&hi(this,ws,kn).call(this))};bc=new WeakSet;Wp=function(i){if(i.pointerType==="touch"){let e=!this.hasAttribute(Le.USER_INACTIVE);[this,this.media].includes(i.target)&&e?hi(this,Rn,ro).call(this):hi(this,ws,kn).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&hi(this,ws,kn).call(this)};Rn=new WeakSet;ro=function(){if(this.autohide<0||this.hasAttribute(Le.USER_INACTIVE))return;this.setAttribute(Le.USER_INACTIVE,"");let i=new w.CustomEvent(Yi.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};so=new WeakSet;Tc=function(){if(!this.hasAttribute(Le.USER_INACTIVE))return;this.removeAttribute(Le.USER_INACTIVE);let i=new w.CustomEvent(Yi.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};ws=new WeakSet;kn=function(){hi(this,so,Tc).call(this),clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=setTimeout(()=>{hi(this,Rn,ro).call(this)},this.autohide*1e3))};var Yp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},mt=(i,e,t)=>(Yp(i,e,"read from private field"),t?t.call(i):e.get(i)),wn=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},no=(i,e,t,r)=>(Yp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ds,Cs,ao,Or,ji,dr,cr=class{constructor(e,t,{defaultValue:r}={defaultValue:void 0}){wn(this,ji),wn(this,Ds,void 0),wn(this,Cs,void 0),wn(this,ao,void 0),wn(this,Or,new Set),no(this,Ds,e),no(this,Cs,t),no(this,ao,new Set(r))}[Symbol.iterator](){return mt(this,ji,dr).values()}get length(){return mt(this,ji,dr).size}get value(){var e;return(e=[...mt(this,ji,dr)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(no(this,Or,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...mt(this,ji,dr)][e]}values(){return mt(this,ji,dr).values()}forEach(e){mt(this,ji,dr).forEach(e)}add(...e){var t,r;e.forEach(s=>mt(this,Or).add(s)),!(this.value===""&&!((t=mt(this,Ds))!=null&&t.hasAttribute(`${mt(this,Cs)}`)))&&((r=mt(this,Ds))==null||r.setAttribute(`${mt(this,Cs)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>mt(this,Or).delete(r)),(t=mt(this,Ds))==null||t.setAttribute(`${mt(this,Cs)}`,`${this.value}`)}contains(e){return mt(this,ji,dr).has(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}};Ds=new WeakMap;Cs=new WeakMap;ao=new WeakMap;Or=new WeakMap;ji=new WeakSet;dr=function(){return mt(this,Or).size?mt(this,Or):mt(this,ao)};var DT=(i="")=>i.split(/\s+/),jp=(i="")=>{let[e,t,r]=i.split(":"),s=r?decodeURIComponent(r):void 0;return e=e==="cc"?"captions":"subtitles",{kind:e,language:t,label:s}},Dn=(i="",e={})=>DT(i).map(t=>{let r=jp(t);return{...e,...r}}),_c=i=>Array.isArray(i)?i.map(e=>typeof e=="string"?jp(e):e):typeof i=="string"?Dn(i):[i],oo=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,Nr=(i=[])=>Array.prototype.map.call(i,oo).join(" "),CT=(i,e)=>t=>t[i]===e,zp=i=>{let e=Object.entries(i).map(([t,r])=>CT(t,r));return t=>e.every(r=>r(t))},Cn=(i,e=[],t=[])=>{let r=_c(t).map(zp),s=n=>r.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=i})},lo=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];let t=typeof e=="function"?e:zp(e);return Array.from(i.textTracks).filter(t)},Xp=i=>!!i.getAttribute(S.MEDIA_SUBTITLES_SHOWING);var Je={enter:"requestFullscreen",exit:"exitFullscreen",rootEvents:["fullscreenchange"],mediaEvents:[],element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};q.fullscreenElement===void 0&&(Je.enter="webkitRequestFullScreen",Je.exit=q.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",Je.rootEvents=["webkitfullscreenchange"],Je.mediaEvents=["webkitbeginfullscreen","webkitendfullscreen"],Je.element="webkitFullscreenElement",Je.error="webkitfullscreenerror",Je.enabled="webkitFullscreenEnabled");var co,Ac=()=>{var i,e;return co||(co=(e=(i=q)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),co)},Qp=async(i=Ac())=>{if(!i)return!1;let e=i.volume;return i.volume=e/2+.1,await qa(0),i.volume!==e},MT=(i=Ac())=>typeof(i==null?void 0:i.requestPictureInPicture)=="function",PT=(i=Ac())=>{let e=q[Je.enabled];return!e&&i&&(e="webkitSupportsFullscreen"in i),e},Sc=PT(),Zp=MT(),Jp=!!w.WebKitPlaybackTargetAvailabilityEvent,eg=!!w.chrome;var ho,tg=Qp().then(i=>(ho=i,ho)),OT=Object.values(ui),uo=i=>lo(i.media,e=>[Ls.SUBTITLES,Ls.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),ig=i=>lo(i.media,e=>e.mode===Rs.SHOWING&&[Ls.SUBTITLES,Ls.CAPTIONS].includes(e.kind)),Bt={MEDIA_PAUSED:{get:function(i){let{media:e}=i;return e?e.paused:!0},mediaEvents:["play","playing","pause","emptied"]},MEDIA_HAS_PLAYED:{get:function(i){let{media:e}=i;return e?!e.paused:!1},mediaEvents:["playing","emptied"]},MEDIA_ENDED:{get:function(i){let{media:e}=i;return e?e.ended:!1},mediaEvents:["seeked","ended","emptied"]},MEDIA_PLAYBACK_RATE:{get:function(i){let{media:e}=i;return!e||typeof e.playbackRate=="undefined"?1:e.playbackRate},mediaEvents:["ratechange","loadstart"]},MEDIA_MUTED:{get:function(i){let{media:e}=i;return!e||typeof e.muted=="undefined"?!1:e.muted},mediaEvents:["volumechange"]},MEDIA_VOLUME:{get:function(i){let{media:e}=i;return!e||typeof e.volume=="undefined"?1:Number(e.volume)},mediaEvents:["volumechange"]},MEDIA_VOLUME_LEVEL:{get:function(i){let{media:e}=i,t="high";if(!e||typeof e.volume=="undefined")return t;let{muted:r,volume:s}=e;return s===0||r?t="off":s<.5?t="low":s<.75&&(t="medium"),t},mediaEvents:["volumechange"]},MEDIA_CURRENT_TIME:{get:function(i){let{media:e}=i;return!e||typeof e.currentTime=="undefined"?0:e.currentTime},mediaEvents:["playing","pause","timeupdate","loadedmetadata"]},MEDIA_DURATION:{get:function(i){let{media:e}=i;return i.hasAttribute("defaultduration")&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?+i.getAttribute("defaultduration"):!e||!Number.isFinite(e.duration)?Number.NaN:e.duration},mediaEvents:["durationchange","loadedmetadata","emptied"]},MEDIA_SEEKABLE:{get:function(i){var e;let{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;let r=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!r&&!s))return[Number(r.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress"]},MEDIA_LOADING:{get:function(i){var e;return((e=i.media)==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},MEDIA_BUFFERED:{get:function(i){var e,t,r;let s=(e=i.media)==null?void 0:e.buffered;return Array.from((r=(t=i.media)==null?void 0:t.buffered)!=null?r:[]).map((n,a)=>[Number(s.start(a)).toFixed(3),Number(s.end(a)).toFixed(3)])},mediaEvents:["progress","emptied"]},MEDIA_STREAM_TYPE:{get:function(i){let{media:e}=i;if(!e)return;let{streamType:t}=e;if(OT.includes(t)){if(t===ui.UNKNOWN){let s=i.getAttribute("defaultstreamtype");return[ui.LIVE,ui.ON_DEMAND].includes(s)?s:void 0}return t}let r=e.duration;if(r===1/0)return ui.LIVE;if(Number.isFinite(r))return ui.ON_DEMAND;{let s=i.getAttribute("defaultstreamtype");if([ui.LIVE,ui.ON_DEMAND].includes(s))return s}},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},MEDIA_TARGET_LIVE_WINDOW:{get:function(i){let{media:e}=i;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,r=Bt.MEDIA_STREAM_TYPE.get(i);return(t==null||Number.isNaN(t))&&r===ui.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},MEDIA_TIME_IS_LIVE:{get:function(i){let{media:e}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(Bt.MEDIA_STREAM_TYPE.get(i)==="live"))return!1;let r=e.seekable;if(!r)return!0;if(!r.length)return!1;let s=i.hasAttribute("liveedgeoffset")?Number(i.getAttribute("liveedgeoffset")):10,n=r.end(r.length-1)-s;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},MEDIA_IS_FULLSCREEN:{get:function(i,e){var t,r;let s=i.media;if(s&&q[Je.element]===void 0&&"webkitDisplayingFullscreen"in s)return s.webkitDisplayingFullscreen&&s.webkitPresentationMode==="fullscreen";let n;return e?n=q[Je.element]?e.target:null:n=(r=(t=Lp(i))==null?void 0:t.fullscreenElement)!=null?r:q[Je.element],nr(i.fullscreenElement,n)},rootEvents:Je.rootEvents,mediaEvents:Je.mediaEvents},MEDIA_IS_PIP:{get:function(i,e){var t;let r=i.media;if(!r)return!1;if(e)return e.type=="enterpictureinpicture";{let s=(t=i.getRootNode().pictureInPictureElement)!=null?t:q.pictureInPictureElement;return nr(r,s)}},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},MEDIA_IS_AIRPLAYING:{get:function(i){var e;let{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:t.remote.state},remoteEvents:["playing","connect","connecting","disconnect"]},MEDIA_IS_CASTING:{get:function(i){var e;let{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:t.remote.state},remoteEvents:["connect","connecting","disconnect"]},MEDIA_AIRPLAY_UNAVAILABLE:{get:function(i,{availability:e=!1}={}){if(!Jp)return jt.UNSUPPORTED;if(!(e==null||e===!0))return jt.UNAVAILABLE},mediaSetCallback(i,e){var t;(t=i.remote)==null||t.watchAvailability(r=>e({availability:r}))},mediaUnsetCallback(i){var e;(e=i.remote)==null||e.cancelWatchAvailability()}},MEDIA_CAST_UNAVAILABLE:{get:function(i,{availability:e=!1}={}){var t;let{media:r}=i;if(!eg||!((t=r==null?void 0:r.remote)!=null&&t.state))return jt.UNSUPPORTED;if(!(e==null||e===!0))return jt.UNAVAILABLE},mediaSetCallback(i,e){var t;(t=i.remote)==null||t.watchAvailability(r=>e({availability:r}))},mediaUnsetCallback(i){var e;(e=i.remote)==null||e.cancelWatchAvailability()}},MEDIA_FULLSCREEN_UNAVAILABLE:{get:function(){return Sc?void 0:jt.UNAVAILABLE}},MEDIA_PIP_UNAVAILABLE:{get:function(){return Zp?void 0:jt.UNSUPPORTED}},MEDIA_RENDITION_UNAVAILABLE:{get:function(i){var e;let{media:t}=i;if(!(t!=null&&t.videoRenditions))return jt.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return jt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_AUDIO_TRACK_UNAVAILABLE:{get:function(i){var e,t;let{media:r}=i;if(!(r!=null&&r.audioTracks))return jt.UNSUPPORTED;if(((t=(e=r.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return jt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},MEDIA_VOLUME_UNAVAILABLE:{get:function(i){if(ho!==void 0&&!ho)return jt.UNSUPPORTED;let{media:e}=i;if(e&&typeof e.volume=="undefined")return jt.UNAVAILABLE},mediaEvents:["loadstart"]},MEDIA_SUBTITLES_LIST:{get:function(i){return uo(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},MEDIA_SUBTITLES_SHOWING:{get:function(i){return i.hasAttribute("defaultsubtitles")&&!i.hasAttribute(S.MEDIA_HAS_PLAYED)&&!i.hasAttribute(S.MEDIA_SUBTITLES_SHOWING)&&Mn.MEDIA_TOGGLE_SUBTITLES_REQUEST(void 0,void 0,i),ig(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"]},MEDIA_RENDITION_LIST:{get:function(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]]},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_RENDITION_SELECTED:{get:function(i){var e,t,r;let{media:s}=i;return(r=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:r.id},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},MEDIA_AUDIO_TRACK_LIST:{get:function(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},MEDIA_AUDIO_TRACK_ENABLED:{get:function(i){var e,t;let{media:r}=i;return(t=[...(e=r==null?void 0:r.audioTracks)!=null?e:[]].find(s=>s.enabled))==null?void 0:t.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]}},Mn={MEDIA_PLAY_REQUEST:(i,e,t)=>{var r;let s=Bt.MEDIA_STREAM_TYPE.get(t),n=t.getAttribute("noautoseektolive")===null;s==ui.LIVE&&n&&Mn.MEDIA_SEEK_TO_LIVE_REQUEST(i),(r=i.play())==null||r.catch(()=>{})},MEDIA_PAUSE_REQUEST:i=>i.pause(),MEDIA_MUTE_REQUEST:i=>i.muted=!0,MEDIA_UNMUTE_REQUEST:i=>{i.muted=!1,i.volume===0&&(i.volume=.25)},MEDIA_VOLUME_REQUEST:(i,e,t)=>{let r=e.detail;if(i.volume=r,r>0&&i.muted&&(i.muted=!1),!t.hasAttribute("novolumepref"))try{w.localStorage.setItem("media-chrome-pref-volume",r.toString())}catch{}},MEDIA_ENTER_FULLSCREEN_REQUEST:(i,e,t)=>{if(!Sc){console.warn("MediaChrome: Fullscreen support is unavailable; not entering fullscreen");return}q.pictureInPictureElement&&q.exitPictureInPicture(),t[Je.enter]?t.fullscreenElement[Je.enter]():i.webkitEnterFullscreen?i.webkitEnterFullscreen():i.requestFullscreen?i.requestFullscreen():console.warn("MediaChrome: Fullscreen not supported")},MEDIA_EXIT_FULLSCREEN_REQUEST:()=>{q[Je.exit]()},MEDIA_ENTER_PIP_REQUEST:i=>{if(!q.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!i.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}q[Je.element]&&q[Je.exit]();let e=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};i.requestPictureInPicture().catch(t=>{if(t.code===11)if(i.readyState===0&&i.preload==="none"){let r=()=>{i.removeEventListener("loadedmetadata",s),i.preload="none"},s=()=>{i.requestPictureInPicture().catch(e),r()};i.addEventListener("loadedmetadata",s),i.preload="metadata",setTimeout(()=>{i.readyState===0&&e(),r()},1e3)}else throw t;else throw t})},MEDIA_EXIT_PIP_REQUEST:()=>{q.pictureInPictureElement&&q.exitPictureInPicture()},MEDIA_ENTER_CAST_REQUEST:async i=>{var e;if(((e=i.remote)==null?void 0:e.state)==="disconnected"){if(q[Je.element]&&q[Je.exit](),!i.remote.prompt){console.warn("MediaChrome: Casting is not supported in this environment");return}try{await i.remote.prompt()}catch{}}},MEDIA_EXIT_CAST_REQUEST:i=>{var e;((e=i.remote)==null?void 0:e.state)==="connected"&&i.remote.prompt()},MEDIA_SEEK_REQUEST:(i,e)=>{let t=e.detail;(i.readyState>0||i.readyState===void 0)&&(i.currentTime=t)},MEDIA_PLAYBACK_RATE_REQUEST:(i,e)=>{i.playbackRate=e.detail},MEDIA_PREVIEW_REQUEST:(i,e,t)=>{var r;if(!i)return;let s=e.detail;s===null&&t.propagateMediaState(S.MEDIA_PREVIEW_TIME,void 0),t.propagateMediaState(S.MEDIA_PREVIEW_TIME,s);let[n]=lo(i,{kind:Ls.METADATA,label:"thumbnails"});if(!(n&&n.cues))return;if(s===null){t.propagateMediaState(S.MEDIA_PREVIEW_IMAGE,void 0),t.propagateMediaState(S.MEDIA_PREVIEW_COORDS,void 0);return}let a=Array.prototype.find.call(n.cues,c=>c.startTime>=s);if(!a)return;let o=/'^(?:[a-z]+:)?\/\//i.test(a.text)||(r=i.querySelector('track[label="thumbnails"]'))==null?void 0:r.src,l=new URL(a.text,o),d=new URLSearchParams(l.hash).get("#xywh");t.propagateMediaState(S.MEDIA_PREVIEW_IMAGE,l.href),t.propagateMediaState(S.MEDIA_PREVIEW_COORDS,d.split(","))},MEDIA_SHOW_SUBTITLES_REQUEST:(i,e,t)=>{var r;let s=uo(t),{detail:n=[]}=e,a=_c(n),o=(r=a[0])==null?void 0:r.language;o&&!(t!=null&&t.hasAttribute("nosubtitleslangpref"))&&w.localStorage.setItem("media-chrome-pref-subtitles-lang",o),Cn(Rs.SHOWING,s,a)},MEDIA_DISABLE_SUBTITLES_REQUEST:(i,e,t)=>{let r=uo(t),{detail:s=[]}=e;Cn(Rs.DISABLED,r,s)},MEDIA_TOGGLE_SUBTITLES_REQUEST:(i,e,t)=>{let{detail:r}=e!=null?e:{},s=uo(t),n=ig(t),a=!!n.length;if(!(!s.length||a&&r||!a&&r===!1))if(a)Cn(Rs.DISABLED,s,n);else{let o=s[0];if(!(t!=null&&t.hasAttribute("nosubtitleslangpref"))){let u=w.localStorage.getItem("media-chrome-pref-subtitles-lang"),h=u?[u,...w.navigator.languages]:w.navigator.languages,f=s.filter(g=>h.some(E=>g.language.toLowerCase().startsWith(E.split("-")[0]))).sort((g,E)=>{let T=h.findIndex(R=>g.language.toLowerCase().startsWith(R.split("-")[0])),A=h.findIndex(R=>E.language.toLowerCase().startsWith(R.split("-")[0]));return T-A});f[0]&&(o=f[0])}let{language:l,label:d,kind:c}=o;Cn(Rs.SHOWING,s,[{language:l,label:d,kind:c}])}},MEDIA_AIRPLAY_REQUEST:async i=>{if(i!=null&&i.remote){if(!i.remote.prompt){console.warn("MediaChrome: AirPlay is not supported in this environment");return}try{await i.remote.prompt()}catch{}}},MEDIA_SEEK_TO_LIVE_REQUEST:i=>{let e=i.seekable;if(!e){console.warn("MediaChrome: Media element does not support seeking to live.");return}if(!e.length){console.warn("MediaChrome: Media is unable to seek to live.");return}i.currentTime=e.end(e.length-1)},MEDIA_RENDITION_REQUEST:(i,e)=>{if(!(i!=null&&i.videoRenditions)){console.warn("MediaChrome: Rendition selection not supported by this media.");return}let t=e.detail,r=[...i.videoRenditions].findIndex(s=>s.id==t);i.videoRenditions.selectedIndex!=r&&(i.videoRenditions.selectedIndex=r)},MEDIA_AUDIO_TRACK_REQUEST:(i,e)=>{if(!(i!=null&&i.audioTracks)){console.warn("MediaChrome: Audio track selection not supported by this media.");return}let t=e.detail;for(let r of i.audioTracks)r.enabled=t==r.id}};var Rc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ii=(i,e,t)=>(Rc(i,e,"read from private field"),t?t.call(i):e.get(i)),Pn=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},xc=(i,e,t,r)=>(Rc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ps=(i,e,t)=>(Rc(i,e,"access private method"),t),ur,On,Ms,Os,Nn,fo,Ic,lg=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],NT=10,rg=0,Dt={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys"},mo=class extends io{constructor(){super(),Pn(this,Os),Pn(this,fo),Pn(this,ur,new cr(this,Dt.HOTKEYS)),Pn(this,On,void 0),Pn(this,Ms,void 0),Bt.MEDIA_VOLUME_UNAVAILABLE.get(this)===void 0&&tg.then(()=>{this.propagateMediaState(S.MEDIA_VOLUME_UNAVAILABLE,Bt.MEDIA_VOLUME_UNAVAILABLE.get(this))}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this),Object.keys(Mn).forEach(e=>{let t=`_handle${Ka(e,!0)}`;this[t]=r=>{if(r.stopPropagation(),!this.media){console.warn("MediaController: No media available.");return}Mn[e](this.media,r,this)},this.addEventListener(ee[e],this[t])}),this._mediaStatePropagators={},Object.keys(Bt).forEach(e=>{this._mediaStatePropagators[e]=t=>{this.propagateMediaState(Cr[e],Bt[e].get(this,t))}})}static get observedAttributes(){return super.observedAttributes.concat(Dt.NO_HOTKEYS,Dt.HOTKEYS,Dt.DEFAULT_STREAM_TYPE,Dt.DEFAULT_SUBTITLES,Dt.DEFAULT_DURATION)}get fullscreenElement(){var e;return(e=Ii(this,On))!=null?e:this}set fullscreenElement(e){this.hasAttribute(Dt.FULLSCREEN_ELEMENT)&&this.removeAttribute(Dt.FULLSCREEN_ELEMENT),xc(this,On,e)}attributeChangedCallback(e,t,r){var s;if(super.attributeChangedCallback(e,t,r),e===Dt.NO_HOTKEYS)r!==t&&r===""?(this.hasAttribute(Dt.HOTKEYS)&&console.warn("Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):r!==t&&r===null&&this.enableHotkeys();else if(e===Dt.HOTKEYS)Ii(this,ur).value=r;else if(e===Dt.DEFAULT_SUBTITLES&&r!==t&&r==="")this.dispatchEvent(new w.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:!0}));else if(e===Dt.DEFAULT_STREAM_TYPE)this.propagateMediaState(Cr.MEDIA_STREAM_TYPE);else if(e===Dt.FULLSCREEN_ELEMENT){let n=r?(s=Ii(this,Ms))==null?void 0:s.getElementById(r):void 0;xc(this,On,n)}}connectedCallback(){super.connectedCallback(),xc(this,Ms,this.getRootNode()),this.enableHotkeys()}disconnectedCallback(){super.disconnectedCallback(),this.disableHotkeys(),this.dispatchEvent(new w.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:!1}))}mediaSetCallback(e){if(super.mediaSetCallback(e),e.hasAttribute("tabindex")||(e.tabIndex=-1),Object.keys(Bt).forEach(t=>{let{mediaSetCallback:r,mediaEvents:s,rootEvents:n,textTracksEvents:a,videoRenditionsEvents:o,audioTracksEvents:l,remoteEvents:d}=Bt[t],c=this._mediaStatePropagators[t];r&&(r(e,c),c()),s==null||s.forEach(u=>{e.addEventListener(u,c),c()}),n==null||n.forEach(u=>{var h;(h=Ii(this,Ms))==null||h.addEventListener(u,c),c()}),a==null||a.forEach(u=>{var h;(h=e.textTracks)==null||h.addEventListener(u,c),c()}),o==null||o.forEach(u=>{var h;(h=e.videoRenditions)==null||h.addEventListener(u,c),c()}),l==null||l.forEach(u=>{var h;(h=e.audioTracks)==null||h.addEventListener(u,c),c()}),d==null||d.forEach(u=>{var h;(h=e.remote)==null||h.addEventListener(u,c),c()})}),!this.hasAttribute("novolumepref"))try{let t=w.localStorage.getItem("media-chrome-pref-volume");t!==null&&(e.volume=t)}catch(t){console.debug("Error getting volume pref",t)}}mediaUnsetCallback(e){super.mediaUnsetCallback(e),Object.keys(Bt).forEach(t=>{let{mediaUnsetCallback:r,mediaEvents:s,rootEvents:n,textTracksEvents:a,videoRenditionsEvents:o,audioTracksEvents:l,remoteEvents:d}=Bt[t],c=this._mediaStatePropagators[t];s==null||s.forEach(u=>{e.removeEventListener(u,c)}),n==null||n.forEach(u=>{var h;(h=Ii(this,Ms))==null||h.removeEventListener(u,c)}),a==null||a.forEach(u=>{var h;(h=e.textTracks)==null||h.removeEventListener(u,c)}),o==null||o.forEach(u=>{var h;(h=e.videoRenditions)==null||h.removeEventListener(u,c),c()}),l==null||l.forEach(u=>{var h;(h=e.audioTracks)==null||h.removeEventListener(u,c),c()}),d==null||d.forEach(u=>{var h;(h=e.remote)==null||h.removeEventListener(u,c),c()}),r&&(r(e,c),c())}),this.propagateMediaState(Cr.MEDIA_PAUSED,!0)}propagateMediaState(e,t){let r=og(this.mediaStateReceivers,e);if(ag(this.mediaStateReceivers,e,t),r===og(this.mediaStateReceivers,e))return;let s=e.toLowerCase(),n=new w.CustomEvent(bp[s],{composed:!0,bubbles:!0,detail:t});this.dispatchEvent(n)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let r=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=GT(e,r,s);Object.keys(ee).forEach(a=>{e.addEventListener(ee[a],this[`_handle${Ka(a,!0)}`])}),t.set(e,n)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.keys(ee).forEach(s=>{e.removeEventListener(ee[s],this[`_handle${Ka(s,!0)}`])})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),Object.keys(Bt).forEach(s=>{let n=Bt[s];ag([e],Cr[s],n.get(this))}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,r=t.indexOf(e);r<0||t.splice(r,1)}enableHotkeys(){this.addEventListener("keydown",Ps(this,fo,Ic))}disableHotkeys(){this.removeEventListener("keydown",Ps(this,fo,Ic)),this.removeEventListener("keyup",Ps(this,Os,Nn))}get hotkeys(){return Ii(this,ur)}keyboardShortcutHandler(e){var t,r,s,n;if(((n=(s=(t=e.target.getAttribute(Dt.KEYS_USED))==null?void 0:t.split(" "))!=null?s:(r=e.target)==null?void 0:r.keysUsed)!=null?n:[]).map(f=>f==="Space"?" ":f).filter(Boolean).includes(e.key))return;let o,l,d,c,u,h=NT;if(!Ii(this,ur).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&Ii(this,ur).contains("nospace")))switch(e.key){case" ":case"k":o=this.getAttribute(S.MEDIA_PAUSED)!=null?ee.MEDIA_PLAY_REQUEST:ee.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new w.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"m":o=this.getAttribute(S.MEDIA_VOLUME_LEVEL)==="off"?ee.MEDIA_UNMUTE_REQUEST:ee.MEDIA_MUTE_REQUEST,this.dispatchEvent(new w.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"f":o=this.getAttribute(S.MEDIA_IS_FULLSCREEN)!=null?ee.MEDIA_EXIT_FULLSCREEN_REQUEST:ee.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new w.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new w.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":l=this.getAttribute(S.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:rg,c=Math.max(d-h,0),u=new w.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break;case"ArrowRight":l=this.getAttribute(S.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:rg,c=Math.max(d+h,0),u=new w.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break;default:break}}};ur=new WeakMap;On=new WeakMap;Ms=new WeakMap;Os=new WeakSet;Nn=function(i){let{key:e}=i;if(!lg.includes(e)){this.removeEventListener("keyup",Ps(this,Os,Nn));return}this.keyboardShortcutHandler(i)};fo=new WeakSet;Ic=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!lg.includes(r)){this.removeEventListener("keyup",Ps(this,Os,Nn));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(Ii(this,ur).contains(`no${r.toLowerCase()}`)||r===" "&&Ii(this,ur).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",Ps(this,Os,Nn),{once:!0})};var UT=Object.values(S),FT=Object.values(Cr),kc=i=>{var e,t,r,s;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)!=null&&e.includes("-"))&&(w.customElements.upgrade(i),{observedAttributes:n}=i.constructor);let a=(s=(r=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,pe.MEDIA_CHROME_ATTRIBUTES))==null?void 0:r.split)==null?void 0:s.call(r,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>UT.includes(o)):[]},BT=i=>{var e,t;return(e=i.nodeName)!=null&&e.includes("-")&&w.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof w.customElements.get(i.nodeName.toLowerCase()))&&w.customElements.upgrade(i),FT.some(r=>r in i)},Lc=i=>BT(i)||!!kc(i).length,sg=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},ng={[S.MEDIA_SUBTITLES_LIST]:Nr,[S.MEDIA_SUBTITLES_SHOWING]:Nr,[S.MEDIA_SEEKABLE]:sg,[S.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(sg).join(" "),[S.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[S.MEDIA_RENDITION_LIST]:yp,[S.MEDIA_AUDIO_TRACK_LIST]:_p},$T=async(i,e,t)=>{var r,s;if(i.isConnected||await qa(0),typeof t=="boolean"||t==null)return Oe(i,e,t);if(typeof t=="number")return Ke(i,e,t);if(typeof t=="string")return Be(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);let n=(s=(r=ng[e])==null?void 0:r.call(ng,t))!=null?s:t;return i.setAttribute(e,n)},HT=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Ur=(i,e)=>{if(HT(i))return;let t=(s,n)=>{var a,o;Lc(s)&&n(s);let{children:l=[]}=s!=null?s:{},d=(o=(a=s==null?void 0:s.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(u=>Ur(u,n))},r=i==null?void 0:i.nodeName.toLowerCase();if(r.includes("-")&&!Lc(i)){w.customElements.whenDefined(r).then(()=>{t(i,e)});return}t(i,e)},ag=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}let s=kc(r),n=e.toLowerCase();s.includes(n)&&$T(r,n,t)})},og=(i,e)=>{for(let t of i){if(e in t)return t[e];let r=kc(t),s=e.toLowerCase();if(r.includes(s))return t.getAttribute(s)}},GT=(i,e,t)=>{Ur(i,e);let r=c=>{var u;let h=(u=c==null?void 0:c.composedPath()[0])!=null?u:c.target;e(h)},s=c=>{var u;let h=(u=c==null?void 0:c.composedPath()[0])!=null?u:c.target;t(h)};i.addEventListener(ee.REGISTER_MEDIA_STATE_RECEIVER,r),i.addEventListener(ee.UNREGISTER_MEDIA_STATE_RECEIVER,s);let n=c=>{c.forEach(u=>{let{addedNodes:h=[],removedNodes:f=[],type:g,target:E,attributeName:T}=u;g==="childList"?(Array.prototype.forEach.call(h,A=>Ur(A,e)),Array.prototype.forEach.call(f,A=>Ur(A,t))):g==="attributes"&&T===pe.MEDIA_CHROME_ATTRIBUTES&&(Lc(E)?e(E):t(E))})},a=[],o=c=>{let u=c.target;u.name!=="media"&&(a.forEach(h=>Ur(h,t)),a=[...u.assignedElements({flatten:!0})],a.forEach(h=>Ur(h,e)))};i.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{Ur(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener(ee.REGISTER_MEDIA_STATE_RECEIVER,r),i.removeEventListener(ee.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};w.customElements.get("media-controller")||w.customElements.define("media-controller",mo);var wc=mo;var Uc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},fi=(i,e,t)=>(Uc(i,e,"read from private field"),t?t.call(i):e.get(i)),zt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Fr=(i,e,t,r)=>(Uc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Li=(i,e,t)=>(Uc(i,e,"access private method"),t),Ri,_o,bo,yo,po,go,vo,Dc,Eo,Cc,To,Fc,Mc,dg,Pc,cg,Oc,ug,Nc,hg,fg=q.createElement("template");fg.innerHTML=`
222
240
  <style>
223
241
  :host {
224
242
  --_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
@@ -253,19 +271,31 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
253
271
  background: var(--media-control-hover-background, rgb(50 50 70 / .7));
254
272
  }
255
273
 
274
+ #leftgap {
275
+ padding-left: var(--media-range-padding-left, var(--_media-range-padding));
276
+ }
277
+
278
+ #rightgap {
279
+ padding-right: var(--media-range-padding-right, var(--_media-range-padding));
280
+ }
281
+
282
+ #startpoint,
283
+ #endpoint {
284
+ position: absolute;
285
+ }
286
+
287
+ #endpoint {
288
+ right: 0;
289
+ }
290
+
256
291
  #container {
257
292
 
258
- width: calc(
259
- var(--media-range-track-width, 100%)
260
- - var(--media-range-padding-left, var(--_media-range-padding))
261
- - var(--media-range-padding-right, var(--_media-range-padding)));
262
- transform: translate(
263
- calc(var(--media-range-track-translate-x, 0px) + var(--media-range-padding-left, var(--_media-range-padding))),
264
- var(--media-range-track-translate-y, 0px));
293
+ width: var(--media-range-track-width, 100%);
294
+ transform: translate(var(--media-range-track-translate-x, 0px), var(--media-range-track-translate-y, 0px));
295
+ position: relative;
265
296
  height: 100%;
266
297
  display: flex;
267
298
  align-items: center;
268
- position: relative;
269
299
  min-width: 40px;
270
300
  }
271
301
 
@@ -329,6 +359,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
329
359
  #background {
330
360
  background: var(--media-range-track-background, rgb(255 255 255 / .2));
331
361
  backdrop-filter: var(--media-range-track-background-backdrop-filter);
362
+ -webkit-backdrop-filter: var(--media-range-track-background-backdrop-filter);
332
363
  }
333
364
 
334
365
  #track {
@@ -336,6 +367,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
336
367
  outline: var(--media-range-track-outline);
337
368
  outline-offset: var(--media-range-track-outline-offset);
338
369
  backdrop-filter: var(--media-range-track-backdrop-filter);
370
+ -webkit-backdrop-filter: var(--media-range-track-backdrop-filter);
339
371
  box-shadow: var(--media-range-track-box-shadow, none);
340
372
  overflow: hidden;
341
373
  }
@@ -391,7 +423,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
391
423
  background-color: #777;
392
424
  }
393
425
  </style>
426
+ <div id="leftgap"></div>
394
427
  <div id="container">
428
+ <div id="startpoint"></div>
429
+ <div id="endpoint"></div>
395
430
  <div id="appearance">
396
431
  <div id="background"></div>
397
432
  <div id="track">
@@ -403,7 +438,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
403
438
  </div>
404
439
  <input id="range" type="range" min="0" max="1" step="any" value="0">
405
440
  </div>
406
- `;var Vr=class extends w.HTMLElement{constructor(){super(),mi(this,co),mi(this,uo),mi(this,ho),mi(this,cc),mi(this,uc),mi(this,hc),mi(this,fc),mi(this,Ci,void 0),mi(this,fo,void 0),mi(this,oo,()=>{if(this.range.matches(":focus-visible")){let{style:t}=et(this.shadowRoot,":host");t.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),mi(this,lo,()=>{let{style:t}=et(this.shadowRoot,":host");t.removeProperty("--_focus-visible-box-shadow")}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(bp.content.cloneNode(!0)));let{style:e}=et(this.shadowRoot,":host");e.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.container=this.shadowRoot.querySelector("#container"),this.range=this.shadowRoot.querySelector("#range")}static get observedAttributes(){return["disabled","aria-disabled",ye.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ye.MEDIA_CONTROLLER?(t&&((n=(s=tr(this,Ci))==null?void 0:s.unassociateElement)==null||n.call(s,this),Rn(this,Ci,null)),r&&this.isConnected&&(Rn(this,Ci,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=tr(this,Ci))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==r)&&(r==null?(this.range.removeAttribute(e),Di(this,co,lc).call(this)):(this.range.setAttribute(e,r),Di(this,uo,dc).call(this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(ye.MEDIA_CONTROLLER);s&&(Rn(this,Ci,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=tr(this,Ci))==null?void 0:t.associateElement)==null||r.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",tr(this,oo)),this.shadowRoot.addEventListener("focusout",tr(this,lo)),Di(this,co,lc).call(this)}disconnectedCallback(){var e,t;Di(this,uo,dc).call(this),(t=(e=tr(this,Ci))==null?void 0:e.unassociateElement)==null||t.call(e,this),Rn(this,Ci,null),this.shadowRoot.removeEventListener("focusin",tr(this,oo)),this.shadowRoot.removeEventListener("focusout",tr(this,lo))}updatePointerBar(e){let t=this.range.getBoundingClientRect(),r=(e.clientX-t.left)/t.width;r=Math.max(0,Math.min(1,r))*100;let{style:s}=et(this.shadowRoot,"#pointer");s.setProperty("width",`${r}%`)}updateBar(){let e=this.range.valueAsNumber*100,t=et(this.shadowRoot,"#progress"),r=et(this.shadowRoot,"#thumb");t.style.setProperty("width",`${e}%`),r.style.setProperty("left",`${e}%`)}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"input":this.updateBar();break;case"pointerenter":Di(this,cc,pp).call(this,e);break;case"pointerdown":Di(this,ho,pc).call(this,e);break;case"pointermove":Di(this,fc,Ep).call(this,e);break;case"pointerup":Di(this,uc,gp).call(this);break;case"pointerleave":Di(this,hc,vp).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};Ci=new WeakMap;fo=new WeakMap;oo=new WeakMap;lo=new WeakMap;co=new WeakSet;lc=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};uo=new WeakSet;dc=function(){var i,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(i=w.window)==null||i.removeEventListener("pointerup",this),(e=w.window)==null||e.removeEventListener("pointermove",this)};ho=new WeakSet;pc=function(i){var e;Rn(this,fo,i.composedPath().includes(this.range)),(e=w.window)==null||e.addEventListener("pointerup",this)};cc=new WeakSet;pp=function(i){var e;i.pointerType!=="mouse"&&Di(this,ho,pc).call(this,i),this.addEventListener("pointerleave",this),(e=w.window)==null||e.addEventListener("pointermove",this)};uc=new WeakSet;gp=function(){var i;(i=w.window)==null||i.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};hc=new WeakSet;vp=function(){var i;this.removeEventListener("pointerleave",this),(i=w.window)==null||i.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};fc=new WeakSet;Ep=function(i){if(this.toggleAttribute("dragging",i.buttons===1||i.pointerType!=="mouse"),this.updatePointerBar(i),this.dragging&&(i.pointerType!=="mouse"||!tr(this,fo))){this.range.disabled=!0;let e=this.range.getBoundingClientRect(),t=(i.clientX-e.left)/e.width;t=Math.max(0,Math.min(1,t)),this.range.valueAsNumber=t,this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}};w.customElements.get("media-chrome-range")||w.customElements.define("media-chrome-range",Vr);var yp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},mo=(i,e,t)=>(yp(i,e,"read from private field"),t?t.call(i):e.get(i)),Uy=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},po=(i,e,t,r)=>(yp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mi,Tp=j.createElement("template");Tp.innerHTML=`
441
+ <div id="rightgap"></div>
442
+ `;var Br=class extends w.HTMLElement{constructor(){super(),zt(this,vo),zt(this,Eo),zt(this,To),zt(this,Mc),zt(this,Pc),zt(this,Oc),zt(this,Nc),zt(this,Ri,void 0),zt(this,_o,void 0),zt(this,bo,void 0),zt(this,yo,void 0),zt(this,po,()=>{if(this.range.matches(":focus-visible")){let{style:t}=Ye(this.shadowRoot,":host");t.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),zt(this,go,()=>{let{style:t}=Ye(this.shadowRoot,":host");t.removeProperty("--_focus-visible-box-shadow")}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(fg.content.cloneNode(!0)));let{style:e}=Ye(this.shadowRoot,":host");e.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.container=this.shadowRoot.querySelector("#container"),Fr(this,bo,this.shadowRoot.querySelector("#startpoint")),Fr(this,yo,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range")}static get observedAttributes(){return["disabled","aria-disabled",pe.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===pe.MEDIA_CONTROLLER?(t&&((n=(s=fi(this,Ri))==null?void 0:s.unassociateElement)==null||n.call(s,this),Fr(this,Ri,null)),r&&this.isConnected&&(Fr(this,Ri,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=fi(this,Ri))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==r)&&(r==null?(this.range.removeAttribute(e),Li(this,vo,Dc).call(this)):(this.range.setAttribute(e,r),Li(this,Eo,Cc).call(this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(pe.MEDIA_CONTROLLER);s&&(Fr(this,Ri,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=fi(this,Ri))==null?void 0:t.associateElement)==null||r.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",fi(this,po)),this.shadowRoot.addEventListener("focusout",fi(this,go)),Li(this,vo,Dc).call(this)}disconnectedCallback(){var e,t;Li(this,Eo,Cc).call(this),(t=(e=fi(this,Ri))==null?void 0:e.unassociateElement)==null||t.call(e,this),Fr(this,Ri,null),this.shadowRoot.removeEventListener("focusin",fi(this,po)),this.shadowRoot.removeEventListener("focusout",fi(this,go))}updatePointerBar(e){let t=this.range.getBoundingClientRect(),r=(e.clientX-t.left)/t.width;r=Math.max(0,Math.min(1,r))*100;let{style:s}=Ye(this.shadowRoot,"#pointer");s.setProperty("width",`${r}%`)}updateBar(){let e=this.range.valueAsNumber*100,t=Ye(this.shadowRoot,"#progress"),r=Ye(this.shadowRoot,"#thumb");t.style.setProperty("width",`${e}%`),r.style.setProperty("left",`${e}%`)}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"input":this.updateBar();break;case"pointerenter":Li(this,Mc,dg).call(this,e);break;case"pointerdown":Li(this,To,Fc).call(this,e);break;case"pointermove":Li(this,Nc,hg).call(this,e);break;case"pointerup":Li(this,Pc,cg).call(this);break;case"pointerleave":Li(this,Oc,ug).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};Ri=new WeakMap;_o=new WeakMap;bo=new WeakMap;yo=new WeakMap;po=new WeakMap;go=new WeakMap;vo=new WeakSet;Dc=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};Eo=new WeakSet;Cc=function(){var i,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(i=w.window)==null||i.removeEventListener("pointerup",this),(e=w.window)==null||e.removeEventListener("pointermove",this)};To=new WeakSet;Fc=function(i){var e;Fr(this,_o,i.composedPath().includes(this.range)),(e=w.window)==null||e.addEventListener("pointerup",this)};Mc=new WeakSet;dg=function(i){var e;i.pointerType!=="mouse"&&Li(this,To,Fc).call(this,i),this.addEventListener("pointerleave",this),(e=w.window)==null||e.addEventListener("pointermove",this)};Pc=new WeakSet;cg=function(){var i;(i=w.window)==null||i.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};Oc=new WeakSet;ug=function(){var i;this.removeEventListener("pointerleave",this),(i=w.window)==null||i.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};Nc=new WeakSet;hg=function(i){if(this.toggleAttribute("dragging",i.buttons===1||i.pointerType!=="mouse"),this.updatePointerBar(i),this.dragging&&(i.pointerType!=="mouse"||!fi(this,_o))){this.range.disabled=!0;let e=kp(i.clientX,i.clientY,fi(this,bo).getBoundingClientRect(),fi(this,yo).getBoundingClientRect());e=Math.max(0,Math.min(1,e)),this.range.valueAsNumber=e,this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}};w.customElements.get("media-chrome-range")||w.customElements.define("media-chrome-range",Br);var mg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ao=(i,e,t)=>(mg(i,e,"read from private field"),t?t.call(i):e.get(i)),VT=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},So=(i,e,t,r)=>(mg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ki,pg=q.createElement("template");pg.innerHTML=`
407
443
  <style>
408
444
  :host {
409
445
 
@@ -425,7 +461,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
425
461
  </style>
426
462
 
427
463
  <slot></slot>
428
- `;var gc=class extends w.HTMLElement{constructor(){super(),Uy(this,Mi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Tp.content.cloneNode(!0)))}static get observedAttributes(){return[ye.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ye.MEDIA_CONTROLLER&&(t&&((n=(s=mo(this,Mi))==null?void 0:s.unassociateElement)==null||n.call(s,this),po(this,Mi,null)),r&&this.isConnected&&(po(this,Mi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=mo(this,Mi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(ye.MEDIA_CONTROLLER);s&&(po(this,Mi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=mo(this,Mi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=mo(this,Mi))==null?void 0:e.unassociateElement)==null||t.call(e,this),po(this,Mi,null)}};Mi=new WeakMap;w.customElements.get("media-control-bar")||w.customElements.define("media-control-bar",gc);var _p=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},go=(i,e,t)=>(_p(i,e,"read from private field"),t?t.call(i):e.get(i)),Fy=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},vo=(i,e,t,r)=>(_p(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Oi,Ap=j.createElement("template");Ap.innerHTML=`
464
+ `;var Bc=class extends w.HTMLElement{constructor(){super(),VT(this,ki,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(pg.content.cloneNode(!0)))}static get observedAttributes(){return[pe.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===pe.MEDIA_CONTROLLER&&(t&&((n=(s=Ao(this,ki))==null?void 0:s.unassociateElement)==null||n.call(s,this),So(this,ki,null)),r&&this.isConnected&&(So(this,ki,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Ao(this,ki))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(pe.MEDIA_CONTROLLER);s&&(So(this,ki,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Ao(this,ki))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Ao(this,ki))==null?void 0:e.unassociateElement)==null||t.call(e,this),So(this,ki,null)}};ki=new WeakMap;w.customElements.get("media-control-bar")||w.customElements.define("media-control-bar",Bc);var gg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},xo=(i,e,t)=>(gg(i,e,"read from private field"),t?t.call(i):e.get(i)),KT=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Io=(i,e,t,r)=>(gg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),wi,vg=q.createElement("template");vg.innerHTML=`
429
465
  <style>
430
466
  :host {
431
467
  font: var(--media-font,
@@ -458,11 +494,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
458
494
  }
459
495
  </style>
460
496
  <slot></slot>
461
- `;var ir=class extends w.HTMLElement{constructor(){super(),Fy(this,Oi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ap.content.cloneNode(!0)));let{style:e}=et(this.shadowRoot,":host");e.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`)}static get observedAttributes(){return[ye.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ye.MEDIA_CONTROLLER&&(t&&((n=(s=go(this,Oi))==null?void 0:s.unassociateElement)==null||n.call(s,this),vo(this,Oi,null)),r&&this.isConnected&&(vo(this,Oi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=go(this,Oi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(ye.MEDIA_CONTROLLER);s&&(vo(this,Oi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=go(this,Oi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=go(this,Oi))==null?void 0:e.unassociateElement)==null||t.call(e,this),vo(this,Oi,null)}};Oi=new WeakMap;w.customElements.get("media-text-display")||w.customElements.define("media-text-display",ir);var xp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Sp=(i,e,t)=>(xp(i,e,"read from private field"),t?t.call(i):e.get(i)),By=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},$y=(i,e,t,r)=>(xp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),wn,vc=class extends ir{constructor(){super(),By(this,wn,void 0),$y(this,wn,this.shadowRoot.querySelector("slot")),Sp(this,wn).textContent=Ri(0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_DURATION]}attributeChangedCallback(e,t,r){e===S.MEDIA_DURATION&&(Sp(this,wn).textContent=Ri(r)),super.attributeChangedCallback(e,t,r)}get mediaDuration(){return Fe(this,S.MEDIA_DURATION)}set mediaDuration(e){ze(this,S.MEDIA_DURATION,e)}};wn=new WeakMap;w.customElements.get("media-duration-display")||w.customElements.define("media-duration-display",vc);var Rp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ec=(i,e,t)=>(Rp(i,e,"read from private field"),t?t.call(i):e.get(i)),Hy=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Gy=(i,e,t,r)=>(Rp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Cs,pi={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},Ip=[...Object.values(pi),S.MEDIA_CURRENT_TIME,S.MEDIA_DURATION,S.MEDIA_SEEKABLE],Lp=["Enter"," "],Vy="&nbsp;/&nbsp;",kp=(i,{timesSep:e=Vy}={})=>{var t,r,s,n;let a=i.hasAttribute(pi.REMAINING),o=i.hasAttribute(pi.SHOW_DURATION),l=(t=i.mediaCurrentTime)!=null?t:0,[,d]=(r=i.mediaSeekable)!=null?r:[],c=(n=(s=i.mediaDuration)!=null?s:d)!=null?n:0,u=a?Ri(0-(c-l)):Ri(l);return o?`${u}${e}${Ri(c)}`:u},Ky="video not loaded, unknown time.",Wy=i=>{var e;let t=i.mediaCurrentTime,[,r]=(e=i.mediaSeekable)!=null?e:[],s=i.mediaDuration||r;if(t==null||s==null){i.setAttribute("aria-valuetext",Ky);return}let n=i.hasAttribute(pi.REMAINING),a=i.hasAttribute(pi.SHOW_DURATION),o=n?Ur(0-(s-t)):Ur(t);if(!a){i.setAttribute("aria-valuetext",o);return}let l=Ur(s),d=`${o} of ${l}`;i.setAttribute("aria-valuetext",d)},bc=class extends ir{constructor(){super(),Hy(this,Cs,void 0),Gy(this,Cs,this.shadowRoot.querySelector("slot")),Ec(this,Cs).innerHTML=`${kp(this)}`;let{style:e}=et(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))")}static get observedAttributes(){return[...super.observedAttributes,...Ip,"disabled"]}connectedCallback(){this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Rt.PLAYBACK_TIME());let e=t=>{let{key:r}=t;if(!Lp.includes(r)){this.removeEventListener("keyup",e);return}this.toggleTimeDisplay()};this.addEventListener("keydown",t=>{let{metaKey:r,altKey:s,key:n}=t;if(r||s||!Lp.includes(n)){this.removeEventListener("keyup",e);return}this.addEventListener("keyup",e)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){Ip.includes(e)?this.update():e==="disabled"&&r!==t&&(r==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,r)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return Ye(this,pi.REMAINING)}set remaining(e){Ke(this,pi.REMAINING,e)}get showDuration(){return Ye(this,pi.SHOW_DURATION)}set showDuration(e){Ke(this,pi.SHOW_DURATION,e)}get noToggle(){return Ye(this,pi.NO_TOGGLE)}set noToggle(e){Ke(this,pi.NO_TOGGLE,e)}get mediaDuration(){return Fe(this,S.MEDIA_DURATION)}set mediaDuration(e){ze(this,S.MEDIA_DURATION,e)}get mediaCurrentTime(){return Fe(this,S.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){ze(this,S.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(S.MEDIA_SEEKABLE);if(!!e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(S.MEDIA_SEEKABLE);return}this.setAttribute(S.MEDIA_SEEKABLE,e.join(":"))}update(){let e=kp(this);Wy(this),e!==Ec(this,Cs).innerHTML&&(Ec(this,Cs).innerHTML=e)}};Cs=new WeakMap;w.customElements.get("media-time-display")||w.customElements.define("media-time-display",bc);var qy=`<svg aria-hidden="true" viewBox="0 0 26 24">
497
+ `;var zi=class extends w.HTMLElement{constructor(){super(),KT(this,wi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(vg.content.cloneNode(!0)));let{style:e}=Ye(this.shadowRoot,":host");e.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`)}static get observedAttributes(){return[pe.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===pe.MEDIA_CONTROLLER&&(t&&((n=(s=xo(this,wi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Io(this,wi,null)),r&&this.isConnected&&(Io(this,wi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=xo(this,wi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(pe.MEDIA_CONTROLLER);s&&(Io(this,wi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=xo(this,wi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=xo(this,wi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Io(this,wi,null)}};wi=new WeakMap;w.customElements.get("media-text-display")||w.customElements.define("media-text-display",zi);var bg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Eg=(i,e,t)=>(bg(i,e,"read from private field"),t?t.call(i):e.get(i)),WT=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},qT=(i,e,t,r)=>(bg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Un,$c=class extends zi{constructor(){super(),WT(this,Un,void 0),qT(this,Un,this.shadowRoot.querySelector("slot")),Eg(this,Un).textContent=Si(0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_DURATION]}attributeChangedCallback(e,t,r){e===S.MEDIA_DURATION&&(Eg(this,Un).textContent=Si(r)),super.attributeChangedCallback(e,t,r)}get mediaDuration(){return Ue(this,S.MEDIA_DURATION)}set mediaDuration(e){Ke(this,S.MEDIA_DURATION,e)}};Un=new WeakMap;w.customElements.get("media-duration-display")||w.customElements.define("media-duration-display",$c);var Ag=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Hc=(i,e,t)=>(Ag(i,e,"read from private field"),t?t.call(i):e.get(i)),YT=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},jT=(i,e,t,r)=>(Ag(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ns,mi={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},yg=[...Object.values(mi),S.MEDIA_CURRENT_TIME,S.MEDIA_DURATION,S.MEDIA_SEEKABLE],Tg=["Enter"," "],zT="&nbsp;/&nbsp;",_g=(i,{timesSep:e=zT}={})=>{var t,r,s,n;let a=i.hasAttribute(mi.REMAINING),o=i.hasAttribute(mi.SHOW_DURATION),l=(t=i.mediaCurrentTime)!=null?t:0,[,d]=(r=i.mediaSeekable)!=null?r:[],c=(n=(s=i.mediaDuration)!=null?s:d)!=null?n:0,u=a?Si(0-(c-l)):Si(l);return o?`${u}${e}${Si(c)}`:u},XT="video not loaded, unknown time.",QT=i=>{var e;let t=i.mediaCurrentTime,[,r]=(e=i.mediaSeekable)!=null?e:[],s=i.mediaDuration||r;if(t==null||s==null){i.setAttribute("aria-valuetext",XT);return}let n=i.hasAttribute(mi.REMAINING),a=i.hasAttribute(mi.SHOW_DURATION),o=n?Mr(0-(s-t)):Mr(t);if(!a){i.setAttribute("aria-valuetext",o);return}let l=Mr(s),d=`${o} of ${l}`;i.setAttribute("aria-valuetext",d)},Gc=class extends zi{constructor(){super(),YT(this,Ns,void 0),jT(this,Ns,this.shadowRoot.querySelector("slot")),Hc(this,Ns).innerHTML=`${_g(this)}`;let{style:e}=Ye(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))")}static get observedAttributes(){return[...super.observedAttributes,...yg,"disabled"]}connectedCallback(){this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",St.PLAYBACK_TIME());let e=t=>{let{key:r}=t;if(!Tg.includes(r)){this.removeEventListener("keyup",e);return}this.toggleTimeDisplay()};this.addEventListener("keydown",t=>{let{metaKey:r,altKey:s,key:n}=t;if(r||s||!Tg.includes(n)){this.removeEventListener("keyup",e);return}this.addEventListener("keyup",e)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){yg.includes(e)?this.update():e==="disabled"&&r!==t&&(r==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,r)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return Fe(this,mi.REMAINING)}set remaining(e){Oe(this,mi.REMAINING,e)}get showDuration(){return Fe(this,mi.SHOW_DURATION)}set showDuration(e){Oe(this,mi.SHOW_DURATION,e)}get noToggle(){return Fe(this,mi.NO_TOGGLE)}set noToggle(e){Oe(this,mi.NO_TOGGLE,e)}get mediaDuration(){return Ue(this,S.MEDIA_DURATION)}set mediaDuration(e){Ke(this,S.MEDIA_DURATION,e)}get mediaCurrentTime(){return Ue(this,S.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){Ke(this,S.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(S.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(S.MEDIA_SEEKABLE);return}this.setAttribute(S.MEDIA_SEEKABLE,e.join(":"))}update(){let e=_g(this);QT(this),e!==Hc(this,Ns).innerHTML&&(Hc(this,Ns).innerHTML=e)}};Ns=new WeakMap;w.customElements.get("media-time-display")||w.customElements.define("media-time-display",Gc);var ZT=`<svg aria-hidden="true" viewBox="0 0 26 24">
462
498
  <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"/>
463
- </svg>`,Yy=`<svg aria-hidden="true" viewBox="0 0 26 24">
499
+ </svg>`,JT=`<svg aria-hidden="true" viewBox="0 0 26 24">
464
500
  <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"/>
465
- </svg>`,Mp=j.createElement("template");Mp.innerHTML=`
501
+ </svg>`,Lg=q.createElement("template");Lg.innerHTML=`
466
502
  <style>
467
503
  :host([aria-checked="true"]) slot[name=off] {
468
504
  display: none !important;
@@ -475,16 +511,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
475
511
  </style>
476
512
 
477
513
  <slot name="icon">
478
- <slot name="on">${qy}</slot>
479
- <slot name="off">${Yy}</slot>
514
+ <slot name="on">${ZT}</slot>
515
+ <slot name="off">${JT}</slot>
480
516
  </slot>
481
- `;var wp=i=>{i.setAttribute("aria-checked",Jd(i))},yc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_SUBTITLES_LIST,S.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:Mp,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Rt.CLOSED_CAPTIONS()),wp(this)}attributeChangedCallback(e,t,r){e===S.MEDIA_SUBTITLES_SHOWING&&wp(this),super.attributeChangedCallback(e,t,r)}get mediaSubtitlesList(){return Dp(this,S.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Cp(this,S.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Dp(this,S.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Cp(this,S.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){er(this)}},Dp=(i,e)=>{let t=i.getAttribute(e);return t?In(t):[]},Cp=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=$r(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};w.customElements.get("media-captions-button")||w.customElements.define("media-captions-button",yc);var Ms={SEEK_OFFSET:"seekoffset"},Eo=30,jy=`<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)">${Eo}</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>`,Op=j.createElement("template");Op.innerHTML=`
482
- <slot name="icon">${jy}</slot>
483
- `;var zy=0,Tc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_CURRENT_TIME,Ms.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Op,...e})}connectedCallback(){this.seekOffset=Fe(this,Ms.SEEK_OFFSET,Eo),super.connectedCallback()}attributeChangedCallback(e,t,r){e===Ms.SEEK_OFFSET&&(this.seekOffset=Fe(this,Ms.SEEK_OFFSET,Eo)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return Fe(this,Ms.SEEK_OFFSET,Eo)}set seekOffset(e){ze(this,Ms.SEEK_OFFSET,e),this.setAttribute("aria-label",Xe.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),Ga(Va(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Fe(this,S.MEDIA_CURRENT_TIME,zy)}set mediaCurrentTime(e){ze(this,S.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new w.CustomEvent(re.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};w.customElements.get("media-seek-forward-button")||w.customElements.define("media-seek-forward-button",Tc);var Xy=`<svg aria-hidden="true" viewBox="0 0 26 24">
517
+ `;var Sg=i=>{i.setAttribute("aria-checked",Xp(i))},Vc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_SUBTITLES_LIST,S.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:Lg,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",St.CLOSED_CAPTIONS()),Sg(this)}attributeChangedCallback(e,t,r){e===S.MEDIA_SUBTITLES_SHOWING&&Sg(this),super.attributeChangedCallback(e,t,r)}get mediaSubtitlesList(){return xg(this,S.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Ig(this,S.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return xg(this,S.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Ig(this,S.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new w.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}},xg=(i,e)=>{let t=i.getAttribute(e);return t?Dn(t):[]},Ig=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=Nr(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};w.customElements.get("media-captions-button")||w.customElements.define("media-captions-button",Vc);var Us={SEEK_OFFSET:"seekoffset"},Lo=30,e_=`<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)">${Lo}</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>`,Rg=q.createElement("template");Rg.innerHTML=`
518
+ <slot name="icon">${e_}</slot>
519
+ `;var t_=0,Kc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_CURRENT_TIME,Us.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Rg,...e})}connectedCallback(){this.seekOffset=Ue(this,Us.SEEK_OFFSET,Lo),super.connectedCallback()}attributeChangedCallback(e,t,r){e===Us.SEEK_OFFSET&&(this.seekOffset=Ue(this,Us.SEEK_OFFSET,Lo)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return Ue(this,Us.SEEK_OFFSET,Lo)}set seekOffset(e){Ke(this,Us.SEEK_OFFSET,e),this.setAttribute("aria-label",Ve.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),Ya(ja(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Ue(this,S.MEDIA_CURRENT_TIME,t_)}set mediaCurrentTime(e){Ke(this,S.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new w.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};w.customElements.get("media-seek-forward-button")||w.customElements.define("media-seek-forward-button",Kc);var i_=`<svg aria-hidden="true" viewBox="0 0 26 24">
484
520
  <path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
485
- </svg>`,Qy=`<svg aria-hidden="true" viewBox="0 0 26 24">
521
+ </svg>`,r_=`<svg aria-hidden="true" viewBox="0 0 26 24">
486
522
  <path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
487
- </svg>`,Np=j.createElement("template");Np.innerHTML=`
523
+ </svg>`,wg=q.createElement("template");wg.innerHTML=`
488
524
  <style>
489
525
  :host([${S.MEDIA_IS_FULLSCREEN}]) slot:not([name=exit]):not([name=icon]) {
490
526
  display: none !important;
@@ -497,10 +533,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
497
533
  </style>
498
534
 
499
535
  <slot name="icon">
500
- <slot name="enter">${Xy}</slot>
501
- <slot name="exit">${Qy}</slot>
536
+ <slot name="enter">${i_}</slot>
537
+ <slot name="exit">${r_}</slot>
502
538
  </slot>
503
- `;var Pp=i=>{let e=i.mediaIsFullscreen?Xe.EXIT_FULLSCREEN():Xe.ENTER_FULLSCREEN();i.setAttribute("aria-label",e)},_c=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_FULLSCREEN,S.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Np,...e})}connectedCallback(){Pp(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===S.MEDIA_IS_FULLSCREEN&&Pp(this),super.attributeChangedCallback(e,t,r)}get mediaFullscreenUnavailable(){return We(this,S.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){Be(this,S.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return Ye(this,S.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){Ke(this,S.MEDIA_IS_FULLSCREEN,e)}handleClick(){let e=this.mediaIsFullscreen?re.MEDIA_EXIT_FULLSCREEN_REQUEST:re.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-fullscreen-button")||w.customElements.define("media-fullscreen-button",_c);var{MEDIA_TIME_IS_LIVE:bo,MEDIA_PAUSED:Dn}=S,{MEDIA_SEEK_TO_LIVE_REQUEST:Zy,MEDIA_PLAY_REQUEST:Jy}=re,eT='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',Fp=j.createElement("template");Fp.innerHTML=`
539
+ `;var kg=i=>{let e=i.mediaIsFullscreen?Ve.EXIT_FULLSCREEN():Ve.ENTER_FULLSCREEN();i.setAttribute("aria-label",e)},Wc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_FULLSCREEN,S.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:wg,...e})}connectedCallback(){kg(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===S.MEDIA_IS_FULLSCREEN&&kg(this),super.attributeChangedCallback(e,t,r)}get mediaFullscreenUnavailable(){return He(this,S.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){Be(this,S.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return Fe(this,S.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){Oe(this,S.MEDIA_IS_FULLSCREEN,e)}handleClick(){let e=this.mediaIsFullscreen?ee.MEDIA_EXIT_FULLSCREEN_REQUEST:ee.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-fullscreen-button")||w.customElements.define("media-fullscreen-button",Wc);var{MEDIA_TIME_IS_LIVE:Ro,MEDIA_PAUSED:Fn}=S,{MEDIA_SEEK_TO_LIVE_REQUEST:s_,MEDIA_PLAY_REQUEST:n_}=ee,a_='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',Cg=q.createElement("template");Cg.innerHTML=`
504
540
  <style>
505
541
 
506
542
  slot[name=indicator] > *,
@@ -511,57 +547,57 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
511
547
  color: var(--media-live-button-icon-color, rgb(140, 140, 140));
512
548
  }
513
549
 
514
- :host([${bo}]:not([${Dn}])) slot[name=indicator] > *,
515
- :host([${bo}]:not([${Dn}])) ::slotted([slot=indicator]) {
550
+ :host([${Ro}]:not([${Fn}])) slot[name=indicator] > *,
551
+ :host([${Ro}]:not([${Fn}])) ::slotted([slot=indicator]) {
516
552
  fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));
517
553
  color: var(--media-live-button-indicator-color, rgb(255, 0, 0));
518
554
  }
519
555
 
520
- :host([${bo}]:not([${Dn}])) {
556
+ :host([${Ro}]:not([${Fn}])) {
521
557
  cursor: not-allowed;
522
558
  }
523
559
 
524
560
  </style>
525
561
 
526
- <slot name="indicator">${eT}</slot>
562
+ <slot name="indicator">${a_}</slot>
527
563
 
528
564
  <slot name="spacer">&nbsp;</slot><slot name="text">LIVE</slot>
529
- `;var Up=i=>{let e=i.mediaPaused||!i.mediaTimeIsLive,t=e?Xe.SEEK_LIVE():Xe.PLAYING_LIVE();i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")},Ac=class extends $e{static get observedAttributes(){return[...super.observedAttributes,Dn,bo]}constructor(e={}){super({slotTemplate:Fp,...e})}connectedCallback(){Up(this),super.connectedCallback()}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),Up(this)}get mediaPaused(){return Ye(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ke(this,S.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return Ye(this,S.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){Ke(this,S.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new w.CustomEvent(Zy,{composed:!0,bubbles:!0})),this.hasAttribute(Dn)&&this.dispatchEvent(new w.CustomEvent(Jy,{composed:!0,bubbles:!0})))}};w.customElements.get("media-live-button")||w.customElements.define("media-live-button",Ac);var{MEDIA_VOLUME_LEVEL:Cn}=S,tT=`<svg aria-hidden="true" viewBox="0 0 24 24">
565
+ `;var Dg=i=>{let e=i.mediaPaused||!i.mediaTimeIsLive,t=e?Ve.SEEK_LIVE():Ve.PLAYING_LIVE();i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")},qc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,Fn,Ro]}constructor(e={}){super({slotTemplate:Cg,...e})}connectedCallback(){Dg(this),super.connectedCallback()}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),Dg(this)}get mediaPaused(){return Fe(this,S.MEDIA_PAUSED)}set mediaPaused(e){Oe(this,S.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return Fe(this,S.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){Oe(this,S.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new w.CustomEvent(s_,{composed:!0,bubbles:!0})),this.hasAttribute(Fn)&&this.dispatchEvent(new w.CustomEvent(n_,{composed:!0,bubbles:!0})))}};w.customElements.get("media-live-button")||w.customElements.define("media-live-button",qc);var{MEDIA_VOLUME_LEVEL:Bn}=S,o_=`<svg aria-hidden="true" viewBox="0 0 24 24">
530
566
  <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"/>
531
- </svg>`,Bp=`<svg aria-hidden="true" viewBox="0 0 24 24">
567
+ </svg>`,Mg=`<svg aria-hidden="true" viewBox="0 0 24 24">
532
568
  <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"/>
533
- </svg>`,iT=`<svg aria-hidden="true" viewBox="0 0 24 24">
569
+ </svg>`,l_=`<svg aria-hidden="true" viewBox="0 0 24 24">
534
570
  <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"/>
535
- </svg>`,Hp=j.createElement("template");Hp.innerHTML=`
571
+ </svg>`,Og=q.createElement("template");Og.innerHTML=`
536
572
  <style>
537
573
 
538
- :host(:not([${Cn}])) slot:not([name=high]):not([name=icon]),
539
- :host([${Cn}=high]) slot:not([name=high]):not([name=icon]) {
574
+ :host(:not([${Bn}])) slot:not([name=high]):not([name=icon]),
575
+ :host([${Bn}=high]) slot:not([name=high]):not([name=icon]) {
540
576
  display: none !important;
541
577
  }
542
578
 
543
- :host([${Cn}=off]) slot:not([name=off]):not([name=icon]) {
579
+ :host([${Bn}=off]) slot:not([name=off]):not([name=icon]) {
544
580
  display: none !important;
545
581
  }
546
582
 
547
- :host([${Cn}=low]) slot:not([name=low]):not([name=icon]) {
583
+ :host([${Bn}=low]) slot:not([name=low]):not([name=icon]) {
548
584
  display: none !important;
549
585
  }
550
586
 
551
- :host([${Cn}=medium]) slot:not([name=medium]):not([name=icon]) {
587
+ :host([${Bn}=medium]) slot:not([name=medium]):not([name=icon]) {
552
588
  display: none !important;
553
589
  }
554
590
  </style>
555
591
 
556
592
  <slot name="icon">
557
- <slot name="off">${tT}</slot>
558
- <slot name="low">${Bp}</slot>
559
- <slot name="medium">${Bp}</slot>
560
- <slot name="high">${iT}</slot>
593
+ <slot name="off">${o_}</slot>
594
+ <slot name="low">${Mg}</slot>
595
+ <slot name="medium">${Mg}</slot>
596
+ <slot name="high">${l_}</slot>
561
597
  </slot>
562
- `;var $p=i=>{let t=i.mediaVolumeLevel==="off"?Xe.UNMUTE():Xe.MUTE();i.setAttribute("aria-label",t)},Sc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:Hp,...e})}connectedCallback(){$p(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===S.MEDIA_VOLUME_LEVEL&&$p(this),super.attributeChangedCallback(e,t,r)}get mediaVolumeLevel(){return We(this,S.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){Be(this,S.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e=this.mediaVolumeLevel==="off"?re.MEDIA_UNMUTE_REQUEST:re.MEDIA_MUTE_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-mute-button")||w.customElements.define("media-mute-button",Sc);var Gp=`<svg aria-hidden="true" viewBox="0 0 28 24">
598
+ `;var Pg=i=>{let t=i.mediaVolumeLevel==="off"?Ve.UNMUTE():Ve.MUTE();i.setAttribute("aria-label",t)},Yc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:Og,...e})}connectedCallback(){Pg(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===S.MEDIA_VOLUME_LEVEL&&Pg(this),super.attributeChangedCallback(e,t,r)}get mediaVolumeLevel(){return He(this,S.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){Be(this,S.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e=this.mediaVolumeLevel==="off"?ee.MEDIA_UNMUTE_REQUEST:ee.MEDIA_MUTE_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-mute-button")||w.customElements.define("media-mute-button",Yc);var Ng=`<svg aria-hidden="true" viewBox="0 0 28 24">
563
599
  <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"/>
564
- </svg>`,Kp=j.createElement("template");Kp.innerHTML=`
600
+ </svg>`,Fg=q.createElement("template");Fg.innerHTML=`
565
601
  <style>
566
602
  :host([${S.MEDIA_IS_PIP}]) slot:not([name=exit]):not([name=icon]) {
567
603
  display: none !important;
@@ -574,14 +610,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
574
610
  </style>
575
611
 
576
612
  <slot name="icon">
577
- <slot name="enter">${Gp}</slot>
578
- <slot name="exit">${Gp}</slot>
613
+ <slot name="enter">${Ng}</slot>
614
+ <slot name="exit">${Ng}</slot>
579
615
  </slot>
580
- `;var Vp=i=>{let e=i.mediaIsPip?Xe.EXIT_PIP():Xe.ENTER_PIP();i.setAttribute("aria-label",e)},xc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_PIP,S.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Kp,...e})}connectedCallback(){Vp(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===S.MEDIA_IS_PIP&&Vp(this),super.attributeChangedCallback(e,t,r)}get mediaPipUnavailable(){return We(this,S.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){Be(this,S.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return Ye(this,S.MEDIA_IS_PIP)}set mediaIsPip(e){Ke(this,S.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?re.MEDIA_EXIT_PIP_REQUEST:re.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-pip-button")||w.customElements.define("media-pip-button",xc);var rT=`<svg aria-hidden="true" viewBox="0 0 24 24">
616
+ `;var Ug=i=>{let e=i.mediaIsPip?Ve.EXIT_PIP():Ve.ENTER_PIP();i.setAttribute("aria-label",e)},jc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_PIP,S.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Fg,...e})}connectedCallback(){Ug(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===S.MEDIA_IS_PIP&&Ug(this),super.attributeChangedCallback(e,t,r)}get mediaPipUnavailable(){return He(this,S.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){Be(this,S.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return Fe(this,S.MEDIA_IS_PIP)}set mediaIsPip(e){Oe(this,S.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?ee.MEDIA_EXIT_PIP_REQUEST:ee.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-pip-button")||w.customElements.define("media-pip-button",jc);var d_=`<svg aria-hidden="true" viewBox="0 0 24 24">
581
617
  <path d="m6 21 15-9L6 3v18Z"/>
582
- </svg>`,sT=`<svg aria-hidden="true" viewBox="0 0 24 24">
618
+ </svg>`,c_=`<svg aria-hidden="true" viewBox="0 0 24 24">
583
619
  <path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
584
- </svg>`,qp=j.createElement("template");qp.innerHTML=`
620
+ </svg>`,$g=q.createElement("template");$g.innerHTML=`
585
621
  <style>
586
622
  :host([${S.MEDIA_PAUSED}]) slot[name=pause] {
587
623
  display: none !important;
@@ -593,10 +629,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
593
629
  </style>
594
630
 
595
631
  <slot name="icon">
596
- <slot name="play">${rT}</slot>
597
- <slot name="pause">${sT}</slot>
632
+ <slot name="play">${d_}</slot>
633
+ <slot name="pause">${c_}</slot>
598
634
  </slot>
599
- `;var Wp=i=>{let e=i.mediaPaused?Xe.PLAY():Xe.PAUSE();i.setAttribute("aria-label",e)},Ic=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PAUSED,S.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:qp,...e})}connectedCallback(){Wp(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===S.MEDIA_PAUSED&&Wp(this),super.attributeChangedCallback(e,t,r)}get mediaPaused(){return Ye(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ke(this,S.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?re.MEDIA_PLAY_REQUEST:re.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-play-button")||w.customElements.define("media-play-button",Ic);var nT=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},yo=(i,e,t)=>(nT(i,e,"read from private field"),t?t.call(i):e.get(i)),aT=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Os,Lc={RATES:"rates"},Rc=[1,1.2,1.5,1.7,2],Ps=1,Yp=j.createElement("template");Yp.innerHTML=`
635
+ `;var Bg=i=>{let e=i.mediaPaused?Ve.PLAY():Ve.PAUSE();i.setAttribute("aria-label",e)},zc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PAUSED,S.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:$g,...e})}connectedCallback(){Bg(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===S.MEDIA_PAUSED&&Bg(this),super.attributeChangedCallback(e,t,r)}get mediaPaused(){return Fe(this,S.MEDIA_PAUSED)}set mediaPaused(e){Oe(this,S.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?ee.MEDIA_PLAY_REQUEST:ee.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new w.CustomEvent(e,{composed:!0,bubbles:!0}))}};w.customElements.get("media-play-button")||w.customElements.define("media-play-button",zc);var u_=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ko=(i,e,t)=>(u_(i,e,"read from private field"),t?t.call(i):e.get(i)),h_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Fs,Xc={RATES:"rates"},Zc=[1,1.2,1.5,1.7,2],Bs=1,Hg=q.createElement("template");Hg.innerHTML=`
600
636
  <style>
601
637
  :host {
602
638
  min-width: 5ch;
@@ -604,7 +640,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
604
640
  }
605
641
  </style>
606
642
  <span id="container"></span>
607
- `;var kc=class extends $e{constructor(e={}){super({slotTemplate:Yp,...e}),aT(this,Os,new vr(this,Lc.RATES,{defaultValue:Rc})),this.container=this.shadowRoot.querySelector("#container"),this.container.innerHTML=`${Ps}x`}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PLAYBACK_RATE,Lc.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===Lc.RATES&&(yo(this,Os).value=r),e===S.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?Ps:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Rt.PLAYBACK_RATE({playbackRate:n}))}}get rates(){return yo(this,Os)}set rates(e){e?Array.isArray(e)&&(yo(this,Os).value=e.join(" ")):yo(this,Os).value=""}get mediaPlaybackRate(){return Fe(this,S.MEDIA_PLAYBACK_RATE,Ps)}set mediaPlaybackRate(e){ze(this,S.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let r=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),s=(t=(e=r.find(a=>a>this.mediaPlaybackRate))!=null?e:r[0])!=null?t:Ps,n=new w.CustomEvent(re.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}};Os=new WeakMap;w.customElements.get("media-playback-rate-button")||w.customElements.define("media-playback-rate-button",kc);var Pi={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},jp=j.createElement("template");jp.innerHTML=`
643
+ `;var Qc=class extends $e{constructor(e={}){super({slotTemplate:Hg,...e}),h_(this,Fs,new cr(this,Xc.RATES,{defaultValue:Zc})),this.container=this.shadowRoot.querySelector("#container"),this.container.innerHTML=`${Bs}x`}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PLAYBACK_RATE,Xc.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===Xc.RATES&&(ko(this,Fs).value=r),e===S.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?Bs:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",St.PLAYBACK_RATE({playbackRate:n}))}}get rates(){return ko(this,Fs)}set rates(e){e?Array.isArray(e)&&(ko(this,Fs).value=e.join(" ")):ko(this,Fs).value=""}get mediaPlaybackRate(){return Ue(this,S.MEDIA_PLAYBACK_RATE,Bs)}set mediaPlaybackRate(e){Ke(this,S.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let r=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),s=(t=(e=r.find(a=>a>this.mediaPlaybackRate))!=null?e:r[0])!=null?t:Bs,n=new w.CustomEvent(ee.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}};Fs=new WeakMap;w.customElements.get("media-playback-rate-button")||w.customElements.define("media-playback-rate-button",Qc);var Di={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},Gg=q.createElement("template");Gg.innerHTML=`
608
644
  <style>
609
645
  :host {
610
646
  pointer-events: none;
@@ -626,9 +662,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
626
662
  </style>
627
663
 
628
664
  <img part="poster img" aria-hidden="true" id="image"/>
629
- `;var oT=i=>{i.style.removeProperty("background-image")},lT=(i,e)=>{i.style["background-image"]=`url('${e}')`},wc=class extends w.HTMLElement{static get observedAttributes(){return[Pi.PLACEHOLDER_SRC,Pi.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(jp.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,r){e===Pi.SRC&&(r==null?this.image.removeAttribute(Pi.SRC):this.image.setAttribute(Pi.SRC,r)),e===Pi.PLACEHOLDER_SRC&&(r==null?oT(this.image):lT(this.image,r))}get placeholderSrc(){return We(this,Pi.PLACEHOLDER_SRC)}set placeholderSrc(e){Be(this,Pi.SRC,e)}get src(){return We(this,Pi.SRC)}set src(e){Be(this,Pi.SRC,e)}};w.customElements.get("media-poster-image")||w.customElements.define("media-poster-image",wc);var Ns={SEEK_OFFSET:"seekoffset"},To=30,dT=`<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)">${To}</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>`,zp=j.createElement("template");zp.innerHTML=`
630
- <slot name="icon">${dT}</slot>
631
- `;var cT=0,Dc=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_CURRENT_TIME,Ns.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:zp,...e})}connectedCallback(){this.seekOffset=Fe(this,Ns.SEEK_OFFSET,To),super.connectedCallback()}attributeChangedCallback(e,t,r){e===Ns.SEEK_OFFSET&&(this.seekOffset=Fe(this,Ns.SEEK_OFFSET,To)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return Fe(this,Ns.SEEK_OFFSET,To)}set seekOffset(e){ze(this,Ns.SEEK_OFFSET,e),this.setAttribute("aria-label",Xe.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),Ga(Va(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Fe(this,S.MEDIA_CURRENT_TIME,cT)}set mediaCurrentTime(e){ze(this,S.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new w.CustomEvent(re.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};w.customElements.get("media-seek-backward-button")||w.customElements.define("media-seek-backward-button",Dc);var Qp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Xp=(i,e,t)=>(Qp(i,e,"read from private field"),t?t.call(i):e.get(i)),uT=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},hT=(i,e,t,r)=>(Qp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mn,Cc=class extends ir{constructor(){super(),uT(this,Mn,void 0),hT(this,Mn,this.shadowRoot.querySelector("slot")),Xp(this,Mn).textContent=Ri(0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,r){e===S.MEDIA_PREVIEW_TIME&&r!=null&&(Xp(this,Mn).textContent=Ri(r)),super.attributeChangedCallback(e,t,r)}get mediaPreviewTime(){return Fe(this,S.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){ze(this,S.MEDIA_PREVIEW_TIME,e)}};Mn=new WeakMap;w.customElements.get("media-preview-time-display")||w.customElements.define("media-preview-time-display",Cc);var Zp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},_o=(i,e,t)=>(Zp(i,e,"read from private field"),t?t.call(i):e.get(i)),fT=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ao=(i,e,t,r)=>(Zp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ni,Jp=j.createElement("template");Jp.innerHTML=`
665
+ `;var f_=i=>{i.style.removeProperty("background-image")},m_=(i,e)=>{i.style["background-image"]=`url('${e}')`},Jc=class extends w.HTMLElement{static get observedAttributes(){return[Di.PLACEHOLDER_SRC,Di.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Gg.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,r){e===Di.SRC&&(r==null?this.image.removeAttribute(Di.SRC):this.image.setAttribute(Di.SRC,r)),e===Di.PLACEHOLDER_SRC&&(r==null?f_(this.image):m_(this.image,r))}get placeholderSrc(){return He(this,Di.PLACEHOLDER_SRC)}set placeholderSrc(e){Be(this,Di.SRC,e)}get src(){return He(this,Di.SRC)}set src(e){Be(this,Di.SRC,e)}};w.customElements.get("media-poster-image")||w.customElements.define("media-poster-image",Jc);var $s={SEEK_OFFSET:"seekoffset"},wo=30,p_=`<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)">${wo}</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>`,Vg=q.createElement("template");Vg.innerHTML=`
666
+ <slot name="icon">${p_}</slot>
667
+ `;var g_=0,eu=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_CURRENT_TIME,$s.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Vg,...e})}connectedCallback(){this.seekOffset=Ue(this,$s.SEEK_OFFSET,wo),super.connectedCallback()}attributeChangedCallback(e,t,r){e===$s.SEEK_OFFSET&&(this.seekOffset=Ue(this,$s.SEEK_OFFSET,wo)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return Ue(this,$s.SEEK_OFFSET,wo)}set seekOffset(e){Ke(this,$s.SEEK_OFFSET,e),this.setAttribute("aria-label",Ve.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),Ya(ja(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Ue(this,S.MEDIA_CURRENT_TIME,g_)}set mediaCurrentTime(e){Ke(this,S.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new w.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};w.customElements.get("media-seek-backward-button")||w.customElements.define("media-seek-backward-button",eu);var Wg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Kg=(i,e,t)=>(Wg(i,e,"read from private field"),t?t.call(i):e.get(i)),v_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},E_=(i,e,t,r)=>(Wg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),$n,tu=class extends zi{constructor(){super(),v_(this,$n,void 0),E_(this,$n,this.shadowRoot.querySelector("slot")),Kg(this,$n).textContent=Si(0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,r){e===S.MEDIA_PREVIEW_TIME&&r!=null&&(Kg(this,$n).textContent=Si(r)),super.attributeChangedCallback(e,t,r)}get mediaPreviewTime(){return Ue(this,S.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){Ke(this,S.MEDIA_PREVIEW_TIME,e)}};$n=new WeakMap;w.customElements.get("media-preview-time-display")||w.customElements.define("media-preview-time-display",tu);var qg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Do=(i,e,t)=>(qg(i,e,"read from private field"),t?t.call(i):e.get(i)),b_=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Co=(i,e,t,r)=>(qg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ci,Yg=q.createElement("template");Yg.innerHTML=`
632
668
  <style>
633
669
  :host {
634
670
  box-sizing: border-box;
@@ -642,7 +678,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
642
678
  }
643
679
  </style>
644
680
  <img crossorigin loading="eager" decoding="async">
645
- `;var Mc=class extends w.HTMLElement{constructor(){super(),fT(this,Ni,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Jp.content.cloneNode(!0)))}static get observedAttributes(){return[ye.MEDIA_CONTROLLER,S.MEDIA_PREVIEW_IMAGE,S.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,r;let s=this.getAttribute(ye.MEDIA_CONTROLLER);s&&(Ao(this,Ni,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=_o(this,Ni))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=_o(this,Ni))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ao(this,Ni,null)}attributeChangedCallback(e,t,r){var s,n,a,o,l;[S.MEDIA_PREVIEW_IMAGE,S.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===ye.MEDIA_CONTROLLER&&(t&&((n=(s=_o(this,Ni))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ao(this,Ni,null)),r&&this.isConnected&&(Ao(this,Ni,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=_o(this,Ni))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return We(this,S.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){Be(this,S.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(S.MEDIA_PREVIEW_COORDS);if(!!e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(S.MEDIA_PREVIEW_COORDS);return}this.setAttribute(S.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;let[r,s,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:c,minWidth:u,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(c)/a),g=Math.max(parseInt(u)/n,parseInt(h)/a),E=f<1,T=E?f:g>1?g:1,{style:A}=et(this.shadowRoot,":host"),k=et(this.shadowRoot,"img").style,L=this.shadowRoot.querySelector("img"),N=E?"min":"max";A.setProperty(`${N}-width`,"initial","important"),A.setProperty(`${N}-height`,"initial","important"),A.width=`${n*T}px`,A.height=`${a*T}px`;let D=()=>{k.width=`${this.imgWidth*T}px`,k.height=`${this.imgHeight*T}px`,k.display="block"};L.src!==o&&(L.onload=()=>{this.imgWidth=L.naturalWidth,this.imgHeight=L.naturalHeight,D()},L.src=o,D()),D(),k.transform=`translate(-${r*T}px, -${s*T}px)`}};Ni=new WeakMap;w.customElements.get("media-preview-thumbnail")||w.customElements.define("media-preview-thumbnail",Mc);var eg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},yt=(i,e,t)=>(eg(i,e,"read from private field"),t?t.call(i):e.get(i)),Ui=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Qt=(i,e,t,r)=>(eg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),mT=(i,e,t,r)=>({set _(s){Qt(i,e,s,t)},get _(){return yt(i,e,r)}}),Us,So,Fs,On,xo,Io,Lo,Bs,Kr,ko,Ro=class{constructor(e,t,r){Ui(this,Us,void 0),Ui(this,So,void 0),Ui(this,Fs,void 0),Ui(this,On,void 0),Ui(this,xo,void 0),Ui(this,Io,void 0),Ui(this,Lo,void 0),Ui(this,Bs,void 0),Ui(this,Kr,0),Ui(this,ko,(s=performance.now())=>{Qt(this,Kr,requestAnimationFrame(yt(this,ko))),Qt(this,On,performance.now()-yt(this,Fs));let n=1e3/this.fps;if(yt(this,On)>n){Qt(this,Fs,s-yt(this,On)%n);let a=1e3/((s-yt(this,So))/++mT(this,xo)._),o=(s-yt(this,Io))/1e3/this.duration,l=yt(this,Lo)+o*this.playbackRate;l-yt(this,Us).valueAsNumber>0?Qt(this,Bs,this.playbackRate/this.duration/a):(Qt(this,Bs,.995*yt(this,Bs)),l=yt(this,Us).valueAsNumber+yt(this,Bs)),this.callback(l)}}),Qt(this,Us,e),this.callback=t,this.fps=r}start(){yt(this,Kr)===0&&(Qt(this,Fs,performance.now()),Qt(this,So,yt(this,Fs)),Qt(this,xo,0),yt(this,ko).call(this))}stop(){yt(this,Kr)!==0&&(cancelAnimationFrame(yt(this,Kr)),Qt(this,Kr,0))}update({start:e,duration:t,playbackRate:r}){let s=e-yt(this,Us).valueAsNumber;(s>0||s<-.03)&&this.callback(e),Qt(this,Lo,e),Qt(this,Io,performance.now()),this.duration=t,this.playbackRate=r}};Us=new WeakMap;So=new WeakMap;Fs=new WeakMap;On=new WeakMap;xo=new WeakMap;Io=new WeakMap;Lo=new WeakMap;Bs=new WeakMap;Kr=new WeakMap;ko=new WeakMap;var Fc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},gi=(i,e,t)=>(Fc(i,e,"read from private field"),t?t.call(i):e.get(i)),Zt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},$s=(i,e,t,r)=>(Fc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ai=(i,e,t)=>(Fc(i,e,"access private method"),t),Wr,wo,Do,Pn,Co,Mo,Hs,Nn,Bc,ig,Oc,Oo,$c,Pc,rg,Un,Po,Nc,sg,pT="video not loaded, unknown time.",gT=i=>{let e=i.range,t=Ur(+ag(i)),r=Ur(+i.mediaSeekableEnd),s=t&&r?`${t} of ${r}`:pT;e.setAttribute("aria-valuetext",s)},ng=j.createElement("template");ng.innerHTML=`
681
+ `;var iu=class extends w.HTMLElement{constructor(){super(),b_(this,Ci,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Yg.content.cloneNode(!0)))}static get observedAttributes(){return[pe.MEDIA_CONTROLLER,S.MEDIA_PREVIEW_IMAGE,S.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,r;let s=this.getAttribute(pe.MEDIA_CONTROLLER);s&&(Co(this,Ci,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Do(this,Ci))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Do(this,Ci))==null?void 0:e.unassociateElement)==null||t.call(e,this),Co(this,Ci,null)}attributeChangedCallback(e,t,r){var s,n,a,o,l;[S.MEDIA_PREVIEW_IMAGE,S.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===pe.MEDIA_CONTROLLER&&(t&&((n=(s=Do(this,Ci))==null?void 0:s.unassociateElement)==null||n.call(s,this),Co(this,Ci,null)),r&&this.isConnected&&(Co(this,Ci,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Do(this,Ci))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return He(this,S.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){Be(this,S.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(S.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(S.MEDIA_PREVIEW_COORDS);return}this.setAttribute(S.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;let[r,s,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:c,minWidth:u,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(c)/a),g=Math.max(parseInt(u)/n,parseInt(h)/a),E=f<1,T=E?f:g>1?g:1,{style:A}=Ye(this.shadowRoot,":host"),R=Ye(this.shadowRoot,"img").style,L=this.shadowRoot.querySelector("img"),N=E?"min":"max";A.setProperty(`${N}-width`,"initial","important"),A.setProperty(`${N}-height`,"initial","important"),A.width=`${n*T}px`,A.height=`${a*T}px`;let M=()=>{R.width=`${this.imgWidth*T}px`,R.height=`${this.imgHeight*T}px`,R.display="block"};L.src!==o&&(L.onload=()=>{this.imgWidth=L.naturalWidth,this.imgHeight=L.naturalHeight,M()},L.src=o,M()),M(),R.transform=`translate(-${r*T}px, -${s*T}px)`}};Ci=new WeakMap;w.customElements.get("media-preview-thumbnail")||w.customElements.define("media-preview-thumbnail",iu);var jg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},pt=(i,e,t)=>(jg(i,e,"read from private field"),t?t.call(i):e.get(i)),Mi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Xt=(i,e,t,r)=>(jg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),y_=(i,e,t,r)=>({set _(s){Xt(i,e,s,t)},get _(){return pt(i,e,r)}}),Hs,Mo,Gs,Hn,Po,Oo,No,Vs,$r,Uo,Fo=class{constructor(e,t,r){Mi(this,Hs,void 0),Mi(this,Mo,void 0),Mi(this,Gs,void 0),Mi(this,Hn,void 0),Mi(this,Po,void 0),Mi(this,Oo,void 0),Mi(this,No,void 0),Mi(this,Vs,void 0),Mi(this,$r,0),Mi(this,Uo,(s=performance.now())=>{Xt(this,$r,requestAnimationFrame(pt(this,Uo))),Xt(this,Hn,performance.now()-pt(this,Gs));let n=1e3/this.fps;if(pt(this,Hn)>n){Xt(this,Gs,s-pt(this,Hn)%n);let a=1e3/((s-pt(this,Mo))/++y_(this,Po)._),o=(s-pt(this,Oo))/1e3/this.duration,l=pt(this,No)+o*this.playbackRate;l-pt(this,Hs).valueAsNumber>0?Xt(this,Vs,this.playbackRate/this.duration/a):(Xt(this,Vs,.995*pt(this,Vs)),l=pt(this,Hs).valueAsNumber+pt(this,Vs)),this.callback(l)}}),Xt(this,Hs,e),this.callback=t,this.fps=r}start(){pt(this,$r)===0&&(Xt(this,Gs,performance.now()),Xt(this,Mo,pt(this,Gs)),Xt(this,Po,0),pt(this,Uo).call(this))}stop(){pt(this,$r)!==0&&(cancelAnimationFrame(pt(this,$r)),Xt(this,$r,0))}update({start:e,duration:t,playbackRate:r}){let s=e-pt(this,Hs).valueAsNumber;(s>0||s<-.03)&&this.callback(e),Xt(this,No,e),Xt(this,Oo,performance.now()),this.duration=t,this.playbackRate=r}};Hs=new WeakMap;Mo=new WeakMap;Gs=new WeakMap;Hn=new WeakMap;Po=new WeakMap;Oo=new WeakMap;No=new WeakMap;Vs=new WeakMap;$r=new WeakMap;Uo=new WeakMap;var ou=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Qt=(i,e,t)=>(ou(i,e,"read from private field"),t?t.call(i):e.get(i)),$t=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},hr=(i,e,t,r)=>(ou(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ri=(i,e,t)=>(ou(i,e,"access private method"),t),Ks,Hr,Bo,$o,Gn,Ho,Go,Ws,Vn,lu,Xg,ru,Vo,du,su,Qg,Kn,Ko,nu,Zg,T_="video not loaded, unknown time.",__=i=>{let e=i.range,t=Mr(+e0(i)),r=Mr(+i.mediaSeekableEnd),s=t&&r?`${t} of ${r}`:T_;e.setAttribute("aria-valuetext",s)},Jg=q.createElement("template");Jg.innerHTML=`
646
682
  <style>
647
683
  :host {
648
684
  --media-preview-border-radius: 3px;
@@ -767,7 +803,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
767
803
 
768
804
  </slot>
769
805
  </div>
770
- `;var tg=(i,e=i.mediaCurrentTime)=>{if(Number.isNaN(i.mediaSeekableEnd))return 0;let t=(e-i.mediaSeekableStart)/(i.mediaSeekableEnd-i.mediaSeekableStart);return Math.max(0,Math.min(t,1))},ag=(i,e=i.range.valueAsNumber)=>Number.isNaN(i.mediaSeekableEnd)?0:e*(i.mediaSeekableEnd-i.mediaSeekableStart)+i.mediaSeekableStart,Uc=class extends Vr{constructor(){super(),Zt(this,Hs),Zt(this,Bc),Zt(this,Oo),Zt(this,Pc),Zt(this,Un),Zt(this,Nc),Zt(this,Wr,void 0),Zt(this,wo,void 0),Zt(this,Do,void 0),Zt(this,Pn,void 0),Zt(this,Co,void 0),Zt(this,Mo,void 0),Zt(this,Oc,t=>{this.dragging||(this.range.valueAsNumber=t,this.updateBar())}),this.container.appendChild(ng.content.cloneNode(!0)),$s(this,wo,this.shadowRoot.querySelectorAll('[part~="box"]')),$s(this,Do,this.shadowRoot.querySelector('[part~="preview-box"]')),$s(this,Pn,this.shadowRoot.querySelector('[part~="current-box"]'));let e=getComputedStyle(this);$s(this,Co,parseInt(e.getPropertyValue("--media-box-padding-left"))),$s(this,Mo,parseInt(e.getPropertyValue("--media-box-padding-right"))),$s(this,Wr,new Ro(this.range,gi(this,Oc),60)),this.addEventListener("transitionstart",this)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PAUSED,S.MEDIA_DURATION,S.MEDIA_SEEKABLE,S.MEDIA_CURRENT_TIME,S.MEDIA_PREVIEW_IMAGE,S.MEDIA_PREVIEW_TIME,S.MEDIA_BUFFERED,S.MEDIA_PLAYBACK_RATE,S.MEDIA_LOADING,S.MEDIA_ENDED]}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",Rt.SEEK()),ai(this,Hs,Nn).call(this)}disconnectedCallback(){super.disconnectedCallback(),ai(this,Hs,Nn).call(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),t!=r&&(e===S.MEDIA_CURRENT_TIME||e===S.MEDIA_PAUSED||e===S.MEDIA_ENDED||e===S.MEDIA_LOADING||e===S.MEDIA_DURATION||e===S.MEDIA_SEEKABLE?(gi(this,Wr).update({start:tg(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),ai(this,Hs,Nn).call(this),gT(this)):e===S.MEDIA_BUFFERED&&this.updateBufferedBar())}get mediaPaused(){return Ye(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ke(this,S.MEDIA_PAUSED,e)}get mediaLoading(){return Ye(this,S.MEDIA_LOADING)}set mediaLoading(e){Ke(this,S.MEDIA_LOADING,e)}get mediaDuration(){return Fe(this,S.MEDIA_DURATION)}set mediaDuration(e){ze(this,S.MEDIA_DURATION,e)}get mediaCurrentTime(){return Fe(this,S.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){ze(this,S.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return Fe(this,S.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){ze(this,S.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(S.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(S.MEDIA_BUFFERED);return}let t=e.map(r=>r.join(":")).join(" ");this.setAttribute(S.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(S.MEDIA_SEEKABLE);if(!!e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(S.MEDIA_SEEKABLE);return}this.setAttribute(S.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;let[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return We(this,S.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){Be(this,S.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return Fe(this,S.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){ze(this,S.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return Ye(this,S.MEDIA_ENDED)}set mediaEnded(e){Ke(this,S.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;let t=this.mediaBuffered;if(!t.length)return;let r;if(this.mediaEnded)r=1;else{let n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];r=tg(this,a)}let{style:s}=et(this.shadowRoot,"#highlight");s.setProperty("width",`${r*100}%`)}updateCurrentBox(){if(!gi(this,Pn).assignedElements().length)return;let e=ai(this,Oo,$c).call(this,gi(this,Pn),this.range.valueAsNumber),{style:t}=et(this.shadowRoot,"#current-rail");t.transform=`translateX(${e})`}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":ai(this,Nc,sg).call(this);break;case"pointermove":ai(this,Pc,rg).call(this,e);break;case"pointerup":case"pointerleave":ai(this,Un,Po).call(this,null);break;case"transitionstart":setTimeout(()=>ai(this,Hs,Nn).call(this),0);break}}};Wr=new WeakMap;wo=new WeakMap;Do=new WeakMap;Pn=new WeakMap;Co=new WeakMap;Mo=new WeakMap;Hs=new WeakSet;Nn=function(){ai(this,Bc,ig).call(this)?gi(this,Wr).start():gi(this,Wr).stop()};Bc=new WeakSet;ig=function(){return this.isConnected&&Hm(this)&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded};Oc=new WeakMap;Oo=new WeakSet;$c=function(i,e){var t;let r=`${e*100*100}%`,s=i.offsetWidth;if(!s)return r;let n=(t=this.getAttribute("bounds")?mr(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?t:this,a=this.range.getBoundingClientRect(),o=n.getBoundingClientRect(),l=(gi(this,Co)-(a.left-o.left-s/2))/a.width*100,d=(o.right-a.left-s/2-gi(this,Mo))/a.width*100;return Number.isNaN(l)||(r=`max(${l*100}%, ${r})`),Number.isNaN(d)||(r=`min(${r}, ${d*100}%)`),r};Pc=new WeakSet;rg=function(i){let e=[...gi(this,wo)].some(o=>i.composedPath().includes(o));if(!this.dragging&&(e||!i.composedPath().includes(this))){ai(this,Un,Po).call(this,null);return}let t=this.mediaDuration;if(!t)return;let r=this.range.getBoundingClientRect(),s=(i.clientX-r.left)/r.width;s=Math.max(0,Math.min(1,s));let n=ai(this,Oo,$c).call(this,gi(this,Do),s),{style:a}=et(this.shadowRoot,"#preview-rail");a.transform=`translateX(${n})`,ai(this,Un,Po).call(this,s*t)};Un=new WeakSet;Po=function(i){this.dispatchEvent(new w.CustomEvent(re.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};Nc=new WeakSet;sg=function(){gi(this,Wr).stop();let i=ag(this);this.dispatchEvent(new w.CustomEvent(re.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};w.customElements.get("media-time-range")||w.customElements.define("media-time-range",Uc);var lg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Gs=(i,e,t)=>(lg(i,e,"read from private field"),t?t.call(i):e.get(i)),Hc=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Vs=(i,e,t,r)=>(lg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Fi,No,Uo,og={LOADING_DELAY:"loadingdelay"},dg=500,cg=j.createElement("template"),vT=`
806
+ `;var zg=(i,e=i.mediaCurrentTime)=>{if(Number.isNaN(i.mediaSeekableEnd))return 0;let t=(e-i.mediaSeekableStart)/(i.mediaSeekableEnd-i.mediaSeekableStart);return Math.max(0,Math.min(t,1))},e0=(i,e=i.range.valueAsNumber)=>Number.isNaN(i.mediaSeekableEnd)?0:e*(i.mediaSeekableEnd-i.mediaSeekableStart)+i.mediaSeekableStart,au=class extends Br{constructor(){super(),$t(this,Ws),$t(this,lu),$t(this,Vo),$t(this,su),$t(this,Kn),$t(this,nu),$t(this,Ks,void 0),$t(this,Hr,void 0),$t(this,Bo,void 0),$t(this,$o,void 0),$t(this,Gn,void 0),$t(this,Ho,void 0),$t(this,Go,void 0),$t(this,ru,t=>{this.dragging||(this.range.valueAsNumber=t,this.updateBar())}),this.container.appendChild(Jg.content.cloneNode(!0)),hr(this,Bo,this.shadowRoot.querySelectorAll('[part~="box"]')),hr(this,$o,this.shadowRoot.querySelector('[part~="preview-box"]')),hr(this,Gn,this.shadowRoot.querySelector('[part~="current-box"]'));let e=getComputedStyle(this);hr(this,Ho,parseInt(e.getPropertyValue("--media-box-padding-left"))),hr(this,Go,parseInt(e.getPropertyValue("--media-box-padding-right"))),hr(this,Hr,new Fo(this.range,Qt(this,ru),60))}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PAUSED,S.MEDIA_DURATION,S.MEDIA_SEEKABLE,S.MEDIA_CURRENT_TIME,S.MEDIA_PREVIEW_IMAGE,S.MEDIA_PREVIEW_TIME,S.MEDIA_BUFFERED,S.MEDIA_PLAYBACK_RATE,S.MEDIA_LOADING,S.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",St.SEEK()),ri(this,Ws,Vn).call(this),hr(this,Ks,this.getRootNode()),(e=Qt(this,Ks))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),ri(this,Ws,Vn).call(this),(e=Qt(this,Ks))==null||e.removeEventListener("transitionstart",this),hr(this,Ks,null)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),t!=r&&(e===S.MEDIA_CURRENT_TIME||e===S.MEDIA_PAUSED||e===S.MEDIA_ENDED||e===S.MEDIA_LOADING||e===S.MEDIA_DURATION||e===S.MEDIA_SEEKABLE?(Qt(this,Hr).update({start:zg(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),ri(this,Ws,Vn).call(this),__(this)):e===S.MEDIA_BUFFERED&&this.updateBufferedBar())}get mediaPaused(){return Fe(this,S.MEDIA_PAUSED)}set mediaPaused(e){Oe(this,S.MEDIA_PAUSED,e)}get mediaLoading(){return Fe(this,S.MEDIA_LOADING)}set mediaLoading(e){Oe(this,S.MEDIA_LOADING,e)}get mediaDuration(){return Ue(this,S.MEDIA_DURATION)}set mediaDuration(e){Ke(this,S.MEDIA_DURATION,e)}get mediaCurrentTime(){return Ue(this,S.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){Ke(this,S.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return Ue(this,S.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){Ke(this,S.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(S.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(S.MEDIA_BUFFERED);return}let t=e.map(r=>r.join(":")).join(" ");this.setAttribute(S.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(S.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(S.MEDIA_SEEKABLE);return}this.setAttribute(S.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;let[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return He(this,S.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){Be(this,S.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return Ue(this,S.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){Ke(this,S.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return Fe(this,S.MEDIA_ENDED)}set mediaEnded(e){Oe(this,S.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;let t=this.mediaBuffered;if(!t.length)return;let r;if(this.mediaEnded)r=1;else{let n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];r=zg(this,a)}let{style:s}=Ye(this.shadowRoot,"#highlight");s.setProperty("width",`${r*100}%`)}updateCurrentBox(){if(!Qt(this,Gn).assignedElements().length)return;let e=ri(this,Vo,du).call(this,Qt(this,Gn),this.range.valueAsNumber),{style:t}=Ye(this.shadowRoot,"#current-rail");t.transform=`translateX(${e})`}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":ri(this,nu,Zg).call(this);break;case"pointermove":ri(this,su,Qg).call(this,e);break;case"pointerup":case"pointerleave":ri(this,Kn,Ko).call(this,null);break;case"transitionstart":nr(e.target,this)&&setTimeout(()=>ri(this,Ws,Vn).call(this),0);break}}};Ks=new WeakMap;Hr=new WeakMap;Bo=new WeakMap;$o=new WeakMap;Gn=new WeakMap;Ho=new WeakMap;Go=new WeakMap;Ws=new WeakSet;Vn=function(){ri(this,lu,Xg).call(this)?Qt(this,Hr).start():Qt(this,Hr).stop()};lu=new WeakSet;Xg=function(){return this.isConnected&&Rp(this)&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded};ru=new WeakMap;Vo=new WeakSet;du=function(i,e){var t;let r=`${e*100*100}%`,s=i.offsetWidth;if(!s)return r;let n=(t=this.getAttribute("bounds")?ar(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?t:this,a=this.range.getBoundingClientRect(),o=n.getBoundingClientRect(),l=(Qt(this,Ho)-(a.left-o.left-s/2))/a.width*100,d=(o.right-a.left-s/2-Qt(this,Go))/a.width*100;return Number.isNaN(l)||(r=`max(${l*100}%, ${r})`),Number.isNaN(d)||(r=`min(${r}, ${d*100}%)`),r};su=new WeakSet;Qg=function(i){let e=[...Qt(this,Bo)].some(o=>i.composedPath().includes(o));if(!this.dragging&&(e||!i.composedPath().includes(this))){ri(this,Kn,Ko).call(this,null);return}let t=this.mediaDuration;if(!t)return;let r=this.range.getBoundingClientRect(),s=(i.clientX-r.left)/r.width;s=Math.max(0,Math.min(1,s));let n=ri(this,Vo,du).call(this,Qt(this,$o),s),{style:a}=Ye(this.shadowRoot,"#preview-rail");a.transform=`translateX(${n})`,ri(this,Kn,Ko).call(this,s*t)};Kn=new WeakSet;Ko=function(i){this.dispatchEvent(new w.CustomEvent(ee.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};nu=new WeakSet;Zg=function(){Qt(this,Hr).stop();let i=e0(this);this.dispatchEvent(new w.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};w.customElements.get("media-time-range")||w.customElements.define("media-time-range",au);var i0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},qs=(i,e,t)=>(i0(i,e,"read from private field"),t?t.call(i):e.get(i)),cu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ys=(i,e,t,r)=>(i0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Pi,Wo,qo,t0={LOADING_DELAY:"loadingdelay"},r0=500,s0=q.createElement("template"),A_=`
771
807
  <svg aria-hidden="true" viewBox="0 0 100 100">
772
808
  <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">
773
809
  <animateTransform
@@ -780,13 +816,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
780
816
  repeatCount="indefinite" />
781
817
  </path>
782
818
  </svg>
783
- `;cg.innerHTML=`
819
+ `;s0.innerHTML=`
784
820
  <style>
785
821
  :host {
786
822
  display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
787
823
  vertical-align: middle;
788
824
  box-sizing: border-box;
789
- --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${dg}ms);
825
+ --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${r0}ms);
790
826
  }
791
827
 
792
828
  #status {
@@ -825,12 +861,12 @@ svg, img, ::slotted(svg), ::slotted(img) {
825
861
  }
826
862
  </style>
827
863
 
828
- <slot name="icon">${vT}</slot>
829
- <div id="status" role="status" aria-live="polite">${Rt.MEDIA_LOADING()}</div>
830
- `;var Gc=class extends w.HTMLElement{constructor(){if(super(),Hc(this,Fi,void 0),Hc(this,No,dg),Hc(this,Uo,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),r=cg.content.cloneNode(!0);t.appendChild(r)}let{style:e}=et(this.shadowRoot,":host");Vs(this,Uo,e)}static get observedAttributes(){return[ye.MEDIA_CONTROLLER,S.MEDIA_PAUSED,S.MEDIA_LOADING,og.LOADING_DELAY]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===og.LOADING_DELAY&&t!==r?this.loadingDelay=Number(r):e===ye.MEDIA_CONTROLLER&&(t&&((n=(s=Gs(this,Fi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Vs(this,Fi,null)),r&&this.isConnected&&(Vs(this,Fi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Gs(this,Fi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(ye.MEDIA_CONTROLLER);s&&(Vs(this,Fi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Gs(this,Fi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Gs(this,Fi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Vs(this,Fi,null)}get loadingDelay(){return Gs(this,No)}set loadingDelay(e){Vs(this,No,e),Gs(this,Uo).setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return Ye(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ke(this,S.MEDIA_PAUSED,e)}get mediaLoading(){return Ye(this,S.MEDIA_LOADING)}set mediaLoading(e){Ke(this,S.MEDIA_LOADING,e)}};Fi=new WeakMap;No=new WeakMap;Uo=new WeakMap;w.customElements.get("media-loading-indicator")||w.customElements.define("media-loading-indicator",Gc);var ET=1,bT=i=>i.mediaMuted?0:i.mediaVolume,yT=({value:i})=>`${Math.round(i*100)}%`,Vc=class extends Vr{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_VOLUME,S.MEDIA_MUTED,S.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new w.CustomEvent(re.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",Rt.VOLUME())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),(e===S.MEDIA_VOLUME||e===S.MEDIA_MUTED)&&(this.range.valueAsNumber=bT(this),this.range.setAttribute("aria-valuetext",yT(this.range)),this.updateBar())}get mediaVolume(){return Fe(this,S.MEDIA_VOLUME,ET)}set mediaVolume(e){ze(this,S.MEDIA_VOLUME,e)}get mediaMuted(){return Ye(this,S.MEDIA_MUTED)}set mediaMuted(e){Ke(this,S.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return We(this,S.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){Be(this,S.MEDIA_VOLUME_UNAVAILABLE,e)}};w.customElements.get("media-volume-range")||w.customElements.define("media-volume-range",Vc);var zc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},It=(i,e,t)=>(zc(i,e,"read from private field"),t?t.call(i):e.get(i)),Jt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ei=(i,e,t,r)=>(zc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),vi=(i,e,t)=>(zc(i,e,"access private method"),t),Bi,br,Ws,Fn,Fo,Bo,Kc,Ks,Wc,$o,qc,Bn,Ho,Go,Yc,jc,ug,Xc,hg,TT=`
864
+ <slot name="icon">${A_}</slot>
865
+ <div id="status" role="status" aria-live="polite">${St.MEDIA_LOADING()}</div>
866
+ `;var uu=class extends w.HTMLElement{constructor(){if(super(),cu(this,Pi,void 0),cu(this,Wo,r0),cu(this,qo,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),r=s0.content.cloneNode(!0);t.appendChild(r)}let{style:e}=Ye(this.shadowRoot,":host");Ys(this,qo,e)}static get observedAttributes(){return[pe.MEDIA_CONTROLLER,S.MEDIA_PAUSED,S.MEDIA_LOADING,t0.LOADING_DELAY]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===t0.LOADING_DELAY&&t!==r?this.loadingDelay=Number(r):e===pe.MEDIA_CONTROLLER&&(t&&((n=(s=qs(this,Pi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ys(this,Pi,null)),r&&this.isConnected&&(Ys(this,Pi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=qs(this,Pi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(pe.MEDIA_CONTROLLER);s&&(Ys(this,Pi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=qs(this,Pi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=qs(this,Pi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ys(this,Pi,null)}get loadingDelay(){return qs(this,Wo)}set loadingDelay(e){Ys(this,Wo,e),qs(this,qo).setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return Fe(this,S.MEDIA_PAUSED)}set mediaPaused(e){Oe(this,S.MEDIA_PAUSED,e)}get mediaLoading(){return Fe(this,S.MEDIA_LOADING)}set mediaLoading(e){Oe(this,S.MEDIA_LOADING,e)}};Pi=new WeakMap;Wo=new WeakMap;qo=new WeakMap;w.customElements.get("media-loading-indicator")||w.customElements.define("media-loading-indicator",uu);var S_=1,x_=i=>i.mediaMuted?0:i.mediaVolume,I_=({value:i})=>`${Math.round(i*100)}%`,hu=class extends Br{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_VOLUME,S.MEDIA_MUTED,S.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new w.CustomEvent(ee.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",St.VOLUME())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),(e===S.MEDIA_VOLUME||e===S.MEDIA_MUTED)&&(this.range.valueAsNumber=x_(this),this.range.setAttribute("aria-valuetext",I_(this.range)),this.updateBar())}get mediaVolume(){return Ue(this,S.MEDIA_VOLUME,S_)}set mediaVolume(e){Ke(this,S.MEDIA_VOLUME,e)}get mediaMuted(){return Fe(this,S.MEDIA_MUTED)}set mediaMuted(e){Oe(this,S.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return He(this,S.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){Be(this,S.MEDIA_VOLUME_UNAVAILABLE,e)}};w.customElements.get("media-volume-range")||w.customElements.define("media-volume-range",hu);var Eu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},yt=(i,e,t)=>(Eu(i,e,"read from private field"),t?t.call(i):e.get(i)),Zt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},gi=(i,e,t,r)=>(Eu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),pi=(i,e,t)=>(Eu(i,e,"access private method"),t),Oi,fr,zs,Wn,Yo,jo,fu,js,mu,zo,pu,qn,Xo,Qo,gu,vu,n0,bu,a0,L_=`
831
867
  <svg aria-hidden="true" viewBox="0 1 24 24" part="select-indicator indicator">
832
868
  <path d="m10 15.17 9.193-9.191 1.414 1.414-10.606 10.606-6.364-6.364 1.414-1.414 4.95 4.95Z"/>
833
- </svg>`;function $i(i,e,t){let r=j.createElement("media-chrome-option");r.part.add("option"),r.value=e,r.selected=t;let s=j.createElement("span");return s.textContent=i,r.append(s),r}function bi(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);return(t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t?(t=t.cloneNode(!0),t.removeAttribute("slot"),t):i.shadowRoot.querySelector(`[name="${e}"] > svg`).cloneNode(!0)}var fg=j.createElement("template");fg.innerHTML=`
869
+ </svg>`;function Ni(i,e,t){let r=q.createElement("media-chrome-option");r.part.add("option"),r.value=e,r.selected=t;let s=q.createElement("span");return s.textContent=i,r.append(s),r}function vi(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);return(t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t?(t=t.cloneNode(!0),t.removeAttribute("slot"),t):i.shadowRoot.querySelector(`[name="${e}"] > svg`).cloneNode(!0)}var o0=q.createElement("template");o0.innerHTML=`
834
870
  <style>
835
871
  :host {
836
872
  font: var(--media-font,
@@ -909,8 +945,8 @@ svg, img, ::slotted(svg), ::slotted(img) {
909
945
  </style>
910
946
  <slot name="header"></slot>
911
947
  <slot id="container"></slot>
912
- <slot name="select-indicator" hidden>${TT}</slot>
913
- `;var oi=class extends w.HTMLElement{constructor(e={}){super(),Jt(this,Bo),Jt(this,$o),Jt(this,Bn),Jt(this,Go),Jt(this,jc),Jt(this,Xc),Jt(this,Bi,void 0),Jt(this,br,""),Jt(this,Ws,null),Jt(this,Fn,!1),Jt(this,Fo,t=>{this.handleClick(t)}),Jt(this,Ks,t=>{let{key:r}=t;if(r==="Escape"){this.removeEventListener("keyup",It(this,Ks));return}if(r==="Meta"){Ei(this,Fn,!1);return}vi(this,Bo,Kc).call(this,t)}),Jt(this,Wc,t=>{let{key:r,altKey:s}=t;if(s){this.removeEventListener("keyup",It(this,Ks));return}if(r==="Meta"){Ei(this,Fn,!0);return}if(this.keysUsed.includes(r)&&t.preventDefault(),It(this,Fn)&&this.keysUsed.includes(r)){vi(this,Bo,Kc).call(this,t);return}this.addEventListener("keyup",It(this,Ks),{once:!0})}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=fg.content.cloneNode(!0),e.slotTemplate&&this.nativeEl.append(e.slotTemplate.content.cloneNode(!0)),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.container.addEventListener("slotchange",t=>{for(let r of t.target.assignedNodes({flatten:!0}))r.nodeType===3&&r.textContent.trim()===""&&r.remove()})}static get observedAttributes(){return["disabled","style",ye.MEDIA_CONTROLLER]}static formatOptionText(e){return e}formatOptionText(e,t){return this.constructor.formatOptionText(e,t)}get options(){var e;let t=this.querySelectorAll("media-chrome-option");return t.length||(t=(e=this.container)==null?void 0:e.querySelectorAll("media-chrome-option")),Array.from(t)}get selectedOptions(){return this.options.filter(e=>e.selected)}get value(){var e,t;return(t=(e=this.selectedOptions[0])==null?void 0:e.value)!=null?t:""}set value(e){let t=this.options.find(r=>r.value===e);!t||vi(this,Go,Yc).call(this,t)}focus(){var e;(e=this.selectedOptions[0])==null||e.focus()}enable(){this.addEventListener("click",It(this,Fo)),this.addEventListener("keydown",It(this,Wc))}disable(){this.removeEventListener("click",It(this,Fo)),this.removeEventListener("keyup",It(this,Ks))}attributeChangedCallback(e,t,r){var s,n,a,o,l;e==="style"&&r!==t?vi(this,$o,qc).call(this):e===ye.MEDIA_CONTROLLER?(t&&((n=(s=It(this,Bi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ei(this,Bi,null)),r&&this.isConnected&&(Ei(this,Bi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=It(this,Bi))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;vi(this,$o,qc).call(this),this.hasAttribute("disabled")||this.enable(),this.hasAttribute("role")||this.setAttribute("role","listbox");let s=this.getAttribute(ye.MEDIA_CONTROLLER);s&&(Ei(this,Bi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=It(this,Bi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=It(this,Bi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ei(this,Bi,null)}get keysUsed(){return["Enter"," ","ArrowDown","ArrowUp","Home","End"]}handleSelection(e,t){let r=vi(this,Bn,Ho).call(this,e);!r||vi(this,Go,Yc).call(this,r,t)}handleMovement(e){let{key:t}=e,r=this.options,s=vi(this,Bn,Ho).call(this,e);s||(s=r.filter(a=>a.getAttribute("tabindex")==="0")[0]);let n;switch(t){case"ArrowDown":n=s.nextElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.nextElementSibling);break;case"ArrowUp":n=s.previousElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.previousElementSibling);break;case"Home":n=r[0];break;case"End":n=r[r.length-1];break;default:n=vi(this,jc,ug).call(this,t);break}n&&(r.forEach(a=>a.setAttribute("tabindex","-1")),n.setAttribute("tabindex","0"),n.focus())}handleClick(e){let t=vi(this,Bn,Ho).call(this,e);!t||t.hasAttribute("disabled")||(this.options.forEach(r=>r.setAttribute("tabindex","-1")),t.setAttribute("tabindex","0"),this.handleSelection(e,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"))}};Bi=new WeakMap;br=new WeakMap;Ws=new WeakMap;Fn=new WeakMap;Fo=new WeakMap;Bo=new WeakSet;Kc=function(i){let{key:e}=i;e==="Enter"||e===" "?this.handleSelection(i,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"):this.handleMovement(i)};Ks=new WeakMap;Wc=new WeakMap;$o=new WeakSet;qc=function(){var i;let e=this.shadowRoot.querySelector("#layout-row"),t=((i=getComputedStyle(this).getPropertyValue("--media-listbox-layout"))==null?void 0:i.trim())==="row";e.setAttribute("media",t?"":"width:0")};Bn=new WeakSet;Ho=function(i){let e=i.composedPath(),t=e.findIndex(r=>r.nodeName==="MEDIA-CHROME-OPTION");return e[t]};Go=new WeakSet;Yc=function(i,e){let t=[...this.selectedOptions];(!this.hasAttribute("aria-multiselectable")||this.getAttribute("aria-multiselectable")!=="true")&&this.options.forEach(r=>r.selected=!1),e?i.selected=!i.selected:i.selected=!0,this.selectedOptions.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};jc=new WeakSet;ug=function(i){vi(this,Xc,hg).call(this);let e=this.options,t=e.findIndex(d=>d.getAttribute("tabindex")==="0");Ei(this,br,It(this,br)+i);let r=It(this,br).split("").every(d=>d===i),s=e.slice(t+(r?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(It(this,br))),n=e.slice(0,t-(r?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(It(this,br))),a=[],o=[];return r&&(a=e.slice(t+(r?1:0)).filter(d=>d.textContent.startsWith(i)),o=e.slice(0,t-(r?1:0)).filter(d=>d.textContent.startsWith(i))),[...s,...n,...a,...o][0]};Xc=new WeakSet;hg=function(){clearTimeout(It(this,Ws)),Ei(this,Ws,null),Ei(this,Ws,setTimeout(()=>{Ei(this,br,""),Ei(this,Ws,null)},500))};w.customElements.get("media-chrome-listbox")||w.customElements.define("media-chrome-listbox",oi);var iu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Jc=(i,e,t)=>(iu(i,e,"read from private field"),t?t.call(i):e.get(i)),Qc=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Zc=(i,e,t,r)=>(iu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),mg=(i,e,t)=>(iu(i,e,"access private method"),t),Vo,qs,Ko,eu,pg=j.createElement("template");pg.innerHTML=`
948
+ <slot name="select-indicator" hidden>${L_}</slot>
949
+ `;var si=class extends w.HTMLElement{constructor(e={}){super(),Zt(this,jo),Zt(this,zo),Zt(this,qn),Zt(this,Qo),Zt(this,vu),Zt(this,bu),Zt(this,Oi,void 0),Zt(this,fr,""),Zt(this,zs,null),Zt(this,Wn,!1),Zt(this,Yo,t=>{this.handleClick(t)}),Zt(this,js,t=>{let{key:r}=t;if(r==="Escape"){this.removeEventListener("keyup",yt(this,js));return}if(r==="Meta"){gi(this,Wn,!1);return}pi(this,jo,fu).call(this,t)}),Zt(this,mu,t=>{let{key:r,altKey:s}=t;if(s){this.removeEventListener("keyup",yt(this,js));return}if(r==="Meta"){gi(this,Wn,!0);return}if(this.keysUsed.includes(r)&&t.preventDefault(),yt(this,Wn)&&this.keysUsed.includes(r)){pi(this,jo,fu).call(this,t);return}this.addEventListener("keyup",yt(this,js),{once:!0})}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=o0.content.cloneNode(!0),e.slotTemplate&&this.nativeEl.append(e.slotTemplate.content.cloneNode(!0)),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.container.addEventListener("slotchange",t=>{for(let r of t.target.assignedNodes({flatten:!0}))r.nodeType===3&&r.textContent.trim()===""&&r.remove()})}static get observedAttributes(){return["disabled","style",pe.MEDIA_CONTROLLER]}static formatOptionText(e){return e}formatOptionText(e,t){return this.constructor.formatOptionText(e,t)}get options(){var e;let t=this.querySelectorAll("media-chrome-option");return t.length||(t=(e=this.container)==null?void 0:e.querySelectorAll("media-chrome-option")),Array.from(t)}get selectedOptions(){return this.options.filter(e=>e.selected)}get value(){var e,t;return(t=(e=this.selectedOptions[0])==null?void 0:e.value)!=null?t:""}set value(e){let t=this.options.find(r=>r.value===e);t&&pi(this,Qo,gu).call(this,t)}focus(){var e;(e=this.selectedOptions[0])==null||e.focus()}enable(){this.addEventListener("click",yt(this,Yo)),this.addEventListener("keydown",yt(this,mu))}disable(){this.removeEventListener("click",yt(this,Yo)),this.removeEventListener("keyup",yt(this,js))}attributeChangedCallback(e,t,r){var s,n,a,o,l;e==="style"&&r!==t?pi(this,zo,pu).call(this):e===pe.MEDIA_CONTROLLER?(t&&((n=(s=yt(this,Oi))==null?void 0:s.unassociateElement)==null||n.call(s,this),gi(this,Oi,null)),r&&this.isConnected&&(gi(this,Oi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=yt(this,Oi))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;pi(this,zo,pu).call(this),this.hasAttribute("disabled")||this.enable(),this.hasAttribute("role")||this.setAttribute("role","listbox");let s=this.getAttribute(pe.MEDIA_CONTROLLER);s&&(gi(this,Oi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=yt(this,Oi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=yt(this,Oi))==null?void 0:e.unassociateElement)==null||t.call(e,this),gi(this,Oi,null)}get keysUsed(){return["Enter"," ","ArrowDown","ArrowUp","Home","End"]}handleSelection(e,t){let r=pi(this,qn,Xo).call(this,e);r&&pi(this,Qo,gu).call(this,r,t)}handleMovement(e){let{key:t}=e,r=this.options,s=pi(this,qn,Xo).call(this,e);s||(s=r.filter(a=>a.getAttribute("tabindex")==="0")[0]);let n;switch(t){case"ArrowDown":n=s.nextElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.nextElementSibling);break;case"ArrowUp":n=s.previousElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.previousElementSibling);break;case"Home":n=r[0];break;case"End":n=r[r.length-1];break;default:n=pi(this,vu,n0).call(this,t);break}n&&(r.forEach(a=>a.setAttribute("tabindex","-1")),n.setAttribute("tabindex","0"),n.focus())}handleClick(e){let t=pi(this,qn,Xo).call(this,e);!t||t.hasAttribute("disabled")||(this.options.forEach(r=>r.setAttribute("tabindex","-1")),t.setAttribute("tabindex","0"),this.handleSelection(e,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"))}};Oi=new WeakMap;fr=new WeakMap;zs=new WeakMap;Wn=new WeakMap;Yo=new WeakMap;jo=new WeakSet;fu=function(i){let{key:e}=i;e==="Enter"||e===" "?this.handleSelection(i,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"):this.handleMovement(i)};js=new WeakMap;mu=new WeakMap;zo=new WeakSet;pu=function(){var i;let e=this.shadowRoot.querySelector("#layout-row"),t=((i=getComputedStyle(this).getPropertyValue("--media-listbox-layout"))==null?void 0:i.trim())==="row";e.setAttribute("media",t?"":"width:0")};qn=new WeakSet;Xo=function(i){let e=i.composedPath(),t=e.findIndex(r=>r.nodeName==="MEDIA-CHROME-OPTION");return e[t]};Qo=new WeakSet;gu=function(i,e){let t=[...this.selectedOptions];(!this.hasAttribute("aria-multiselectable")||this.getAttribute("aria-multiselectable")!=="true")&&this.options.forEach(r=>r.selected=!1),e?i.selected=!i.selected:i.selected=!0,this.selectedOptions.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};vu=new WeakSet;n0=function(i){pi(this,bu,a0).call(this);let e=this.options,t=e.findIndex(d=>d.getAttribute("tabindex")==="0");gi(this,fr,yt(this,fr)+i);let r=yt(this,fr).split("").every(d=>d===i),s=e.slice(t+(r?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(yt(this,fr))),n=e.slice(0,t-(r?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(yt(this,fr))),a=[],o=[];return r&&(a=e.slice(t+(r?1:0)).filter(d=>d.textContent.startsWith(i)),o=e.slice(0,t-(r?1:0)).filter(d=>d.textContent.startsWith(i))),[...s,...n,...a,...o][0]};bu=new WeakSet;a0=function(){clearTimeout(yt(this,zs)),gi(this,zs,null),gi(this,zs,setTimeout(()=>{gi(this,fr,""),gi(this,zs,null)},500))};w.customElements.get("media-chrome-listbox")||w.customElements.define("media-chrome-listbox",si);var xu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},_u=(i,e,t)=>(xu(i,e,"read from private field"),t?t.call(i):e.get(i)),yu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Tu=(i,e,t,r)=>(xu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),l0=(i,e,t)=>(xu(i,e,"access private method"),t),Zo,Xs,Jo,Au,d0=q.createElement("template");d0.innerHTML=`
914
950
  <style>
915
951
  :host {
916
952
  cursor: pointer;
@@ -948,7 +984,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
948
984
  }
949
985
  </style>
950
986
  <slot></slot>
951
- `;var yr={VALUE:"value",SELECTED:"selected",DISABLED:"disabled"},Wo=class extends w.HTMLElement{constructor(){super(),Qc(this,Ko),Qc(this,Vo,!1),Qc(this,qs,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(pg.content.cloneNode(!0)))}static get observedAttributes(){return[yr.DISABLED,yr.SELECTED,yr.VALUE]}get value(){var e;return(e=this.getAttribute(yr.VALUE))!=null?e:this.text}set value(e){this.setAttribute(yr.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get selected(){return this.getAttribute("aria-selected")==="true"}set selected(e){Zc(this,Vo,!0),this.setAttribute("aria-selected",e?"true":"false"),e?this.part.add("option-selected"):this.part.remove("option-selected")}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex",-1),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false")}disable(){this.removeAttribute("tabindex")}attributeChangedCallback(e,t,r){e===yr.SELECTED&&!Jc(this,Vo)?this.setAttribute("aria-selected",r!=null?"true":"false"):e===yr.DISABLED&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(yr.DISABLED)||this.enable(),this.setAttribute("role","option"),Zc(this,qs,tu(this,this.parentNode)),mg(this,Ko,eu).call(this)}disconnectedCallback(){this.disable(),mg(this,Ko,eu).call(this),Zc(this,qs,null)}handleClick(){}};Vo=new WeakMap;qs=new WeakMap;Ko=new WeakSet;eu=function(){var i;let e=(i=Jc(this,qs))==null?void 0:i.options;if(!e)return;let t=e.filter(r=>r.getAttribute("aria-selected")==="true").pop();t||(t=e[0]),Jc(this,qs).getAttribute("aria-multiselectable")!=="true"&&e.forEach(r=>{r.setAttribute("tabindex","-1"),r.setAttribute("aria-selected","false")}),t==null||t.setAttribute("tabindex","0"),t==null||t.setAttribute("aria-selected","true")};function tu(i,e){if(!i)return null;let{host:t}=i.getRootNode();return!e&&t?tu(i,t):e!=null&&e.options?e:tu(e,e==null?void 0:e.parentNode)}w.customElements.get("media-chrome-option")||w.customElements.define("media-chrome-option",Wo);var gg=new WeakMap,ru=i=>{let e=gg.get(i);return e||gg.set(i,e=new Set),e},vg=new w.ResizeObserver(i=>{for(let e of i)for(let t of ru(e.target))t(e)});function su(i,e){ru(i).add(e),vg.observe(i)}function nu(i,e){let t=ru(i);t.delete(e),t.size||vg.unobserve(i)}var ou=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ae=(i,e,t)=>(ou(i,e,"read from private field"),t?t.call(i):e.get(i)),Gt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Hi=(i,e,t,r)=>(ou(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),qr=(i,e,t)=>(ou(i,e,"access private method"),t),Gi,wt,$n,ot,yi,Ys,qo,Yo,jo,zo,Xo,au,lu,Eg,js,Hn,Yr,bg=j.createElement("template");bg.innerHTML=`
987
+ `;var mr={VALUE:"value",SELECTED:"selected",DISABLED:"disabled"},el=class extends w.HTMLElement{constructor(){super(),yu(this,Jo),yu(this,Zo,!1),yu(this,Xs,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(d0.content.cloneNode(!0)))}static get observedAttributes(){return[mr.DISABLED,mr.SELECTED,mr.VALUE]}get value(){var e;return(e=this.getAttribute(mr.VALUE))!=null?e:this.text}set value(e){this.setAttribute(mr.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get selected(){return this.getAttribute("aria-selected")==="true"}set selected(e){Tu(this,Zo,!0),this.setAttribute("aria-selected",e?"true":"false"),e?this.part.add("option-selected"):this.part.remove("option-selected")}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex",-1),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false")}disable(){this.removeAttribute("tabindex")}attributeChangedCallback(e,t,r){e===mr.SELECTED&&!_u(this,Zo)?this.setAttribute("aria-selected",r!=null?"true":"false"):e===mr.DISABLED&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(mr.DISABLED)||this.enable(),this.setAttribute("role","option"),Tu(this,Xs,Su(this,this.parentNode)),l0(this,Jo,Au).call(this)}disconnectedCallback(){this.disable(),l0(this,Jo,Au).call(this),Tu(this,Xs,null)}handleClick(){}};Zo=new WeakMap;Xs=new WeakMap;Jo=new WeakSet;Au=function(){var i;let e=(i=_u(this,Xs))==null?void 0:i.options;if(!e)return;let t=e.filter(r=>r.getAttribute("aria-selected")==="true").pop();t||(t=e[0]),_u(this,Xs).getAttribute("aria-multiselectable")!=="true"&&e.forEach(r=>{r.setAttribute("tabindex","-1"),r.setAttribute("aria-selected","false")}),t==null||t.setAttribute("tabindex","0"),t==null||t.setAttribute("aria-selected","true")};function Su(i,e){if(!i)return null;let{host:t}=i.getRootNode();return!e&&t?Su(i,t):e!=null&&e.options?e:Su(e,e==null?void 0:e.parentNode)}w.customElements.get("media-chrome-option")||w.customElements.define("media-chrome-option",el);var Lu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ie=(i,e,t)=>(Lu(i,e,"read from private field"),t?t.call(i):e.get(i)),Ht=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ui=(i,e,t,r)=>(Lu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Gr=(i,e,t)=>(Lu(i,e,"access private method"),t),Fi,xt,Yn,et,Ei,Qs,tl,il,rl,sl,nl,Iu,Ru,c0,Zs,jn,Vr,u0=q.createElement("template");u0.innerHTML=`
952
988
  <style>
953
989
  :host {
954
990
  font: var(--media-font,
@@ -999,63 +1035,63 @@ svg, img, ::slotted(svg), ::slotted(img) {
999
1035
  <slot></slot>
1000
1036
  </media-chrome-listbox>
1001
1037
  </slot>
1002
- `;var li=class extends w.HTMLElement{constructor(){var e;super(),Gt(this,Xo),Gt(this,lu),Gt(this,js),Gt(this,Gi,void 0),Gt(this,wt,void 0),Gt(this,$n,void 0),Gt(this,ot,void 0),Gt(this,yi,void 0),Gt(this,Ys,r=>{let{key:s}=r;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",ae(this,Ys));return}r.composedPath().includes(ae(this,wt))&&(s==="Enter"||s===" ")?qr(this,Xo,au).call(this):s==="Escape"&&qr(this,js,Hn).call(this)}),Gt(this,qo,r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",ae(this,Ys));return}r.preventDefault(),this.addEventListener("keyup",ae(this,Ys),{once:!0})}),Gt(this,Yo,r=>{r.composedPath().includes(this)||qr(this,js,Hn).call(this)}),Gt(this,jo,r=>{r.composedPath().includes(ae(this,wt))&&qr(this,Xo,au).call(this)}),Gt(this,zo,()=>{qr(this,js,Hn).call(this)}),Gt(this,Yr,()=>{if(ae(this,ot).offsetWidth===0)return;let r=ae(this,ot).offsetWidth,s=ae(this,wt).getBoundingClientRect();if(this.hasAttribute("mediacontroller")||ae(this,wt).hasAttribute("mediacontroller")||ae(this,ot).hasAttribute("mediacontroller")){ae(this,ot).style.zIndex="1",ae(this,ot).style.bottom="unset",ae(this,ot).style.right=null,ae(this,ot).style.left="0",ae(this,ot).style.top=`${s.height}px`;return}let a=Gn(this).getBoundingClientRect(),o=s.x+r,l=Math.max(s.right-o,s.right-a.right);ae(this,ot).style.left=null,ae(this,ot).style.right=`${l}px`,ae(this,ot).style.maxHeight=`${a.height-s.height}px`}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(bg.content.cloneNode(!0)));let{style:t}=et(this.shadowRoot,":host");t.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),(e=this.init)==null||e.call(this),Hi(this,wt,this.shadowRoot.querySelector("[part=button]")),Hi(this,ot,this.shadowRoot.querySelector("[part=listbox]")),Hi(this,$n,this.shadowRoot.querySelector("slot[name=button]")),ae(this,$n).addEventListener("slotchange",()=>{let r=ae(this,$n).assignedElements()[0];if(!r)return;Hi(this,wt,r),ae(this,wt).preventClick=!0,this.hasAttribute("disabled")||ae(this,wt).hasAttribute("disabled")?this.disable():(this.enable(),ae(this,wt).setAttribute("aria-haspopup","listbox"))}),Hi(this,yi,this.shadowRoot.querySelector("slot[name=listbox]")),ae(this,yi).addEventListener("slotchange",()=>{Hi(this,ot,ae(this,yi).assignedElements()[0]||ae(this,ot))})}static get observedAttributes(){return["disabled",ye.MEDIA_CONTROLLER]}enable(){ae(this,wt).toggleAttribute("disabled",!1),this.addEventListener("change",ae(this,zo)),this.addEventListener("keydown",ae(this,qo)),this.addEventListener("click",ae(this,jo)),j.addEventListener("click",ae(this,Yo))}disable(){ae(this,wt).toggleAttribute("disabled",!0),this.removeEventListener("change",ae(this,zo)),this.removeEventListener("keydown",ae(this,qo)),this.removeEventListener("keyup",ae(this,Ys)),this.removeEventListener("click",ae(this,jo)),j.removeEventListener("click",ae(this,Yo))}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ye.MEDIA_CONTROLLER?(t&&((n=(s=ae(this,Gi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Hi(this,Gi,null),ae(this,ot).removeAttribute(ye.MEDIA_CONTROLLER)),r&&this.isConnected&&(Hi(this,Gi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ae(this,Gi))==null?void 0:o.associateElement)==null||l.call(o,this),ae(this,ot).setAttribute(ye.MEDIA_CONTROLLER,r))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;let s=this.getAttribute(ye.MEDIA_CONTROLLER);s&&(Hi(this,Gi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=ae(this,Gi))==null?void 0:t.associateElement)==null||r.call(t,this),ae(this,ot).setAttribute(ye.MEDIA_CONTROLLER,s)),this.hasAttribute("disabled")||this.enable(),ae(this,yi).hidden||su(Gn(this),ae(this,Yr))}disconnectedCallback(){var e,t;nu(Gn(this),ae(this,Yr)),this.disable(),(t=(e=ae(this,Gi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Hi(this,Gi,null),ae(this,ot).removeAttribute(ye.MEDIA_CONTROLLER)}get keysUsed(){return["Enter","Escape"," ","ArrowUp","ArrowDown","f","c","k","m"]}};Gi=new WeakMap;wt=new WeakMap;$n=new WeakMap;ot=new WeakMap;yi=new WeakMap;Ys=new WeakMap;qo=new WeakMap;Yo=new WeakMap;jo=new WeakMap;zo=new WeakMap;Xo=new WeakSet;au=function(){ae(this,yi).hidden?qr(this,lu,Eg).call(this):qr(this,js,Hn).call(this)};lu=new WeakSet;Eg=function(){!ae(this,yi).hidden||(ae(this,yi).hidden=!1,ae(this,wt).setAttribute("aria-expanded","true"),ae(this,Yr).call(this),ae(this,ot).focus(),su(Gn(this),ae(this,Yr)))};js=new WeakSet;Hn=function(){if(ae(this,yi).hidden)return;nu(Gn(this),ae(this,Yr));let i=qd();ae(this,yi).hidden=!0,ae(this,wt).setAttribute("aria-expanded","false"),Fr(ae(this,ot),i)&&ae(this,wt).focus()};Yr=new WeakMap;function Gn(i){var e;return(e=i.getAttribute("bounds")?mr(i,`#${i.getAttribute("bounds")}`):_T(i)||i.parentElement)!=null?e:i}function _T(i){var e;let t=i.getAttribute(ye.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):mr(i,"media-controller")}w.customElements.get("media-chrome-selectmenu")||w.customElements.define("media-chrome-selectmenu",li);var fu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},AT=(i,e,t)=>(fu(i,e,"read from private field"),t?t.call(i):e.get(i)),du=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ST=(i,e,t,r)=>(fu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),cu=(i,e,t)=>(fu(i,e,"access private method"),t),Zo,uu,_g,Qo,hu,xT=`
1038
+ `;var ni=class extends w.HTMLElement{constructor(){var e;super(),Ht(this,nl),Ht(this,Ru),Ht(this,Zs),Ht(this,Fi,void 0),Ht(this,xt,void 0),Ht(this,Yn,void 0),Ht(this,et,void 0),Ht(this,Ei,void 0),Ht(this,Qs,r=>{let{key:s}=r;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",ie(this,Qs));return}r.composedPath().includes(ie(this,xt))&&(s==="Enter"||s===" ")?Gr(this,nl,Iu).call(this):s==="Escape"&&Gr(this,Zs,jn).call(this)}),Ht(this,tl,r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",ie(this,Qs));return}r.preventDefault(),this.addEventListener("keyup",ie(this,Qs),{once:!0})}),Ht(this,il,r=>{r.composedPath().includes(this)||Gr(this,Zs,jn).call(this)}),Ht(this,rl,r=>{r.composedPath().includes(ie(this,xt))&&Gr(this,nl,Iu).call(this)}),Ht(this,sl,()=>{Gr(this,Zs,jn).call(this)}),Ht(this,Vr,()=>{if(ie(this,et).offsetWidth===0)return;let r=ie(this,et).offsetWidth,s=ie(this,xt).getBoundingClientRect();if(this.hasAttribute("mediacontroller")||ie(this,xt).hasAttribute("mediacontroller")||ie(this,et).hasAttribute("mediacontroller")){ie(this,et).style.zIndex="1",ie(this,et).style.bottom="unset",ie(this,et).style.right=null,ie(this,et).style.left="0",ie(this,et).style.top=`${s.height}px`;return}let a=zn(this).getBoundingClientRect(),o=s.x+r,l=Math.max(s.right-o,s.right-a.right);ie(this,et).style.left=null,ie(this,et).style.right=`${l}px`,ie(this,et).style.maxHeight=`${a.height-s.height}px`}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(u0.content.cloneNode(!0)));let{style:t}=Ye(this.shadowRoot,":host");t.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),(e=this.init)==null||e.call(this),Ui(this,xt,this.shadowRoot.querySelector("[part=button]")),Ui(this,et,this.shadowRoot.querySelector("[part=listbox]")),Ui(this,Yn,this.shadowRoot.querySelector("slot[name=button]")),ie(this,Yn).addEventListener("slotchange",()=>{let r=ie(this,Yn).assignedElements()[0];if(!r)return;Ui(this,xt,r),ie(this,xt).preventClick=!0,this.hasAttribute("disabled")||ie(this,xt).hasAttribute("disabled")?this.disable():(this.enable(),ie(this,xt).setAttribute("aria-haspopup","listbox"))}),Ui(this,Ei,this.shadowRoot.querySelector("slot[name=listbox]")),ie(this,Ei).addEventListener("slotchange",()=>{Ui(this,et,ie(this,Ei).assignedElements()[0]||ie(this,et))})}static get observedAttributes(){return["disabled",pe.MEDIA_CONTROLLER]}enable(){ie(this,xt).toggleAttribute("disabled",!1),this.addEventListener("change",ie(this,sl)),this.addEventListener("keydown",ie(this,tl)),this.addEventListener("click",ie(this,rl)),q.addEventListener("click",ie(this,il))}disable(){ie(this,xt).toggleAttribute("disabled",!0),this.removeEventListener("change",ie(this,sl)),this.removeEventListener("keydown",ie(this,tl)),this.removeEventListener("keyup",ie(this,Qs)),this.removeEventListener("click",ie(this,rl)),q.removeEventListener("click",ie(this,il))}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===pe.MEDIA_CONTROLLER?(t&&((n=(s=ie(this,Fi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ui(this,Fi,null),ie(this,et).removeAttribute(pe.MEDIA_CONTROLLER)),r&&this.isConnected&&(Ui(this,Fi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ie(this,Fi))==null?void 0:o.associateElement)==null||l.call(o,this),ie(this,et).setAttribute(pe.MEDIA_CONTROLLER,r))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;let s=this.getAttribute(pe.MEDIA_CONTROLLER);s&&(Ui(this,Fi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=ie(this,Fi))==null?void 0:t.associateElement)==null||r.call(t,this),ie(this,et).setAttribute(pe.MEDIA_CONTROLLER,s)),this.hasAttribute("disabled")||this.enable(),ie(this,Ei).hidden||In(zn(this),ie(this,Vr))}disconnectedCallback(){var e,t;gc(zn(this),ie(this,Vr)),this.disable(),(t=(e=ie(this,Fi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ui(this,Fi,null),ie(this,et).removeAttribute(pe.MEDIA_CONTROLLER)}get keysUsed(){return["Enter","Escape"," ","ArrowUp","ArrowDown","f","c","k","m"]}};Fi=new WeakMap;xt=new WeakMap;Yn=new WeakMap;et=new WeakMap;Ei=new WeakMap;Qs=new WeakMap;tl=new WeakMap;il=new WeakMap;rl=new WeakMap;sl=new WeakMap;nl=new WeakSet;Iu=function(){ie(this,Ei).hidden?Gr(this,Ru,c0).call(this):Gr(this,Zs,jn).call(this)};Ru=new WeakSet;c0=function(){ie(this,Ei).hidden&&(ie(this,Ei).hidden=!1,ie(this,xt).setAttribute("aria-expanded","true"),ie(this,Vr).call(this),ie(this,et).focus(),In(zn(this),ie(this,Vr)))};Zs=new WeakSet;jn=function(){if(ie(this,Ei).hidden)return;gc(zn(this),ie(this,Vr));let i=dc();ie(this,Ei).hidden=!0,ie(this,xt).setAttribute("aria-expanded","false"),nr(ie(this,et),i)&&ie(this,xt).focus()};Vr=new WeakMap;function zn(i){var e;return(e=i.getAttribute("bounds")?ar(i,`#${i.getAttribute("bounds")}`):R_(i)||i.parentElement)!=null?e:i}function R_(i){var e;let t=i.getAttribute(pe.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):ar(i,"media-controller")}w.customElements.get("media-chrome-selectmenu")||w.customElements.define("media-chrome-selectmenu",ni);var Mu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},k_=(i,e,t)=>(Mu(i,e,"read from private field"),t?t.call(i):e.get(i)),ku=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},w_=(i,e,t,r)=>(Mu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),wu=(i,e,t)=>(Mu(i,e,"access private method"),t),ol,Du,m0,al,Cu,D_=`
1003
1039
  <svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
1004
1040
  <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"/>
1005
- </svg>`,Ag=j.createElement("template");Ag.innerHTML=`
1006
- <slot name="captions-indicator" hidden>${xT}</slot>
1007
- `;var Jo=class extends oi{constructor(){super({slotTemplate:Ag}),du(this,uu),du(this,Qo),du(this,Zo,void 0)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",S.MEDIA_SUBTITLES_LIST,S.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_SUBTITLES_LIST&&t!==r?cu(this,uu,_g).call(this):e===S.MEDIA_SUBTITLES_SHOWING&&t!==r?this.value=r:e==="aria-multiselectable"&&(this.removeAttribute("aria-multiselectable"),console.warn("Captions List doesn't currently support multiple selections. You can enable multiple items via the media.textTrack API."))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",cu(this,Qo,hu))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",cu(this,Qo,hu))}get mediaSubtitlesList(){return yg(this,S.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Tg(this,S.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return yg(this,S.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Tg(this,S.MEDIA_SUBTITLES_SHOWING,e)}};Zo=new WeakMap;uu=new WeakSet;_g=function(){var i;if(AT(this,Zo)===JSON.stringify(this.mediaSubtitlesList))return;ST(this,Zo,JSON.stringify(this.mediaSubtitlesList));let e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.value,r=$i(this.formatOptionText("Off"),"off",t);r.prepend(bi(this,"select-indicator")),e.append(r);let s=this.mediaSubtitlesList;for(let n of s){let a=$i(this.formatOptionText(n.label,n),Ja(n),this.value==Ja(n));a.prepend(bi(this,"select-indicator")),((i=n.kind)!=null?i:"subs")==="captions"&&a.append(bi(this,"captions-indicator")),e.append(a)}};Qo=new WeakSet;hu=function(){if(er(this,!1),!this.value)return;let i=new w.CustomEvent(re.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};var yg=(i,e)=>{let t=i.getAttribute(e);return t?In(t):[]},Tg=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=$r(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};w.customElements.get("media-captions-listbox")||w.customElements.define("media-captions-listbox",Jo);var el=class extends li{init(){let e=j.createElement("media-captions-button");e.part.add("button"),e.preventClick=!0;let t=j.createElement("media-captions-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};w.customElements.get("media-captions-selectmenu")||w.customElements.define("media-captions-selectmenu",el);var Sg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},tl=(i,e,t)=>(Sg(i,e,"read from private field"),t?t.call(i):e.get(i)),mu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Vn=(i,e,t)=>(Sg(i,e,"access private method"),t),zs,Kn,il,rl,gu,pu={RATES:"rates"},sl=class extends oi{constructor(){super(),mu(this,Kn),mu(this,rl),mu(this,zs,new vr(this,pu.RATES,{defaultValue:Rc})),Vn(this,Kn,il).call(this)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",S.MEDIA_PLAYBACK_RATE,pu.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===pu.RATES&&t!=r&&(tl(this,zs).value=r,Vn(this,Kn,il).call(this))}get rates(){return tl(this,zs)}set rates(e){e?Array.isArray(e)&&(tl(this,zs).value=e.join(" ")):tl(this,zs).value="",Vn(this,Kn,il).call(this)}get mediaPlaybackRate(){return Fe(this,S.MEDIA_PLAYBACK_RATE,Ps)}set mediaPlaybackRate(e){ze(this,S.MEDIA_PLAYBACK_RATE,e)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Vn(this,rl,gu))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Vn(this,rl,gu))}};zs=new WeakMap;Kn=new WeakSet;il=function(){let i=this.shadowRoot.querySelector("#container");i.textContent="";for(let e of this.rates){let t=$i(this.formatOptionText(`${e}x`,e),e,this.mediaPlaybackRate==e);t.prepend(bi(this,"select-indicator")),i.append(t)}};rl=new WeakSet;gu=function(){if(!this.value)return;let i=new w.CustomEvent(re.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};w.customElements.get("media-playback-rate-listbox")||w.customElements.define("media-playback-rate-listbox",sl);var nl=class extends li{init(){let e=j.createElement("media-playback-rate-button");e.part.add("button"),e.preventClick=!0;let t=j.createElement("media-playback-rate-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};w.customElements.get("media-playback-rate-selectmenu")||w.customElements.define("media-playback-rate-selectmenu",nl);var yu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},xg=(i,e,t)=>(yu(i,e,"read from private field"),t?t.call(i):e.get(i)),al=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},vu=(i,e,t,r)=>(yu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ol=(i,e,t)=>(yu(i,e,"access private method"),t),Wn,cl,ll,Eu,dl,bu,ul=class extends oi{constructor(){super(...arguments),al(this,ll),al(this,dl),al(this,Wn,[]),al(this,cl,void 0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_LIST,S.MEDIA_RENDITION_SELECTED]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_RENDITION_SELECTED&&t!==r?this.value=r!=null?r:"auto":e===S.MEDIA_RENDITION_LIST&&t!==r&&(vu(this,Wn,Pm(r)),ol(this,ll,Eu).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",ol(this,dl,bu))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",ol(this,dl,bu))}get mediaRenditionList(){return xg(this,Wn)}set mediaRenditionList(e){vu(this,Wn,e),ol(this,ll,Eu).call(this)}get mediaRenditionSelected(){return We(this,S.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Be(this,S.MEDIA_RENDITION_SELECTED,e)}};Wn=new WeakMap;cl=new WeakMap;ll=new WeakSet;Eu=function(){if(xg(this,cl)===JSON.stringify(this.mediaRenditionList))return;vu(this,cl,JSON.stringify(this.mediaRenditionList));let i=this.mediaRenditionList.sort((s,n)=>n.height-s.height),e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.mediaRenditionSelected;for(let s of i){let n=this.formatOptionText(`${Math.min(s.width,s.height)}p`,s),a=$i(n,`${s.id}`,s.selected&&!t);a.prepend(bi(this,"select-indicator")),e.append(a)}let r=$i(this.formatOptionText("Auto"),"auto",t);r.prepend(bi(this,"select-indicator")),e.append(r)};dl=new WeakSet;bu=function(){if(this.value==null)return;let i=new w.CustomEvent(re.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};w.customElements.get("media-rendition-listbox")||w.customElements.define("media-rendition-listbox",ul);var IT=`<svg aria-hidden="true" viewBox="0 0 24 24">
1041
+ </svg>`,p0=q.createElement("template");p0.innerHTML=`
1042
+ <slot name="captions-indicator" hidden>${D_}</slot>
1043
+ `;var ll=class extends si{constructor(){super({slotTemplate:p0}),ku(this,Du),ku(this,al),ku(this,ol,void 0)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",S.MEDIA_SUBTITLES_LIST,S.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_SUBTITLES_LIST&&t!==r?wu(this,Du,m0).call(this):e===S.MEDIA_SUBTITLES_SHOWING&&t!==r?this.value=r:e==="aria-multiselectable"&&(this.removeAttribute("aria-multiselectable"),console.warn("Captions List doesn't currently support multiple selections. You can enable multiple items via the media.textTracks API."))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",wu(this,al,Cu))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",wu(this,al,Cu))}get mediaSubtitlesList(){return h0(this,S.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){f0(this,S.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return h0(this,S.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){f0(this,S.MEDIA_SUBTITLES_SHOWING,e)}};ol=new WeakMap;Du=new WeakSet;m0=function(){var i;if(k_(this,ol)===JSON.stringify(this.mediaSubtitlesList))return;w_(this,ol,JSON.stringify(this.mediaSubtitlesList));let e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.value,r=Ni(this.formatOptionText("Off"),"off",t);r.prepend(vi(this,"select-indicator")),e.append(r);let s=this.mediaSubtitlesList;for(let n of s){let a=Ni(this.formatOptionText(n.label,n),oo(n),this.value==oo(n));a.prepend(vi(this,"select-indicator")),((i=n.kind)!=null?i:"subs")==="captions"&&a.append(vi(this,"captions-indicator")),e.append(a)}};al=new WeakSet;Cu=function(){let i=this.mediaSubtitlesShowing,e=this.getAttribute(S.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new w.CustomEvent(ee.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;let r=new w.CustomEvent(ee.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};var h0=(i,e)=>{let t=i.getAttribute(e);return t?Dn(t):[]},f0=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=Nr(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};w.customElements.get("media-captions-listbox")||w.customElements.define("media-captions-listbox",ll);var dl=class extends ni{init(){let e=q.createElement("media-captions-button");e.part.add("button"),e.preventClick=!0;let t=q.createElement("media-captions-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};w.customElements.get("media-captions-selectmenu")||w.customElements.define("media-captions-selectmenu",dl);var g0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},cl=(i,e,t)=>(g0(i,e,"read from private field"),t?t.call(i):e.get(i)),Pu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Xn=(i,e,t)=>(g0(i,e,"access private method"),t),Js,Qn,ul,hl,Nu,Ou={RATES:"rates"},fl=class extends si{constructor(){super(),Pu(this,Qn),Pu(this,hl),Pu(this,Js,new cr(this,Ou.RATES,{defaultValue:Zc})),Xn(this,Qn,ul).call(this)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",S.MEDIA_PLAYBACK_RATE,Ou.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===Ou.RATES&&t!=r&&(cl(this,Js).value=r,Xn(this,Qn,ul).call(this))}get rates(){return cl(this,Js)}set rates(e){e?Array.isArray(e)&&(cl(this,Js).value=e.join(" ")):cl(this,Js).value="",Xn(this,Qn,ul).call(this)}get mediaPlaybackRate(){return Ue(this,S.MEDIA_PLAYBACK_RATE,Bs)}set mediaPlaybackRate(e){Ke(this,S.MEDIA_PLAYBACK_RATE,e)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Xn(this,hl,Nu))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Xn(this,hl,Nu))}};Js=new WeakMap;Qn=new WeakSet;ul=function(){let i=this.shadowRoot.querySelector("#container");i.textContent="";for(let e of this.rates){let t=Ni(this.formatOptionText(`${e}x`,e),e,this.mediaPlaybackRate==e);t.prepend(vi(this,"select-indicator")),i.append(t)}};hl=new WeakSet;Nu=function(){if(!this.value)return;let i=new w.CustomEvent(ee.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};w.customElements.get("media-playback-rate-listbox")||w.customElements.define("media-playback-rate-listbox",fl);var ml=class extends ni{init(){let e=q.createElement("media-playback-rate-button");e.part.add("button"),e.preventClick=!0;let t=q.createElement("media-playback-rate-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};w.customElements.get("media-playback-rate-selectmenu")||w.customElements.define("media-playback-rate-selectmenu",ml);var $u=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},v0=(i,e,t)=>($u(i,e,"read from private field"),t?t.call(i):e.get(i)),pl=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Uu=(i,e,t,r)=>($u(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),gl=(i,e,t)=>($u(i,e,"access private method"),t),Zn,bl,vl,Fu,El,Bu,yl=class extends si{constructor(){super(...arguments),pl(this,vl),pl(this,El),pl(this,Zn,[]),pl(this,bl,void 0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_LIST,S.MEDIA_RENDITION_SELECTED]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_RENDITION_SELECTED&&t!==r?this.value=r!=null?r:"auto":e===S.MEDIA_RENDITION_LIST&&t!==r&&(Uu(this,Zn,Tp(r)),gl(this,vl,Fu).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",gl(this,El,Bu))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",gl(this,El,Bu))}get mediaRenditionList(){return v0(this,Zn)}set mediaRenditionList(e){Uu(this,Zn,e),gl(this,vl,Fu).call(this)}get mediaRenditionSelected(){return He(this,S.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Be(this,S.MEDIA_RENDITION_SELECTED,e)}};Zn=new WeakMap;bl=new WeakMap;vl=new WeakSet;Fu=function(){if(v0(this,bl)===JSON.stringify(this.mediaRenditionList))return;Uu(this,bl,JSON.stringify(this.mediaRenditionList));let i=this.mediaRenditionList.sort((s,n)=>n.height-s.height),e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.mediaRenditionSelected;for(let s of i){let n=this.formatOptionText(`${Math.min(s.width,s.height)}p`,s),a=Ni(n,`${s.id}`,s.selected&&!t);a.prepend(vi(this,"select-indicator")),e.append(a)}let r=Ni(this.formatOptionText("Auto"),"auto",t);r.prepend(vi(this,"select-indicator")),e.append(r)};El=new WeakSet;Bu=function(){if(this.value==null)return;let i=new w.CustomEvent(ee.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};w.customElements.get("media-rendition-listbox")||w.customElements.define("media-rendition-listbox",yl);var C_=`<svg aria-hidden="true" viewBox="0 0 24 24">
1008
1044
  <path d="M13.5 2.5h2v6h-2v-2h-11v-2h11v-2Zm4 2h4v2h-4v-2Zm-12 4h2v6h-2v-2h-3v-2h3v-2Zm4 2h12v2h-12v-2Zm1 4h2v6h-2v-2h-8v-2h8v-2Zm4 2h7v2h-7v-2Z" />
1009
- </svg>`,Ig=j.createElement("template");Ig.innerHTML=`
1010
- <slot name="icon">${IT}</slot>
1011
- `;var Tu=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_SELECTED,S.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:Ig})}get mediaRenditionSelected(){return We(this,S.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Be(this,S.MEDIA_RENDITION_SELECTED,e)}};w.customElements.get("media-rendition-button")||w.customElements.define("media-rendition-button",Tu);var hl=class extends li{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_SELECTED,S.MEDIA_RENDITION_UNAVAILABLE]}init(){let e=j.createElement("media-rendition-button");e.part.add("button"),e.preventClick=!0;let t=j.createElement("media-rendition-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};w.customElements.get("media-rendition-selectmenu")||w.customElements.define("media-rendition-selectmenu",hl);var xu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Lg=(i,e,t)=>(xu(i,e,"read from private field"),t?t.call(i):e.get(i)),fl=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},_u=(i,e,t,r)=>(xu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ml=(i,e,t)=>(xu(i,e,"access private method"),t),qn,vl,pl,Au,gl,Su,El=class extends oi{constructor(){super(...arguments),fl(this,pl),fl(this,gl),fl(this,qn,[]),fl(this,vl,void 0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_AUDIO_TRACK_LIST,S.MEDIA_AUDIO_TRACK_ENABLED]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===S.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(_u(this,qn,Um(r)),ml(this,pl,Au).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",ml(this,gl,Su))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",ml(this,gl,Su))}get mediaAudioTrackList(){return Lg(this,qn)}set mediaAudioTrackList(e){_u(this,qn,e),ml(this,pl,Au).call(this)}get mediaAudioTrackEnabled(){return We(this,S.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){Be(this,S.MEDIA_AUDIO_TRACK_ENABLED,e)}};qn=new WeakMap;vl=new WeakMap;pl=new WeakSet;Au=function(){if(Lg(this,vl)===JSON.stringify(this.mediaAudioTrackList))return;_u(this,vl,JSON.stringify(this.mediaAudioTrackList));let i=this.mediaAudioTrackList,e=this.shadowRoot.querySelector("#container");e.textContent="";for(let t of i){let r=this.formatOptionText(t.label,t),s=$i(r,`${t.id}`,t.enabled);s.prepend(bi(this,"select-indicator")),e.append(s)}};gl=new WeakSet;Su=function(){if(this.value==null)return;let i=new w.CustomEvent(re.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};w.customElements.get("media-audio-track-listbox")||w.customElements.define("media-audio-track-listbox",El);var LT=`<svg aria-hidden="true" viewBox="0 0 24 24">
1045
+ </svg>`,E0=q.createElement("template");E0.innerHTML=`
1046
+ <slot name="icon">${C_}</slot>
1047
+ `;var Hu=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_SELECTED,S.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:E0})}get mediaRenditionSelected(){return He(this,S.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Be(this,S.MEDIA_RENDITION_SELECTED,e)}};w.customElements.get("media-rendition-button")||w.customElements.define("media-rendition-button",Hu);var Tl=class extends ni{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_SELECTED,S.MEDIA_RENDITION_UNAVAILABLE]}init(){let e=q.createElement("media-rendition-button");e.part.add("button"),e.preventClick=!0;let t=q.createElement("media-rendition-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};w.customElements.get("media-rendition-selectmenu")||w.customElements.define("media-rendition-selectmenu",Tl);var Wu=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},b0=(i,e,t)=>(Wu(i,e,"read from private field"),t?t.call(i):e.get(i)),_l=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Gu=(i,e,t,r)=>(Wu(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Al=(i,e,t)=>(Wu(i,e,"access private method"),t),Jn,Il,Sl,Vu,xl,Ku,Ll=class extends si{constructor(){super(...arguments),_l(this,Sl),_l(this,xl),_l(this,Jn,[]),_l(this,Il,void 0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_AUDIO_TRACK_LIST,S.MEDIA_AUDIO_TRACK_ENABLED]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===S.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===S.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(Gu(this,Jn,Ap(r)),Al(this,Sl,Vu).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Al(this,xl,Ku))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Al(this,xl,Ku))}get mediaAudioTrackList(){return b0(this,Jn)}set mediaAudioTrackList(e){Gu(this,Jn,e),Al(this,Sl,Vu).call(this)}get mediaAudioTrackEnabled(){return He(this,S.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){Be(this,S.MEDIA_AUDIO_TRACK_ENABLED,e)}};Jn=new WeakMap;Il=new WeakMap;Sl=new WeakSet;Vu=function(){if(b0(this,Il)===JSON.stringify(this.mediaAudioTrackList))return;Gu(this,Il,JSON.stringify(this.mediaAudioTrackList));let i=this.mediaAudioTrackList,e=this.shadowRoot.querySelector("#container");e.textContent="";for(let t of i){let r=this.formatOptionText(t.label,t),s=Ni(r,`${t.id}`,t.enabled);s.prepend(vi(this,"select-indicator")),e.append(s)}};xl=new WeakSet;Ku=function(){if(this.value==null)return;let i=new w.CustomEvent(ee.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};w.customElements.get("media-audio-track-listbox")||w.customElements.define("media-audio-track-listbox",Ll);var M_=`<svg aria-hidden="true" viewBox="0 0 24 24">
1012
1048
  <path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>
1013
1049
  <path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0Z"/>
1014
- </svg>`,kg=j.createElement("template");kg.innerHTML=`
1015
- <slot name="icon">${LT}</slot>
1016
- `;var Iu=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_AUDIO_TRACK_ENABLED,S.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:kg})}get mediaAudioTrackEnabled(){return We(this,S.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){Be(this,S.MEDIA_AUDIO_TRACK_ENABLED,e)}};w.customElements.get("media-audio-track-button")||w.customElements.define("media-audio-track-button",Iu);var bl=class extends li{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_AUDIO_TRACK_ENABLED,S.MEDIA_AUDIO_TRACK_UNAVAILABLE]}init(){let e=j.createElement("media-audio-track-button");e.part.add("button"),e.preventClick=!0;let t=j.createElement("media-audio-track-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};w.customElements.get("media-audio-track-selectmenu")||w.customElements.define("media-audio-track-selectmenu",bl);var ed=zb(Rg(),1);function kT(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var g0={exports:{}};(function(i,e){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,c){if(c=c||{},l=l.trim(),d=d.trim(),!d){if(!c.alwaysNormalize)return l;var u=o.parseURL(l);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return c.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var g=s.exec(f.path);f.netLoc=g[1],f.path=g[2]}f.netLoc&&!f.path&&(f.path="/");var E={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(E.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)E.path=f.path,h.params||(E.params=f.params,h.query||(E.query=f.query));else{var T=f.path,A=T.substring(0,T.lastIndexOf("/")+1)+h.path;E.path=o.normalizePath(A)}return E.path===null&&(E.path=c.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(E)},parseURL:function(l){var d=r.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(g0);var Yh=g0.exports;function wg(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function Yt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?wg(Object(t),!0).forEach(function(r){RT(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):wg(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function RT(i,e,t){return e=DT(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function mt(){return mt=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},mt.apply(this,arguments)}function wT(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function DT(i){var e=wT(i,"string");return typeof e=="symbol"?e:String(e)}var ce=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},b=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i}({}),pe=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),B=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({}),zr=function(){},ju={trace:zr,debug:zr,log:zr,warn:zr,info:zr,error:zr},zn=ju;function CT(i){let e=self.console[i];return e?e.bind(self.console,`[${i}] >`):zr}function MT(i,...e){e.forEach(function(t){zn[t]=i[t]?i[t].bind(i):CT(t)})}function OT(i,e){if(self.console&&i===!0||typeof i=="object"){MT(i,"debug","log","info","warn","error");try{zn.log(`Debug logs enabled for "${e}" in hls.js version 1.4.10`)}catch{zn=ju}}else zn=ju}var M=zn,PT=/^(\d+)x(\d+)$/,Dg=/(.+?)=(".*?"|.*?)(?:,|$)/g,Qe=class{constructor(e){typeof e=="string"&&(e=Qe.parseAttrList(e));for(let t in e)e.hasOwnProperty(t)&&(t.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let r=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=PT.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,r={},s='"';for(Dg.lastIndex=0;(t=Dg.exec(e))!==null;){let n=t[2];n.indexOf(s)===0&&n.lastIndexOf(s)===n.length-1&&(n=n.slice(1,-1));let a=t[1].trim();r[a]=n}return r}};function NT(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function UT(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}var Dl=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let r=t.attr;for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==r[s]){M.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=mt(new Qe({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let r=new Date(this.attr["END-DATE"]);ce(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;let e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(ce(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&ce(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}},tn=class{constructor(){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}}},qe={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Cl=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[qe.AUDIO]:null,[qe.VIDEO]:null,[qe.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let r=e.split("@",2),s=[];r.length===1?s[0]=t?t.byteRangeEndOffset:0:s[0]=parseInt(r[1]),s[1]=parseInt(r[0])+s[0],this._byteRange=s}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Yh.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},Xn=class extends Cl{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new tn,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=e}get decryptdata(){let{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){let t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{let r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!ce(this.programDateTime))return null;let e=ce(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){let t=Object.keys(this.levelkeys),r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){let t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,r,s,n,a=!1){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:r,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[qe.AUDIO]=null,e[qe.VIDEO]=null,e[qe.AUDIOVIDEO]=null}},zu=class extends Cl{constructor(e,t,r,s,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new tn,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}},FT=10,Xu=class{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?ce(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||FT}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}};function jh(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function BT(i){let e=v0(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function $T(i){let e=function(r,s,n){let a=r[s];r[s]=r[n],r[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function HT(i){let e=i.split(":"),t=null;if(e[0]==="data"&&e.length===2){let r=e[1].split(";"),s=r[r.length-1].split(",");if(s.length===2){let n=s[0]==="base64",a=s[1];n?(r.splice(-1,1),t=jh(a)):t=BT(a)}}return t}function v0(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}var nt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},qt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Cg(i){switch(i){case qt.FAIRPLAY:return nt.FAIRPLAY;case qt.PLAYREADY:return nt.PLAYREADY;case qt.WIDEVINE:return nt.WIDEVINE;case qt.CLEARKEY:return nt.CLEARKEY}}var E0={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function GT(i){if(i===E0.WIDEVINE)return nt.WIDEVINE}function Mg(i){switch(i){case nt.FAIRPLAY:return qt.FAIRPLAY;case nt.PLAYREADY:return qt.PLAYREADY;case nt.WIDEVINE:return qt.WIDEVINE;case nt.CLEARKEY:return qt.CLEARKEY}}function ku(i){let{drmSystems:e,widevineLicenseUrl:t}=i,r=e?[nt.FAIRPLAY,nt.WIDEVINE,nt.PLAYREADY,nt.CLEARKEY].filter(s=>!!e[s]):[];return!r[nt.WIDEVINE]&&t&&r.push(nt.WIDEVINE),r}var b0=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function VT(i,e,t,r){let s;switch(i){case nt.FAIRPLAY:s=["cenc","sinf"];break;case nt.WIDEVINE:case nt.PLAYREADY:s=["cenc"];break;case nt.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return KT(s,e,t,r)}function KT(i,e,t,r){return[{initDataTypes:i,persistentState:r.persistentState||"not-allowed",distinctiveIdentifier:r.distinctiveIdentifier||"not-allowed",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function Xr(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}var zh=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,y0=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Ml=(i,e)=>{let t=e,r=0;for(;zh(i,e);){r+=10;let s=Zl(i,e+6);r+=s,y0(i,e+10)&&(r+=10),e+=r}if(r>0)return i.subarray(t,t+r)},Zl=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},WT=(i,e)=>zh(i,e)&&Zl(i,e+6)+10<=i.length-e,qT=i=>{let e=_0(i);for(let t=0;t<e.length;t++){let r=e[t];if(T0(r))return ZT(r)}},T0=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",YT=i=>{let e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=Zl(i,4),r=10;return{type:e,size:t,data:i.subarray(r,r+t)}},_0=i=>{let e=0,t=[];for(;zh(i,e);){let r=Zl(i,e+6);e+=10;let s=e+r;for(;e+8<s;){let n=YT(i.subarray(e)),a=jT(n);a&&t.push(a),e+=n.size+10}y0(i,e)&&(e+=10)}return t},jT=i=>i.type==="PRIV"?zT(i):i.type[0]==="W"?QT(i):XT(i),zT=i=>{if(i.size<2)return;let e=ji(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},XT=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1,r=ji(i.data.subarray(t),!0);t+=r.length+1;let s=ji(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=ji(i.data.subarray(1));return{key:i.type,data:e}},QT=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1,r=ji(i.data.subarray(t),!0);t+=r.length+1;let s=ji(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=ji(i.data);return{key:i.type,data:e}},ZT=i=>{if(i.data.byteLength===8){let e=new Uint8Array(i.data),t=e[3]&1,r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},ji=(i,e=!1)=>{let t=JT();if(t){let d=t.decode(i);if(e){let c=d.indexOf("\0");return c!==-1?d.substring(0,c):d}return d.replace(/\0/g,"")}let r=i.length,s,n,a,o="",l=0;for(;l<r;){if(s=i[l++],s===0&&e)return o;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o},Ru;function JT(){return!Ru&&typeof self.TextDecoder!="undefined"&&(Ru=new self.TextDecoder("utf-8")),Ru}var Vi={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let r=i[t].toString(16);r.length<2&&(r="0"+r),e+=r}return e}},Ol=Math.pow(2,32)-1,e_=[].push,A0={video:1,audio:2,id3:3,text:4};function Lt(i){return String.fromCharCode.apply(null,i)}function S0(i,e){let t=i[e]<<8|i[e+1];return t<0?65536+t:t}function Te(i,e){let t=x0(i,e);return t<0?4294967296+t:t}function x0(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function wu(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function Pe(i,e){let t=[];if(!e.length)return t;let r=i.byteLength;for(let s=0;s<r;){let n=Te(i,s),a=Lt(i.subarray(s+4,s+8)),o=n>1?s+n:r;if(a===e[0])if(e.length===1)t.push(i.subarray(s+8,o));else{let l=Pe(i.subarray(s+8,o),e.slice(1));l.length&&e_.apply(t,l)}s=o}return t}function t_(i){let e=[],t=i[0],r=8,s=Te(i,r);r+=4;let n=0,a=0;t===0?r+=8:r+=16,r+=2;let o=i.length+a,l=S0(i,r);r+=2;for(let d=0;d<l;d++){let c=r,u=Te(i,c);c+=4;let h=u&2147483647;if((u&2147483648)>>>31===1)return M.warn("SIDX has hierarchical references (not supported)"),null;let g=Te(i,c);c+=4,e.push({referenceSize:h,subsegmentDuration:g,info:{duration:g/s,start:o,end:o+h-1}}),o+=h,c+=4,r=c}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function I0(i){let e=[],t=Pe(i,["moov","trak"]);for(let s=0;s<t.length;s++){let n=t[s],a=Pe(n,["tkhd"])[0];if(a){let o=a[0],l=o===0?12:20,d=Te(a,l),c=Pe(n,["mdia","mdhd"])[0];if(c){o=c[0],l=o===0?12:20;let u=Te(c,l),h=Pe(n,["mdia","hdlr"])[0];if(h){let f=Lt(h.subarray(8,12)),g={soun:qe.AUDIO,vide:qe.VIDEO}[f];if(g){let E=Pe(n,["mdia","minf","stbl","stsd"])[0],T;E&&(T=Lt(E.subarray(12,16))),e[d]={timescale:u,type:g},e[g]={timescale:u,id:d,codec:T}}}}}}return Pe(i,["moov","mvex","trex"]).forEach(s=>{let n=Te(s,4),a=e[n];a&&(a.default={duration:Te(s,12),flags:Te(s,20)})}),e}function i_(i,e){if(!i||!e)return i;let t=e.keyId;return t&&e.isCommonEncryption&&Pe(i,["moov","trak"]).forEach(s=>{let a=Pe(s,["mdia","minf","stbl","stsd"])[0].subarray(8),o=Pe(a,["enca"]),l=o.length>0;l||(o=Pe(a,["encv"])),o.forEach(d=>{let c=l?d.subarray(28):d.subarray(78);Pe(c,["sinf"]).forEach(h=>{let f=L0(h);if(f){let g=f.subarray(8,24);g.some(E=>E!==0)||(M.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Vi.hexDump(g)} -> ${Vi.hexDump(t)}`),f.set(t,8))}})})}),i}function L0(i){let e=Pe(i,["schm"])[0];if(e){let t=Lt(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return Pe(i,["schi","tenc"])[0]}return M.error("[eme] missing 'schm' box"),null}function r_(i,e){return Pe(e,["moof","traf"]).reduce((t,r)=>{let s=Pe(r,["tfdt"])[0],n=s[0],a=Pe(r,["tfhd"]).reduce((o,l)=>{let d=Te(l,4),c=i[d];if(c){let u=Te(s,4);if(n===1){if(u===Ol)return M.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;u*=Ol+1,u+=Te(s,8)}let h=c.timescale||9e4,f=u/h;if(isFinite(f)&&(o===null||f<o))return f}return o},null);return a!==null&&isFinite(a)&&(t===null||a<t)?a:t},null)}function s_(i,e){let t=0,r=0,s=0,n=Pe(i,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=Pe(o,["tfhd"])[0],d=Te(l,4),c=e[d];if(!c)continue;let u=c.default,h=Te(l,0)|(u==null?void 0:u.flags),f=u==null?void 0:u.duration;h&8&&(h&2?f=Te(l,12):f=Te(l,8));let g=c.timescale||9e4,E=Pe(o,["trun"]);for(let T=0;T<E.length;T++){if(t=n_(E[T]),!t&&f){let A=Te(E[T],4);t=f*A}c.type===qe.VIDEO?r+=t/g:c.type===qe.AUDIO&&(s+=t/g)}}if(r===0&&s===0){let a=0,o=Pe(i,["sidx"]);for(let l=0;l<o.length;l++){let d=t_(o[l]);d!=null&&d.references&&(a+=d.references.reduce((c,u)=>c+u.info.duration||0,0))}return a}return r||s}function n_(i){let e=Te(i,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let r=0,s=Te(i,4);for(let n=0;n<s;n++){if(e&256){let a=Te(i,t);r+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return r}function a_(i,e,t){Pe(e,["moof","traf"]).forEach(r=>{Pe(r,["tfhd"]).forEach(s=>{let n=Te(s,4),a=i[n];if(!a)return;let o=a.timescale||9e4;Pe(r,["tfdt"]).forEach(l=>{let d=l[0],c=Te(l,4);if(d===0)c-=t*o,c=Math.max(c,0),wu(l,4,c);else{c*=Math.pow(2,32),c+=Te(l,8),c-=t*o,c=Math.max(c,0);let u=Math.floor(c/(Ol+1)),h=Math.floor(c%(Ol+1));wu(l,4,u),wu(l,8,h)}})})})}function o_(i){let e={valid:null,remainder:null},t=Pe(i,["moof"]);if(t){if(t.length<2)return e.remainder=i,e}else return e;let r=t[t.length-1];return e.valid=Xr(i,0,r.byteOffset-8),e.remainder=Xr(i,r.byteOffset-8),e}function Qr(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function Og(i,e){let t=[],r=e.samples,s=e.timescale,n=e.id,a=!1;return Pe(r,["moof"]).map(l=>{let d=l.byteOffset-8;Pe(l,["traf"]).map(u=>{let h=Pe(u,["tfdt"]).map(f=>{let g=f[0],E=Te(f,4);return g===1&&(E*=Math.pow(2,32),E+=Te(f,8)),E/s})[0];return h!==void 0&&(i=h),Pe(u,["tfhd"]).map(f=>{let g=Te(f,4),E=Te(f,0)&16777215,T=(E&1)!==0,A=(E&2)!==0,k=(E&8)!==0,L=0,N=(E&16)!==0,D=0,$=(E&32)!==0,O=8;g===n&&(T&&(O+=8),A&&(O+=4),k&&(L=Te(f,O),O+=4),N&&(D=Te(f,O),O+=4),$&&(O+=4),e.type==="video"&&(a=l_(e.codec)),Pe(u,["trun"]).map(G=>{let Y=G[0],P=Te(G,0)&16777215,X=(P&1)!==0,z=0,Ae=(P&4)!==0,Ee=(P&256)!==0,be=0,we=(P&512)!==0,Se=0,Z=(P&1024)!==0,ne=(P&2048)!==0,se=0,xe=Te(G,4),Ie=8;X&&(z=Te(G,Ie),Ie+=4),Ae&&(Ie+=4);let Ve=z+d;for(let ht=0;ht<xe;ht++){if(Ee?(be=Te(G,Ie),Ie+=4):be=L,we?(Se=Te(G,Ie),Ie+=4):Se=D,Z&&(Ie+=4),ne&&(Y===0?se=Te(G,Ie):se=x0(G,Ie),Ie+=4),e.type===qe.VIDEO){let V=0;for(;V<Se;){let ee=Te(r,Ve);if(Ve+=4,d_(a,r[Ve])){let ke=r.subarray(Ve,Ve+ee);k0(ke,a?2:1,i+se/s,t)}Ve+=ee,V+=ee+4}}i+=be/s}}))})})}),t}function l_(i){if(!i)return!1;let e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function d_(i,e){if(i){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function k0(i,e,t,r){let s=R0(i),n=0;n+=e;let a=0,o=0,l=!1,d=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;d=s[n++],a+=d}while(d===255);o=0;do{if(n>=s.length)break;d=s[n++],o+=d}while(d===255);let c=s.length-n;if(!l&&a===4&&n<s.length){if(l=!0,s[n++]===181){let h=S0(s,n);if(n+=2,h===49){let f=Te(s,n);if(n+=4,f===1195456820){let g=s[n++];if(g===3){let E=s[n++],T=31&E,A=64&E,k=A?2+T*3:0,L=new Uint8Array(k);if(A){L[0]=E;for(let N=1;N<k;N++)L[N]=s[n++]}r.push({type:g,payloadType:a,pts:t,bytes:L})}}}}}else if(a===5&&o<c){if(l=!0,o>16){let u=[];for(let g=0;g<16;g++){let E=s[n++].toString(16);u.push(E.length==1?"0"+E:E),(g===3||g===5||g===7||g===9)&&u.push("-")}let h=o-16,f=new Uint8Array(h);for(let g=0;g<h;g++)f[g]=s[n++];r.push({payloadType:a,pts:t,uuid:u.join(""),userData:ji(f),userDataBytes:f})}}else if(o<c)n+=o;else if(o>c)break}}function R0(i){let e=i.byteLength,t=[],r=1;for(;r<e-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return i;let s=e-t.length,n=new Uint8Array(s),a=0;for(r=0;r<s;a++,r++)a===t[0]&&(a++,t.shift()),n[r]=i[a];return n}function c_(i){let e=i[0],t="",r="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;Lt(i.subarray(d,d+1))!=="\0";)t+=Lt(i.subarray(d,d+1)),d+=1;for(t+=Lt(i.subarray(d,d+1)),d+=1;Lt(i.subarray(d,d+1))!=="\0";)r+=Lt(i.subarray(d,d+1)),d+=1;r+=Lt(i.subarray(d,d+1)),d+=1,s=Te(i,12),n=Te(i,16),o=Te(i,20),l=Te(i,24),d=28}else if(e===1){d+=4,s=Te(i,d),d+=4;let u=Te(i,d);d+=4;let h=Te(i,d);for(d+=4,a=2**32*u+h,Number.isSafeInteger(a)||(a=Number.MAX_SAFE_INTEGER,M.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Te(i,d),d+=4,l=Te(i,d),d+=4;Lt(i.subarray(d,d+1))!=="\0";)t+=Lt(i.subarray(d,d+1)),d+=1;for(t+=Lt(i.subarray(d,d+1)),d+=1;Lt(i.subarray(d,d+1))!=="\0";)r+=Lt(i.subarray(d,d+1)),d+=1;r+=Lt(i.subarray(d,d+1)),d+=1}let c=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:r,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:c}}function u_(i,...e){let t=e.length,r=8,s=t;for(;s--;)r+=e[s].byteLength;let n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=r&255,n.set(i,4),s=0,r=8;s<t;s++)n.set(e[s],r),r+=e[s].byteLength;return n}function h_(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,s;if(e){r=1,s=new Uint8Array(e.length*16);for(let o=0;o<e.length;o++){let l=e[o];if(l.byteLength!==16)throw new RangeError("Invalid key");s.set(l,o*16)}}else r=0,s=new Uint8Array;let n;r>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;let a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),u_([112,115,115,104],new Uint8Array([r,0,0,0]),i,n,s,a,t||new Uint8Array)}function f_(i){if(!(i instanceof ArrayBuffer)||i.byteLength<32)return null;let e={version:0,systemId:"",kids:null,data:null},t=new DataView(i),r=t.getUint32(0);if(i.byteLength!==r&&r>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=Vi.hexDump(new Uint8Array(i,12,16));let n=t.getUint32(28);if(e.version===0){if(r-32<n)return null;e.data=new Uint8Array(i,32,n)}else if(e.version===1){e.kids=[];for(let a=0;a<n;a++)e.kids.push(new Uint8Array(i,32+a*16,16))}return e}var Tl={},Zr=class{static clearKeyUriToKeyIdMap(){Tl={}}constructor(e,t,r,s=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case qt.FAIRPLAY:case qt.WIDEVINE:case qt.PLAYREADY:case qt.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&M.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let r=m_(e);return new Zr(this.method,this.uri,"identity",this.keyFormatVersions,r)}let t=HT(this.uri);if(t)switch(this.keyFormat){case qt.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case qt.PLAYREADY:{let r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=h_(r,null,t);let s=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),n=String.fromCharCode.apply(null,Array.from(s)),a=n.substring(n.indexOf("<"),n.length),d=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(d){let c=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(c){let u=jh(c).subarray(0,16);$T(u),this.keyId=u}}break}default:{let r=t.subarray(0,16);if(r.length!==16){let s=new Uint8Array(16);s.set(r,16-r.length),r=s}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=Tl[this.uri];if(!r){let s=Object.keys(Tl).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),Tl[this.uri]=r}this.keyId=r}return this}};function m_(i){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}var w0=/\{\$([a-zA-Z0-9-_]+)\}/g;function Pg(i){return w0.test(i)}function Kt(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let r=t.length;r--;){let s=t[r],n=e[s];n&&(e[s]=Qu(i,n))}}function Qu(i,e){if(i.variableList!==null||i.hasVariableRefs){let t=i.variableList;return e.replace(w0,r=>{let s=r.substring(2,r.length-1),n=t==null?void 0:t[s];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),r):n})}return e}function Ng(i,e,t){let r=i.variableList;r||(i.variableList=r={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{let a=new self.URL(t).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=n||""}function p_(i,e,t){let r=e.IMPORT;if(t&&r in t){let s=i.variableList;s||(i.variableList=s={}),s[r]=t[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function Jl(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}var g_={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},Ug=Jl();function v_(i,e){let t=g_[e];return!!t&&t[i.slice(0,4)]===!0}function Du(i,e){var t;return(t=Ug==null?void 0:Ug.isTypeSupported(`${e||"video"}/mp4;codecs="${i}"`))!=null?t:!1}var Fg=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Bg=/#EXT-X-MEDIA:(.*)/g,E_=/^#EXT(?:INF|-X-TARGETDURATION):/m,$g=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),b_=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|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("|")),ei=class{static findGroup(e,t){for(let r=0;r<e.length;r++){let s=e[r];if(s.id===t)return s}}static convertAVC1ToAVCOTI(e){let t=e.split(".");if(t.length>2){let r=t.shift()+".";return r+=parseInt(t.shift()).toString(16),r+=("000"+parseInt(t.shift()).toString(16)).slice(-4),r}return e}static resolve(e,t){return Yh.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return E_.test(e)}static parseMasterPlaylist(e,t){let r=Pg(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},n=[];Fg.lastIndex=0;let a;for(;(a=Fg.exec(e))!=null;)if(a[1]){var o;let d=new Qe(a[1]);Kt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let c=Qu(s,a[2]),u={attrs:d,bitrate:d.decimalInteger("AVERAGE-BANDWIDTH")||d.decimalInteger("BANDWIDTH"),name:d.NAME,url:ei.resolve(c,t)},h=d.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),y_((d.CODECS||"").split(/[ ,]+/).filter(f=>f),u),u.videoCodec&&u.videoCodec.indexOf("avc1")!==-1&&(u.videoCodec=ei.convertAVC1ToAVCOTI(u.videoCodec)),(o=u.unknownCodecs)!=null&&o.length||n.push(u),s.levels.push(u)}else if(a[3]){let d=a[3],c=a[4];switch(d){case"SESSION-DATA":{let u=new Qe(c);Kt(s,u,["DATA-ID","LANGUAGE","VALUE","URI"]);let h=u["DATA-ID"];h&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[h]=u);break}case"SESSION-KEY":{let u=Hg(c,t,s);u.encrypted&&u.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(u)):M.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${c}"`);break}case"DEFINE":{{let u=new Qe(c);Kt(s,u,["NAME","VALUE","QUERYPARAM"]),Ng(s,u,t)}break}case"CONTENT-STEERING":{let u=new Qe(c);Kt(s,u,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:ei.resolve(u["SERVER-URI"],t),pathwayId:u["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=Gg(c);break}}}let l=n.length>0&&n.length<s.levels.length;return s.levels=l?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let s,n={},a=r.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(Bg.lastIndex=0;(s=Bg.exec(e))!==null;){let d=new Qe(s[1]),c=d.TYPE;if(c){let u=o[c],h=n[c]||[];n[c]=h,Kt(r,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let f={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",instreamId:d["INSTREAM-ID"],name:d.NAME||d.LANGUAGE||"",type:c,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:d.LANGUAGE,url:d.URI?ei.resolve(d.URI,t):""};if(u!=null&&u.length){let g=ei.findGroup(u,f.groupId)||u[0];Vg(f,g,"audioCodec"),Vg(f,g,"textCodec")}h.push(f)}}return n}static parseLevelPlaylist(e,t,r,s,n,a){let o=new Xu(t),l=o.fragments,d=null,c=0,u=0,h=0,f=0,g=null,E=new Xn(s,t),T,A,k,L=-1,N=!1;for($g.lastIndex=0,o.m3u8=e,o.hasVariableRefs=Pg(e);(T=$g.exec(e))!==null;){N&&(N=!1,E=new Xn(s,t),E.start=h,E.sn=c,E.cc=f,E.level=r,d&&(E.initSegment=d,E.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null));let G=T[1];if(G){E.duration=parseFloat(G);let Y=(" "+T[2]).slice(1);E.title=Y||null,E.tagList.push(Y?["INF",G,Y]:["INF",G])}else if(T[3]){if(ce(E.duration)){E.start=h,k&&qg(E,k,o),E.sn=c,E.level=r,E.cc=f,E.urlId=n,l.push(E);let Y=(" "+T[3]).slice(1);E.relurl=Qu(o,Y),Kg(E,g),g=E,h+=E.duration,c++,u=0,N=!0}}else if(T[4]){let Y=(" "+T[4]).slice(1);g?E.setByteRange(Y,g):E.setByteRange(Y)}else if(T[5])E.rawProgramDateTime=(" "+T[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),L===-1&&(L=l.length);else{if(T=T[0].match(b_),!T){M.warn("No matches on slow regex match for level playlist!");continue}for(A=1;A<T.length&&typeof T[A]=="undefined";A++);let Y=(" "+T[A]).slice(1),P=(" "+T[A+1]).slice(1),X=T[A+2]?(" "+T[A+2]).slice(1):"";switch(Y){case"PLAYLIST-TYPE":o.type=P.toUpperCase();break;case"MEDIA-SEQUENCE":c=o.startSN=parseInt(P);break;case"SKIP":{let z=new Qe(P);Kt(o,z,["RECENTLY-REMOVED-DATERANGES"]);let Ae=z.decimalInteger("SKIPPED-SEGMENTS");if(ce(Ae)){o.skippedSegments=Ae;for(let be=Ae;be--;)l.unshift(null);c+=Ae}let Ee=z.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ee&&(o.recentlyRemovedDateranges=Ee.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(P),1);break;case"VERSION":o.version=parseInt(P);break;case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(P||X)&&E.tagList.push(X?[P,X]:[P]);break;case"DISCONTINUITY":f++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([Y]);break;case"BITRATE":E.tagList.push([Y,P]);break;case"DATERANGE":{let z=new Qe(P);Kt(o,z,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Kt(o,z,z.clientAttrs);let Ae=new Dl(z,o.dateRanges[z.ID]);Ae.isValid||o.skippedSegments?o.dateRanges[Ae.id]=Ae:M.warn(`Ignoring invalid DATERANGE tag: "${P}"`),E.tagList.push(["EXT-X-DATERANGE",P]);break}case"DEFINE":{{let z=new Qe(P);Kt(o,z,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in z?p_(o,z,a):Ng(o,z,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(P);break;case"KEY":{let z=Hg(P,t,o);if(z.isSupported()){if(z.method==="NONE"){k=void 0;break}k||(k={}),k[z.keyFormat]&&(k=mt({},k)),k[z.keyFormat]=z}else M.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${P}"`);break}case"START":o.startTimeOffset=Gg(P);break;case"MAP":{let z=new Qe(P);if(Kt(o,z,["BYTERANGE","URI"]),E.duration){let Ae=new Xn(s,t);Wg(Ae,z,r,k),d=Ae,E.initSegment=d,d.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=d.rawProgramDateTime)}else Wg(E,z,r,k),d=E,N=!0;break}case"SERVER-CONTROL":{let z=new Qe(P);o.canBlockReload=z.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=z.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&z.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=z.optionalFloat("PART-HOLD-BACK",0),o.holdBack=z.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{let z=new Qe(P);o.partTarget=z.decimalFloatingPoint("PART-TARGET");break}case"PART":{let z=o.partList;z||(z=o.partList=[]);let Ae=u>0?z[z.length-1]:void 0,Ee=u++,be=new Qe(P);Kt(o,be,["BYTERANGE","URI"]);let we=new zu(be,E,t,Ee,Ae);z.push(we),E.duration+=we.duration;break}case"PRELOAD-HINT":{let z=new Qe(P);Kt(o,z,["URI"]),o.preloadHint=z;break}case"RENDITION-REPORT":{let z=new Qe(P);Kt(o,z,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(z);break}default:M.warn(`line parsed but not handled: ${T}`);break}}}g&&!g.relurl?(l.pop(),h-=g.duration,o.partList&&(o.fragmentHint=g)):o.partList&&(Kg(E,g),E.cc=f,o.fragmentHint=E,k&&qg(E,k,o));let D=l.length,$=l[0],O=l[D-1];if(h+=o.skippedSegments*o.targetduration,h>0&&D&&O){o.averagetargetduration=h/D;let G=O.sn;o.endSN=G!=="initSegment"?G:0,o.live||(O.endList=!0),$&&(o.startCC=$.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,L>0&&T_(l,L),o}};function Hg(i,e,t){var r,s;let n=new Qe(i);Kt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(r=n.METHOD)!=null?r:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,c=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&M.error(`Invalid IV: ${n.IV}`);let u=o?ei.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Zr(a,u,c,h,l)}function Gg(i){let t=new Qe(i).decimalFloatingPoint("TIME-OFFSET");return ce(t)?t:null}function y_(i,e){["video","audio","text"].forEach(t=>{let r=i.filter(s=>v_(s,t));if(r.length){let s=r.filter(n=>n.lastIndexOf("avc1",0)===0||n.lastIndexOf("mp4a",0)===0);e[`${t}Codec`]=s.length>0?s[0]:r[0],i=i.filter(n=>r.indexOf(n)===-1)}}),e.unknownCodecs=i}function Vg(i,e,t){let r=e[t];r&&(i[t]=r)}function T_(i,e){let t=i[e];for(let r=e;r--;){let s=i[r];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function Kg(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),ce(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function Wg(i,e,t,r){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function qg(i,e,t){i.levelkeys=e;let{encryptedFragments:r}=t;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&r.push(i)}var Ue={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},ge={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Yg(i){let{type:e}=i;switch(e){case Ue.AUDIO_TRACK:return ge.AUDIO;case Ue.SUBTITLE_TRACK:return ge.SUBTITLE;default:return ge.MAIN}}function Cu(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var Zu=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(b.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_LOADING,this.onLevelLoading,this),e.off(b.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(b.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,r=t.pLoader,s=t.loader,n=r||s,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Ue.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){let{id:r,level:s,url:n,deliveryDirectives:a}=t;this.load({id:r,level:s,responseType:"text",type:Ue.LEVEL,url:n,deliveryDirectives:a})}onAudioTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Ue.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Ue.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;let r=this.hls.config,s=this.getInternalLoader(e);if(s){let d=s.context;if(d&&d.url===e.url){M.trace("[playlist-loader]: playlist request ongoing");return}M.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===Ue.MANIFEST?n=r.manifestLoadPolicy.default:n=mt({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part){let d;if(e.type===Ue.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Ue.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Ue.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){let c=d.partTarget,u=d.targetduration;if(c&&u){let h=Math.max(c*3,u*.8)*1e3;n=mt({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,c,u,h)=>{let f=this.getInternalLoader(u);this.resetInternalLoader(u.type);let g=d.data;if(g.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,u,new Error("no EXTM3U delimiter"),h||null,c);return}c.parsing.start=performance.now(),ei.isMediaPlaylist(g)?this.handleTrackOrLevelPlaylist(d,c,u,h||null,f):this.handleMasterPlaylist(d,c,u,h)},onError:(d,c,u,h)=>{this.handleNetworkError(c,u,!1,d,h)},onTimeout:(d,c,u)=>{this.handleNetworkError(c,u,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,r,s){let n=this.hls,a=e.data,o=Cu(e,r),l=ei.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,s,t);return}let{contentSteering:d,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:g}=l;this.variableList=g;let{AUDIO:E=[],SUBTITLES:T,"CLOSED-CAPTIONS":A}=ei.parseMasterPlaylistMedia(a,o,l);E.length&&!E.some(L=>!L.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(M.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Qe({}),bitrate:0,url:""})),n.trigger(b.MANIFEST_LOADED,{levels:c,audioTracks:E,subtitles:T,captions:A,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:g})}handleTrackOrLevelPlaylist(e,t,r,s,n){let a=this.hls,{id:o,level:l,type:d}=r,c=Cu(e,r),u=ce(o)?o:0,h=ce(l)?l:u,f=Yg(r),g=ei.parseLevelPlaylist(e.data,c,h,f,u,this.variableList);if(d===Ue.MANIFEST){let E={attrs:new Qe({}),bitrate:0,details:g,name:"",url:c};a.trigger(b.MANIFEST_LOADED,{levels:[E],audioTracks:[],url:c,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=g,this.handlePlaylistLoaded(g,e,t,r,s,n)}handleManifestParsingError(e,t,r,s,n){this.hls.trigger(b.ERROR,{type:pe.NETWORK_ERROR,details:B.MANIFEST_PARSING_ERROR,fatal:t.type===Ue.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,r=!1,s,n){let a=`A network ${r?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===Ue.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Ue.AUDIO_TRACK||e.type===Ue.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);M.warn(`[playlist-loader]: ${a}`);let l=B.UNKNOWN,d=!1,c=this.getInternalLoader(e);switch(e.type){case Ue.MANIFEST:l=r?B.MANIFEST_LOAD_TIMEOUT:B.MANIFEST_LOAD_ERROR,d=!0;break;case Ue.LEVEL:l=r?B.LEVEL_LOAD_TIMEOUT:B.LEVEL_LOAD_ERROR,d=!1;break;case Ue.AUDIO_TRACK:l=r?B.AUDIO_TRACK_LOAD_TIMEOUT:B.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Ue.SUBTITLE_TRACK:l=r?B.SUBTITLE_TRACK_LOAD_TIMEOUT:B.SUBTITLE_LOAD_ERROR,d=!1;break}c&&this.resetInternalLoader(e.type);let u={type:pe.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(s){let h=(t==null?void 0:t.url)||e.url;u.response=Yt({url:h,data:void 0},s)}this.hls.trigger(b.ERROR,u)}handlePlaylistLoaded(e,t,r,s,n,a){let o=this.hls,{type:l,level:d,id:c,groupId:u,deliveryDirectives:h}=s,f=Cu(t,s),g=Yg(s),E=typeof s.level=="number"&&g===ge.MAIN?d:void 0;if(!e.fragments.length){let A=new Error("No Segments found in Playlist");o.trigger(b.ERROR,{type:pe.NETWORK_ERROR,details:B.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:A,reason:A.message,response:t,context:s,level:E,parent:g,networkDetails:n,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let T=e.playlistParsingError;if(T){o.trigger(b.ERROR,{type:pe.NETWORK_ERROR,details:B.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:T,reason:T.message,response:t,context:s,level:E,parent:g,networkDetails:n,stats:r});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case Ue.MANIFEST:case Ue.LEVEL:o.trigger(b.LEVEL_LOADED,{details:e,level:E||0,id:c||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case Ue.AUDIO_TRACK:o.trigger(b.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case Ue.SUBTITLE_TRACK:o.trigger(b.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break}}};function D0(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function C0(i,e){let t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){M.debug(`[texttrack-utils]: ${r}`);try{let s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,i.addCue(s)}catch(s){M.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(i.mode=t)}function Js(i){let e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function Ju(i,e,t,r){let s=i.mode;if(s==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){let n=A_(i.cues,e,t);for(let a=0;a<n.length;a++)(!r||r(n[a]))&&i.removeCue(n[a])}s==="disabled"&&(i.mode=s)}function __(i,e){if(e<i[0].startTime)return 0;let t=i.length-1;if(e>i[t].endTime)return-1;let r=0,s=t;for(;r<=s;){let n=Math.floor((s+r)/2);if(e<i[n].startTime)s=n-1;else if(e>i[n].startTime&&r<t)r=n+1;else return n}return i[r].startTime-e<e-i[s].startTime?r:s}function A_(i,e,t){let r=[],s=__(i,e);if(s>-1)for(let n=s,a=i.length;n<a;n++){let o=i[n];if(o.startTime>=e&&o.endTime<=t)r.push(o);else if(o.startTime>t)return r}return r}var Ai={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},S_=.25;function eh(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var _l=(()=>{let i=eh();try{new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Mu(i,e){return i.getTime()/1e3-e}function x_(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var th=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){!this.id3Track||(Js(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(!!this.media){for(let t=0;t<e.length;t++){let r=e[t];if(r.kind==="metadata"&&r.label==="id3")return D0(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:s}}}=this;if(!r&&!s)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=eh();for(let o=0;o<n.length;o++){let l=n[o].type;if(l===Ai.emsg&&!r||!s)continue;let d=_0(n[o].data);if(d){let c=n[o].pts,u=c+n[o].duration;u>_l&&(u=_l),u-c<=0&&(u=c+S_);for(let f=0;f<d.length;f++){let g=d[f];if(!T0(g)){this.updateId3CueEnds(c,l);let E=new a(c,u,"");E.value=g,l&&(E.type=l),this.id3Track.addCue(E)}}}}}updateId3CueEnds(e,t){var r;let s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(let n=s.length;n--;){let a=s[n];a.type===t&&a.startTime<e&&a.endTime===_l&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:s}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;s==="audio"?d=c=>c.type===Ai.audioId3&&l:s==="video"?d=c=>c.type===Ai.emsg&&o:d=c=>c.type===Ai.audioId3&&l||c.type===Ai.emsg&&o,Ju(n,t,r,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:r,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){let c=Object.keys(r).filter(u=>!a.includes(u));for(let u=c.length;u--;){let h=c[u];Object.keys(r[h].cues).forEach(f=>{s.removeCue(r[h].cues[f])}),delete r[h]}}let o=t.fragments[t.fragments.length-1];if(a.length===0||!ce(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=o.programDateTime/1e3-o.start,d=eh();for(let c=0;c<a.length;c++){let u=a[c],h=n[u],f=r[u],g=(f==null?void 0:f.cues)||{},E=(f==null?void 0:f.durationKnown)||!1,T=Mu(h.startDate,l),A=_l,k=h.endDate;if(k)A=Mu(k,l),E=!0;else if(h.endOnNext&&!E){let N=a.reduce((D,$)=>{let O=n[$];return O.class===h.class&&O.id!==$&&O.startDate>h.startDate&&D.push(O),D},[]).sort((D,$)=>D.startDate.getTime()-$.startDate.getTime())[0];N&&(A=Mu(N.startDate,l),E=!0)}let L=Object.keys(h.attr);for(let N=0;N<L.length;N++){let D=L[N];if(!NT(D))continue;let $=g[D];if($)E&&!f.durationKnown&&($.endTime=A);else{let O=h.attr[D];$=new d(T,A,""),UT(D)&&(O=x_(O)),$.value={key:D,data:O},$.type=Ai.dateRange,$.id=u,this.id3Track.addCue($),g[D]=$}}r[u]={cues:g,dateRange:h,durationKnown:E}}}},ih=class{constructor(e){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=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){let{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let{levelDetails:e}=this;if(e===null)return null;let{holdBack:t,partHoldBack:r,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*s);let c=s,u=1;return d+Math.min(this.stallCount*u,c)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;let s=r.edge,n=e-t-this.edgeStalled,a=s-r.totalduration,o=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){let{levelDetails:e}=this;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e,levelDetails:t}=this;if(!e||!t)return 0;let r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(b.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(b.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(b.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(b.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===B.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&M.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1)return;let a=this.targetLatency;if(a===null)return;let o=r-a,l=Math.min(this.maxLatency,a+t.targetduration),d=o<l;if(t.live&&d&&o>.05&&this.forwardBufferLength>1){let c=Math.min(2,Math.max(1,n)),u=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,u))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){let{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},rh=["NONE","TYPE-0","TYPE-1",null],Qn={No:"",Yes:"YES",v2:"v2"};function I_(i,e){let{canSkipUntil:t,canSkipDateRanges:r,endSN:s}=i,n=e!==void 0?e-s:0;return t&&n<t?r?Qn.v2:Qn.Yes:Qn.No}var Pl=class{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){let t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}},Jr=class{constructor(e){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=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>t).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(e){let t=e%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var e;return(e=this.audioGroupIds)==null?void 0:e[this.urlId]}get textGroupId(){var e;return(e=this.textGroupIds)==null?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}};function Ou(i,e){let t=e.startPTS;if(ce(t)){let r=0,s;e.sn>i.sn?(r=t-i.start,s=i):(r=i.start-t,s=e),s.duration!==r&&(s.duration=r)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function M0(i,e,t,r,s,n){r-t<=0&&(M.warn("Fragment should have a positive duration",e),r=t+e.duration,n=s+e.duration);let o=t,l=r,d=e.startPTS,c=e.endPTS;if(ce(d)){let T=Math.abs(d-t);ce(e.deltaPTS)?e.deltaPTS=Math.max(T,e.deltaPTS):e.deltaPTS=T,o=Math.max(t,d),t=Math.min(t,d),s=Math.min(s,e.startDTS),l=Math.min(r,c),r=Math.max(r,c),n=Math.max(n,e.endDTS)}let u=t-e.start;e.start!==0&&(e.start=t),e.duration=r-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=r,e.minEndPTS=l,e.endDTS=n;let h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f,g=h-i.startSN,E=i.fragments;for(E[g]=e,f=g;f>0;f--)Ou(E[f],E[f-1]);for(f=g;f<E.length-1;f++)Ou(E[f],E[f+1]);return i.fragmentHint&&Ou(E[E.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,u}function L_(i,e){let t=null,r=i.fragments;for(let l=r.length-1;l>=0;l--){let d=r[l].initSegment;if(d){t=d;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let s=0,n;if(w_(i,e,(l,d)=>{l.relurl&&(s=l.cc-d.cc),ce(l.startPTS)&&ce(l.endPTS)&&(d.start=d.startPTS=l.startPTS,d.startDTS=l.startDTS,d.maxStartPTS=l.maxStartPTS,d.endPTS=l.endPTS,d.endDTS=l.endDTS,d.minEndPTS=l.minEndPTS,d.duration=l.endPTS-l.startPTS,d.duration&&(n=d),e.PTSKnown=e.alignedSliding=!0),d.elementaryStreams=l.elementaryStreams,d.loader=l.loader,d.stats=l.stats,d.urlId=l.urlId,l.initSegment&&(d.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(d=>{var c;(!d.initSegment||d.initSegment.relurl===((c=t)==null?void 0:c.relurl))&&(d.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){M.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=k_(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));let a=e.fragments;if(s){M.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),R_(i.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?M0(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):O0(i,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;let o=e.advancedDateTime;if(e.advanced&&o){let l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function k_(i,e,t){let r=mt({},i);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{let n=new Dl(e[s].attr,r[s]);n.isValid?r[s]=n:M.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),r}function R_(i,e,t){if(i&&e){let r=0;for(let s=0,n=i.length;s<=n;s++){let a=i[s],o=e[s+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):r--}}}function w_(i,e,t){let r=e.skippedSegments,s=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(r?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=s;d<=n;d++){let c=l[a+d],u=o[d];r&&!u&&d<r&&(u=e.fragments[d]=c),c&&u&&t(c,u)}}function O0(i,e){let t=e.startSN+e.skippedSegments-i.startSN,r=i.fragments;t<0||t>=r.length||sh(e,r[t].start)}function sh(i,e){if(e){let t=i.fragments;for(let r=i.skippedSegments;r<t.length;r++)t[r].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function D_(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){let r=i.fragments,s=4;if(r.length&&t*s>e){let n=r[r.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function C_(i,e,t){if(!(i!=null&&i.details))return null;let r=i.details,s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,s&&s.sn===e)?s:e<r.startSN&&t&&t.sn===e?t:null}function jg(i,e,t){var r;return i!=null&&i.details?P0((r=i.details)==null?void 0:r.partList,e,t):null}function P0(i,e,t){if(i)for(let r=i.length;r--;){let s=i[r];if(s.index===t&&s.fragment.sn===e)return s}return null}function Nl(i){switch(i.details){case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_TIMEOUT:case B.LEVEL_LOAD_TIMEOUT:case B.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function zg(i,e){let t=Nl(e);return i.default[`${t?"timeout":"error"}Retry`]}function Xh(i,e){let t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function Xg(i){return Yt(Yt({},i),{errorRetry:null,timeoutRetry:null})}function Ul(i,e,t,r){return!!i&&e<i.maxNumRetry&&(M_(r)||!!t)}function M_(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}var N0={search:function(i,e){let t=0,r=i.length-1,s=null,n=null;for(;t<=r;){s=(t+r)/2|0,n=i[s];let a=e(n);if(a>0)t=s+1;else if(a<0)r=s-1;else return n}return null}};function O_(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!ce(e))return null;let r=i[0].programDateTime;if(e<(r||0))return null;let s=i[i.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<i.length;++n){let a=i[n];if(P_(e,t,a))return a}return null}function ea(i,e,t=0,r=0){let s=null;if(i?s=e[i.sn-e[0].sn+1]||null:t===0&&e[0].start===0&&(s=e[0]),s&&nh(t,r,s)===0)return s;let n=N0.search(e,nh.bind(null,t,r));return n&&(n!==i||!s)?n:s}function nh(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=i?1:t.start-r>i&&t.start?-1:0}function P_(i,e,t){let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>i}function N_(i,e){return N0.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var U_=3e5,Ct={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},di={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},ah=class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=M.log.bind(M,"[info]:"),this.warn=M.warn.bind(M,"[warning]:"),this.error=M.error.bind(M,"[error]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(b.ERROR,this.onError,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;!e||(e.off(b.ERROR,this.onError,this),e.off(b.ERROR,this.onErrorOut,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(e==null?void 0:e.type)===ge.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,s;if(t.fatal)return;let n=this.hls,a=t.context;switch(t.details){case B.FRAG_LOAD_ERROR:case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_ERROR:case B.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case B.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:Ct.DoNothing,flags:di.None};return}case B.FRAG_GAP:case B.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Ct.SendAlternateToPenaltyBox;return}case B.LEVEL_EMPTY_ERROR:case B.LEVEL_PARSING_ERROR:{var o,l;let d=t.parent===ge.MAIN?t.level:n.loadLevel;t.details===B.LEVEL_EMPTY_ERROR&&!!((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case B.LEVEL_LOAD_ERROR:case B.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case B.AUDIO_TRACK_LOAD_ERROR:case B.AUDIO_TRACK_LOAD_TIMEOUT:case B.SUBTITLE_LOAD_ERROR:case B.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){let d=n.levels[n.loadLevel];if(d&&(a.type===Ue.AUDIO_TRACK&&a.groupId===d.audioGroupId||a.type===Ue.SUBTITLE_TRACK&&a.groupId===d.textGroupId)){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=Ct.SendAlternateToPenaltyBox,t.errorAction.flags=di.MoveAllAlternatesMatchingHost;return}}return;case B.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let d=n.levels[n.loadLevel],c=d==null?void 0:d.attrs["HDCP-LEVEL"];c&&(t.errorAction={action:Ct.SendAlternateToPenaltyBox,flags:di.MoveAllAlternatesMatchingHDCP,hdcpLevel:c})}return;case B.BUFFER_ADD_CODEC_ERROR:case B.REMUX_ALLOC_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:n.loadLevel);return;case B.INTERNAL_EXCEPTION:case B.BUFFER_APPENDING_ERROR:case B.BUFFER_APPEND_ERROR:case B.BUFFER_FULL_ERROR:case B.LEVEL_SWITCH_ERROR:case B.BUFFER_STALLED_ERROR:case B.BUFFER_SEEK_OVER_HOLE:case B.BUFFER_NUDGE_ON_STALL:t.errorAction={action:Ct.DoNothing,flags:di.None};return}if(t.type===pe.KEY_SYSTEM_ERROR){let d=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d);return}}getPlaylistRetryOrSwitchAction(e,t){var r;let s=this.hls,n=zg(s.config.playlistLoadPolicy,e),a=this.playlistError++,o=(r=e.response)==null?void 0:r.code;if(Ul(n,a,Nl(e),o))return{action:Ct.RetryRequest,flags:di.None,retryConfig:n,retryCount:a};let d=this.getLevelSwitchAction(e,t);return n&&(d.retryConfig=n,d.retryCount=a),d}getFragRetryOrSwitchAction(e){let t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=zg(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((u,h)=>u+h.fragmentError,0);if(s){var d;e.details!==B.FRAG_GAP&&s.fragmentError++;let u=(d=e.response)==null?void 0:d.code;if(Ul(o,l,Nl(e),u))return{action:Ct.RetryRequest,flags:di.None,retryConfig:o,retryCount:l}}let c=this.getLevelSwitchAction(e,r);return o&&(c.retryConfig=o,c.retryCount=l),c}getLevelSwitchAction(e,t){let r=this.hls;t==null&&(t=r.loadLevel);let s=this.hls.levels[t];if(s&&(s.loadError++,r.autoLevelEnabled)){var n,a;let o=-1,{levels:l,loadLevel:d,minAutoLevel:c,maxAutoLevel:u}=r,h=(n=e.frag)==null?void 0:n.type,{type:f,groupId:g}=(a=e.context)!=null?a:{};for(let E=l.length;E--;){let T=(E+d)%l.length;if(T!==d&&T>=c&&T<=u&&l[T].loadError===0){let A=l[T];if(e.details===B.FRAG_GAP&&e.frag){let k=l[T].details;if(k){let L=ea(e.frag,k.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else{if(f===Ue.AUDIO_TRACK&&g===A.audioGroupId||f===Ue.SUBTITLE_TRACK&&g===A.textGroupId)continue;if(h===ge.AUDIO&&s.audioGroupId===A.audioGroupId||h===ge.SUBTITLE&&s.textGroupId===A.textGroupId)continue}o=T;break}}if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:Ct.SendAlternateToPenaltyBox,flags:di.None,nextAutoLevel:o}}return{action:Ct.SendAlternateToPenaltyBox,flags:di.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case Ct.DoNothing:break;case Ct.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==B.FRAG_GAP&&(t.fatal=!0);break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){let t=this.hls,r=e.errorAction;if(!r)return;let{flags:s,hdcpLevel:n,nextAutoLevel:a}=r;switch(s){case di.None:this.switchLevel(e,a);break;case di.MoveAllAlternatesMatchingHost:r.resolved||(r.resolved=this.redundantFailover(e));break;case di.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=rh[rh.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(e){let{hls:t,penalizedRenditions:r}=this,s=e.parent===ge.MAIN?e.level:t.loadLevel,n=t.levels[s],a=n.url.length,o=e.frag?e.frag.urlId:n.urlId;n.urlId===o&&(!e.frag||n.details)&&this.penalizeRendition(n,e);for(let l=1;l<a;l++){let d=(o+l)%a,c=r[d];if(!c||F_(c,e,r[o]))return this.warn(`Switching to Redundant Stream ${d+1}/${a}: "${n.url[d]}" after ${e.details}`),this.playlistError=0,t.levels.forEach(u=>{u.urlId=d}),t.nextLoadLevel=s,!0}return!1}penalizeRendition(e,t){let{penalizedRenditions:r}=this,s=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};s.lastErrorPerfMs=performance.now(),s.errors.push(t),s.details=e.details,r[e.urlId]=s}};function F_(i,e,t){if(performance.now()-i.lastErrorPerfMs>U_)return!0;let r=i.details;if(e.details===B.FRAG_GAP&&r&&e.frag){let s=e.frag.start,n=ea(null,r.fragments,s);if(n&&!n.gap)return!0}if(t&&i.errors.length<t.errors.length){let s=i.errors[i.errors.length-1];if(r&&s.frag&&e.frag&&Math.abs(s.frag.start-e.frag.start)>r.targetduration*3)return!0}return!1}var ta=class{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=M.log.bind(M,`${t}:`),this.warn=M.warn.bind(M,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t){let r=t==null?void 0:t.renditionReports;if(r){let s=-1;for(let n=0;n<r.length;n++){let a=r[n],o;try{o=new self.URL(a.URI,t.url).href}catch(l){M.warn(`Could not construct new URL for Rendition Report: ${l}`),o=a.URI||""}if(o===e){s=n;break}else o===e.substring(0,o.length)&&(s=n)}if(s!==-1){let n=r[s],a=parseInt(n["LAST-MSN"])||(t==null?void 0:t.lastPartSn),o=parseInt(n["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){let l=Math.min(t.age-t.partTarget,t.targetduration);o>=0&&l>t.partTarget&&(o+=1)}return new Pl(a,o>=0?o:void 0,Qn.No)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){let{details:s,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||r!=null&&r.live){if(s.reloaded(r),r&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:"MISSED"}`),r&&s.fragments.length>0&&L_(r,s),!this.canLoad||!s.live)return;let l,d,c;if(s.canBlockReload&&s.endSN&&s.advanced){let T=this.hls.config.lowLatencyMode,A=s.lastPartSn,k=s.endSN,L=s.lastPartIndex,N=L!==-1,D=A===k,$=T?0:L;N?(d=D?k+1:A,c=D?$:L+1):d=k+1;let O=s.age,G=O+s.ageHeader,Y=Math.min(G-s.partTarget,s.targetduration*1.5);if(Y>0){if(r&&Y>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${Y} with playlist age: ${s.age}`),Y=0;else{let P=Math.floor(Y/s.targetduration);if(d+=P,c!==void 0){let X=Math.round(Y%s.targetduration/s.partTarget);c+=X}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${O.toFixed(2)}s goal: ${Y} skip sn ${P} to part ${c}`)}s.tuneInGoal=Y}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,c),T||!D){this.loadPlaylist(l);return}}else s.canBlockReload&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,c));let u=this.hls.mainForwardBufferInfo,h=u?u.end-u.len:0,f=(s.edge-h)*1e3,g=D_(s,f);s.updated&&a>this.requestScheduled+g&&(this.requestScheduled=n.loading.start),d!==void 0&&s.canBlockReload?this.requestScheduled=n.loading.first+g-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+g<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=g);let E=this.requestScheduled-a;E=Math.max(0,E),this.log(`reload live playlist ${e} in ${Math.round(E)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),E)}else this.clearTimer()}getDeliveryDirectives(e,t,r,s){let n=I_(e,r);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,n=Qn.No),new Pl(r,s,n)}checkRetry(e){let t=e.details,r=Nl(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===Ct.RetryRequest||!s.resolved&&n===Ct.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(r&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let c=Xh(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${c}ms`)}e.levelRetry=!0,s.resolved=!0}return l}},Pu,oh=class extends ta{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){let r=[],s={},n;t.levels.forEach(a=>{var o;let l=a.attrs;((o=a.audioCodec)==null?void 0:o.indexOf("mp4a.40.34"))!==-1&&(Pu||(Pu=/chrome|firefox/i.test(navigator.userAgent)),Pu&&(a.audioCodec=void 0));let{AUDIO:d,CODECS:c,"FRAME-RATE":u,"PATHWAY-ID":h,RESOLUTION:f,SUBTITLES:g}=l,T=`${`${h||"."}-`}${a.bitrate}-${f}-${u}-${c}`;n=s[T],n?n.addFallback(a):(n=new Jr(a),s[T]=n,r.push(n)),Fl(n,"audio",d),Fl(n,"text",g)}),this.filterAndSortMediaOptions(r,t)}filterAndSortMediaOptions(e,t){let r=[],s=[],n=!1,a=!1,o=!1,l=e.filter(({audioCodec:f,videoCodec:g,width:E,height:T,unknownCodecs:A})=>(n||(n=!!(E&&T)),a||(a=!!g),o||(o=!!f),!(A!=null&&A.length)&&(!f||Du(f,"audio"))&&(!g||Du(g,"video"))));if((n||a)&&o&&(l=l.filter(({videoCodec:f,width:g,height:E})=>!!f||!!(g&&E))),l.length===0){Promise.resolve().then(()=>{if(this.hls){let f=new Error("no level with compatible codecs found in manifest");this.hls.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:f,reason:f.message})}});return}t.audioTracks&&(r=t.audioTracks.filter(f=>!f.audioCodec||Du(f.audioCodec,"audio")),Qg(r)),t.subtitles&&(s=t.subtitles,Qg(s));let d=l.slice(0);l.sort((f,g)=>f.attrs["HDCP-LEVEL"]!==g.attrs["HDCP-LEVEL"]?(f.attrs["HDCP-LEVEL"]||"")>(g.attrs["HDCP-LEVEL"]||"")?1:-1:f.bitrate!==g.bitrate?f.bitrate-g.bitrate:f.attrs["FRAME-RATE"]!==g.attrs["FRAME-RATE"]?f.attrs.decimalFloatingPoint("FRAME-RATE")-g.attrs.decimalFloatingPoint("FRAME-RATE"):f.attrs.SCORE!==g.attrs.SCORE?f.attrs.decimalFloatingPoint("SCORE")-g.attrs.decimalFloatingPoint("SCORE"):n&&f.height!==g.height?f.height-g.height:0);let c=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let f=0;f<d.length;f++)if(d[f].pathwayId===l[0].pathwayId){c=d[f];break}}this._levels=l;for(let f=0;f<l.length;f++)if(l[f]===c){this._firstLevel=f,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${c.bitrate}`);break}let u=o&&!a,h={levels:l,audioTracks:r,subtitleTracks:s,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:o,video:a,altAudio:!u&&r.some(f=>!!f.url)};this.hls.trigger(b.MANIFEST_PARSED,h),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(b.ERROR,{type:pe.OTHER_ERROR,details:B.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,t.length-1)}let r=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,r===e&&a.details&&s&&n===o)return;this.log(`Switching to level ${e}${o?" with Pathway "+o:""} from level ${r}${n?" with Pathway "+n:""}`);let l=mt({},a,{level:e,maxBitrate:a.maxBitrate,attrs:a.attrs,uri:a.uri,urlId:a.urlId});delete l._attrs,delete l._urlId,this.hls.trigger(b.LEVEL_SWITCHING,l);let d=a.details;if(!d||d.live){let c=this.switchParams(a.uri,s==null?void 0:s.details);this.loadPlaylist(c)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){let e=this.hls.config.startLevel;return e!==void 0?e:this._firstLevel}else return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===Ue.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(t!==void 0&&t.type===ge.MAIN){let r=this._levels[t.level];r!==void 0&&(r.loadError=0)}}onLevelLoaded(e,t){var r;let{level:s,details:n}=t,a=this._levels[s];if(!a){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):(r=t.deliveryDirectives)!=null&&r.skip&&(n.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,t){let r=this.currentLevel;if(!r)return;let s=this.hls.audioTracks[t.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==s){let n=-1;for(let a=0;a<r.audioGroupIds.length;a++)if(r.audioGroupIds[a]===s){n=a;break}n!==-1&&n!==r.urlId&&(r.urlId=n,this.canLoad&&this.startLoad())}}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.urlId,n=r.uri;if(e)try{n=e.addDirectives(n)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}let a=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${a?" Pathway "+a:""} URI ${s+1}/${r.url.length} ${n}`),this.clearTimer(),this.hls.trigger(b.LEVEL_LOADING,{url:n,level:t,id:s,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e,t){let r=(n,a)=>a!==t,s=this._levels.filter((n,a)=>a!==e?!0:n.url.length>1&&t!==void 0?(n.url=n.url.filter(r),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(r)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(r)),n.urlId=0,!0):(this.steering&&this.steering.removeLevel(n),!1));this.hls.trigger(b.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(e,{levels:t}){t.forEach((r,s)=>{let{details:n}=r;n!=null&&n.fragments&&n.fragments.forEach(a=>{a.level=s})}),this._levels=t}};function Fl(i,e,t){!t||(e==="audio"?(i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds[i.url.length-1]=t):e==="text"&&(i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds[i.url.length-1]=t))}function Qg(i){let e={};i.forEach(t=>{let r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}var Tt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},lh=class{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(b.BUFFER_APPENDED,this.onBufferAppended,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.BUFFER_APPENDED,this.onBufferAppended,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let r=this.activePartLists[t];if(r)for(let s=r.length;s--;){let n=r[s];if(!n)break;let a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){let{fragments:r}=this,s=Object.keys(r);for(let n=s.length;n--;){let a=r[s[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){let o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,r,s){this.timeRanges&&(this.timeRanges[e]=t);let n=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===r&&this.removeFragment(o.body);return}let l=o.range[e];!l||l.time.some(d=>{let c=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return c&&this.removeFragment(o.body),c})})}detectPartialFragments(e){let t=this.timeRanges,{frag:r,part:s}=e;if(!t||r.sn==="initSegment")return;let n=Xs(r),a=this.fragments[n];if(!a||a.buffered&&r.gap)return;let o=!r.relurl;Object.keys(t).forEach(l=>{let d=r.elementaryStreams[l];if(!d)return;let c=t[l],u=o||d.partial===!0;a.range[l]=this.getBufferedTimes(r,s,u,c)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,a.body.endList&&(this.endListFragments[a.body.type]=a),Al(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}removeParts(e,t){let r=this.activePartLists[t];!r||(this.activePartLists[t]=r.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){let r=Xs(e),s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,r,s){let n={time:[],partial:r},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let c=0;c<s.length;c++){let u=s.start(c)-this.bufferPadding,h=s.end(c)+this.bufferPadding;if(d>=u&&l<=h){n.time.push({startPTS:Math.max(a,s.start(c)),endPTS:Math.min(o,s.end(c))});break}else if(a<h&&o>u)n.partial=!0,n.time.push({startPTS:Math.max(a,s.start(c)),endPTS:Math.min(o,s.end(c))});else if(o<=u)break}return n}getPartialFragment(e){let t=null,r,s,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let c=l[d];!c||Al(c)&&(s=c.body.start-o,n=c.body.end+o,e>=s&&e<=n&&(r=Math.min(e-s,n-e),a<=r&&(t=c.body,a=r)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||Al(t))}getState(e){let t=Xs(e),r=this.fragments[t];return r?r.buffered?Al(r)?Tt.PARTIAL:Tt.OK:Tt.APPENDING:Tt.NOT_LOADED}isTimeBuffered(e,t,r){let s,n;for(let a=0;a<r.length;a++){if(s=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){let{frag:r,part:s}=t;if(r.sn==="initSegment"||r.bitrateTest)return;let n=s?null:t,a=Xs(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:r,part:s,timeRanges:n}=t;if(r.sn==="initSegment")return;let a=r.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n,Object.keys(n).forEach(o=>{let l=n[o];this.detectEvictedFragments(o,l,a,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=Xs(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,r,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let l=o.body;l.type!==r||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){let t=Xs(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let r=this.activePartLists[e.type];if(r){let s=e.sn;this.activePartLists[e.type]=r.filter(n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}};function Al(i){var e,t,r;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function Xs(i){return`${i.type}_${i.level}_${i.urlId}_${i.sn}`}var Zg=Math.pow(2,17),dh=class{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let r=e.url;if(!r)return Promise.reject(new _i({type:pe.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(e0(e));return}else e.gap=!1;let d=this.loader=e.loader=n?new n(s):new a(s),c=Jg(e),u=Xg(s.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Zg};e.stats=d.stats,d.load(c,h,{onSuccess:(f,g,E,T)=>{this.resetLoader(e,d);let A=f.data;E.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(A.slice(0,16)),A=A.slice(16)),o({frag:e,part:null,payload:A,networkDetails:T})},onError:(f,g,E,T)=>{this.resetLoader(e,d),l(new _i({type:pe.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Yt({url:r,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:E,stats:T}))},onAbort:(f,g,E)=>{this.resetLoader(e,d),l(new _i({type:pe.NETWORK_ERROR,details:B.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:E,stats:f}))},onTimeout:(f,g,E)=>{this.resetLoader(e,d),l(new _i({type:pe.NETWORK_ERROR,details:B.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:f}))},onProgress:(f,g,E,T)=>{t&&t({frag:e,part:null,payload:E,networkDetails:T})}})})}loadPart(e,t,r){this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(e0(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),c=Jg(e,t),u=Xg(s.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Zg};t.stats=d.stats,d.load(c,h,{onSuccess:(f,g,E,T)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);let A={frag:e,part:t,payload:f.data,networkDetails:T};r(A),o(A)},onError:(f,g,E,T)=>{this.resetLoader(e,d),l(new _i({type:pe.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Yt({url:c.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:E,stats:T}))},onAbort:(f,g,E)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new _i({type:pe.NETWORK_ERROR,details:B.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:E,stats:f}))},onTimeout:(f,g,E)=>{this.resetLoader(e,d),l(new _i({type:pe.NETWORK_ERROR,details:B.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:f}))}})})}updateStatsFromPart(e,t){let r=e.stats,s=t.stats,n=s.total;if(r.loaded+=s.loaded,n){let l=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/n),l),u=(l-d)*Math.round(r.loaded/d);r.total=r.loaded+u}else r.total=Math.max(r.loaded,r.total);let a=r.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}};function Jg(i,e=null){let t=e||i,r={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(ce(s)&&ce(n)){var a;let o=s,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){let d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(r.resetIV=!0,o=s-16)}r.rangeStart=o,r.rangeEnd=l}return r}function e0(i,e){let t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:pe.MEDIA_ERROR,details:B.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(r.part=e),(e||i).stats.aborted=!0,new _i(r)}var _i=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},ch=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let t in this.keyUriToKeyInfo){let r=this.keyUriToKeyInfo[t].loader;if(r){if(e&&e!==r.context.frag.type)return;r.abort()}}}detach(){for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=B.KEY_LOAD_ERROR,r,s,n){return new _i({type:pe.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:r,cc:s}=e;for(let n=0;n<t.length;n++){let a=t[n];if(s<=a.cc&&(r==="initSegment"||a.sn==="initSegment"||r<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,s;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,B.KEY_LOAD_ERROR,d))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,B.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((r=o)!=null&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,B.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){let r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,r))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(r)}loadKeyHTTP(e,t){let r=this.config,s=r.loader,n=new s(r);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=r.keyLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,E)=>{let{frag:T,keyInfo:A,url:k}=g;if(!T.decryptdata||A!==this.keyUriToKeyInfo[k])return o(this.createKeyLoadError(T,B.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),E));A.decryptdata.key=T.decryptdata.key=new Uint8Array(h.data),T.keyLoader=null,A.loader=null,a({frag:T,keyInfo:A})},onError:(h,f,g,E)=>{this.resetLoader(f),o(this.createKeyLoadError(t,B.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),g,Yt({url:l.url,data:void 0},h)))},onTimeout:(h,f,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,B.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),g))},onAbort:(h,f,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,B.INTERNAL_ABORTED,new Error("key loading aborted"),g))}};n.load(l,c,u)})}resetLoader(e){let{frag:t,keyInfo:r,url:s}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}},uh=class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}},B_={length:0,start:()=>0,end:()=>0},je=class{static isBuffered(e,t){try{if(e){let r=je.getBuffered(e);for(let s=0;s<r.length;s++)if(t>=r.start(s)&&t<=r.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,r){try{if(e){let s=je.getBuffered(e),n=[],a;for(a=0;a<s.length;a++)n.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(n,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort(function(d,c){let u=d.start-c.start;return u||c.end-d.end});let s=[];if(r)for(let d=0;d<e.length;d++){let c=s.length;if(c){let u=s[c-1].end;e[d].start-u<r?e[d].end>u&&(s[c-1].end=e[d].end):s.push(e[d])}else s.push(e[d])}else s=e;let n=0,a,o=t,l=t;for(let d=0;d<s.length;d++){let c=s[d].start,u=s[d].end;if(t+r>=c&&t<u)o=c,l=u,n=l-t;else if(t+r<c){a=c;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return M.log("failed to get media.buffered",t),B_}}},ia=class{constructor(e,t,r,s=0,n=-1,a=!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=Sl(),this.buffering={audio:Sl(),video:Sl(),audiovideo:Sl()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=n,this.partial=a}};function Sl(){return{start:0,executeStart:0,executeEnd:0,end:0}}function U0(i,e){let t=null;for(let r=0,s=i.length;r<s;r++){let n=i[r];if(n&&n.cc===e){t=n;break}}return t}function $_(i,e,t){return!!(e.details&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function H_(i,e,t=0){let r=i.fragments,s=e.fragments;if(!s.length||!r.length){M.log("No fragments to align");return}let n=U0(r,s[0].cc);if(!n||n&&!n.startPTS){M.log("No frag in previous level to align on");return}return n}function t0(i,e){if(i){let t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function Qh(i,e){let t=e.fragments;for(let r=0,s=t.length;r<s;r++)t0(t[r],i);e.fragmentHint&&t0(e.fragmentHint,i),e.alignedSliding=!0}function G_(i,e,t){!e||(V_(i,t,e),!t.alignedSliding&&e.details&&K_(t,e.details),!t.alignedSliding&&e.details&&!t.skippedSegments&&O0(e.details,t))}function V_(i,e,t){if($_(i,t,e)){let r=H_(t.details,e);r&&ce(r.start)&&(M.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),Qh(r.start,e))}}function K_(i,e){if(!e.fragments.length||!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=e.fragments[0].programDateTime,r=i.fragments[0].programDateTime,s=(r-t)/1e3+e.fragments[0].start;s&&ce(s)&&(M.log(`Adjusting PTS using programDateTime delta ${r-t}ms, sliding:${s.toFixed(3)} ${i.url} `),Qh(s,i))}function F0(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=i.fragments,r=e.fragments;if(!t.length||!r.length)return;let s=Math.round(r.length/2)-1,n=r[s],a=U0(t,n.cc)||t[Math.round(t.length/2)-1],o=n.programDateTime,l=a.programDateTime;if(o===null||l===null)return;let d=(l-o)/1e3-(a.start-n.start);Qh(d,i)}var hh=class{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}},fh=class{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}};function W_(i){let e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?Xr(i,0,e-t):i}var mh=class{constructor(){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()}uint8ArrayToUint32Array_(e){let t=new DataView(e),r=new Uint32Array(4);for(let s=0;s<4;s++)r[s]=t.getUint32(s*4);return r}initTable(){let e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],n=r[1],a=r[2],o=r[3],l=this.invSubMix,d=l[0],c=l[1],u=l[2],h=l[3],f=new Uint32Array(256),g=0,E=0,T=0;for(T=0;T<256;T++)T<128?f[T]=T<<1:f[T]=T<<1^283;for(T=0;T<256;T++){let A=E^E<<1^E<<2^E<<3^E<<4;A=A>>>8^A&255^99,e[g]=A,t[A]=g;let k=f[g],L=f[k],N=f[L],D=f[A]*257^A*16843008;s[g]=D<<24|D>>>8,n[g]=D<<16|D>>>16,a[g]=D<<8|D>>>24,o[g]=D,D=N*16843009^L*65537^k*257^g*16843008,d[A]=D<<24|D>>>8,c[A]=D<<16|D>>>16,u[A]=D<<8|D>>>24,h[A]=D,g?(g=k^f[f[f[N^k]]],E^=f[f[E]]):g=E=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),r=!0,s=0;for(;s<t.length&&r;)r=t[s]===this.key[s],s++;if(r)return;this.key=t;let n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);let a=this.ksRows=(n+6+1)*4,o,l,d=this.keySchedule=new Uint32Array(a),c=this.invKeySchedule=new Uint32Array(a),u=this.sBox,h=this.rcon,f=this.invSubMix,g=f[0],E=f[1],T=f[2],A=f[3],k,L;for(o=0;o<a;o++){if(o<n){k=d[o]=t[o];continue}L=k,o%n===0?(L=L<<8|L>>>24,L=u[L>>>24]<<24|u[L>>>16&255]<<16|u[L>>>8&255]<<8|u[L&255],L^=h[o/n|0]<<24):n>6&&o%n===4&&(L=u[L>>>24]<<24|u[L>>>16&255]<<16|u[L>>>8&255]<<8|u[L&255]),d[o]=k=(d[o-n]^L)>>>0}for(l=0;l<a;l++)o=a-l,l&3?L=d[o]:L=d[o-4],l<4||o<=4?c[l]=L:c[l]=g[u[L>>>24]]^E[u[L>>>16&255]]^T[u[L>>>8&255]]^A[u[L&255]],c[l]=c[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,r){let s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],c=o[2],u=o[3],h=this.uint8ArrayToUint32Array_(r),f=h[0],g=h[1],E=h[2],T=h[3],A=new Int32Array(e),k=new Int32Array(A.length),L,N,D,$,O,G,Y,P,X,z,Ae,Ee,be,we,Se=this.networkToHostOrderSwap;for(;t<A.length;){for(X=Se(A[t]),z=Se(A[t+1]),Ae=Se(A[t+2]),Ee=Se(A[t+3]),O=X^n[0],G=Ee^n[1],Y=Ae^n[2],P=z^n[3],be=4,we=1;we<s;we++)L=l[O>>>24]^d[G>>16&255]^c[Y>>8&255]^u[P&255]^n[be],N=l[G>>>24]^d[Y>>16&255]^c[P>>8&255]^u[O&255]^n[be+1],D=l[Y>>>24]^d[P>>16&255]^c[O>>8&255]^u[G&255]^n[be+2],$=l[P>>>24]^d[O>>16&255]^c[G>>8&255]^u[Y&255]^n[be+3],O=L,G=N,Y=D,P=$,be=be+4;L=a[O>>>24]<<24^a[G>>16&255]<<16^a[Y>>8&255]<<8^a[P&255]^n[be],N=a[G>>>24]<<24^a[Y>>16&255]<<16^a[P>>8&255]<<8^a[O&255]^n[be+1],D=a[Y>>>24]<<24^a[P>>16&255]<<16^a[O>>8&255]<<8^a[G&255]^n[be+2],$=a[P>>>24]<<24^a[O>>16&255]<<16^a[G>>8&255]<<8^a[Y&255]^n[be+3],k[t]=Se(L^f),k[t+1]=Se($^g),k[t+2]=Se(D^E),k[t+3]=Se(N^T),f=X,g=z,E=Ae,T=Ee,t=t+4}return k.buffer}},q_=16,ra=class{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?W_(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,r);let a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){let{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Qr(a,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new mh),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=Xr(o,-16).buffer,d||null}webCryptoDecrypt(e,t,r){let s=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new fh(s,t)),this.fastAesKey.expandKey().then(n=>s?(this.logOnce("WebCrypto AES decrypt"),new hh(s,new Uint8Array(r)).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(M.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);let s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,r=e.length-e.length%q_;return r!==e.length&&(t=Xr(e,0,r),this.remainderData=Xr(e,r)),t}logOnce(e){!this.logEnabled||(M.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},Y_={toString:function(i){let e="",t=i.length;for(let r=0;r<t;r++)e+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return e}},W={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"},sa=class extends uh{constructor(e,t,r,s,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=W.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=M.log.bind(M,`${s}:`),this.warn=M.warn.bind(M,`${s}:`),this.hls=e,this.fragmentLoader=new dh(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new ra(e.config),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=W.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;let r=t.partList;if(r!=null&&r.length){let n=r[r.length-1];return je.isBuffered(this.media,n.start+n.duration/2)}let s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levels[this.levelLastLoaded])==null?void 0:e.details}}onMediaAttached(e,t){let r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);let s=this.config;this.levels&&s.autoStartLoad&&this.state===W.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){let e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){let{config:e,fragCurrent:t,media:r,mediaBuffer:s,state:n}=this,a=r?r.currentTime:0,o=je.bufferInfo(s||r,a,e.maxBufferHole);if(this.log(`media seeking to ${ce(a)?a.toFixed(3):a}, state: ${n}`),this.state===W.ENDED)this.resetLoadingState();else if(t){let l=e.maxFragLookUpTolerance,d=t.start-l,c=t.start+t.duration+l;if(!o.len||c<o.start||d>o.end){let u=a>c;(a<d||u)&&(u&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=W.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){let s=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,r,s).then(n=>{if(!n)return;let a=this.state;if(this.fragContextChanged(e)){(a===W.FRAG_LOADING||!this.fragCurrent&&a===W.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=W.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(b.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===W.STOPPED||this.state===W.ERROR||(this.warn(n),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:r}=this;if(r.getState(e)===Tt.APPENDING){let n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength);this.reduceMaxBufferLength(o)&&r.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===Tt.PARTIAL&&r.removeFragment(e))}flushMainBuffer(e,t,r=null){if(!(e-t))return;let s={startOffset:e,endOffset:t,type:r};this.hls.trigger(b.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(r=>{if(!r||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{let{hls:s}=this,{payload:n}=r,a=e.decryptdata;if(n&&n.byteLength>0&&a&&a.key&&a.iv&&a.method==="AES-128"){let o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw s.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{let d=self.performance.now();return s.trigger(b.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),r.payload=l,r})}return r}).then(r=>{let{fragCurrent:s,hls:n,levels:a}=this;if(!a)throw new Error("init load aborted, missing levels");let o=e.stats;this.state=W.IDLE,t.fragmentError=0,e.data=new Uint8Array(r.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),r.frag===s&&n.trigger(b.FRAG_BUFFERED,{stats:o,frag:s,part:null,id:e.type}),this.tick()}).catch(r=>{this.state===W.STOPPED||this.state===W.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var r,s,n,a;let o=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===ge.MAIN?"level":"track"} ${e.level} (frag:[${((r=e.startPTS)!=null?r:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?Y_.toString(je.getBuffered(o)):"(detached)"})`),this.state=W.IDLE,o&&(!this.loadedmetadata&&e.type==ge.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:r,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new ia(r.level,r.sn,r.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,s){var n;let a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=W.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(c=>{if(!this.fragContextChanged(c.frag))return this.hls.trigger(b.KEY_LOADED,c),this.state===W.KEY_LOADING&&(this.state=W.IDLE),c}),this.hls.trigger(b.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let c=a.partList;if(c&&s){r>e.end&&a.fragmentHint&&(e=a.fragmentHint);let u=this.getNextPart(c,e,r);if(u>-1){let h=c[u];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${u}-${c.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=W.FRAG_LOADING;let f;return o?f=o.then(g=>!g||this.fragContextChanged(g.frag)?null:this.doFragPartsLoad(e,h,t,s)).catch(g=>this.handleFragLoadError(g)):f=this.doFragPartsLoad(e,h,t,s).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(b.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(c,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),ce(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=W.FRAG_LOADING;let l=this.config.progressive,d;return l&&o?d=o.then(c=>!c||this.fragContextChanged(c==null?void 0:c.frag)?null:this.fragmentLoader.load(e,s)).catch(c=>this.handleFragLoadError(c)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([c])=>(!l&&c&&s&&s(c),c)).catch(c=>this.handleFragLoadError(c)),this.hls.trigger(b.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,s){return new Promise((n,a)=>{var o;let l=[],d=(o=r.details)==null?void 0:o.partList,c=u=>{this.fragmentLoader.loadPart(e,u,s).then(h=>{l[u.index]=h;let f=h.part;this.hls.trigger(b.FRAG_LOADED,h);let g=jg(r,e.sn,u.index+1)||P0(d,e.sn,u.index+1);if(g)c(g);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};c(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===B.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(b.ERROR,t)}else this.hls.trigger(b.ERROR,{type:pe.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==W.PARSING){!this.fragCurrent&&this.state!==W.STOPPED&&this.state!==W.ERROR&&(this.state=W.IDLE);return}let{frag:r,part:s,level:n}=t,a=self.performance.now();r.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(r,s,n,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:r}=this,{level:s,sn:n,part:a}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${s}. The current chunk will not be buffered.`),null;let o=t[s],l=a>-1?jg(o,n,a):null,d=l?l.fragment:C_(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,r,s,n){var a;if(!e||this.state!==W.PARSING)return;let{data1:o,data2:l}=e,d=o;if(o&&l&&(d=Qr(o,l)),!((a=d)!=null&&a.length))return;let c={type:e.type,frag:t,part:r,chunkMeta:s,parent:t.type,data:d};if(this.hls.trigger(b.BUFFER_APPENDING,c),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!je.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let r=t.currentTime,s=je.bufferInfo(t,r,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){let r=this.getLoadPosition();return ce(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){let{config:{maxBufferHole:s}}=this,n=je.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return je.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){let{config:t}=this,r;return e?r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):r=t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e){let t=this.config,r=e||t.maxBufferLength;return t.maxMaxBufferLength>=r?(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,t=ge.MAIN){let r=this.fragmentTracker.getAppendedFrag(e,ge.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){let r=t.fragments,s=r.length;if(!s)return null;let{config:n}=this,a=r[0].start,o;if(t.live){let l=n.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(o=this.getInitialLiveFragment(t,r),this.startPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=r[0]);if(!o){let l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){let r=this.fragmentTracker.getState(e);return(r===Tt.OK||r===Tt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,s,n){let a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&r.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,s);if(l!==null&&r.len+l.len>=n)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,r){let s=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){let d=e[o];if(a=a&&!d.independent,s>-1&&r<d.start)break;let c=d.loaded;c?s=-1:(n||d.independent||a)&&d.fragment===t&&(s=o),n=c}return s}loadedEndOfParts(e,t){let r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){let r=this.fragPrevious,s=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),s=O_(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){let n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];r.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=N_(t,r.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{let n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){let{config:s}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=r,{fragmentHint:l}=r,d=s.maxFragLookUpTolerance,c=r.partList,u=!!(s.lowLatencyMode&&c!=null&&c.length&&l);u&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){let f=e>t-d?0:d;h=ea(n,a,e,f)}else h=a[a.length-1];if(h){let f=h.sn-r.startSN,g=this.fragmentTracker.getState(h);if((g===Tt.OK||g===Tt.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!u||c[0].fragment.sn>h.sn)&&n&&h.level===n.level){let T=a[f+1];h.sn<o&&this.fragmentTracker.getState(T)!==Tt.OK?h=T:h=null}}return h}synchronizeToLiveEdge(e){let{config:t,media:r}=this;if(!r)return;let s=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&r.duration>s&&(n<s||!l)){let d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),r.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),r.currentTime=s))}}alignPlaylists(e,t){let{levels:r,levelLastLoaded:s,fragPrevious:n}=this,a=s!==null?r[s]:null,o=e.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;let l=e.fragments[0].start,d=!t,c=e.alignedSliding&&ce(l);if(d||!c&&!l){G_(n,a,e);let u=e.fragments[0].start;return this.log(`Live playlist sliding: ${u.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${n?n.sn:"na"} fragments: ${o}`),u}return l}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),r===-1||this.lastCurrentTime===-1){let s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&ce(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){let{media:e}=this,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==W.FRAG_LOADING_WAITING_RETRY)&&(this.state=W.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let u=this.getCurrentContext(t.chunkMeta);u&&(t.frag=u.frag)}let r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var s;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}let n=t.details===B.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(r,!0);let a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===Ct.RetryRequest&&d){var c;this.resetStartWhenNotLoaded((c=this.levelLastLoaded)!=null?c:r.level);let u=Xh(d,l);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${u}ms`),a.resolved=!0,this.retryDate=self.performance.now()+u,this.state=W.FRAG_LOADING_WAITING_RETRY}else d&&a?(this.resetFragmentErrors(e),l<d.maxNumRetry?n||(a.resolved=!0):M.warn(`${t.details} reached or exceeded max retry (${l})`)):(a==null?void 0:a.action)===Ct.SendAlternateToPenaltyBox?this.state=W.WAITING_LEVEL:this.state=W.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===W.PARSING||this.state===W.PARSED){let t=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,t),s=r&&r.len>.5;s&&this.reduceMaxBufferLength(r.len);let n=!s;return n&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===ge.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==W.STOPPED&&(this.state=W.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;let s=je.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,r),this.state===W.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=W.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;let t=this.levels?this.levels[e].details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){var t;this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((t=this.levelLastLoaded)!=null?t:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,s){var n;let a=r.details;if(!a){this.warn("level.details undefined");return}if(Object.keys(e.elementaryStreams).reduce((l,d)=>{let c=e.elementaryStreams[d];if(c){let u=c.endPTS-c.startPTS;if(u<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${u})`),l||!1;let h=s?0:M0(a,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS);return this.hls.trigger(b.LEVEL_PTS_UPDATED,{details:a,level:r,drift:h,type:d,frag:e,start:c.startPTS,end:c.endPTS}),!0}return l},!1))r.fragmentError=0;else if(((n=this.transmuxer)==null?void 0:n.error)===null){let l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=W.PARSED,this.hls.trigger(b.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){if(e.event==="demuxerWorker"){var t,r,s;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((t=(r=this.levelLastLoaded)!=null?r:(s=this.fragCurrent)==null?void 0:s.level)!=null?t:0),this.resetLoadingState()}}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}};function B0(){return self.SourceBuffer||self.WebKitSourceBuffer}function j_(){let i=Jl();if(!i)return!1;let e=B0(),t=i&&typeof i.isTypeSupported=="function"&&i.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),r=!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function";return!!t&&!!r}function z_(){var i;let e=B0();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}function X_(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Q_(){let i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function Z_(i){let e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function Ki(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var Bl=class{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Qr(this.cachedData,e),this.cachedData=null);let r=Ml(e,0),s=r?r.length:0,n,a=this._audioTrack,o=this._id3Track,l=r?qT(r):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&ce(l))&&(this.basePTS=J_(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ai.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){let c=this.appendFrame(a,e,s);c?(this.frameIndex++,this.lastPTS=c.sample.pts,s+=c.length,n=s):s=d}else WT(e,s)?(r=Ml(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ai.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,n=s):s++;if(s===d&&n!==d){let c=Xr(e,n);this.cachedData?this.cachedData=Qr(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:Ki(),id3Track:o,textTrack:Ki()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Ki(),id3Track:this._id3Track,textTrack:Ki()}}destroy(){}},J_=(i,e,t)=>{if(ce(i))return i*90;let r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function eA(i,e,t,r){let s,n,a,o,l=navigator.userAgent.toLowerCase(),d=r,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;let u=(e[t+2]&60)>>>2;if(u>c.length-1){i.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${u}`});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,M.log(`manifest codec:${r}, ADTS type:${s}, samplingIndex:${u}`),/firefox/i.test(l)?u>=6?(s=5,o=new Array(4),n=u-3):(s=2,o=new Array(2),n=u):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=u):(s=5,o=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&u>=6?n=u-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(u>=6&&a===1||/vivaldi/i.test(l))||!r&&a===1)&&(s=2,o=new Array(2)),n=u)),o[0]=s<<3,o[0]|=(u&14)>>1,o[1]|=(u&1)<<7,o[1]|=a<<3,s===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=2<<2,o[3]=0),{config:o,samplerate:c[u],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d}}function $0(i,e){return i[e]===255&&(i[e+1]&246)===240}function H0(i,e){return i[e+1]&1?7:9}function Zh(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function tA(i,e){return e+5<i.length}function $l(i,e){return e+1<i.length&&$0(i,e)}function iA(i,e){return tA(i,e)&&$0(i,e)&&Zh(i,e)<=i.length-e}function rA(i,e){if($l(i,e)){let t=H0(i,e);if(e+t>=i.length)return!1;let r=Zh(i,e);if(r<=t)return!1;let s=e+r;return s===i.length||$l(i,s)}return!1}function G0(i,e,t,r,s){if(!i.samplerate){let n=eA(e,t,r,s);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,M.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function V0(i){return 1024*9e4/i}function sA(i,e){let t=H0(i,e);if(e+t<=i.length){let r=Zh(i,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function K0(i,e,t,r,s){let n=V0(i.samplerate),a=r+s*n,o=sA(e,t),l;if(o){let{frameLength:u,headerLength:h}=o,f=h+u,g=Math.max(0,t+f-e.length);g?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);let E={unit:l,pts:a};return g||i.samples.push(E),{sample:E,length:f,missing:g}}let d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}var ph=class extends Bl{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let r=(Ml(e,0)||[]).length;for(let s=e.length;r<s;r++)if(rA(e,r))return M.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return iA(e,t)}appendFrame(e,t,r){G0(e,this.observer,t,r,e.manifestCodec);let s=K0(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},nA=/\/emsg[-/]ID3/i,gh=class{constructor(e,t){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=t}resetTimeStamp(){}resetInitSegment(e,t,r,s){let n=this.videoTrack=Ki("video",1),a=this.audioTrack=Ki("audio",1),o=this.txtTrack=Ki("text",1);if(this.id3Track=Ki("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=I0(e);if(l.video){let{id:d,timescale:c,codec:u}=l.video;n.id=d,n.timescale=o.timescale=c,n.codec=u}if(l.audio){let{id:d,timescale:c,codec:u}=l.audio;a.id=d,a.timescale=c,a.codec=u}o.id=A0.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return e=e.length>16384?e.subarray(0,16384):e,Pe(e,["moof"]).length>0}demux(e,t){this.timeOffset=t;let r=e,s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Qr(this.remainderData,e));let o=o_(r);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=r;let a=this.extractID3Track(s,t);return n.samples=Og(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(t,this.timeOffset);return r.samples=Og(e,t),{videoTrack:t,audioTrack:Ki(),id3Track:s,textTrack:Ki()}}extractID3Track(e,t){let r=this.id3Track;if(e.samples.length){let s=Pe(e.samples,["emsg"]);s&&s.forEach(n=>{let a=c_(n);if(nA.test(a.schemeIdUri)){let o=ce(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale,l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);let d=a.payload;r.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:Ai.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},xl=null,aA=[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],oA=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],lA=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],dA=[0,1,1,4];function W0(i,e,t,r,s){if(t+24>e.length)return;let n=q0(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=r+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function q0(i,e){let t=i[e+1]>>3&3,r=i[e+1]>>1&3,s=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){let a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-r:r===3?3:4,d=aA[l*14+s-1]*1e3,u=oA[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=lA[t][r],g=dA[r],E=f*8*g,T=Math.floor(f*d/u+a)*g;if(xl===null){let L=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);xl=L?parseInt(L[1]):0}return!!xl&&xl<=87&&r===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:u,channelCount:h,frameLength:T,samplesPerFrame:E}}}function Jh(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function Y0(i,e){return e+1<i.length&&Jh(i,e)}function cA(i,e){return Jh(i,e)&&4<=i.length-e}function uA(i,e){if(e+1<i.length&&Jh(i,e)){let r=q0(i,e),s=4;r!=null&&r.frameLength&&(s=r.frameLength);let n=e+s;return n===i.length||Y0(i,n)}return!1}var Hl=class{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){let e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(r,r+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&M.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8,s;for(let n=0;n<e;n++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r}readSPS(){let e=0,t=0,r=0,s=0,n,a,o,l=this.readUByte.bind(this),d=this.readBits.bind(this),c=this.readUEG.bind(this),u=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),g=this.skipUEG.bind(this),E=this.skipScalingList.bind(this);l();let T=l();if(d(5),h(3),l(),g(),T===100||T===110||T===122||T===244||T===44||T===83||T===86||T===118||T===128){let $=c();if($===3&&h(1),g(),g(),h(1),u())for(a=$!==3?8:12,o=0;o<a;o++)u()&&(o<6?E(16):E(64))}g();let A=c();if(A===0)c();else if(A===1)for(h(1),f(),f(),n=c(),o=0;o<n;o++)f();g(),h(1);let k=c(),L=c(),N=d(1);N===0&&h(1),h(1),u()&&(e=c(),t=c(),r=c(),s=c());let D=[1,1];if(u()&&u())switch(l()){case 1:D=[1,1];break;case 2:D=[12,11];break;case 3:D=[10,11];break;case 4:D=[16,11];break;case 5:D=[40,33];break;case 6:D=[24,11];break;case 7:D=[20,11];break;case 8:D=[32,11];break;case 9:D=[80,33];break;case 10:D=[18,11];break;case 11:D=[15,11];break;case 12:D=[64,33];break;case 13:D=[160,99];break;case 14:D=[4,3];break;case 15:D=[3,2];break;case 16:D=[2,1];break;case 255:{D=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((k+1)*16-e*2-t*2),height:(2-N)*(L+1)*16-(N?2:4)*(r+s),pixelRatio:D}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},vh=class{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new ra(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){let s=e[t].unit;if(s.length<=16)return;let n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)r.set(e.subarray(n,n+16),s);return r}getAvcDecryptedUnit(e,t){let r=new Uint8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(r.subarray(s,s+16),n);return e}decryptAvcSample(e,t,r,s,n){let a=R0(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,s)})}decryptAvcSamples(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}let n=e[t].units;for(;!(r>=n.length);r++){let a=n[r];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,r,s,a),!this.decrypter.isSync()))return}}}},Dt=188,Wi=class{constructor(e,t,r){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=e,this.config=t,this.typeSupported=r}static probe(e){let t=Wi.syncOffset(e);return t>0&&M.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){let t=e.length,r=Math.min(Dt*5,e.length-Dt)+1,s=0;for(;s<r;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=Dt)if(e[l]===71){if(o++,a===-1&&(a=l,a!==0&&(r=Math.min(a+Dt*99,e.length-Dt)+1)),n||(n=Eh(e,l)===0),n&&o>1&&(a===0&&o>2||l+Dt>r))return a}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:A0[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Wi.createTrack("video"),this._audioTrack=Wi.createTrack("audio",s),this._id3Track=Wi.createTrack("id3"),this._txtTrack=Wi.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_avcTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,t,r=!1,s=!1){r||(this.sampleAes=null);let n,a=this._avcTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack,c=a.pid,u=a.pesData,h=o.pid,f=l.pid,g=o.pesData,E=l.pesData,T=null,A=this.pmtParsed,k=this._pmtId,L=e.length;if(this.remainderData&&(e=Qr(this.remainderData,e),L=e.length,this.remainderData=null),L<Dt&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let N=Math.max(0,Wi.syncOffset(e));L-=(L-N)%Dt,L<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));let D=0;for(let O=N;O<L;O+=Dt)if(e[O]===71){let G=!!(e[O+1]&64),Y=Eh(e,O),P=(e[O+3]&48)>>4,X;if(P>1){if(X=O+5+e[O+4],X===O+Dt)continue}else X=O+4;switch(Y){case c:G&&(u&&(n=Qs(u))&&this.parseAVCPES(a,d,n,!1),u={data:[],size:0}),u&&(u.data.push(e.subarray(X,O+Dt)),u.size+=O+Dt-X);break;case h:if(G){if(g&&(n=Qs(g)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break}g={data:[],size:0}}g&&(g.data.push(e.subarray(X,O+Dt)),g.size+=O+Dt-X);break;case f:G&&(E&&(n=Qs(E))&&this.parseID3PES(l,n),E={data:[],size:0}),E&&(E.data.push(e.subarray(X,O+Dt)),E.size+=O+Dt-X);break;case 0:G&&(X+=e[X]+1),k=this._pmtId=hA(e,X);break;case k:{G&&(X+=e[X]+1);let z=fA(e,X,this.typeSupported,r);c=z.avc,c>0&&(a.pid=c),h=z.audio,h>0&&(o.pid=h,o.segmentCodec=z.segmentCodec),f=z.id3,f>0&&(l.pid=f),T!==null&&!A&&(M.warn(`MPEG-TS PMT found at ${O} after unknown PID '${T}'. Backtracking to sync byte @${N} to parse all TS packets.`),T=null,O=N-188),A=this.pmtParsed=!0;break}case 17:case 8191:break;default:T=Y;break}}else D++;if(D>0){let O=new Error(`Found ${D} TS packet/s that do not start with 0x47`);this.observer.emit(b.ERROR,b.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:O,reason:O.message})}a.pesData=u,o.pesData=g,l.pesData=E;let $={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples($),$}flush(){let{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){let{audioTrack:t,videoTrack:r,id3Track:s,textTrack:n}=e,a=r.pesData,o=t.pesData,l=s.pesData,d;if(a&&(d=Qs(a))?(this.parseAVCPES(r,n,d,!0),r.pesData=null):r.pesData=a,o&&(d=Qs(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break}t.pesData=null}else o!=null&&o.size&&M.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=Qs(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){let s=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new vh(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(r=>{let{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAVCPES(e,t,r,s){let n=this.parseAVCNALu(e,r.data),a=this.avcSample,o,l=!1;r.data=null,a&&n.length&&!e.audFound&&(Yn(a,e),a=this.avcSample=Il(!1,r.pts,r.dts,"")),n.forEach(d=>{var c;switch(d.type){case 1:{let h=!1;o=!0;let f=d.data;if(l&&f.length>4){let g=new Hl(f).readSliceType();(g===2||g===4||g===7||g===9)&&(h=!0)}if(h){var u;(u=a)!=null&&u.frame&&!a.key&&(Yn(a,e),a=this.avcSample=null)}a||(a=this.avcSample=Il(!0,r.pts,r.dts,"")),a.frame=!0,a.key=h;break}case 5:o=!0,(c=a)!=null&&c.frame&&!a.key&&(Yn(a,e),a=this.avcSample=null),a||(a=this.avcSample=Il(!0,r.pts,r.dts,"")),a.key=!0,a.frame=!0;break;case 6:{o=!0,k0(d.data,1,r.pts,t.samples);break}case 7:if(o=!0,l=!0,!e.sps){let h=d.data,g=new Hl(h).readSPS();e.width=g.width,e.height=g.height,e.pixelRatio=g.pixelRatio,e.sps=[h],e.duration=this._duration;let E=h.subarray(1,4),T="avc1.";for(let A=0;A<3;A++){let k=E[A].toString(16);k.length<2&&(k="0"+k),T+=k}e.codec=T}break;case 8:o=!0,e.pps||(e.pps=[d.data]);break;case 9:o=!1,e.audFound=!0,a&&Yn(a,e),a=this.avcSample=Il(!1,r.pts,r.dts,"");break;case 12:o=!0;break;default:o=!1,a&&(a.debug+="unknown NAL "+d.type+" ");break}a&&o&&a.units.push(d)}),s&&a&&(Yn(a,e),this.avcSample=null)}getLastNalUnit(e){var t;let r=this.avcSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){let n=r.units;s=n[n.length-1]}return s}parseAVCNALu(e,t){let r=t.byteLength,s=e.naluState||0,n=s,a=[],o=0,l,d,c,u=-1,h=0;for(s===-1&&(u=0,h=t[0]&31,s=0,o=1);o<r;){if(l=t[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(u>=0){let f={data:t.subarray(u,o-s-1),type:h};a.push(f)}else{let f=this.getLastNalUnit(e.samples);if(f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d=o-s-1,d>0)){let g=new Uint8Array(f.data.byteLength+d);g.set(f.data,0),g.set(t.subarray(0,d),f.data.byteLength),f.data=g,f.state=0}}o<r?(c=t[o]&31,u=o,h=c,s=0):s=-1}else s=0}if(u>=0&&s>=0){let f={data:t.subarray(u,r),type:h,state:s};a.push(f)}if(a.length===0){let f=this.getLastNalUnit(e.samples);if(f){let g=new Uint8Array(f.data.byteLength+t.byteLength);g.set(f.data,0),g.set(t,f.data.byteLength),f.data=g}}return e.naluState=s,a}parseAACPES(e,t){let r=0,s=this.aacOverFlow,n=t.data;if(s){this.aacOverFlow=null;let u=s.missing,h=s.sample.unit.byteLength;if(u===-1){let f=new Uint8Array(h+n.byteLength);f.set(s.sample.unit,0),f.set(n,h),n=f}else{let f=h-u;s.sample.unit.set(n.subarray(0,u),f),e.samples.push(s.sample),r=s.missing}}let a,o;for(a=r,o=n.length;a<o-1&&!$l(n,a);a++);if(a!==r){let u,h=a<o-1;h?u=`AAC PES did not start with ADTS header,offset:${a}`:u="No ADTS header found in AAC PES";let f=new Error(u);if(M.warn(`parsing error: ${u}`),this.observer.emit(b.ERROR,b.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,levelRetry:h,error:f,reason:u}),!h)return}G0(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let u=V0(e.samplerate);l=s.sample.pts+u}else{M.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,c;for(;a<o;)if(c=K0(e,n,a,l,d),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(d++;a<o-1&&!$l(n,a);a++);}parseMPEGPES(e,t){let r=t.data,s=r.length,n=0,a=0,o=t.pts;if(o===void 0){M.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(Y0(r,a)){let l=W0(e,r,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseID3PES(e,t){if(t.pts===void 0){M.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let r=mt({},t,{type:this._avcTrack?Ai.emsg:Ai.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}};function Il(i,e,t,r){return{key:i,frame:!1,pts:e,dts:t,units:[],debug:r,length:0}}function Eh(i,e){return((i[e+1]&31)<<8)+i[e+2]}function hA(i,e){return(i[e+10]&31)<<8|i[e+11]}function fA(i,e,t,r){let s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=(i[e+1]&15)<<8|i[e+2],a=e+3+n-4,o=(i[e+10]&15)<<8|i[e+11];for(e+=12+o;e<a;){let l=Eh(i,e);switch(i[e]){case 207:if(!r){M.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:s.audio===-1&&(s.audio=l);break;case 21:s.id3===-1&&(s.id3=l);break;case 219:if(!r){M.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:s.avc===-1&&(s.avc=l);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?M.log("MPEG audio found, not supported in this browser"):s.audio===-1&&(s.audio=l,s.segmentCodec="mp3");break;case 36:M.warn("Unsupported HEVC stream type found");break}e+=((i[e+3]&15)<<8|i[e+4])+5}return s}function Qs(i){let e=0,t,r,s,n,a,o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;){let d=new Uint8Array(o[0].length+o[1].length);d.set(o[0]),d.set(o[1],o[0].length),o[0]=d,o.splice(1,1)}if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(r=(t[4]<<8)+t[5],r&&r>i.size-6)return null;let d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(M.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=t[8];let c=s+9;if(i.size<=c)return null;i.size-=c;let u=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let g=t.byteLength;if(c)if(c>g){c-=g;continue}else t=t.subarray(c),g-=c,c=0;u.set(t,e),e+=g}return r&&(r-=s+3),{data:u,pts:n,dts:a,len:r}}return null}function Yn(i,e){if(i.units.length&&i.frame){if(i.pts===void 0){let t=e.samples,r=t.length;if(r){let s=t[r-1];i.pts=s.pts,i.dts=s.dts}else{e.dropped++;return}}e.samples.push(i)}i.debug.length&&M.log(i.pts+"/"+i.dts+":"+i.debug)}var bh=class extends Bl{resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let r=(Ml(e,0)||[]).length;for(let s=e.length;r<s;r++)if(uA(e,r))return M.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return cA(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return W0(e,t,r,this.basePTS,this.frameIndex)}},Gl=class{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===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(t===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(t===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(t===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(t===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}}},Tr=Math.pow(2,32)-1,F=class{static init(){F.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:[]};let e;for(e in F.types)F.types.hasOwnProperty(e)&&(F.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=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]),r=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]);F.HDLR_TYPES={video:t,audio:r};let s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);F.STTS=F.STSC=F.STCO=n,F.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),F.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),F.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),F.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);F.FTYP=F.box(F.types.ftyp,a,l,a,o),F.DINF=F.box(F.types.dinf,F.box(F.types.dref,s))}static box(e,...t){let r=8,s=t.length,n=s;for(;s--;)r+=t[s].byteLength;let a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=r&255,a.set(e,4),s=0,r=8;s<n;s++)a.set(t[s],r),r+=t[s].byteLength;return a}static hdlr(e){return F.box(F.types.hdlr,F.HDLR_TYPES[e])}static mdat(e){return F.box(F.types.mdat,e)}static mdhd(e,t){t*=e;let r=Math.floor(t/(Tr+1)),s=Math.floor(t%(Tr+1));return F.box(F.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return F.box(F.types.mdia,F.mdhd(e.timescale,e.duration),F.hdlr(e.type),F.minf(e))}static mfhd(e){return F.box(F.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?F.box(F.types.minf,F.box(F.types.smhd,F.SMHD),F.DINF,F.stbl(e)):F.box(F.types.minf,F.box(F.types.vmhd,F.VMHD),F.DINF,F.stbl(e))}static moof(e,t,r){return F.box(F.types.moof,F.mfhd(e),F.traf(r,t))}static moov(e){let t=e.length,r=[];for(;t--;)r[t]=F.trak(e[t]);return F.box.apply(null,[F.types.moov,F.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(F.mvex(e)))}static mvex(e){let t=e.length,r=[];for(;t--;)r[t]=F.trex(e[t]);return F.box.apply(null,[F.types.mvex,...r])}static mvhd(e,t){t*=e;let r=Math.floor(t/(Tr+1)),s=Math.floor(t%(Tr+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&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 F.box(F.types.mvhd,n)}static sdtp(e){let t=e.samples||[],r=new Uint8Array(4+t.length),s,n;for(s=0;s<t.length;s++)n=t[s].flags,r[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return F.box(F.types.sdtp,r)}static stbl(e){return F.box(F.types.stbl,F.stsd(e),F.box(F.types.stts,F.STTS),F.box(F.types.stsc,F.STSC),F.box(F.types.stsz,F.STSZ),F.box(F.types.stco,F.STCO))}static avc1(e){let t=[],r=[],s,n,a;for(s=0;s<e.sps.length;s++)n=e.sps[s],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],a=n.byteLength,r.push(a>>>8&255),r.push(a&255),r=r.concat(Array.prototype.slice.call(n));let o=F.box(F.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(r))),l=e.width,d=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return F.box(F.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,l>>8&255,l&255,d>>8&255,d&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]),o,F.box(F.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),F.box(F.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,c&255,u>>24,u>>16&255,u>>8&255,u&255])))}static esds(e){let t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static mp4a(e){let t=e.samplerate;return F.box(F.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]),F.box(F.types.esds,F.esds(e)))}static mp3(e){let t=e.samplerate;return F.box(F.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?F.box(F.types.stsd,F.STSD,F.mp3(e)):F.box(F.types.stsd,F.STSD,F.mp4a(e)):F.box(F.types.stsd,F.STSD,F.avc1(e))}static tkhd(e){let t=e.id,r=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(r/(Tr+1)),o=Math.floor(r%(Tr+1));return F.box(F.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&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,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){let r=F.sdtp(e),s=e.id,n=Math.floor(t/(Tr+1)),a=Math.floor(t%(Tr+1));return F.box(F.types.traf,F.box(F.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),F.box(F.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),F.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,F.box(F.types.trak,F.tkhd(e),F.mdia(e))}static trex(e){let t=e.id;return F.box(F.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let r=e.samples||[],s=r.length,n=12+16*s,a=new Uint8Array(n),o,l,d,c,u,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=r[o],d=l.duration,c=l.size,u=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,u.degradPrio&240<<8,u.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return F.box(F.types.trun,a)}static initSegment(e){F.types||F.init();let t=F.moov(e),r=new Uint8Array(F.FTYP.byteLength+t.byteLength);return r.set(F.FTYP),r.set(t,F.FTYP.byteLength),r}};F.types=void 0;F.HDLR_TYPES=void 0;F.STTS=void 0;F.STSC=void 0;F.STCO=void 0;F.STSZ=void 0;F.VMHD=void 0;F.SMHD=void 0;F.STSD=void 0;F.FTYP=void 0;F.DINF=void 0;var j0=9e4;function ef(i,e,t=1,r=!1){let s=i*e*t;return r?Math.round(s):s}function mA(i,e,t=1,r=!1){return ef(i,e,1/t,r)}function jn(i,e=!1){return ef(i,1e3,1/j0,e)}function pA(i,e=1){return ef(i,j0,1/e)}var gA=10*1e3,i0=1024,vA=1152,Ll=null,Nu=null,Zn=class{constructor(e,t,r,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,Ll===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ll=a?parseInt(a[1]):0}if(Nu===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);Nu=n?parseInt(n[1]):0}}destroy(){}resetTimeStamp(e){M.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){M.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){M.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let t=!1,r=e.reduce((s,n)=>{let a=n.pts-s;return a<-4294967296?(t=!0,ci(s,n.pts)):a>0?s:n.pts},e[0].pts);return t&&M.debug("PTS rollover detected"),r}remux(e,t,r,s,n,a,o,l){let d,c,u,h,f,g,E=n,T=n,A=e.pid>-1,k=t.pid>-1,L=t.samples.length,N=e.samples.length>0,D=o&&L>0||L>1;if((!A||N)&&(!k||D)||this.ISGenerated||o){this.ISGenerated||(u=this.generateIS(e,t,n,a));let O=this.isVideoContiguous,G=-1,Y;if(D&&(G=EA(t.samples),!O&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,G>0){M.warn(`[mp4-remuxer]: Dropped ${G} out of ${L} video samples due to a missing keyframe`);let P=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(G),t.dropped+=G,T+=(t.samples[0].pts-P)/t.inputTimeScale,Y=T}else G===-1&&(M.warn(`[mp4-remuxer]: No keyframe found out of ${L} video samples`),g=!1);if(this.ISGenerated){if(N&&D){let P=this.getVideoStartPts(t.samples),z=(ci(e.samples[0].pts,P)-P)/t.inputTimeScale;E+=Math.max(0,z),T+=Math.max(0,-z)}if(N){if(e.samplerate||(M.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(e,t,n,a)),c=this.remuxAudio(e,E,this.isAudioContiguous,a,k||D||l===ge.AUDIO?T:void 0),D){let P=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(M.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,T,O,P)}}else D&&(d=this.remuxVideo(t,T,O,0));d&&(d.firstKeyFrame=G,d.independent=G!==-1,d.firstKeyFramePTS=Y)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=z0(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=X0(s,n,this._initPTS))),{audio:c,video:d,initSegment:u,independent:g,text:h,id3:f}}generateIS(e,t,r,s){let n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS,c=!d||s,u="audio/mp4",h,f,g;if(c&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(u="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break}l.audio={id:"audio",container:u,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):F.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(g=e.inputTimeScale,!d||g!==d.timescale?h=f=n[0].pts-Math.round(g*r):c=!1)}if(t.sps&&t.pps&&a.length&&(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:F.initSegment([t]),metadata:{width:t.width,height:t.height}},c))if(g=t.inputTimeScale,!d||g!==d.timescale){let E=this.getVideoStartPts(a),T=Math.round(g*r);f=Math.min(f,ci(a[0].dts,E)-T),h=Math.min(h,E-T)}else c=!1;if(Object.keys(l).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:h,timescale:g},this._initDTS={baseTime:f,timescale:g}):h=g=void 0,{tracks:l,initPTS:h,timescale:g}}remuxVideo(e,t,r,s){let n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS,c=this.nextAvcDts,u=8,h=this.videoSampleDuration,f,g,E=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,A=!1;if(!r||c===null){let Z=t*n,ne=a[0].pts-ci(a[0].dts,a[0].pts);c=Z-ne}let k=d.baseTime*n/d.timescale;for(let Z=0;Z<l;Z++){let ne=a[Z];ne.pts=ci(ne.pts-k,c),ne.dts=ci(ne.dts-k,c),ne.dts<a[Z>0?Z-1:Z].dts&&(A=!0)}A&&a.sort(function(Z,ne){let se=Z.dts-ne.dts,xe=Z.pts-ne.pts;return se||xe}),f=a[0].dts,g=a[a.length-1].dts;let L=g-f,N=L?Math.round(L/(l-1)):h||e.inputTimeScale/30;if(r){let Z=f-c,ne=Z>N,se=Z<-1;if((ne||se)&&(ne?M.warn(`AVC: ${jn(Z,!0)} ms (${Z}dts) hole between fragments detected, filling it`):M.warn(`AVC: ${jn(-Z,!0)} ms (${Z}dts) overlapping between fragments detected`),!se||c>=a[0].pts)){f=c;let xe=a[0].pts-Z;a[0].dts=f,a[0].pts=xe,M.log(`Video: First PTS/DTS adjusted: ${jn(xe,!0)}/${jn(f,!0)}, delta: ${jn(Z,!0)} ms`)}}f=Math.max(0,f);let D=0,$=0;for(let Z=0;Z<l;Z++){let ne=a[Z],se=ne.units,xe=se.length,Ie=0;for(let Ve=0;Ve<xe;Ve++)Ie+=se[Ve].data.length;$+=Ie,D+=xe,ne.length=Ie,ne.dts=Math.max(ne.dts,f),E=Math.min(ne.pts,E),T=Math.max(ne.pts,T)}g=a[l-1].dts;let O=$+4*D+8,G;try{G=new Uint8Array(O)}catch(Z){this.observer.emit(b.ERROR,b.ERROR,{type:pe.MUX_ERROR,details:B.REMUX_ALLOC_ERROR,fatal:!1,error:Z,bytes:O,reason:`fail allocating video mdat ${O}`});return}let Y=new DataView(G.buffer);Y.setUint32(0,O),G.set(F.types.mdat,4);let P=!1,X=Number.POSITIVE_INFINITY,z=Number.POSITIVE_INFINITY,Ae=Number.NEGATIVE_INFINITY,Ee=Number.NEGATIVE_INFINITY;for(let Z=0;Z<l;Z++){let ne=a[Z],se=ne.units,xe=0;for(let ht=0,V=se.length;ht<V;ht++){let ee=se[ht],ke=ee.data,Je=ee.data.byteLength;Y.setUint32(u,Je),u+=4,G.set(ke,u),u+=Je,xe+=4+Je}let Ie;if(Z<l-1)h=a[Z+1].dts-ne.dts,Ie=a[Z+1].pts-ne.pts;else{let ht=this.config,V=Z>0?ne.dts-a[Z-1].dts:N;if(Ie=Z>0?ne.pts-a[Z-1].pts:N,ht.stretchShortVideoTrack&&this.nextAudioPts!==null){let ee=Math.floor(ht.maxBufferHole*n),ke=(s?E+s*n:this.nextAudioPts)-ne.pts;ke>ee?(h=ke-V,h<0?h=V:P=!0,M.log(`[mp4-remuxer]: It is approximately ${ke/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=V}else h=V}let Ve=Math.round(ne.pts-ne.dts);X=Math.min(X,h),Ae=Math.max(Ae,h),z=Math.min(z,Ie),Ee=Math.max(Ee,Ie),o.push(new Vl(ne.key,h,xe,Ve))}if(o.length){if(Ll){if(Ll<70){let Z=o[0].flags;Z.dependsOn=2,Z.isNonSync=0}}else if(Nu&&Ee-z<Ae-X&&N/Ae<.025&&o[0].cts===0){M.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let Z=f;for(let ne=0,se=o.length;ne<se;ne++){let xe=Z+o[ne].duration,Ie=Z+o[ne].cts;if(ne<se-1){let Ve=xe+o[ne+1].cts;o[ne].duration=Ve-Ie}else o[ne].duration=ne?o[ne-1].duration:N;o[ne].cts=0,Z=xe}}}h=P||!h?N:h,this.nextAvcDts=c=g+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let be=F.moof(e.sequenceNumber++,f,mt({},e,{samples:o})),we="video",Se={data1:be,data2:G,startPTS:E/n,endPTS:(T+h)/n,startDTS:f/n,endDTS:c/n,type:we,hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Se}remuxAudio(e,t,r,s,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=e.segmentCodec==="aac"?i0:vA,c=d*l,u=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],g=n!==void 0,E=e.samples,T=h?0:8,A=this.nextAudioPts||-1,k=t*a,L=u.baseTime*a/u.timescale;if(this.isAudioContiguous=r=r||E.length&&A>0&&(s&&Math.abs(k-A)<9e3||Math.abs(ci(E[0].pts-L,k)-A)<20*c),E.forEach(function(we){we.pts=ci(we.pts-L,k)}),!r||A<0){if(E=E.filter(we=>we.pts>=0),!E.length)return;n===0?A=0:s&&!g?A=Math.max(0,k):A=E[0].pts}if(e.segmentCodec==="aac"){let we=this.config.maxAudioFramesDrift;for(let Se=0,Z=A;Se<E.length;Se++){let ne=E[Se],se=ne.pts,xe=se-Z,Ie=Math.abs(1e3*xe/a);if(xe<=-we*c&&g)Se===0&&(M.warn(`Audio frame @ ${(se/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*xe/a)} ms.`),this.nextAudioPts=A=Z=se);else if(xe>=we*c&&Ie<gA&&g){let Ve=Math.round(xe/c);Z=se-Ve*c,Z<0&&(Ve--,Z+=c),Se===0&&(this.nextAudioPts=A=Z),M.warn(`[mp4-remuxer]: Injecting ${Ve} audio frame @ ${(Z/a).toFixed(3)}s due to ${Math.round(1e3*xe/a)} ms gap.`);for(let ht=0;ht<Ve;ht++){let V=Math.max(Z,0),ee=Gl.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);ee||(M.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),ee=ne.unit.subarray()),E.splice(Se,0,{unit:ee,pts:V}),Z+=c,Se++}}ne.pts=Z,Z+=c}}let N=null,D=null,$,O=0,G=E.length;for(;G--;)O+=E[G].unit.byteLength;for(let we=0,Se=E.length;we<Se;we++){let Z=E[we],ne=Z.unit,se=Z.pts;if(D!==null){let Ie=f[we-1];Ie.duration=Math.round((se-D)/l)}else if(r&&e.segmentCodec==="aac"&&(se=A),N=se,O>0){O+=T;try{$=new Uint8Array(O)}catch(Ie){this.observer.emit(b.ERROR,b.ERROR,{type:pe.MUX_ERROR,details:B.REMUX_ALLOC_ERROR,fatal:!1,error:Ie,bytes:O,reason:`fail allocating audio mdat ${O}`});return}h||(new DataView($.buffer).setUint32(0,O),$.set(F.types.mdat,4))}else return;$.set(ne,T);let xe=ne.byteLength;T+=xe,f.push(new Vl(!0,d,xe,0)),D=se}let Y=f.length;if(!Y)return;let P=f[f.length-1];this.nextAudioPts=A=D+l*P.duration;let X=h?new Uint8Array(0):F.moof(e.sequenceNumber++,N/l,mt({},e,{samples:f}));e.samples=[];let z=N/a,Ae=A/a,be={data1:X,data2:$,startPTS:z,endPTS:Ae,startDTS:z,endDTS:Ae,type:"audio",hasAudio:!0,hasVideo:!1,nb:Y};return this.isAudioContiguous=!0,be}remuxEmptyAudio(e,t,r,s){let n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,c=d.baseTime*9e4/d.timescale,u=(l!==null?l:s.startDTS*n)+c,h=s.endDTS*n+c,f=o*i0,g=Math.ceil((h-u)/f),E=Gl.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(M.warn("[mp4-remuxer]: remux empty Audio"),!E){M.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}let T=[];for(let A=0;A<g;A++){let k=u+A*f;T.push({unit:E,pts:k,dts:k})}return e.samples=T,this.remuxAudio(e,t,r,!1)}};function ci(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function EA(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function z0(i,e,t,r){let s=i.samples.length;if(!s)return;let n=i.inputTimeScale;for(let o=0;o<s;o++){let l=i.samples[o];l.pts=ci(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=ci(l.dts-r.baseTime*n/r.timescale,e*n)/n}let a=i.samples;return i.samples=[],{samples:a}}function X0(i,e,t){let r=i.samples.length;if(!r)return;let s=i.inputTimeScale;for(let a=0;a<r;a++){let o=i.samples[a];o.pts=ci(o.pts-t.baseTime*s/t.timescale,e*s)/s}i.samples.sort((a,o)=>a.pts-o.pts);let n=i.samples;return i.samples=[],{samples:n}}var Vl=class{constructor(e,t,r,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=s,this.flags=new yh(e)}},yh=class{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}},Th=class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(i_(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let s=this.initData=I0(e);t||(t=r0(s.audio,qe.AUDIO)),r||(r=r0(s.video,qe.VIDEO));let n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:M.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,r,s,n,a){var o,l;let{initPTS:d,lastEndTime:c}=this,u={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};ce(c)||(c=this.lastEndTime=n||0);let h=t.samples;if(!(h!=null&&h.length))return u;let f={initPTS:void 0,timescale:1},g=this.initData;if((o=g)!=null&&o.length||(this.generateInitSegment(h),g=this.initData),!((l=g)!=null&&l.length))return M.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);let E=s_(h,g),T=r_(g,h),A=T===null?n:T;(bA(d,A,n,E)||f.timescale!==d.timescale&&a)&&(f.initPTS=A-n,d&&d.timescale===1&&M.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});let k=e?A-d.baseTime/d.timescale:c,L=k+E;a_(g,h,d.baseTime/d.timescale),E>0?this.lastEndTime=L:(M.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let N=!!g.audio,D=!!g.video,$="";N&&($+="audio"),D&&($+="video");let O={data1:h,startPTS:k,startDTS:k,endPTS:L,endDTS:L,type:$,hasAudio:N,hasVideo:D,nb:1,dropped:0};return u.audio=O.type==="audio"?O:void 0,u.video=O.type!=="audio"?O:void 0,u.initSegment=f,u.id3=z0(r,n,d,d),s.samples.length&&(u.text=X0(s,n,d)),u}};function bA(i,e,t,r){if(i===null)return!0;let s=Math.max(r,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>s}function r0(i,e){let t=i==null?void 0:i.codec;return t&&t.length>4?t:t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":t==="avc1"||e===qe.VIDEO?"avc1.42e01e":"mp4a.40.5"}var sr;try{sr=self.performance.now.bind(self.performance)}catch{M.debug("Unable to use Performance API on this environment"),sr=typeof self!="undefined"&&self.Date.now}var Uu=[{demux:gh,remux:Th},{demux:Wi,remux:Zn},{demux:ph,remux:Zn},{demux:bh,remux:Zn}],Kl=class{constructor(e,t,r,s,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,s){let n=r.transmuxing;n.executeStart=sr();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);let{contiguous:d,discontinuity:c,trackSwitch:u,accurateTimeOffset:h,timeOffset:f,initSegmentChange:g}=s||o,{audioCodec:E,videoCodec:T,defaultInitPts:A,duration:k,initSegmentData:L}=l,N=yA(a,t);if(N&&N.method==="AES-128"){let G=this.getDecrypter();if(G.isSync()){let Y=G.softwareDecrypt(a,N.key.buffer,N.iv.buffer);if(r.part>-1&&(Y=G.flush()),!Y)return n.executeEnd=sr(),Fu(r);a=new Uint8Array(Y)}else return this.decryptionPromise=G.webCryptoDecrypt(a,N.key.buffer,N.iv.buffer).then(Y=>{let P=this.push(Y,null,r);return this.decryptionPromise=null,P}),this.decryptionPromise}let D=this.needsProbing(c,u);if(D){let G=this.configureTransmuxer(a);if(G)return M.warn(`[transmuxer] ${G.message}`),this.observer.emit(b.ERROR,b.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:G,reason:G.message}),n.executeEnd=sr(),Fu(r)}(c||u||g||D)&&this.resetInitSegment(L,E,T,k,t),(c||g||D)&&this.resetInitialTimestamp(A),d||this.resetContiguity();let $=this.transmux(a,N,f,h,r),O=this.currentTransmuxState;return O.contiguous=!0,O.discontinuity=!1,O.trackSwitch=!1,n.executeEnd=sr(),$}flush(e){let t=e.transmuxing;t.executeStart=sr();let{decrypter:r,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=s;if(r){let u=r.flush();u&&a.push(this.push(u,null,e))}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=sr(),[Fu(e)];let c=l.flush(o);return wl(c)?c.then(u=>(this.flushRemux(a,u,e),a)):(this.flushRemux(a,c,e),a)}flushRemux(e,t,r){let{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;M.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);let c=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=sr()}resetInitialTimestamp(e){let{demuxer:t,remuxer:r}=this;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,s,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,r,s),o.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,r,s,n):a=this.transmuxUnencrypted(e,r,s,n),a}transmuxUnencrypted(e,t,r,s){let{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,r,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,r,s,n){return this.demuxer.demuxSampleAes(e,t,r).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,r,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:r,typeSupported:s,vendor:n}=this,a;for(let u=0,h=Uu.length;u<h;u++)if(Uu[u].demux.probe(e)){a=Uu[u];break}if(!a)return new Error("Failed to find demuxer by probing fragment data");let o=this.demuxer,l=this.remuxer,d=a.remux,c=a.demux;(!l||!(l instanceof d))&&(this.remuxer=new d(r,t,s,n)),(!o||!(o instanceof c))&&(this.demuxer=new c(r,t,s),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new ra(this.config)),e}};function yA(i,e){let t=null;return i.byteLength>0&&e!=null&&e.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var Fu=i=>({remuxResult:{},chunkMeta:i});function wl(i){return"then"in i&&i.then instanceof Function}var _h=class{constructor(e,t,r,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=s,this.defaultInitPts=n||null}},Ah=class{constructor(e,t,r,s,n,a){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=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}},Q0={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,d,c){this.fn=l,this.context=d,this.once=c||!1}function n(l,d,c,u,h){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,u||l,h),g=t?t+d:d;return l._events[g]?l._events[g].fn?l._events[g]=[l._events[g],f]:l._events[g].push(f):(l._events[g]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new r:delete l._events[d]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],c,u;if(this._eventsCount===0)return d;for(u in c=this._events)e.call(c,u)&&d.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},o.prototype.listeners=function(d){var c=t?t+d:d,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,f=u.length,g=new Array(f);h<f;h++)g[h]=u[h].fn;return g},o.prototype.listenerCount=function(d){var c=t?t+d:d,u=this._events[c];return u?u.fn?1:u.length:0},o.prototype.emit=function(d,c,u,h,f,g){var E=t?t+d:d;if(!this._events[E])return!1;var T=this._events[E],A=arguments.length,k,L;if(T.fn){switch(T.once&&this.removeListener(d,T.fn,void 0,!0),A){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,c),!0;case 3:return T.fn.call(T.context,c,u),!0;case 4:return T.fn.call(T.context,c,u,h),!0;case 5:return T.fn.call(T.context,c,u,h,f),!0;case 6:return T.fn.call(T.context,c,u,h,f,g),!0}for(L=1,k=new Array(A-1);L<A;L++)k[L-1]=arguments[L];T.fn.apply(T.context,k)}else{var N=T.length,D;for(L=0;L<N;L++)switch(T[L].once&&this.removeListener(d,T[L].fn,void 0,!0),A){case 1:T[L].fn.call(T[L].context);break;case 2:T[L].fn.call(T[L].context,c);break;case 3:T[L].fn.call(T[L].context,c,u);break;case 4:T[L].fn.call(T[L].context,c,u,h);break;default:if(!k)for(D=1,k=new Array(A-1);D<A;D++)k[D-1]=arguments[D];T[L].fn.apply(T[L].context,k)}}return!0},o.prototype.on=function(d,c,u){return n(this,d,c,u,!1)},o.prototype.once=function(d,c,u){return n(this,d,c,u,!0)},o.prototype.removeListener=function(d,c,u,h){var f=t?t+d:d;if(!this._events[f])return this;if(!c)return a(this,f),this;var g=this._events[f];if(g.fn)g.fn===c&&(!h||g.once)&&(!u||g.context===u)&&a(this,f);else{for(var E=0,T=[],A=g.length;E<A;E++)(g[E].fn!==c||h&&!g[E].once||u&&g[E].context!==u)&&T.push(g[E]);T.length?this._events[f]=T.length===1?T[0]:T:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var c;return d?(c=t?t+d:d,this._events[c]&&a(this,c)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(Q0);var TA=Q0.exports,tf=kT(TA),Bu=Jl()||{isTypeSupported:()=>!1},Wl=class{constructor(e,t,r,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=s;let a=(d,c)=>{c=c||{},c.frag=this.frag,c.id=this.id,d===b.ERROR&&(this.error=c.error),this.hls.trigger(d,c)};this.observer=new tf,this.observer.on(b.FRAG_DECRYPTED,a),this.observer.on(b.ERROR,a);let o={mp4:Bu.isTypeSupported("video/mp4"),mpeg:Bu.isTypeSupported("audio/mpeg"),mp3:Bu.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"&&(n.workerPath||X_())){try{n.workerPath?(M.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=Z_(n.workerPath)):(M.log(`injecting Web Worker for "${t}"`),this.workerContext=Q_()),this.onwmsg=u=>this.onWorkerMessage(u);let{worker:c}=this.workerContext;c.addEventListener("message",this.onwmsg),c.onerror=u=>{let h=new Error(`${u.message} (${u.filename}:${u.lineno})`);n.enableWorker=!1,M.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(b.ERROR,{type:pe.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},c.postMessage({cmd:"init",typeSupported:o,vendor:l,id:t,config:JSON.stringify(n)})}catch(c){M.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.resetWorker(),this.error=null,this.transmuxer=new Kl(this.observer,o,n,l,t)}return}this.transmuxer=new Kl(this.observer,o,n,l,t)}resetWorker(){if(this.workerContext){let{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,s,n,a,o,l,d,c){var u,h;d.transmuxing.start=self.performance.now();let{transmuxer:f}=this,g=a?a.start:n.start,E=n.decryptdata,T=this.frag,A=!(T&&n.cc===T.cc),k=!(T&&d.level===T.level),L=T?d.sn-T.sn:-1,N=this.part?d.part-this.part.index:-1,D=L===0&&d.id>1&&d.id===(T==null?void 0:T.stats.chunkCount),$=!k&&(L===1||L===0&&(N===1||D&&N<=0)),O=self.performance.now();(k||L||n.stats.parsing.start===0)&&(n.stats.parsing.start=O),a&&(N||!$)&&(a.stats.parsing.start=O);let G=!(T&&((u=n.initSegment)==null?void 0:u.url)===((h=T.initSegment)==null?void 0:h.url)),Y=new Ah(A,$,l,k,g,G);if(!$||A||G){M.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
1050
+ </svg>`,y0=q.createElement("template");y0.innerHTML=`
1051
+ <slot name="icon">${M_}</slot>
1052
+ `;var qu=class extends $e{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_AUDIO_TRACK_ENABLED,S.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:y0})}get mediaAudioTrackEnabled(){return He(this,S.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){Be(this,S.MEDIA_AUDIO_TRACK_ENABLED,e)}};w.customElements.get("media-audio-track-button")||w.customElements.define("media-audio-track-button",qu);var Rl=class extends ni{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_AUDIO_TRACK_ENABLED,S.MEDIA_AUDIO_TRACK_UNAVAILABLE]}init(){let e=q.createElement("media-audio-track-button");e.part.add("button"),e.preventClick=!0;let t=q.createElement("media-audio-track-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};w.customElements.get("media-audio-track-selectmenu")||w.customElements.define("media-audio-track-selectmenu",Rl);var ud=rT(T0(),1);function P_(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var lv={exports:{}};(function(i,e){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,c){if(c=c||{},l=l.trim(),d=d.trim(),!d){if(!c.alwaysNormalize)return l;var u=o.parseURL(l);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return c.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var g=s.exec(f.path);f.netLoc=g[1],f.path=g[2]}f.netLoc&&!f.path&&(f.path="/");var E={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(E.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)E.path=f.path,h.params||(E.params=f.params,h.query||(E.query=f.query));else{var T=f.path,A=T.substring(0,T.lastIndexOf("/")+1)+h.path;E.path=o.normalizePath(A)}return E.path===null&&(E.path=c.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(E)},parseURL:function(l){var d=r.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(lv);var vf=lv.exports;function _0(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function qt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?_0(Object(t),!0).forEach(function(r){O_(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):_0(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function O_(i,e,t){return e=U_(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function dt(){return dt=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},dt.apply(this,arguments)}function N_(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function U_(i){var e=N_(i,"string");return typeof e=="symbol"?e:String(e)}var oe=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},b=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i}({}),he=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),B=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({}),Wr=function(){},mh={trace:Wr,debug:Wr,log:Wr,warn:Wr,info:Wr,error:Wr},ia=mh;function F_(i){let e=self.console[i];return e?e.bind(self.console,`[${i}] >`):Wr}function B_(i,...e){e.forEach(function(t){ia[t]=i[t]?i[t].bind(i):F_(t)})}function $_(i,e){if(self.console&&i===!0||typeof i=="object"){B_(i,"debug","log","info","warn","error");try{ia.log(`Debug logs enabled for "${e}" in hls.js version 1.4.12`)}catch{ia=mh}}else ia=mh}var C=ia,H_=/^(\d+)x(\d+)$/,A0=/(.+?)=(".*?"|.*?)(?:,|$)/g,Qe=class i{constructor(e){typeof e=="string"&&(e=i.parseAttrList(e));for(let t in e)e.hasOwnProperty(t)&&(t.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let r=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=H_.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,r={},s='"';for(A0.lastIndex=0;(t=A0.exec(e))!==null;){let n=t[2];n.indexOf(s)===0&&n.lastIndexOf(s)===n.length-1&&(n=n.slice(1,-1));let a=t[1].trim();r[a]=n}return r}};function G_(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function V_(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}var $l=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let r=t.attr;for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==r[s]){C.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=dt(new Qe({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let r=new Date(this.attr["END-DATE"]);oe(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;let e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(oe(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&oe(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}},an=class{constructor(){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}}},Ge={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Hl=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Ge.AUDIO]:null,[Ge.VIDEO]:null,[Ge.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let r=e.split("@",2),s=[];r.length===1?s[0]=t?t.byteRangeEndOffset:0:s[0]=parseInt(r[1]),s[1]=parseInt(r[0])+s[0],this._byteRange=s}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=vf.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},ra=class extends Hl{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new an,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=e}get decryptdata(){let{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){let t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{let r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!oe(this.programDateTime))return null;let e=oe(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){let t=Object.keys(this.levelkeys),r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){let t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,r,s,n,a=!1){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:r,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[Ge.AUDIO]=null,e[Ge.VIDEO]=null,e[Ge.AUDIOVIDEO]=null}},ph=class extends Hl{constructor(e,t,r,s,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new an,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}},K_=10,gh=class{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?oe(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||K_}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}};function Ef(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function W_(i){let e=dv(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function q_(i){let e=function(r,s,n){let a=r[s];r[s]=r[n],r[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function Y_(i){let e=i.split(":"),t=null;if(e[0]==="data"&&e.length===2){let r=e[1].split(";"),s=r[r.length-1].split(",");if(s.length===2){let n=s[0]==="base64",a=s[1];n?(r.splice(-1,1),t=Ef(a)):t=W_(a)}}return t}function dv(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}var Ze={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Wt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function S0(i){switch(i){case Wt.FAIRPLAY:return Ze.FAIRPLAY;case Wt.PLAYREADY:return Ze.PLAYREADY;case Wt.WIDEVINE:return Ze.WIDEVINE;case Wt.CLEARKEY:return Ze.CLEARKEY}}var cv={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function j_(i){if(i===cv.WIDEVINE)return Ze.WIDEVINE}function x0(i){switch(i){case Ze.FAIRPLAY:return Wt.FAIRPLAY;case Ze.PLAYREADY:return Wt.PLAYREADY;case Ze.WIDEVINE:return Wt.WIDEVINE;case Ze.CLEARKEY:return Wt.CLEARKEY}}function ju(i){let{drmSystems:e,widevineLicenseUrl:t}=i,r=e?[Ze.FAIRPLAY,Ze.WIDEVINE,Ze.PLAYREADY,Ze.CLEARKEY].filter(s=>!!e[s]):[];return!r[Ze.WIDEVINE]&&t&&r.push(Ze.WIDEVINE),r}var uv=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function z_(i,e,t,r){let s;switch(i){case Ze.FAIRPLAY:s=["cenc","sinf"];break;case Ze.WIDEVINE:case Ze.PLAYREADY:s=["cenc"];break;case Ze.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return X_(s,e,t,r)}function X_(i,e,t,r){return[{initDataTypes:i,persistentState:r.persistentState||"not-allowed",distinctiveIdentifier:r.distinctiveIdentifier||"not-allowed",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function Yr(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}var bf=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,hv=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Gl=(i,e)=>{let t=e,r=0;for(;bf(i,e);){r+=10;let s=ld(i,e+6);r+=s,hv(i,e+10)&&(r+=10),e+=r}if(r>0)return i.subarray(t,t+r)},ld=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},Q_=(i,e)=>bf(i,e)&&ld(i,e+6)+10<=i.length-e,Z_=i=>{let e=mv(i);for(let t=0;t<e.length;t++){let r=e[t];if(fv(r))return sA(r)}},fv=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",J_=i=>{let e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=ld(i,4),r=10;return{type:e,size:t,data:i.subarray(r,r+t)}},mv=i=>{let e=0,t=[];for(;bf(i,e);){let r=ld(i,e+6);e+=10;let s=e+r;for(;e+8<s;){let n=J_(i.subarray(e)),a=eA(n);a&&t.push(a),e+=n.size+10}hv(i,e)&&(e+=10)}return t},eA=i=>i.type==="PRIV"?tA(i):i.type[0]==="W"?rA(i):iA(i),tA=i=>{if(i.size<2)return;let e=Hi(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},iA=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1,r=Hi(i.data.subarray(t),!0);t+=r.length+1;let s=Hi(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=Hi(i.data.subarray(1));return{key:i.type,data:e}},rA=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1,r=Hi(i.data.subarray(t),!0);t+=r.length+1;let s=Hi(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=Hi(i.data);return{key:i.type,data:e}},sA=i=>{if(i.data.byteLength===8){let e=new Uint8Array(i.data),t=e[3]&1,r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},Hi=(i,e=!1)=>{let t=nA();if(t){let d=t.decode(i);if(e){let c=d.indexOf("\0");return c!==-1?d.substring(0,c):d}return d.replace(/\0/g,"")}let r=i.length,s,n,a,o="",l=0;for(;l<r;){if(s=i[l++],s===0&&e)return o;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o},zu;function nA(){return!zu&&typeof self.TextDecoder!="undefined"&&(zu=new self.TextDecoder("utf-8")),zu}var Bi={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let r=i[t].toString(16);r.length<2&&(r="0"+r),e+=r}return e}},Vl=Math.pow(2,32)-1,aA=[].push,pv={video:1,audio:2,id3:3,text:4};function Tt(i){return String.fromCharCode.apply(null,i)}function gv(i,e){let t=i[e]<<8|i[e+1];return t<0?65536+t:t}function ge(i,e){let t=vv(i,e);return t<0?4294967296+t:t}function vv(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function Xu(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function Ce(i,e){let t=[];if(!e.length)return t;let r=i.byteLength;for(let s=0;s<r;){let n=ge(i,s),a=Tt(i.subarray(s+4,s+8)),o=n>1?s+n:r;if(a===e[0])if(e.length===1)t.push(i.subarray(s+8,o));else{let l=Ce(i.subarray(s+8,o),e.slice(1));l.length&&aA.apply(t,l)}s=o}return t}function oA(i){let e=[],t=i[0],r=8,s=ge(i,r);r+=4;let n=0,a=0;t===0?r+=8:r+=16,r+=2;let o=i.length+a,l=gv(i,r);r+=2;for(let d=0;d<l;d++){let c=r,u=ge(i,c);c+=4;let h=u&2147483647;if((u&2147483648)>>>31===1)return C.warn("SIDX has hierarchical references (not supported)"),null;let g=ge(i,c);c+=4,e.push({referenceSize:h,subsegmentDuration:g,info:{duration:g/s,start:o,end:o+h-1}}),o+=h,c+=4,r=c}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function Ev(i){let e=[],t=Ce(i,["moov","trak"]);for(let s=0;s<t.length;s++){let n=t[s],a=Ce(n,["tkhd"])[0];if(a){let o=a[0],l=o===0?12:20,d=ge(a,l),c=Ce(n,["mdia","mdhd"])[0];if(c){o=c[0],l=o===0?12:20;let u=ge(c,l),h=Ce(n,["mdia","hdlr"])[0];if(h){let f=Tt(h.subarray(8,12)),g={soun:Ge.AUDIO,vide:Ge.VIDEO}[f];if(g){let E=Ce(n,["mdia","minf","stbl","stsd"])[0],T;E&&(T=Tt(E.subarray(12,16))),e[d]={timescale:u,type:g},e[g]={timescale:u,id:d,codec:T}}}}}}return Ce(i,["moov","mvex","trex"]).forEach(s=>{let n=ge(s,4),a=e[n];a&&(a.default={duration:ge(s,12),flags:ge(s,20)})}),e}function lA(i,e){if(!i||!e)return i;let t=e.keyId;return t&&e.isCommonEncryption&&Ce(i,["moov","trak"]).forEach(s=>{let a=Ce(s,["mdia","minf","stbl","stsd"])[0].subarray(8),o=Ce(a,["enca"]),l=o.length>0;l||(o=Ce(a,["encv"])),o.forEach(d=>{let c=l?d.subarray(28):d.subarray(78);Ce(c,["sinf"]).forEach(h=>{let f=bv(h);if(f){let g=f.subarray(8,24);g.some(E=>E!==0)||(C.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Bi.hexDump(g)} -> ${Bi.hexDump(t)}`),f.set(t,8))}})})}),i}function bv(i){let e=Ce(i,["schm"])[0];if(e){let t=Tt(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return Ce(i,["schi","tenc"])[0]}return C.error("[eme] missing 'schm' box"),null}function dA(i,e){return Ce(e,["moof","traf"]).reduce((t,r)=>{let s=Ce(r,["tfdt"])[0],n=s[0],a=Ce(r,["tfhd"]).reduce((o,l)=>{let d=ge(l,4),c=i[d];if(c){let u=ge(s,4);if(n===1){if(u===Vl)return C.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;u*=Vl+1,u+=ge(s,8)}let h=c.timescale||9e4,f=u/h;if(isFinite(f)&&(o===null||f<o))return f}return o},null);return a!==null&&isFinite(a)&&(t===null||a<t)?a:t},null)}function cA(i,e){let t=0,r=0,s=0,n=Ce(i,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=Ce(o,["tfhd"])[0],d=ge(l,4),c=e[d];if(!c)continue;let u=c.default,h=ge(l,0)|(u==null?void 0:u.flags),f=u==null?void 0:u.duration;h&8&&(h&2?f=ge(l,12):f=ge(l,8));let g=c.timescale||9e4,E=Ce(o,["trun"]);for(let T=0;T<E.length;T++){if(t=uA(E[T]),!t&&f){let A=ge(E[T],4);t=f*A}c.type===Ge.VIDEO?r+=t/g:c.type===Ge.AUDIO&&(s+=t/g)}}if(r===0&&s===0){let a=0,o=Ce(i,["sidx"]);for(let l=0;l<o.length;l++){let d=oA(o[l]);d!=null&&d.references&&(a+=d.references.reduce((c,u)=>c+u.info.duration||0,0))}return a}return r||s}function uA(i){let e=ge(i,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let r=0,s=ge(i,4);for(let n=0;n<s;n++){if(e&256){let a=ge(i,t);r+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return r}function hA(i,e,t){Ce(e,["moof","traf"]).forEach(r=>{Ce(r,["tfhd"]).forEach(s=>{let n=ge(s,4),a=i[n];if(!a)return;let o=a.timescale||9e4;Ce(r,["tfdt"]).forEach(l=>{let d=l[0],c=ge(l,4);if(d===0)c-=t*o,c=Math.max(c,0),Xu(l,4,c);else{c*=Math.pow(2,32),c+=ge(l,8),c-=t*o,c=Math.max(c,0);let u=Math.floor(c/(Vl+1)),h=Math.floor(c%(Vl+1));Xu(l,4,u),Xu(l,8,h)}})})})}function fA(i){let e={valid:null,remainder:null},t=Ce(i,["moof"]);if(t){if(t.length<2)return e.remainder=i,e}else return e;let r=t[t.length-1];return e.valid=Yr(i,0,r.byteOffset-8),e.remainder=Yr(i,r.byteOffset-8),e}function jr(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function I0(i,e){let t=[],r=e.samples,s=e.timescale,n=e.id,a=!1;return Ce(r,["moof"]).map(l=>{let d=l.byteOffset-8;Ce(l,["traf"]).map(u=>{let h=Ce(u,["tfdt"]).map(f=>{let g=f[0],E=ge(f,4);return g===1&&(E*=Math.pow(2,32),E+=ge(f,8)),E/s})[0];return h!==void 0&&(i=h),Ce(u,["tfhd"]).map(f=>{let g=ge(f,4),E=ge(f,0)&16777215,T=(E&1)!==0,A=(E&2)!==0,R=(E&8)!==0,L=0,N=(E&16)!==0,M=0,$=(E&32)!==0,U=8;g===n&&(T&&(U+=8),A&&(U+=4),R&&(L=ge(f,U),U+=4),N&&(M=ge(f,U),U+=4),$&&(U+=4),e.type==="video"&&(a=mA(e.codec)),Ce(u,["trun"]).map(H=>{let W=H[0],O=ge(H,0)&16777215,z=(O&1)!==0,Y=0,ye=(O&4)!==0,Ee=(O&256)!==0,be=0,ke=(O&512)!==0,Se=0,Z=(O&1024)!==0,te=(O&2048)!==0,re=0,xe=ge(H,4),Ie=8;z&&(Y=ge(H,Ie),Ie+=4),ye&&(Ie+=4);let ze=Y+d;for(let kt=0;kt<xe;kt++){if(Ee?(be=ge(H,Ie),Ie+=4):be=L,ke?(Se=ge(H,Ie),Ie+=4):Se=M,Z&&(Ie+=4),te&&(W===0?re=ge(H,Ie):re=vv(H,Ie),Ie+=4),e.type===Ge.VIDEO){let Pt=0;for(;Pt<Se;){let Ot=ge(r,ze);if(ze+=4,pA(a,r[ze])){let Wi=r.subarray(ze,ze+Ot);yv(Wi,a?2:1,i+re/s,t)}ze+=Ot,Pt+=Ot+4}}i+=be/s}}))})})}),t}function mA(i){if(!i)return!1;let e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function pA(i,e){if(i){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function yv(i,e,t,r){let s=Tv(i),n=0;n+=e;let a=0,o=0,l=!1,d=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;d=s[n++],a+=d}while(d===255);o=0;do{if(n>=s.length)break;d=s[n++],o+=d}while(d===255);let c=s.length-n;if(!l&&a===4&&n<s.length){if(l=!0,s[n++]===181){let h=gv(s,n);if(n+=2,h===49){let f=ge(s,n);if(n+=4,f===1195456820){let g=s[n++];if(g===3){let E=s[n++],T=31&E,A=64&E,R=A?2+T*3:0,L=new Uint8Array(R);if(A){L[0]=E;for(let N=1;N<R;N++)L[N]=s[n++]}r.push({type:g,payloadType:a,pts:t,bytes:L})}}}}}else if(a===5&&o<c){if(l=!0,o>16){let u=[];for(let g=0;g<16;g++){let E=s[n++].toString(16);u.push(E.length==1?"0"+E:E),(g===3||g===5||g===7||g===9)&&u.push("-")}let h=o-16,f=new Uint8Array(h);for(let g=0;g<h;g++)f[g]=s[n++];r.push({payloadType:a,pts:t,uuid:u.join(""),userData:Hi(f),userDataBytes:f})}}else if(o<c)n+=o;else if(o>c)break}}function Tv(i){let e=i.byteLength,t=[],r=1;for(;r<e-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return i;let s=e-t.length,n=new Uint8Array(s),a=0;for(r=0;r<s;a++,r++)a===t[0]&&(a++,t.shift()),n[r]=i[a];return n}function gA(i){let e=i[0],t="",r="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;Tt(i.subarray(d,d+1))!=="\0";)t+=Tt(i.subarray(d,d+1)),d+=1;for(t+=Tt(i.subarray(d,d+1)),d+=1;Tt(i.subarray(d,d+1))!=="\0";)r+=Tt(i.subarray(d,d+1)),d+=1;r+=Tt(i.subarray(d,d+1)),d+=1,s=ge(i,12),n=ge(i,16),o=ge(i,20),l=ge(i,24),d=28}else if(e===1){d+=4,s=ge(i,d),d+=4;let u=ge(i,d);d+=4;let h=ge(i,d);for(d+=4,a=2**32*u+h,Number.isSafeInteger(a)||(a=Number.MAX_SAFE_INTEGER,C.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ge(i,d),d+=4,l=ge(i,d),d+=4;Tt(i.subarray(d,d+1))!=="\0";)t+=Tt(i.subarray(d,d+1)),d+=1;for(t+=Tt(i.subarray(d,d+1)),d+=1;Tt(i.subarray(d,d+1))!=="\0";)r+=Tt(i.subarray(d,d+1)),d+=1;r+=Tt(i.subarray(d,d+1)),d+=1}let c=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:r,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:c}}function vA(i,...e){let t=e.length,r=8,s=t;for(;s--;)r+=e[s].byteLength;let n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=r&255,n.set(i,4),s=0,r=8;s<t;s++)n.set(e[s],r),r+=e[s].byteLength;return n}function EA(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,s;if(e){r=1,s=new Uint8Array(e.length*16);for(let o=0;o<e.length;o++){let l=e[o];if(l.byteLength!==16)throw new RangeError("Invalid key");s.set(l,o*16)}}else r=0,s=new Uint8Array;let n;r>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;let a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),vA([112,115,115,104],new Uint8Array([r,0,0,0]),i,n,s,a,t||new Uint8Array)}function bA(i){if(!(i instanceof ArrayBuffer)||i.byteLength<32)return null;let e={version:0,systemId:"",kids:null,data:null},t=new DataView(i),r=t.getUint32(0);if(i.byteLength!==r&&r>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=Bi.hexDump(new Uint8Array(i,12,16));let n=t.getUint32(28);if(e.version===0){if(r-32<n)return null;e.data=new Uint8Array(i,32,n)}else if(e.version===1){e.kids=[];for(let a=0;a<n;a++)e.kids.push(new Uint8Array(i,32+a*16,16))}return e}var wl={},oa=class i{static clearKeyUriToKeyIdMap(){wl={}}constructor(e,t,r,s=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Wt.FAIRPLAY:case Wt.WIDEVINE:case Wt.PLAYREADY:case Wt.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&C.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let r=yA(e);return new i(this.method,this.uri,"identity",this.keyFormatVersions,r)}let t=Y_(this.uri);if(t)switch(this.keyFormat){case Wt.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Wt.PLAYREADY:{let r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=EA(r,null,t);let s=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),n=String.fromCharCode.apply(null,Array.from(s)),a=n.substring(n.indexOf("<"),n.length),d=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(d){let c=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(c){let u=Ef(c).subarray(0,16);q_(u),this.keyId=u}}break}default:{let r=t.subarray(0,16);if(r.length!==16){let s=new Uint8Array(16);s.set(r,16-r.length),r=s}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=wl[this.uri];if(!r){let s=Object.keys(wl).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),wl[this.uri]=r}this.keyId=r}return this}};function yA(i){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}var _v=/\{\$([a-zA-Z0-9-_]+)\}/g;function L0(i){return _v.test(i)}function Vt(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let r=t.length;r--;){let s=t[r],n=e[s];n&&(e[s]=vh(i,n))}}function vh(i,e){if(i.variableList!==null||i.hasVariableRefs){let t=i.variableList;return e.replace(_v,r=>{let s=r.substring(2,r.length-1),n=t==null?void 0:t[s];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),r):n})}return e}function R0(i,e,t){let r=i.variableList;r||(i.variableList=r={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{let a=new self.URL(t).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=n||""}function TA(i,e,t){let r=e.IMPORT;if(t&&r in t){let s=i.variableList;s||(i.variableList=s={}),s[r]=t[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function dd(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}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,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},k0=dd();function AA(i,e){let t=_A[e];return!!t&&t[i.slice(0,4)]===!0}function Qu(i,e){var t;return(t=k0==null?void 0:k0.isTypeSupported(`${e||"video"}/mp4;codecs="${i}"`))!=null?t:!1}var w0=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,D0=/#EXT-X-MEDIA:(.*)/g,SA=/^#EXT(?:INF|-X-TARGETDURATION):/m,C0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),xA=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|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("|")),qr=class i{static findGroup(e,t){for(let r=0;r<e.length;r++){let s=e[r];if(s.id===t)return s}}static convertAVC1ToAVCOTI(e){let t=e.split(".");if(t.length>2){let r=t.shift()+".";return r+=parseInt(t.shift()).toString(16),r+=("000"+parseInt(t.shift()).toString(16)).slice(-4),r}return e}static resolve(e,t){return vf.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return SA.test(e)}static parseMasterPlaylist(e,t){let r=L0(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},n=[];w0.lastIndex=0;let a;for(;(a=w0.exec(e))!=null;)if(a[1]){var o;let d=new Qe(a[1]);Vt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let c=vh(s,a[2]),u={attrs:d,bitrate:d.decimalInteger("AVERAGE-BANDWIDTH")||d.decimalInteger("BANDWIDTH"),name:d.NAME,url:i.resolve(c,t)},h=d.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),IA((d.CODECS||"").split(/[ ,]+/).filter(f=>f),u),u.videoCodec&&u.videoCodec.indexOf("avc1")!==-1&&(u.videoCodec=i.convertAVC1ToAVCOTI(u.videoCodec)),(o=u.unknownCodecs)!=null&&o.length||n.push(u),s.levels.push(u)}else if(a[3]){let d=a[3],c=a[4];switch(d){case"SESSION-DATA":{let u=new Qe(c);Vt(s,u,["DATA-ID","LANGUAGE","VALUE","URI"]);let h=u["DATA-ID"];h&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[h]=u);break}case"SESSION-KEY":{let u=M0(c,t,s);u.encrypted&&u.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(u)):C.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${c}"`);break}case"DEFINE":{{let u=new Qe(c);Vt(s,u,["NAME","VALUE","QUERYPARAM"]),R0(s,u,t)}break}case"CONTENT-STEERING":{let u=new Qe(c);Vt(s,u,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:i.resolve(u["SERVER-URI"],t),pathwayId:u["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=P0(c);break}}}let l=n.length>0&&n.length<s.levels.length;return s.levels=l?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let s,n={},a=r.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(D0.lastIndex=0;(s=D0.exec(e))!==null;){let d=new Qe(s[1]),c=d.TYPE;if(c){let u=o[c],h=n[c]||[];n[c]=h,Vt(r,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let f={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",instreamId:d["INSTREAM-ID"],name:d.NAME||d.LANGUAGE||"",type:c,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:d.LANGUAGE,url:d.URI?i.resolve(d.URI,t):""};if(u!=null&&u.length){let g=i.findGroup(u,f.groupId)||u[0];O0(f,g,"audioCodec"),O0(f,g,"textCodec")}h.push(f)}}return n}static parseLevelPlaylist(e,t,r,s,n,a){let o=new gh(t),l=o.fragments,d=null,c=0,u=0,h=0,f=0,g=null,E=new ra(s,t),T,A,R,L=-1,N=!1;for(C0.lastIndex=0,o.m3u8=e,o.hasVariableRefs=L0(e);(T=C0.exec(e))!==null;){N&&(N=!1,E=new ra(s,t),E.start=h,E.sn=c,E.cc=f,E.level=r,d&&(E.initSegment=d,E.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null));let H=T[1];if(H){E.duration=parseFloat(H);let W=(" "+T[2]).slice(1);E.title=W||null,E.tagList.push(W?["INF",H,W]:["INF",H])}else if(T[3]){if(oe(E.duration)){E.start=h,R&&F0(E,R,o),E.sn=c,E.level=r,E.cc=f,E.urlId=n,l.push(E);let W=(" "+T[3]).slice(1);E.relurl=vh(o,W),N0(E,g),g=E,h+=E.duration,c++,u=0,N=!0}}else if(T[4]){let W=(" "+T[4]).slice(1);g?E.setByteRange(W,g):E.setByteRange(W)}else if(T[5])E.rawProgramDateTime=(" "+T[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),L===-1&&(L=l.length);else{if(T=T[0].match(xA),!T){C.warn("No matches on slow regex match for level playlist!");continue}for(A=1;A<T.length&&typeof T[A]=="undefined";A++);let W=(" "+T[A]).slice(1),O=(" "+T[A+1]).slice(1),z=T[A+2]?(" "+T[A+2]).slice(1):"";switch(W){case"PLAYLIST-TYPE":o.type=O.toUpperCase();break;case"MEDIA-SEQUENCE":c=o.startSN=parseInt(O);break;case"SKIP":{let Y=new Qe(O);Vt(o,Y,["RECENTLY-REMOVED-DATERANGES"]);let ye=Y.decimalInteger("SKIPPED-SEGMENTS");if(oe(ye)){o.skippedSegments=ye;for(let be=ye;be--;)l.unshift(null);c+=ye}let Ee=Y.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ee&&(o.recentlyRemovedDateranges=Ee.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(O),1);break;case"VERSION":o.version=parseInt(O);break;case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(O||z)&&E.tagList.push(z?[O,z]:[O]);break;case"DISCONTINUITY":f++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([W]);break;case"BITRATE":E.tagList.push([W,O]);break;case"DATERANGE":{let Y=new Qe(O);Vt(o,Y,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Vt(o,Y,Y.clientAttrs);let ye=new $l(Y,o.dateRanges[Y.ID]);ye.isValid||o.skippedSegments?o.dateRanges[ye.id]=ye:C.warn(`Ignoring invalid DATERANGE tag: "${O}"`),E.tagList.push(["EXT-X-DATERANGE",O]);break}case"DEFINE":{{let Y=new Qe(O);Vt(o,Y,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in Y?TA(o,Y,a):R0(o,Y,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(O);break;case"KEY":{let Y=M0(O,t,o);if(Y.isSupported()){if(Y.method==="NONE"){R=void 0;break}R||(R={}),R[Y.keyFormat]&&(R=dt({},R)),R[Y.keyFormat]=Y}else C.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${O}"`);break}case"START":o.startTimeOffset=P0(O);break;case"MAP":{let Y=new Qe(O);if(Vt(o,Y,["BYTERANGE","URI"]),E.duration){let ye=new ra(s,t);U0(ye,Y,r,R),d=ye,E.initSegment=d,d.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=d.rawProgramDateTime)}else U0(E,Y,r,R),d=E,N=!0;break}case"SERVER-CONTROL":{let Y=new Qe(O);o.canBlockReload=Y.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=Y.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&Y.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=Y.optionalFloat("PART-HOLD-BACK",0),o.holdBack=Y.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{let Y=new Qe(O);o.partTarget=Y.decimalFloatingPoint("PART-TARGET");break}case"PART":{let Y=o.partList;Y||(Y=o.partList=[]);let ye=u>0?Y[Y.length-1]:void 0,Ee=u++,be=new Qe(O);Vt(o,be,["BYTERANGE","URI"]);let ke=new ph(be,E,t,Ee,ye);Y.push(ke),E.duration+=ke.duration;break}case"PRELOAD-HINT":{let Y=new Qe(O);Vt(o,Y,["URI"]),o.preloadHint=Y;break}case"RENDITION-REPORT":{let Y=new Qe(O);Vt(o,Y,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(Y);break}default:C.warn(`line parsed but not handled: ${T}`);break}}}g&&!g.relurl?(l.pop(),h-=g.duration,o.partList&&(o.fragmentHint=g)):o.partList&&(N0(E,g),E.cc=f,o.fragmentHint=E,R&&F0(E,R,o));let M=l.length,$=l[0],U=l[M-1];if(h+=o.skippedSegments*o.targetduration,h>0&&M&&U){o.averagetargetduration=h/M;let H=U.sn;o.endSN=H!=="initSegment"?H:0,o.live||(U.endList=!0),$&&(o.startCC=$.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,L>0&&LA(l,L),o}};function M0(i,e,t){var r,s;let n=new Qe(i);Vt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(r=n.METHOD)!=null?r:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,c=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&C.error(`Invalid IV: ${n.IV}`);let u=o?qr.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new oa(a,u,c,h,l)}function P0(i){let t=new Qe(i).decimalFloatingPoint("TIME-OFFSET");return oe(t)?t:null}function IA(i,e){["video","audio","text"].forEach(t=>{let r=i.filter(s=>AA(s,t));if(r.length){let s=r.filter(n=>n.lastIndexOf("avc1",0)===0||n.lastIndexOf("mp4a",0)===0);e[`${t}Codec`]=s.length>0?s[0]:r[0],i=i.filter(n=>r.indexOf(n)===-1)}}),e.unknownCodecs=i}function O0(i,e,t){let r=e[t];r&&(i[t]=r)}function LA(i,e){let t=i[e];for(let r=e;r--;){let s=i[r];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function N0(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),oe(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function U0(i,e,t,r){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function F0(i,e,t){i.levelkeys=e;let{encryptedFragments:r}=t;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&r.push(i)}var Me={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},fe={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function B0(i){let{type:e}=i;switch(e){case Me.AUDIO_TRACK:return fe.AUDIO;case Me.SUBTITLE_TRACK:return fe.SUBTITLE;default:return fe.MAIN}}function Zu(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var Eh=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(b.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_LOADING,this.onLevelLoading,this),e.off(b.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(b.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,r=t.pLoader,s=t.loader,n=r||s,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Me.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){let{id:r,level:s,url:n,deliveryDirectives:a}=t;this.load({id:r,level:s,responseType:"text",type:Me.LEVEL,url:n,deliveryDirectives:a})}onAudioTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Me.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Me.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;let r=this.hls.config,s=this.getInternalLoader(e);if(s){let d=s.context;if(d&&d.url===e.url){C.trace("[playlist-loader]: playlist request ongoing");return}C.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===Me.MANIFEST?n=r.manifestLoadPolicy.default:n=dt({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part){let d;if(e.type===Me.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Me.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Me.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){let c=d.partTarget,u=d.targetduration;if(c&&u){let h=Math.max(c*3,u*.8)*1e3;n=dt({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,c,u,h)=>{let f=this.getInternalLoader(u);this.resetInternalLoader(u.type);let g=d.data;if(g.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,u,new Error("no EXTM3U delimiter"),h||null,c);return}c.parsing.start=performance.now(),qr.isMediaPlaylist(g)?this.handleTrackOrLevelPlaylist(d,c,u,h||null,f):this.handleMasterPlaylist(d,c,u,h)},onError:(d,c,u,h)=>{this.handleNetworkError(c,u,!1,d,h)},onTimeout:(d,c,u)=>{this.handleNetworkError(c,u,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,r,s){let n=this.hls,a=e.data,o=Zu(e,r),l=qr.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,s,t);return}let{contentSteering:d,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:g}=l;this.variableList=g;let{AUDIO:E=[],SUBTITLES:T,"CLOSED-CAPTIONS":A}=qr.parseMasterPlaylistMedia(a,o,l);E.length&&!E.some(L=>!L.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(C.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Qe({}),bitrate:0,url:""})),n.trigger(b.MANIFEST_LOADED,{levels:c,audioTracks:E,subtitles:T,captions:A,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:g})}handleTrackOrLevelPlaylist(e,t,r,s,n){let a=this.hls,{id:o,level:l,type:d}=r,c=Zu(e,r),u=oe(o)?o:0,h=oe(l)?l:u,f=B0(r),g=qr.parseLevelPlaylist(e.data,c,h,f,u,this.variableList);if(d===Me.MANIFEST){let E={attrs:new Qe({}),bitrate:0,details:g,name:"",url:c};a.trigger(b.MANIFEST_LOADED,{levels:[E],audioTracks:[],url:c,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=g,this.handlePlaylistLoaded(g,e,t,r,s,n)}handleManifestParsingError(e,t,r,s,n){this.hls.trigger(b.ERROR,{type:he.NETWORK_ERROR,details:B.MANIFEST_PARSING_ERROR,fatal:t.type===Me.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,r=!1,s,n){let a=`A network ${r?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===Me.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Me.AUDIO_TRACK||e.type===Me.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);C.warn(`[playlist-loader]: ${a}`);let l=B.UNKNOWN,d=!1,c=this.getInternalLoader(e);switch(e.type){case Me.MANIFEST:l=r?B.MANIFEST_LOAD_TIMEOUT:B.MANIFEST_LOAD_ERROR,d=!0;break;case Me.LEVEL:l=r?B.LEVEL_LOAD_TIMEOUT:B.LEVEL_LOAD_ERROR,d=!1;break;case Me.AUDIO_TRACK:l=r?B.AUDIO_TRACK_LOAD_TIMEOUT:B.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Me.SUBTITLE_TRACK:l=r?B.SUBTITLE_TRACK_LOAD_TIMEOUT:B.SUBTITLE_LOAD_ERROR,d=!1;break}c&&this.resetInternalLoader(e.type);let u={type:he.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(s){let h=(t==null?void 0:t.url)||e.url;u.response=qt({url:h,data:void 0},s)}this.hls.trigger(b.ERROR,u)}handlePlaylistLoaded(e,t,r,s,n,a){let o=this.hls,{type:l,level:d,id:c,groupId:u,deliveryDirectives:h}=s,f=Zu(t,s),g=B0(s),E=typeof s.level=="number"&&g===fe.MAIN?d:void 0;if(!e.fragments.length){let A=new Error("No Segments found in Playlist");o.trigger(b.ERROR,{type:he.NETWORK_ERROR,details:B.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:A,reason:A.message,response:t,context:s,level:E,parent:g,networkDetails:n,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let T=e.playlistParsingError;if(T){o.trigger(b.ERROR,{type:he.NETWORK_ERROR,details:B.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:T,reason:T.message,response:t,context:s,level:E,parent:g,networkDetails:n,stats:r});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case Me.MANIFEST:case Me.LEVEL:o.trigger(b.LEVEL_LOADED,{details:e,level:E||0,id:c||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case Me.AUDIO_TRACK:o.trigger(b.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case Me.SUBTITLE_TRACK:o.trigger(b.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break}}};function Av(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function Sv(i,e){let t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){C.debug(`[texttrack-utils]: ${r}`);try{let s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,i.addCue(s)}catch(s){C.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(i.mode=t)}function sn(i){let e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function bh(i,e,t,r){let s=i.mode;if(s==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){let n=kA(i.cues,e,t);for(let a=0;a<n.length;a++)(!r||r(n[a]))&&i.removeCue(n[a])}s==="disabled"&&(i.mode=s)}function RA(i,e){if(e<i[0].startTime)return 0;let t=i.length-1;if(e>i[t].endTime)return-1;let r=0,s=t;for(;r<=s;){let n=Math.floor((s+r)/2);if(e<i[n].startTime)s=n-1;else if(e>i[n].startTime&&r<t)r=n+1;else return n}return i[r].startTime-e<e-i[s].startTime?r:s}function kA(i,e,t){let r=[],s=RA(i,e);if(s>-1)for(let n=s,a=i.length;n<a;n++){let o=i[n];if(o.startTime>=e&&o.endTime<=t)r.push(o);else if(o.startTime>t)return r}return r}var Ti={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},wA=.25;function yh(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var Dl=(()=>{let i=yh();try{new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Ju(i,e){return i.getTime()/1e3-e}function DA(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Th=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(sn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let r=e[t];if(r.kind==="metadata"&&r.label==="id3")return Av(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:s}}}=this;if(!r&&!s)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=yh();for(let o=0;o<n.length;o++){let l=n[o].type;if(l===Ti.emsg&&!r||!s)continue;let d=mv(n[o].data);if(d){let c=n[o].pts,u=c+n[o].duration;u>Dl&&(u=Dl),u-c<=0&&(u=c+wA);for(let f=0;f<d.length;f++){let g=d[f];if(!fv(g)){this.updateId3CueEnds(c,l);let E=new a(c,u,"");E.value=g,l&&(E.type=l),this.id3Track.addCue(E)}}}}}updateId3CueEnds(e,t){var r;let s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(let n=s.length;n--;){let a=s[n];a.type===t&&a.startTime<e&&a.endTime===Dl&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:s}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;s==="audio"?d=c=>c.type===Ti.audioId3&&l:s==="video"?d=c=>c.type===Ti.emsg&&o:d=c=>c.type===Ti.audioId3&&l||c.type===Ti.emsg&&o,bh(n,t,r,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:r,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){let c=Object.keys(r).filter(u=>!a.includes(u));for(let u=c.length;u--;){let h=c[u];Object.keys(r[h].cues).forEach(f=>{s.removeCue(r[h].cues[f])}),delete r[h]}}let o=t.fragments[t.fragments.length-1];if(a.length===0||!oe(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=o.programDateTime/1e3-o.start,d=yh();for(let c=0;c<a.length;c++){let u=a[c],h=n[u],f=r[u],g=(f==null?void 0:f.cues)||{},E=(f==null?void 0:f.durationKnown)||!1,T=Ju(h.startDate,l),A=Dl,R=h.endDate;if(R)A=Ju(R,l),E=!0;else if(h.endOnNext&&!E){let N=a.reduce((M,$)=>{let U=n[$];return U.class===h.class&&U.id!==$&&U.startDate>h.startDate&&M.push(U),M},[]).sort((M,$)=>M.startDate.getTime()-$.startDate.getTime())[0];N&&(A=Ju(N.startDate,l),E=!0)}let L=Object.keys(h.attr);for(let N=0;N<L.length;N++){let M=L[N];if(!G_(M))continue;let $=g[M];if($)E&&!f.durationKnown&&($.endTime=A);else{let U=h.attr[M];$=new d(T,A,""),V_(M)&&(U=DA(U)),$.value={key:M,data:U},$.type=Ti.dateRange,$.id=u,this.id3Track.addCue($),g[M]=$}}r[u]={cues:g,dateRange:h,durationKnown:E}}}},_h=class{constructor(e){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=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){let{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let{levelDetails:e}=this;if(e===null)return null;let{holdBack:t,partHoldBack:r,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*s);let c=s,u=1;return d+Math.min(this.stallCount*u,c)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;let s=r.edge,n=e-t-this.edgeStalled,a=s-r.totalduration,o=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){let{levelDetails:e}=this;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e,levelDetails:t}=this;if(!e||!t)return 0;let r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(b.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(b.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(b.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(b.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===B.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&C.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1)return;let a=this.targetLatency;if(a===null)return;let o=r-a,l=Math.min(this.maxLatency,a+t.targetduration),d=o<l;if(t.live&&d&&o>.05&&this.forwardBufferLength>1){let c=Math.min(2,Math.max(1,n)),u=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,u))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){let{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},Ah=["NONE","TYPE-0","TYPE-1",null],sa={No:"",Yes:"YES",v2:"v2"};function CA(i,e){let{canSkipUntil:t,canSkipDateRanges:r,endSN:s}=i,n=e!==void 0?e-s:0;return t&&n<t?r?sa.v2:sa.Yes:sa.No}var Kl=class{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){let t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}},zr=class{constructor(e){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=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>t).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(e){let t=e%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var e;return(e=this.audioGroupIds)==null?void 0:e[this.urlId]}get textGroupId(){var e;return(e=this.textGroupIds)==null?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}};function eh(i,e){let t=e.startPTS;if(oe(t)){let r=0,s;e.sn>i.sn?(r=t-i.start,s=i):(r=i.start-t,s=e),s.duration!==r&&(s.duration=r)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function xv(i,e,t,r,s,n){r-t<=0&&(C.warn("Fragment should have a positive duration",e),r=t+e.duration,n=s+e.duration);let o=t,l=r,d=e.startPTS,c=e.endPTS;if(oe(d)){let T=Math.abs(d-t);oe(e.deltaPTS)?e.deltaPTS=Math.max(T,e.deltaPTS):e.deltaPTS=T,o=Math.max(t,d),t=Math.min(t,d),s=Math.min(s,e.startDTS),l=Math.min(r,c),r=Math.max(r,c),n=Math.max(n,e.endDTS)}let u=t-e.start;e.start!==0&&(e.start=t),e.duration=r-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=r,e.minEndPTS=l,e.endDTS=n;let h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f,g=h-i.startSN,E=i.fragments;for(E[g]=e,f=g;f>0;f--)eh(E[f],E[f-1]);for(f=g;f<E.length-1;f++)eh(E[f],E[f+1]);return i.fragmentHint&&eh(E[E.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,u}function MA(i,e){let t=null,r=i.fragments;for(let l=r.length-1;l>=0;l--){let d=r[l].initSegment;if(d){t=d;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let s=0,n;if(NA(i,e,(l,d)=>{l.relurl&&(s=l.cc-d.cc),oe(l.startPTS)&&oe(l.endPTS)&&(d.start=d.startPTS=l.startPTS,d.startDTS=l.startDTS,d.maxStartPTS=l.maxStartPTS,d.endPTS=l.endPTS,d.endDTS=l.endDTS,d.minEndPTS=l.minEndPTS,d.duration=l.endPTS-l.startPTS,d.duration&&(n=d),e.PTSKnown=e.alignedSliding=!0),d.elementaryStreams=l.elementaryStreams,d.loader=l.loader,d.stats=l.stats,d.urlId=l.urlId,l.initSegment&&(d.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(d=>{var c;(!d.initSegment||d.initSegment.relurl===((c=t)==null?void 0:c.relurl))&&(d.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){C.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=PA(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));let a=e.fragments;if(s){C.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),OA(i.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?xv(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):Iv(i,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;let o=e.advancedDateTime;if(e.advanced&&o){let l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function PA(i,e,t){let r=dt({},i);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{let n=new $l(e[s].attr,r[s]);n.isValid?r[s]=n:C.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),r}function OA(i,e,t){if(i&&e){let r=0;for(let s=0,n=i.length;s<=n;s++){let a=i[s],o=e[s+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):r--}}}function NA(i,e,t){let r=e.skippedSegments,s=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(r?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=s;d<=n;d++){let c=l[a+d],u=o[d];r&&!u&&d<r&&(u=e.fragments[d]=c),c&&u&&t(c,u)}}function Iv(i,e){let t=e.startSN+e.skippedSegments-i.startSN,r=i.fragments;t<0||t>=r.length||Sh(e,r[t].start)}function Sh(i,e){if(e){let t=i.fragments;for(let r=i.skippedSegments;r<t.length;r++)t[r].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function UA(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){let r=i.fragments,s=4;if(r.length&&t*s>e){let n=r[r.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function FA(i,e,t){if(!(i!=null&&i.details))return null;let r=i.details,s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,s&&s.sn===e)?s:e<r.startSN&&t&&t.sn===e?t:null}function $0(i,e,t){var r;return i!=null&&i.details?Lv((r=i.details)==null?void 0:r.partList,e,t):null}function Lv(i,e,t){if(i)for(let r=i.length;r--;){let s=i[r];if(s.index===t&&s.fragment.sn===e)return s}return null}function Wl(i){switch(i.details){case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_TIMEOUT:case B.LEVEL_LOAD_TIMEOUT:case B.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function H0(i,e){let t=Wl(e);return i.default[`${t?"timeout":"error"}Retry`]}function yf(i,e){let t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function G0(i){return qt(qt({},i),{errorRetry:null,timeoutRetry:null})}function ql(i,e,t,r){return!!i&&e<i.maxNumRetry&&(BA(r)||!!t)}function BA(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}var Rv={search:function(i,e){let t=0,r=i.length-1,s=null,n=null;for(;t<=r;){s=(t+r)/2|0,n=i[s];let a=e(n);if(a>0)t=s+1;else if(a<0)r=s-1;else return n}return null}};function $A(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!oe(e))return null;let r=i[0].programDateTime;if(e<(r||0))return null;let s=i[i.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<i.length;++n){let a=i[n];if(HA(e,t,a))return a}return null}function la(i,e,t=0,r=0){let s=null;if(i?s=e[i.sn-e[0].sn+1]||null:t===0&&e[0].start===0&&(s=e[0]),s&&xh(t,r,s)===0)return s;let n=Rv.search(e,xh.bind(null,t,r));return n&&(n!==i||!s)?n:s}function xh(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=i?1:t.start-r>i&&t.start?-1:0}function HA(i,e,t){let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>i}function GA(i,e){return Rv.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var VA=3e5,Lt={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},ai={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},Ih=class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=C.log.bind(C,"[info]:"),this.warn=C.warn.bind(C,"[warning]:"),this.error=C.error.bind(C,"[error]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(b.ERROR,this.onError,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(b.ERROR,this.onError,this),e.off(b.ERROR,this.onErrorOut,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(e==null?void 0:e.type)===fe.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,s;if(t.fatal)return;let n=this.hls,a=t.context;switch(t.details){case B.FRAG_LOAD_ERROR:case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_ERROR:case B.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case B.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:Lt.DoNothing,flags:ai.None};return}case B.FRAG_GAP:case B.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Lt.SendAlternateToPenaltyBox;return}case B.LEVEL_EMPTY_ERROR:case B.LEVEL_PARSING_ERROR:{var o,l;let d=t.parent===fe.MAIN?t.level:n.loadLevel;t.details===B.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case B.LEVEL_LOAD_ERROR:case B.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case B.AUDIO_TRACK_LOAD_ERROR:case B.AUDIO_TRACK_LOAD_TIMEOUT:case B.SUBTITLE_LOAD_ERROR:case B.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){let d=n.levels[n.loadLevel];if(d&&(a.type===Me.AUDIO_TRACK&&a.groupId===d.audioGroupId||a.type===Me.SUBTITLE_TRACK&&a.groupId===d.textGroupId)){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=Lt.SendAlternateToPenaltyBox,t.errorAction.flags=ai.MoveAllAlternatesMatchingHost;return}}return;case B.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let d=n.levels[n.loadLevel],c=d==null?void 0:d.attrs["HDCP-LEVEL"];c&&(t.errorAction={action:Lt.SendAlternateToPenaltyBox,flags:ai.MoveAllAlternatesMatchingHDCP,hdcpLevel:c})}return;case B.BUFFER_ADD_CODEC_ERROR:case B.REMUX_ALLOC_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:n.loadLevel);return;case B.INTERNAL_EXCEPTION:case B.BUFFER_APPENDING_ERROR:case B.BUFFER_APPEND_ERROR:case B.BUFFER_FULL_ERROR:case B.LEVEL_SWITCH_ERROR:case B.BUFFER_STALLED_ERROR:case B.BUFFER_SEEK_OVER_HOLE:case B.BUFFER_NUDGE_ON_STALL:t.errorAction={action:Lt.DoNothing,flags:ai.None};return}if(t.type===he.KEY_SYSTEM_ERROR){let d=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d);return}}getPlaylistRetryOrSwitchAction(e,t){var r;let s=this.hls,n=H0(s.config.playlistLoadPolicy,e),a=this.playlistError++,o=(r=e.response)==null?void 0:r.code;if(ql(n,a,Wl(e),o))return{action:Lt.RetryRequest,flags:ai.None,retryConfig:n,retryCount:a};let d=this.getLevelSwitchAction(e,t);return n&&(d.retryConfig=n,d.retryCount=a),d}getFragRetryOrSwitchAction(e){let t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=H0(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((u,h)=>u+h.fragmentError,0);if(s){var d;e.details!==B.FRAG_GAP&&s.fragmentError++;let u=(d=e.response)==null?void 0:d.code;if(ql(o,l,Wl(e),u))return{action:Lt.RetryRequest,flags:ai.None,retryConfig:o,retryCount:l}}let c=this.getLevelSwitchAction(e,r);return o&&(c.retryConfig=o,c.retryCount=l),c}getLevelSwitchAction(e,t){let r=this.hls;t==null&&(t=r.loadLevel);let s=this.hls.levels[t];if(s&&(s.loadError++,r.autoLevelEnabled)){var n,a;let o=-1,{levels:l,loadLevel:d,minAutoLevel:c,maxAutoLevel:u}=r,h=(n=e.frag)==null?void 0:n.type,{type:f,groupId:g}=(a=e.context)!=null?a:{};for(let E=l.length;E--;){let T=(E+d)%l.length;if(T!==d&&T>=c&&T<=u&&l[T].loadError===0){let A=l[T];if(e.details===B.FRAG_GAP&&e.frag){let R=l[T].details;if(R){let L=la(e.frag,R.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else{if(f===Me.AUDIO_TRACK&&g===A.audioGroupId||f===Me.SUBTITLE_TRACK&&g===A.textGroupId)continue;if(h===fe.AUDIO&&s.audioGroupId===A.audioGroupId||h===fe.SUBTITLE&&s.textGroupId===A.textGroupId)continue}o=T;break}}if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:Lt.SendAlternateToPenaltyBox,flags:ai.None,nextAutoLevel:o}}return{action:Lt.SendAlternateToPenaltyBox,flags:ai.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case Lt.DoNothing:break;case Lt.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==B.FRAG_GAP&&(t.fatal=!0);break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){let t=this.hls,r=e.errorAction;if(!r)return;let{flags:s,hdcpLevel:n,nextAutoLevel:a}=r;switch(s){case ai.None:this.switchLevel(e,a);break;case ai.MoveAllAlternatesMatchingHost:r.resolved||(r.resolved=this.redundantFailover(e));break;case ai.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=Ah[Ah.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(e){let{hls:t,penalizedRenditions:r}=this,s=e.parent===fe.MAIN?e.level:t.loadLevel,n=t.levels[s],a=n.url.length,o=e.frag?e.frag.urlId:n.urlId;n.urlId===o&&(!e.frag||n.details)&&this.penalizeRendition(n,e);for(let l=1;l<a;l++){let d=(o+l)%a,c=r[d];if(!c||KA(c,e,r[o]))return this.warn(`Switching to Redundant Stream ${d+1}/${a}: "${n.url[d]}" after ${e.details}`),this.playlistError=0,t.levels.forEach(u=>{u.urlId=d}),t.nextLoadLevel=s,!0}return!1}penalizeRendition(e,t){let{penalizedRenditions:r}=this,s=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};s.lastErrorPerfMs=performance.now(),s.errors.push(t),s.details=e.details,r[e.urlId]=s}};function KA(i,e,t){if(performance.now()-i.lastErrorPerfMs>VA)return!0;let r=i.details;if(e.details===B.FRAG_GAP&&r&&e.frag){let s=e.frag.start,n=la(null,r.fragments,s);if(n&&!n.gap)return!0}if(t&&i.errors.length<t.errors.length){let s=i.errors[i.errors.length-1];if(r&&s.frag&&e.frag&&Math.abs(s.frag.start-e.frag.start)>r.targetduration*3)return!0}return!1}var da=class{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=C.log.bind(C,`${t}:`),this.warn=C.warn.bind(C,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t){let r=t==null?void 0:t.renditionReports;if(r){let s=-1;for(let n=0;n<r.length;n++){let a=r[n],o;try{o=new self.URL(a.URI,t.url).href}catch(l){C.warn(`Could not construct new URL for Rendition Report: ${l}`),o=a.URI||""}if(o===e){s=n;break}else o===e.substring(0,o.length)&&(s=n)}if(s!==-1){let n=r[s],a=parseInt(n["LAST-MSN"])||(t==null?void 0:t.lastPartSn),o=parseInt(n["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){let l=Math.min(t.age-t.partTarget,t.targetduration);o>=0&&l>t.partTarget&&(o+=1)}return new Kl(a,o>=0?o:void 0,sa.No)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){let{details:s,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||r!=null&&r.live){if(s.reloaded(r),r&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),r&&s.fragments.length>0&&MA(r,s),!this.canLoad||!s.live)return;let l,d,c;if(s.canBlockReload&&s.endSN&&s.advanced){let T=this.hls.config.lowLatencyMode,A=s.lastPartSn,R=s.endSN,L=s.lastPartIndex,N=L!==-1,M=A===R,$=T?0:L;N?(d=M?R+1:A,c=M?$:L+1):d=R+1;let U=s.age,H=U+s.ageHeader,W=Math.min(H-s.partTarget,s.targetduration*1.5);if(W>0){if(r&&W>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${W} with playlist age: ${s.age}`),W=0;else{let O=Math.floor(W/s.targetduration);if(d+=O,c!==void 0){let z=Math.round(W%s.targetduration/s.partTarget);c+=z}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${U.toFixed(2)}s goal: ${W} skip sn ${O} to part ${c}`)}s.tuneInGoal=W}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,c),T||!M){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,c));let u=this.hls.mainForwardBufferInfo,h=u?u.end-u.len:0,f=(s.edge-h)*1e3,g=UA(s,f);s.updated&&a>this.requestScheduled+g&&(this.requestScheduled=n.loading.start),d!==void 0&&s.canBlockReload?this.requestScheduled=n.loading.first+g-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+g<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=g);let E=this.requestScheduled-a;E=Math.max(0,E),this.log(`reload live playlist ${e} in ${Math.round(E)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),E)}else this.clearTimer()}getDeliveryDirectives(e,t,r,s){let n=CA(e,r);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,n=sa.No),new Kl(r,s,n)}checkRetry(e){let t=e.details,r=Wl(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===Lt.RetryRequest||!s.resolved&&n===Lt.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(r&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let c=yf(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${c}ms`)}e.levelRetry=!0,s.resolved=!0}return l}},th,Lh=class extends da{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){let r=[],s={},n;t.levels.forEach(a=>{var o;let l=a.attrs;((o=a.audioCodec)==null?void 0:o.indexOf("mp4a.40.34"))!==-1&&(th||(th=/chrome|firefox/i.test(navigator.userAgent)),th&&(a.audioCodec=void 0));let{AUDIO:d,CODECS:c,"FRAME-RATE":u,"PATHWAY-ID":h,RESOLUTION:f,SUBTITLES:g}=l,T=`${`${h||"."}-`}${a.bitrate}-${f}-${u}-${c}`;n=s[T],n?n.addFallback(a):(n=new zr(a),s[T]=n,r.push(n)),Yl(n,"audio",d),Yl(n,"text",g)}),this.filterAndSortMediaOptions(r,t)}filterAndSortMediaOptions(e,t){let r=[],s=[],n=!1,a=!1,o=!1,l=e.filter(({audioCodec:f,videoCodec:g,width:E,height:T,unknownCodecs:A})=>(n||(n=!!(E&&T)),a||(a=!!g),o||(o=!!f),!(A!=null&&A.length)&&(!f||Qu(f,"audio"))&&(!g||Qu(g,"video"))));if((n||a)&&o&&(l=l.filter(({videoCodec:f,width:g,height:E})=>!!f||!!(g&&E))),l.length===0){Promise.resolve().then(()=>{if(this.hls){let f=new Error("no level with compatible codecs found in manifest");this.hls.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:f,reason:f.message})}});return}t.audioTracks&&(r=t.audioTracks.filter(f=>!f.audioCodec||Qu(f.audioCodec,"audio")),V0(r)),t.subtitles&&(s=t.subtitles,V0(s));let d=l.slice(0);l.sort((f,g)=>f.attrs["HDCP-LEVEL"]!==g.attrs["HDCP-LEVEL"]?(f.attrs["HDCP-LEVEL"]||"")>(g.attrs["HDCP-LEVEL"]||"")?1:-1:f.bitrate!==g.bitrate?f.bitrate-g.bitrate:f.attrs["FRAME-RATE"]!==g.attrs["FRAME-RATE"]?f.attrs.decimalFloatingPoint("FRAME-RATE")-g.attrs.decimalFloatingPoint("FRAME-RATE"):f.attrs.SCORE!==g.attrs.SCORE?f.attrs.decimalFloatingPoint("SCORE")-g.attrs.decimalFloatingPoint("SCORE"):n&&f.height!==g.height?f.height-g.height:0);let c=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let f=0;f<d.length;f++)if(d[f].pathwayId===l[0].pathwayId){c=d[f];break}}this._levels=l;for(let f=0;f<l.length;f++)if(l[f]===c){this._firstLevel=f,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${c.bitrate}`);break}let u=o&&!a,h={levels:l,audioTracks:r,subtitleTracks:s,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:o,video:a,altAudio:!u&&r.some(f=>!!f.url)};this.hls.trigger(b.MANIFEST_PARSED,h),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(b.ERROR,{type:he.OTHER_ERROR,details:B.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,t.length-1)}let r=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,r===e&&a.details&&s&&n===o)return;this.log(`Switching to level ${e}${o?" with Pathway "+o:""} from level ${r}${n?" with Pathway "+n:""}`);let l=dt({},a,{level:e,maxBitrate:a.maxBitrate,attrs:a.attrs,uri:a.uri,urlId:a.urlId});delete l._attrs,delete l._urlId,this.hls.trigger(b.LEVEL_SWITCHING,l);let d=a.details;if(!d||d.live){let c=this.switchParams(a.uri,s==null?void 0:s.details);this.loadPlaylist(c)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){let e=this.hls.config.startLevel;return e!==void 0?e:this._firstLevel}else return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===Me.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(t!==void 0&&t.type===fe.MAIN){let r=this._levels[t.level];r!==void 0&&(r.loadError=0)}}onLevelLoaded(e,t){var r;let{level:s,details:n}=t,a=this._levels[s];if(!a){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):(r=t.deliveryDirectives)!=null&&r.skip&&(n.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,t){let r=this.currentLevel;if(!r)return;let s=this.hls.audioTracks[t.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==s){let n=-1;for(let a=0;a<r.audioGroupIds.length;a++)if(r.audioGroupIds[a]===s){n=a;break}n!==-1&&n!==r.urlId&&(r.urlId=n,this.canLoad&&this.startLoad())}}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.urlId,n=r.uri;if(e)try{n=e.addDirectives(n)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}let a=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${a?" Pathway "+a:""} URI ${s+1}/${r.url.length} ${n}`),this.clearTimer(),this.hls.trigger(b.LEVEL_LOADING,{url:n,level:t,id:s,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e,t){let r=(n,a)=>a!==t,s=this._levels.filter((n,a)=>a!==e?!0:n.url.length>1&&t!==void 0?(n.url=n.url.filter(r),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(r)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(r)),n.urlId=0,!0):(this.steering&&this.steering.removeLevel(n),!1));this.hls.trigger(b.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(e,{levels:t}){t.forEach((r,s)=>{let{details:n}=r;n!=null&&n.fragments&&n.fragments.forEach(a=>{a.level=s})}),this._levels=t}};function Yl(i,e,t){t&&(e==="audio"?(i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds[i.url.length-1]=t):e==="text"&&(i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds[i.url.length-1]=t))}function V0(i){let e={};i.forEach(t=>{let r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}var gt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Rh=class{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(b.BUFFER_APPENDED,this.onBufferAppended,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.BUFFER_APPENDED,this.onBufferAppended,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let r=this.activePartLists[t];if(r)for(let s=r.length;s--;){let n=r[s];if(!n)break;let a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){let{fragments:r}=this,s=Object.keys(r);for(let n=s.length;n--;){let a=r[s[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){let o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,r,s){this.timeRanges&&(this.timeRanges[e]=t);let n=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===r&&this.removeFragment(o.body);return}let l=o.range[e];l&&l.time.some(d=>{let c=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return c&&this.removeFragment(o.body),c})})}detectPartialFragments(e){let t=this.timeRanges,{frag:r,part:s}=e;if(!t||r.sn==="initSegment")return;let n=en(r),a=this.fragments[n];if(!a||a.buffered&&r.gap)return;let o=!r.relurl;Object.keys(t).forEach(l=>{let d=r.elementaryStreams[l];if(!d)return;let c=t[l],u=o||d.partial===!0;a.range[l]=this.getBufferedTimes(r,s,u,c)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=r.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),Cl(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}removeParts(e,t){let r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){let r=en(e),s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,r,s){let n={time:[],partial:r},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let c=0;c<s.length;c++){let u=s.start(c)-this.bufferPadding,h=s.end(c)+this.bufferPadding;if(d>=u&&l<=h){n.time.push({startPTS:Math.max(a,s.start(c)),endPTS:Math.min(o,s.end(c))});break}else if(a<h&&o>u)n.partial=!0,n.time.push({startPTS:Math.max(a,s.start(c)),endPTS:Math.min(o,s.end(c))});else if(o<=u)break}return n}getPartialFragment(e){let t=null,r,s,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let c=l[d];c&&Cl(c)&&(s=c.body.start-o,n=c.body.end+o,e>=s&&e<=n&&(r=Math.min(e-s,n-e),a<=r&&(t=c.body,a=r)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||Cl(t))}getState(e){let t=en(e),r=this.fragments[t];return r?r.buffered?Cl(r)?gt.PARTIAL:gt.OK:gt.APPENDING:gt.NOT_LOADED}isTimeBuffered(e,t,r){let s,n;for(let a=0;a<r.length;a++){if(s=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){let{frag:r,part:s}=t;if(r.sn==="initSegment"||r.bitrateTest)return;let n=s?null:t,a=en(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:r,part:s,timeRanges:n}=t;if(r.sn==="initSegment")return;let a=r.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n,Object.keys(n).forEach(o=>{let l=n[o];this.detectEvictedFragments(o,l,a,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=en(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,r,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let l=o.body;l.type!==r||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){let t=en(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let r=this.activePartLists[e.type];if(r){let s=e.sn;this.activePartLists[e.type]=r.filter(n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}};function Cl(i){var e,t,r;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function en(i){return`${i.type}_${i.level}_${i.urlId}_${i.sn}`}var K0=Math.pow(2,17),kh=class{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let r=e.url;if(!r)return Promise.reject(new yi({type:he.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(q0(e));return}else e.gap=!1;let d=this.loader=e.loader=n?new n(s):new a(s),c=W0(e),u=G0(s.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:K0};e.stats=d.stats,d.load(c,h,{onSuccess:(f,g,E,T)=>{this.resetLoader(e,d);let A=f.data;E.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(A.slice(0,16)),A=A.slice(16)),o({frag:e,part:null,payload:A,networkDetails:T})},onError:(f,g,E,T)=>{this.resetLoader(e,d),l(new yi({type:he.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:qt({url:r,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:E,stats:T}))},onAbort:(f,g,E)=>{this.resetLoader(e,d),l(new yi({type:he.NETWORK_ERROR,details:B.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:E,stats:f}))},onTimeout:(f,g,E)=>{this.resetLoader(e,d),l(new yi({type:he.NETWORK_ERROR,details:B.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:f}))},onProgress:(f,g,E,T)=>{t&&t({frag:e,part:null,payload:E,networkDetails:T})}})})}loadPart(e,t,r){this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(q0(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),c=W0(e,t),u=G0(s.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:K0};t.stats=d.stats,d.load(c,h,{onSuccess:(f,g,E,T)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);let A={frag:e,part:t,payload:f.data,networkDetails:T};r(A),o(A)},onError:(f,g,E,T)=>{this.resetLoader(e,d),l(new yi({type:he.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:qt({url:c.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:E,stats:T}))},onAbort:(f,g,E)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new yi({type:he.NETWORK_ERROR,details:B.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:E,stats:f}))},onTimeout:(f,g,E)=>{this.resetLoader(e,d),l(new yi({type:he.NETWORK_ERROR,details:B.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:f}))}})})}updateStatsFromPart(e,t){let r=e.stats,s=t.stats,n=s.total;if(r.loaded+=s.loaded,n){let l=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/n),l),u=(l-d)*Math.round(r.loaded/d);r.total=r.loaded+u}else r.total=Math.max(r.loaded,r.total);let a=r.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}};function W0(i,e=null){let t=e||i,r={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(oe(s)&&oe(n)){var a;let o=s,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){let d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(r.resetIV=!0,o=s-16)}r.rangeStart=o,r.rangeEnd=l}return r}function q0(i,e){let t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:he.MEDIA_ERROR,details:B.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(r.part=e),(e||i).stats.aborted=!0,new yi(r)}var yi=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},wh=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let t in this.keyUriToKeyInfo){let r=this.keyUriToKeyInfo[t].loader;if(r){if(e&&e!==r.context.frag.type)return;r.abort()}}}detach(){for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=B.KEY_LOAD_ERROR,r,s,n){return new yi({type:he.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:r,cc:s}=e;for(let n=0;n<t.length;n++){let a=t[n];if(s<=a.cc&&(r==="initSegment"||a.sn==="initSegment"||r<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,s;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,B.KEY_LOAD_ERROR,d))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,B.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((r=o)!=null&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,B.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){let r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,r))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(r)}loadKeyHTTP(e,t){let r=this.config,s=r.loader,n=new s(r);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=r.keyLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,E)=>{let{frag:T,keyInfo:A,url:R}=g;if(!T.decryptdata||A!==this.keyUriToKeyInfo[R])return o(this.createKeyLoadError(T,B.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),E));A.decryptdata.key=T.decryptdata.key=new Uint8Array(h.data),T.keyLoader=null,A.loader=null,a({frag:T,keyInfo:A})},onError:(h,f,g,E)=>{this.resetLoader(f),o(this.createKeyLoadError(t,B.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),g,qt({url:l.url,data:void 0},h)))},onTimeout:(h,f,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,B.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),g))},onAbort:(h,f,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,B.INTERNAL_ABORTED,new Error("key loading aborted"),g))}};n.load(l,c,u)})}resetLoader(e){let{frag:t,keyInfo:r,url:s}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}},Dh=class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}},WA={length:0,start:()=>0,end:()=>0},je=class i{static isBuffered(e,t){try{if(e){let r=i.getBuffered(e);for(let s=0;s<r.length;s++)if(t>=r.start(s)&&t<=r.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,r){try{if(e){let s=i.getBuffered(e),n=[],a;for(a=0;a<s.length;a++)n.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(n,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort(function(d,c){let u=d.start-c.start;return u||c.end-d.end});let s=[];if(r)for(let d=0;d<e.length;d++){let c=s.length;if(c){let u=s[c-1].end;e[d].start-u<r?e[d].end>u&&(s[c-1].end=e[d].end):s.push(e[d])}else s.push(e[d])}else s=e;let n=0,a,o=t,l=t;for(let d=0;d<s.length;d++){let c=s[d].start,u=s[d].end;if(t+r>=c&&t<u)o=c,l=u,n=l-t;else if(t+r<c){a=c;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return C.log("failed to get media.buffered",t),WA}}},ca=class{constructor(e,t,r,s=0,n=-1,a=!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=Ml(),this.buffering={audio:Ml(),video:Ml(),audiovideo:Ml()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=n,this.partial=a}};function Ml(){return{start:0,executeStart:0,executeEnd:0,end:0}}function kv(i,e){let t=null;for(let r=0,s=i.length;r<s;r++){let n=i[r];if(n&&n.cc===e){t=n;break}}return t}function qA(i,e,t){return!!(e.details&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function YA(i,e,t=0){let r=i.fragments,s=e.fragments;if(!s.length||!r.length){C.log("No fragments to align");return}let n=kv(r,s[0].cc);if(!n||n&&!n.startPTS){C.log("No frag in previous level to align on");return}return n}function Y0(i,e){if(i){let t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function Tf(i,e){let t=e.fragments;for(let r=0,s=t.length;r<s;r++)Y0(t[r],i);e.fragmentHint&&Y0(e.fragmentHint,i),e.alignedSliding=!0}function jA(i,e,t){e&&(zA(i,t,e),!t.alignedSliding&&e.details&&XA(t,e.details),!t.alignedSliding&&e.details&&!t.skippedSegments&&Iv(e.details,t))}function zA(i,e,t){if(qA(i,t,e)){let r=YA(t.details,e);r&&oe(r.start)&&(C.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),Tf(r.start,e))}}function XA(i,e){if(!e.fragments.length||!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=e.fragments[0].programDateTime,r=i.fragments[0].programDateTime,s=(r-t)/1e3+e.fragments[0].start;s&&oe(s)&&(C.log(`Adjusting PTS using programDateTime delta ${r-t}ms, sliding:${s.toFixed(3)} ${i.url} `),Tf(s,i))}function wv(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=i.fragments,r=e.fragments;if(!t.length||!r.length)return;let s=Math.round(r.length/2)-1,n=r[s],a=kv(t,n.cc)||t[Math.round(t.length/2)-1],o=n.programDateTime,l=a.programDateTime;if(o===null||l===null)return;let d=(l-o)/1e3-(a.start-n.start);Tf(d,i)}var Ch=class{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}},Mh=class{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}};function QA(i){let e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?Yr(i,0,e-t):i}var Ph=class{constructor(){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()}uint8ArrayToUint32Array_(e){let t=new DataView(e),r=new Uint32Array(4);for(let s=0;s<4;s++)r[s]=t.getUint32(s*4);return r}initTable(){let e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],n=r[1],a=r[2],o=r[3],l=this.invSubMix,d=l[0],c=l[1],u=l[2],h=l[3],f=new Uint32Array(256),g=0,E=0,T=0;for(T=0;T<256;T++)T<128?f[T]=T<<1:f[T]=T<<1^283;for(T=0;T<256;T++){let A=E^E<<1^E<<2^E<<3^E<<4;A=A>>>8^A&255^99,e[g]=A,t[A]=g;let R=f[g],L=f[R],N=f[L],M=f[A]*257^A*16843008;s[g]=M<<24|M>>>8,n[g]=M<<16|M>>>16,a[g]=M<<8|M>>>24,o[g]=M,M=N*16843009^L*65537^R*257^g*16843008,d[A]=M<<24|M>>>8,c[A]=M<<16|M>>>16,u[A]=M<<8|M>>>24,h[A]=M,g?(g=R^f[f[f[N^R]]],E^=f[f[E]]):g=E=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),r=!0,s=0;for(;s<t.length&&r;)r=t[s]===this.key[s],s++;if(r)return;this.key=t;let n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);let a=this.ksRows=(n+6+1)*4,o,l,d=this.keySchedule=new Uint32Array(a),c=this.invKeySchedule=new Uint32Array(a),u=this.sBox,h=this.rcon,f=this.invSubMix,g=f[0],E=f[1],T=f[2],A=f[3],R,L;for(o=0;o<a;o++){if(o<n){R=d[o]=t[o];continue}L=R,o%n===0?(L=L<<8|L>>>24,L=u[L>>>24]<<24|u[L>>>16&255]<<16|u[L>>>8&255]<<8|u[L&255],L^=h[o/n|0]<<24):n>6&&o%n===4&&(L=u[L>>>24]<<24|u[L>>>16&255]<<16|u[L>>>8&255]<<8|u[L&255]),d[o]=R=(d[o-n]^L)>>>0}for(l=0;l<a;l++)o=a-l,l&3?L=d[o]:L=d[o-4],l<4||o<=4?c[l]=L:c[l]=g[u[L>>>24]]^E[u[L>>>16&255]]^T[u[L>>>8&255]]^A[u[L&255]],c[l]=c[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,r){let s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],c=o[2],u=o[3],h=this.uint8ArrayToUint32Array_(r),f=h[0],g=h[1],E=h[2],T=h[3],A=new Int32Array(e),R=new Int32Array(A.length),L,N,M,$,U,H,W,O,z,Y,ye,Ee,be,ke,Se=this.networkToHostOrderSwap;for(;t<A.length;){for(z=Se(A[t]),Y=Se(A[t+1]),ye=Se(A[t+2]),Ee=Se(A[t+3]),U=z^n[0],H=Ee^n[1],W=ye^n[2],O=Y^n[3],be=4,ke=1;ke<s;ke++)L=l[U>>>24]^d[H>>16&255]^c[W>>8&255]^u[O&255]^n[be],N=l[H>>>24]^d[W>>16&255]^c[O>>8&255]^u[U&255]^n[be+1],M=l[W>>>24]^d[O>>16&255]^c[U>>8&255]^u[H&255]^n[be+2],$=l[O>>>24]^d[U>>16&255]^c[H>>8&255]^u[W&255]^n[be+3],U=L,H=N,W=M,O=$,be=be+4;L=a[U>>>24]<<24^a[H>>16&255]<<16^a[W>>8&255]<<8^a[O&255]^n[be],N=a[H>>>24]<<24^a[W>>16&255]<<16^a[O>>8&255]<<8^a[U&255]^n[be+1],M=a[W>>>24]<<24^a[O>>16&255]<<16^a[U>>8&255]<<8^a[H&255]^n[be+2],$=a[O>>>24]<<24^a[U>>16&255]<<16^a[H>>8&255]<<8^a[W&255]^n[be+3],R[t]=Se(L^f),R[t+1]=Se($^g),R[t+2]=Se(M^E),R[t+3]=Se(N^T),f=z,g=Y,E=ye,T=Ee,t=t+4}return R.buffer}},ZA=16,ua=class{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?QA(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,r);let a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){let{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=jr(a,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Ph),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=Yr(o,-16).buffer,d||null}webCryptoDecrypt(e,t,r){let s=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new Mh(s,t)),this.fastAesKey.expandKey().then(n=>s?(this.logOnce("WebCrypto AES decrypt"),new Ch(s,new Uint8Array(r)).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(C.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);let s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,r=e.length-e.length%ZA;return r!==e.length&&(t=Yr(e,0,r),this.remainderData=Yr(e,r)),t}logOnce(e){this.logEnabled&&(C.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},JA={toString:function(i){let e="",t=i.length;for(let r=0;r<t;r++)e+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return e}},V={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"},ha=class extends Dh{constructor(e,t,r,s,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=V.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=C.log.bind(C,`${s}:`),this.warn=C.warn.bind(C,`${s}:`),this.hls=e,this.fragmentLoader=new kh(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new ua(e.config),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=V.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;let r=t.partList;if(r!=null&&r.length){let n=r[r.length-1];return je.isBuffered(this.media,n.start+n.duration/2)}let s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levels[this.levelLastLoaded])==null?void 0:e.details}}onMediaAttached(e,t){let r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);let s=this.config;this.levels&&s.autoStartLoad&&this.state===V.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){let e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){let{config:e,fragCurrent:t,media:r,mediaBuffer:s,state:n}=this,a=r?r.currentTime:0,o=je.bufferInfo(s||r,a,e.maxBufferHole);if(this.log(`media seeking to ${oe(a)?a.toFixed(3):a}, state: ${n}`),this.state===V.ENDED)this.resetLoadingState();else if(t){let l=e.maxFragLookUpTolerance,d=t.start-l,c=t.start+t.duration+l;if(!o.len||c<o.start||d>o.end){let u=a>c;(a<d||u)&&(u&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=V.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){let s=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,r,s).then(n=>{if(!n)return;let a=this.state;if(this.fragContextChanged(e)){(a===V.FRAG_LOADING||!this.fragCurrent&&a===V.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=V.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(b.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===V.STOPPED||this.state===V.ERROR||(this.warn(n),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:r}=this;if(r.getState(e)===gt.APPENDING){let n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength);this.reduceMaxBufferLength(o)&&r.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===gt.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;let s={startOffset:e,endOffset:t,type:r};this.hls.trigger(b.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(r=>{if(!r||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{let{hls:s}=this,{payload:n}=r,a=e.decryptdata;if(n&&n.byteLength>0&&a&&a.key&&a.iv&&a.method==="AES-128"){let o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw s.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{let d=self.performance.now();return s.trigger(b.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),r.payload=l,r})}return r}).then(r=>{let{fragCurrent:s,hls:n,levels:a}=this;if(!a)throw new Error("init load aborted, missing levels");let o=e.stats;this.state=V.IDLE,t.fragmentError=0,e.data=new Uint8Array(r.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),r.frag===s&&n.trigger(b.FRAG_BUFFERED,{stats:o,frag:s,part:null,id:e.type}),this.tick()}).catch(r=>{this.state===V.STOPPED||this.state===V.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var r,s,n,a;let o=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===fe.MAIN?"level":"track"} ${e.level} (frag:[${((r=e.startPTS)!=null?r:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?JA.toString(je.getBuffered(o)):"(detached)"})`),this.state=V.IDLE,o&&(!this.loadedmetadata&&e.type==fe.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:r,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new ca(r.level,r.sn,r.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,s){var n;let a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=V.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(c=>{if(!this.fragContextChanged(c.frag))return this.hls.trigger(b.KEY_LOADED,c),this.state===V.KEY_LOADING&&(this.state=V.IDLE),c}),this.hls.trigger(b.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let c=a.partList;if(c&&s){r>e.end&&a.fragmentHint&&(e=a.fragmentHint);let u=this.getNextPart(c,e,r);if(u>-1){let h=c[u];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${u}-${c.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=V.FRAG_LOADING;let f;return o?f=o.then(g=>!g||this.fragContextChanged(g.frag)?null:this.doFragPartsLoad(e,h,t,s)).catch(g=>this.handleFragLoadError(g)):f=this.doFragPartsLoad(e,h,t,s).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(b.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(c,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),oe(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=V.FRAG_LOADING;let l=this.config.progressive,d;return l&&o?d=o.then(c=>!c||this.fragContextChanged(c==null?void 0:c.frag)?null:this.fragmentLoader.load(e,s)).catch(c=>this.handleFragLoadError(c)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([c])=>(!l&&c&&s&&s(c),c)).catch(c=>this.handleFragLoadError(c)),this.hls.trigger(b.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,s){return new Promise((n,a)=>{var o;let l=[],d=(o=r.details)==null?void 0:o.partList,c=u=>{this.fragmentLoader.loadPart(e,u,s).then(h=>{l[u.index]=h;let f=h.part;this.hls.trigger(b.FRAG_LOADED,h);let g=$0(r,e.sn,u.index+1)||Lv(d,e.sn,u.index+1);if(g)c(g);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};c(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===B.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(b.ERROR,t)}else this.hls.trigger(b.ERROR,{type:he.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==V.PARSING){!this.fragCurrent&&this.state!==V.STOPPED&&this.state!==V.ERROR&&(this.state=V.IDLE);return}let{frag:r,part:s,level:n}=t,a=self.performance.now();r.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(r,s,n,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:r}=this,{level:s,sn:n,part:a}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${s}. The current chunk will not be buffered.`),null;let o=t[s],l=a>-1?$0(o,n,a):null,d=l?l.fragment:FA(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,r,s,n){var a;if(!e||this.state!==V.PARSING)return;let{data1:o,data2:l}=e,d=o;if(o&&l&&(d=jr(o,l)),!((a=d)!=null&&a.length))return;let c={type:e.type,frag:t,part:r,chunkMeta:s,parent:t.type,data:d};if(this.hls.trigger(b.BUFFER_APPENDING,c),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!je.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let r=t.currentTime,s=je.bufferInfo(t,r,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){let r=this.getLoadPosition();return oe(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){let{config:{maxBufferHole:s}}=this,n=je.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return je.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){let{config:t}=this,r;return e?r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):r=t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e){let t=this.config,r=e||t.maxBufferLength;return t.maxMaxBufferLength>=r?(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,t=fe.MAIN){let r=this.fragmentTracker.getAppendedFrag(e,fe.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){let r=t.fragments,s=r.length;if(!s)return null;let{config:n}=this,a=r[0].start,o;if(t.live){let l=n.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(o=this.getInitialLiveFragment(t,r),this.startPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=r[0]);if(!o){let l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){let r=this.fragmentTracker.getState(e);return(r===gt.OK||r===gt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,s,n){let a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&r.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,s);if(l!==null&&r.len+l.len>=n)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,r){let s=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){let d=e[o];if(a=a&&!d.independent,s>-1&&r<d.start)break;let c=d.loaded;c?s=-1:(n||d.independent||a)&&d.fragment===t&&(s=o),n=c}return s}loadedEndOfParts(e,t){let r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){let r=this.fragPrevious,s=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),s=$A(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){let n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];r.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=GA(t,r.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{let n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){let{config:s}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=r,{fragmentHint:l}=r,d=s.maxFragLookUpTolerance,c=r.partList,u=!!(s.lowLatencyMode&&c!=null&&c.length&&l);u&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){let f=e>t-d?0:d;h=la(n,a,e,f)}else h=a[a.length-1];if(h){let f=h.sn-r.startSN,g=this.fragmentTracker.getState(h);if((g===gt.OK||g===gt.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!u||c[0].fragment.sn>h.sn)&&n&&h.level===n.level){let T=a[f+1];h.sn<o&&this.fragmentTracker.getState(T)!==gt.OK?h=T:h=null}}return h}synchronizeToLiveEdge(e){let{config:t,media:r}=this;if(!r)return;let s=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&r.duration>s&&(n<s||!l)){let d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),r.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),r.currentTime=s))}}alignPlaylists(e,t){let{levels:r,levelLastLoaded:s,fragPrevious:n}=this,a=s!==null?r[s]:null,o=e.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;let l=e.fragments[0].start,d=!t,c=e.alignedSliding&&oe(l);if(d||!c&&!l){jA(n,a,e);let u=e.fragments[0].start;return this.log(`Live playlist sliding: ${u.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${n?n.sn:"na"} fragments: ${o}`),u}return l}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),r===-1||this.lastCurrentTime===-1){let s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&oe(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){let{media:e}=this,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==V.FRAG_LOADING_WAITING_RETRY)&&(this.state=V.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let u=this.getCurrentContext(t.chunkMeta);u&&(t.frag=u.frag)}let r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var s;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}let n=t.details===B.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(r,!0);let a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===Lt.RetryRequest&&d){var c;this.resetStartWhenNotLoaded((c=this.levelLastLoaded)!=null?c:r.level);let u=yf(d,l);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${u}ms`),a.resolved=!0,this.retryDate=self.performance.now()+u,this.state=V.FRAG_LOADING_WAITING_RETRY}else d&&a?(this.resetFragmentErrors(e),l<d.maxNumRetry?n||(a.resolved=!0):C.warn(`${t.details} reached or exceeded max retry (${l})`)):(a==null?void 0:a.action)===Lt.SendAlternateToPenaltyBox?this.state=V.WAITING_LEVEL:this.state=V.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===V.PARSING||this.state===V.PARSED){let t=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,t),s=r&&r.len>.5;s&&this.reduceMaxBufferLength(r.len);let n=!s;return n&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===fe.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==V.STOPPED&&(this.state=V.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;let s=je.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,r),this.state===V.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=V.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;let t=this.levels?this.levels[e].details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){var t;this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((t=this.levelLastLoaded)!=null?t:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,s){var n;let a=r.details;if(!a){this.warn("level.details undefined");return}if(Object.keys(e.elementaryStreams).reduce((l,d)=>{let c=e.elementaryStreams[d];if(c){let u=c.endPTS-c.startPTS;if(u<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${u})`),l||!1;let h=s?0:xv(a,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS);return this.hls.trigger(b.LEVEL_PTS_UPDATED,{details:a,level:r,drift:h,type:d,frag:e,start:c.startPTS,end:c.endPTS}),!0}return l},!1))r.fragmentError=0;else if(((n=this.transmuxer)==null?void 0:n.error)===null){let l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=V.PARSED,this.hls.trigger(b.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){if(e.event==="demuxerWorker"){var t,r,s;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((t=(r=this.levelLastLoaded)!=null?r:(s=this.fragCurrent)==null?void 0:s.level)!=null?t:0),this.resetLoadingState()}}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}};function Dv(){return self.SourceBuffer||self.WebKitSourceBuffer}function e1(){let i=dd();if(!i)return!1;let e=Dv(),t=i&&typeof i.isTypeSupported=="function"&&i.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),r=!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function";return!!t&&!!r}function t1(){var i;let e=Dv();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}function i1(){return typeof __HLS_WORKER_BUNDLE__=="function"}function r1(){let i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function s1(i){let e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function $i(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var jl=class{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=jr(this.cachedData,e),this.cachedData=null);let r=Gl(e,0),s=r?r.length:0,n,a=this._audioTrack,o=this._id3Track,l=r?Z_(r):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&oe(l))&&(this.basePTS=n1(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ti.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){let c=this.appendFrame(a,e,s);c?(this.frameIndex++,this.lastPTS=c.sample.pts,s+=c.length,n=s):s=d}else Q_(e,s)?(r=Gl(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ti.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,n=s):s++;if(s===d&&n!==d){let c=Yr(e,n);this.cachedData?this.cachedData=jr(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:$i(),id3Track:o,textTrack:$i()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:$i(),id3Track:this._id3Track,textTrack:$i()}}destroy(){}},n1=(i,e,t)=>{if(oe(i))return i*90;let r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function a1(i,e,t,r){let s,n,a,o,l=navigator.userAgent.toLowerCase(),d=r,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;let u=(e[t+2]&60)>>>2;if(u>c.length-1){i.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${u}`});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,C.log(`manifest codec:${r}, ADTS type:${s}, samplingIndex:${u}`),/firefox/i.test(l)?u>=6?(s=5,o=new Array(4),n=u-3):(s=2,o=new Array(2),n=u):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=u):(s=5,o=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&u>=6?n=u-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(u>=6&&a===1||/vivaldi/i.test(l))||!r&&a===1)&&(s=2,o=new Array(2)),n=u)),o[0]=s<<3,o[0]|=(u&14)>>1,o[1]|=(u&1)<<7,o[1]|=a<<3,s===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:c[u],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d}}function Cv(i,e){return i[e]===255&&(i[e+1]&246)===240}function Mv(i,e){return i[e+1]&1?7:9}function _f(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function o1(i,e){return e+5<i.length}function zl(i,e){return e+1<i.length&&Cv(i,e)}function l1(i,e){return o1(i,e)&&Cv(i,e)&&_f(i,e)<=i.length-e}function d1(i,e){if(zl(i,e)){let t=Mv(i,e);if(e+t>=i.length)return!1;let r=_f(i,e);if(r<=t)return!1;let s=e+r;return s===i.length||zl(i,s)}return!1}function Pv(i,e,t,r,s){if(!i.samplerate){let n=a1(e,t,r,s);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,C.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Ov(i){return 1024*9e4/i}function c1(i,e){let t=Mv(i,e);if(e+t<=i.length){let r=_f(i,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function Nv(i,e,t,r,s){let n=Ov(i.samplerate),a=r+s*n,o=c1(e,t),l;if(o){let{frameLength:u,headerLength:h}=o,f=h+u,g=Math.max(0,t+f-e.length);g?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);let E={unit:l,pts:a};return g||i.samples.push(E),{sample:E,length:f,missing:g}}let d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}var Oh=class extends jl{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let r=(Gl(e,0)||[]).length;for(let s=e.length;r<s;r++)if(d1(e,r))return C.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return l1(e,t)}appendFrame(e,t,r){Pv(e,this.observer,t,r,e.manifestCodec);let s=Nv(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},u1=/\/emsg[-/]ID3/i,Nh=class{constructor(e,t){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=t}resetTimeStamp(){}resetInitSegment(e,t,r,s){let n=this.videoTrack=$i("video",1),a=this.audioTrack=$i("audio",1),o=this.txtTrack=$i("text",1);if(this.id3Track=$i("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=Ev(e);if(l.video){let{id:d,timescale:c,codec:u}=l.video;n.id=d,n.timescale=o.timescale=c,n.codec=u}if(l.audio){let{id:d,timescale:c,codec:u}=l.audio;a.id=d,a.timescale=c,a.codec=u}o.id=pv.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return e=e.length>16384?e.subarray(0,16384):e,Ce(e,["moof"]).length>0}demux(e,t){this.timeOffset=t;let r=e,s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=jr(this.remainderData,e));let o=fA(r);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=r;let a=this.extractID3Track(s,t);return n.samples=I0(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(t,this.timeOffset);return r.samples=I0(e,t),{videoTrack:t,audioTrack:$i(),id3Track:s,textTrack:$i()}}extractID3Track(e,t){let r=this.id3Track;if(e.samples.length){let s=Ce(e.samples,["emsg"]);s&&s.forEach(n=>{let a=gA(n);if(u1.test(a.schemeIdUri)){let o=oe(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale,l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);let d=a.payload;r.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:Ti.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},Pl=null,h1=[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],f1=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],m1=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],p1=[0,1,1,4];function Uv(i,e,t,r,s){if(t+24>e.length)return;let n=Fv(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=r+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function Fv(i,e){let t=i[e+1]>>3&3,r=i[e+1]>>1&3,s=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){let a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-r:r===3?3:4,d=h1[l*14+s-1]*1e3,u=f1[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=m1[t][r],g=p1[r],E=f*8*g,T=Math.floor(f*d/u+a)*g;if(Pl===null){let L=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Pl=L?parseInt(L[1]):0}return!!Pl&&Pl<=87&&r===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:u,channelCount:h,frameLength:T,samplesPerFrame:E}}}function Af(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function Bv(i,e){return e+1<i.length&&Af(i,e)}function g1(i,e){return Af(i,e)&&4<=i.length-e}function v1(i,e){if(e+1<i.length&&Af(i,e)){let r=Fv(i,e),s=4;r!=null&&r.frameLength&&(s=r.frameLength);let n=e+s;return n===i.length||Bv(i,n)}return!1}var Xl=class{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){let e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(r,r+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&C.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8,s;for(let n=0;n<e;n++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r}readSPS(){let e=0,t=0,r=0,s=0,n,a,o,l=this.readUByte.bind(this),d=this.readBits.bind(this),c=this.readUEG.bind(this),u=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),g=this.skipUEG.bind(this),E=this.skipScalingList.bind(this);l();let T=l();if(d(5),h(3),l(),g(),T===100||T===110||T===122||T===244||T===44||T===83||T===86||T===118||T===128){let $=c();if($===3&&h(1),g(),g(),h(1),u())for(a=$!==3?8:12,o=0;o<a;o++)u()&&(o<6?E(16):E(64))}g();let A=c();if(A===0)c();else if(A===1)for(h(1),f(),f(),n=c(),o=0;o<n;o++)f();g(),h(1);let R=c(),L=c(),N=d(1);N===0&&h(1),h(1),u()&&(e=c(),t=c(),r=c(),s=c());let M=[1,1];if(u()&&u())switch(l()){case 1:M=[1,1];break;case 2:M=[12,11];break;case 3:M=[10,11];break;case 4:M=[16,11];break;case 5:M=[40,33];break;case 6:M=[24,11];break;case 7:M=[20,11];break;case 8:M=[32,11];break;case 9:M=[80,33];break;case 10:M=[18,11];break;case 11:M=[15,11];break;case 12:M=[64,33];break;case 13:M=[160,99];break;case 14:M=[4,3];break;case 15:M=[3,2];break;case 16:M=[2,1];break;case 255:{M=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((R+1)*16-e*2-t*2),height:(2-N)*(L+1)*16-(N?2:4)*(r+s),pixelRatio:M}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},Uh=class{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new ua(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){let s=e[t].unit;if(s.length<=16)return;let n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)r.set(e.subarray(n,n+16),s);return r}getAvcDecryptedUnit(e,t){let r=new Uint8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(r.subarray(s,s+16),n);return e}decryptAvcSample(e,t,r,s,n){let a=Tv(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,s)})}decryptAvcSamples(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}let n=e[t].units;for(;!(r>=n.length);r++){let a=n[r];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,r,s,a),!this.decrypter.isSync()))return}}}},It=188,Fh=class i{constructor(e,t,r){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=e,this.config=t,this.typeSupported=r}static probe(e){let t=i.syncOffset(e);return t>0&&C.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){let t=e.length,r=Math.min(It*5,e.length-It)+1,s=0;for(;s<r;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=It)if(e[l]===71){if(o++,a===-1&&(a=l,a!==0&&(r=Math.min(a+It*99,e.length-It)+1)),n||(n=Bh(e,l)===0),n&&o>1&&(a===0&&o>2||l+It>r))return a}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:pv[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=i.createTrack("video"),this._audioTrack=i.createTrack("audio",s),this._id3Track=i.createTrack("id3"),this._txtTrack=i.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_avcTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,t,r=!1,s=!1){r||(this.sampleAes=null);let n,a=this._avcTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack,c=a.pid,u=a.pesData,h=o.pid,f=l.pid,g=o.pesData,E=l.pesData,T=null,A=this.pmtParsed,R=this._pmtId,L=e.length;if(this.remainderData&&(e=jr(this.remainderData,e),L=e.length,this.remainderData=null),L<It&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let N=Math.max(0,i.syncOffset(e));L-=(L-N)%It,L<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));let M=0;for(let U=N;U<L;U+=It)if(e[U]===71){let H=!!(e[U+1]&64),W=Bh(e,U),O=(e[U+3]&48)>>4,z;if(O>1){if(z=U+5+e[U+4],z===U+It)continue}else z=U+4;switch(W){case c:H&&(u&&(n=tn(u))&&this.parseAVCPES(a,d,n,!1),u={data:[],size:0}),u&&(u.data.push(e.subarray(z,U+It)),u.size+=U+It-z);break;case h:if(H){if(g&&(n=tn(g)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break}g={data:[],size:0}}g&&(g.data.push(e.subarray(z,U+It)),g.size+=U+It-z);break;case f:H&&(E&&(n=tn(E))&&this.parseID3PES(l,n),E={data:[],size:0}),E&&(E.data.push(e.subarray(z,U+It)),E.size+=U+It-z);break;case 0:H&&(z+=e[z]+1),R=this._pmtId=E1(e,z);break;case R:{H&&(z+=e[z]+1);let Y=b1(e,z,this.typeSupported,r);c=Y.avc,c>0&&(a.pid=c),h=Y.audio,h>0&&(o.pid=h,o.segmentCodec=Y.segmentCodec),f=Y.id3,f>0&&(l.pid=f),T!==null&&!A&&(C.warn(`MPEG-TS PMT found at ${U} after unknown PID '${T}'. Backtracking to sync byte @${N} to parse all TS packets.`),T=null,U=N-188),A=this.pmtParsed=!0;break}case 17:case 8191:break;default:T=W;break}}else M++;if(M>0){let U=new Error(`Found ${M} TS packet/s that do not start with 0x47`);this.observer.emit(b.ERROR,b.ERROR,{type:he.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:U,reason:U.message})}a.pesData=u,o.pesData=g,l.pesData=E;let $={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples($),$}flush(){let{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){let{audioTrack:t,videoTrack:r,id3Track:s,textTrack:n}=e,a=r.pesData,o=t.pesData,l=s.pesData,d;if(a&&(d=tn(a))?(this.parseAVCPES(r,n,d,!0),r.pesData=null):r.pesData=a,o&&(d=tn(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break}t.pesData=null}else o!=null&&o.size&&C.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=tn(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){let s=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new Uh(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(r=>{let{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAVCPES(e,t,r,s){let n=this.parseAVCNALu(e,r.data),a=this.avcSample,o,l=!1;r.data=null,a&&n.length&&!e.audFound&&(ea(a,e),a=this.avcSample=Ol(!1,r.pts,r.dts,"")),n.forEach(d=>{var c;switch(d.type){case 1:{let h=!1;o=!0;let f=d.data;if(l&&f.length>4){let g=new Xl(f).readSliceType();(g===2||g===4||g===7||g===9)&&(h=!0)}if(h){var u;(u=a)!=null&&u.frame&&!a.key&&(ea(a,e),a=this.avcSample=null)}a||(a=this.avcSample=Ol(!0,r.pts,r.dts,"")),a.frame=!0,a.key=h;break}case 5:o=!0,(c=a)!=null&&c.frame&&!a.key&&(ea(a,e),a=this.avcSample=null),a||(a=this.avcSample=Ol(!0,r.pts,r.dts,"")),a.key=!0,a.frame=!0;break;case 6:{o=!0,yv(d.data,1,r.pts,t.samples);break}case 7:if(o=!0,l=!0,!e.sps){let h=d.data,g=new Xl(h).readSPS();e.width=g.width,e.height=g.height,e.pixelRatio=g.pixelRatio,e.sps=[h],e.duration=this._duration;let E=h.subarray(1,4),T="avc1.";for(let A=0;A<3;A++){let R=E[A].toString(16);R.length<2&&(R="0"+R),T+=R}e.codec=T}break;case 8:o=!0,e.pps||(e.pps=[d.data]);break;case 9:o=!1,e.audFound=!0,a&&ea(a,e),a=this.avcSample=Ol(!1,r.pts,r.dts,"");break;case 12:o=!0;break;default:o=!1,a&&(a.debug+="unknown NAL "+d.type+" ");break}a&&o&&a.units.push(d)}),s&&a&&(ea(a,e),this.avcSample=null)}getLastNalUnit(e){var t;let r=this.avcSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){let n=r.units;s=n[n.length-1]}return s}parseAVCNALu(e,t){let r=t.byteLength,s=e.naluState||0,n=s,a=[],o=0,l,d,c,u=-1,h=0;for(s===-1&&(u=0,h=t[0]&31,s=0,o=1);o<r;){if(l=t[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(u>=0){let f={data:t.subarray(u,o-s-1),type:h};a.push(f)}else{let f=this.getLastNalUnit(e.samples);if(f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d=o-s-1,d>0)){let g=new Uint8Array(f.data.byteLength+d);g.set(f.data,0),g.set(t.subarray(0,d),f.data.byteLength),f.data=g,f.state=0}}o<r?(c=t[o]&31,u=o,h=c,s=0):s=-1}else s=0}if(u>=0&&s>=0){let f={data:t.subarray(u,r),type:h,state:s};a.push(f)}if(a.length===0){let f=this.getLastNalUnit(e.samples);if(f){let g=new Uint8Array(f.data.byteLength+t.byteLength);g.set(f.data,0),g.set(t,f.data.byteLength),f.data=g}}return e.naluState=s,a}parseAACPES(e,t){let r=0,s=this.aacOverFlow,n=t.data;if(s){this.aacOverFlow=null;let u=s.missing,h=s.sample.unit.byteLength;if(u===-1){let f=new Uint8Array(h+n.byteLength);f.set(s.sample.unit,0),f.set(n,h),n=f}else{let f=h-u;s.sample.unit.set(n.subarray(0,u),f),e.samples.push(s.sample),r=s.missing}}let a,o;for(a=r,o=n.length;a<o-1&&!zl(n,a);a++);if(a!==r){let u,h=a<o-1;h?u=`AAC PES did not start with ADTS header,offset:${a}`:u="No ADTS header found in AAC PES";let f=new Error(u);if(C.warn(`parsing error: ${u}`),this.observer.emit(b.ERROR,b.ERROR,{type:he.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,levelRetry:h,error:f,reason:u}),!h)return}Pv(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let u=Ov(e.samplerate);l=s.sample.pts+u}else{C.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,c;for(;a<o;)if(c=Nv(e,n,a,l,d),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(d++;a<o-1&&!zl(n,a);a++);}parseMPEGPES(e,t){let r=t.data,s=r.length,n=0,a=0,o=t.pts;if(o===void 0){C.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(Bv(r,a)){let l=Uv(e,r,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseID3PES(e,t){if(t.pts===void 0){C.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let r=dt({},t,{type:this._avcTrack?Ti.emsg:Ti.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}};function Ol(i,e,t,r){return{key:i,frame:!1,pts:e,dts:t,units:[],debug:r,length:0}}function Bh(i,e){return((i[e+1]&31)<<8)+i[e+2]}function E1(i,e){return(i[e+10]&31)<<8|i[e+11]}function b1(i,e,t,r){let s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=(i[e+1]&15)<<8|i[e+2],a=e+3+n-4,o=(i[e+10]&15)<<8|i[e+11];for(e+=12+o;e<a;){let l=Bh(i,e);switch(i[e]){case 207:if(!r){C.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:s.audio===-1&&(s.audio=l);break;case 21:s.id3===-1&&(s.id3=l);break;case 219:if(!r){C.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:s.avc===-1&&(s.avc=l);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?C.log("MPEG audio found, not supported in this browser"):s.audio===-1&&(s.audio=l,s.segmentCodec="mp3");break;case 36:C.warn("Unsupported HEVC stream type found");break}e+=((i[e+3]&15)<<8|i[e+4])+5}return s}function tn(i){let e=0,t,r,s,n,a,o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;){let d=new Uint8Array(o[0].length+o[1].length);d.set(o[0]),d.set(o[1],o[0].length),o[0]=d,o.splice(1,1)}if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(r=(t[4]<<8)+t[5],r&&r>i.size-6)return null;let d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(C.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=t[8];let c=s+9;if(i.size<=c)return null;i.size-=c;let u=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let g=t.byteLength;if(c)if(c>g){c-=g;continue}else t=t.subarray(c),g-=c,c=0;u.set(t,e),e+=g}return r&&(r-=s+3),{data:u,pts:n,dts:a,len:r}}return null}function ea(i,e){if(i.units.length&&i.frame){if(i.pts===void 0){let t=e.samples,r=t.length;if(r){let s=t[r-1];i.pts=s.pts,i.dts=s.dts}else{e.dropped++;return}}e.samples.push(i)}i.debug.length&&C.log(i.pts+"/"+i.dts+":"+i.debug)}var $h=class extends jl{resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let r=(Gl(e,0)||[]).length;for(let s=e.length;r<s;r++)if(v1(e,r))return C.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return g1(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return Uv(e,t,r,this.basePTS,this.frameIndex)}},Ql=class{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===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(t===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(t===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(t===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(t===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}}},pr=Math.pow(2,32)-1,lt=class i{static init(){i.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:[]};let e;for(e in i.types)i.types.hasOwnProperty(e)&&(i.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=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]),r=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]);i.HDLR_TYPES={video:t,audio:r};let s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);i.STTS=i.STSC=i.STCO=n,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);i.FTYP=i.box(i.types.ftyp,a,l,a,o),i.DINF=i.box(i.types.dinf,i.box(i.types.dref,s))}static box(e,...t){let r=8,s=t.length,n=s;for(;s--;)r+=t[s].byteLength;let a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=r&255,a.set(e,4),s=0,r=8;s<n;s++)a.set(t[s],r),r+=t[s].byteLength;return a}static hdlr(e){return i.box(i.types.hdlr,i.HDLR_TYPES[e])}static mdat(e){return i.box(i.types.mdat,e)}static mdhd(e,t){t*=e;let r=Math.floor(t/(pr+1)),s=Math.floor(t%(pr+1));return i.box(i.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return i.box(i.types.mdia,i.mdhd(e.timescale,e.duration),i.hdlr(e.type),i.minf(e))}static mfhd(e){return i.box(i.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?i.box(i.types.minf,i.box(i.types.smhd,i.SMHD),i.DINF,i.stbl(e)):i.box(i.types.minf,i.box(i.types.vmhd,i.VMHD),i.DINF,i.stbl(e))}static moof(e,t,r){return i.box(i.types.moof,i.mfhd(e),i.traf(r,t))}static moov(e){let t=e.length,r=[];for(;t--;)r[t]=i.trak(e[t]);return i.box.apply(null,[i.types.moov,i.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(i.mvex(e)))}static mvex(e){let t=e.length,r=[];for(;t--;)r[t]=i.trex(e[t]);return i.box.apply(null,[i.types.mvex,...r])}static mvhd(e,t){t*=e;let r=Math.floor(t/(pr+1)),s=Math.floor(t%(pr+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&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 i.box(i.types.mvhd,n)}static sdtp(e){let t=e.samples||[],r=new Uint8Array(4+t.length),s,n;for(s=0;s<t.length;s++)n=t[s].flags,r[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return i.box(i.types.sdtp,r)}static stbl(e){return i.box(i.types.stbl,i.stsd(e),i.box(i.types.stts,i.STTS),i.box(i.types.stsc,i.STSC),i.box(i.types.stsz,i.STSZ),i.box(i.types.stco,i.STCO))}static avc1(e){let t=[],r=[],s,n,a;for(s=0;s<e.sps.length;s++)n=e.sps[s],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],a=n.byteLength,r.push(a>>>8&255),r.push(a&255),r=r.concat(Array.prototype.slice.call(n));let o=i.box(i.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(r))),l=e.width,d=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return i.box(i.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,l>>8&255,l&255,d>>8&255,d&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]),o,i.box(i.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),i.box(i.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,c&255,u>>24,u>>16&255,u>>8&255,u&255])))}static esds(e){let t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static mp4a(e){let t=e.samplerate;return i.box(i.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]),i.box(i.types.esds,i.esds(e)))}static mp3(e){let t=e.samplerate;return i.box(i.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?i.box(i.types.stsd,i.STSD,i.mp3(e)):i.box(i.types.stsd,i.STSD,i.mp4a(e)):i.box(i.types.stsd,i.STSD,i.avc1(e))}static tkhd(e){let t=e.id,r=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(r/(pr+1)),o=Math.floor(r%(pr+1));return i.box(i.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&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,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){let r=i.sdtp(e),s=e.id,n=Math.floor(t/(pr+1)),a=Math.floor(t%(pr+1));return i.box(i.types.traf,i.box(i.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),i.box(i.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),i.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,i.box(i.types.trak,i.tkhd(e),i.mdia(e))}static trex(e){let t=e.id;return i.box(i.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let r=e.samples||[],s=r.length,n=12+16*s,a=new Uint8Array(n),o,l,d,c,u,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=r[o],d=l.duration,c=l.size,u=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,u.degradPrio&61440,u.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return i.box(i.types.trun,a)}static initSegment(e){i.types||i.init();let t=i.moov(e),r=new Uint8Array(i.FTYP.byteLength+t.byteLength);return r.set(i.FTYP),r.set(t,i.FTYP.byteLength),r}};lt.types=void 0;lt.HDLR_TYPES=void 0;lt.STTS=void 0;lt.STSC=void 0;lt.STCO=void 0;lt.STSZ=void 0;lt.VMHD=void 0;lt.SMHD=void 0;lt.STSD=void 0;lt.FTYP=void 0;lt.DINF=void 0;var $v=9e4;function Sf(i,e,t=1,r=!1){let s=i*e*t;return r?Math.round(s):s}function y1(i,e,t=1,r=!1){return Sf(i,e,1/t,r)}function ta(i,e=!1){return Sf(i,1e3,1/$v,e)}function T1(i,e=1){return Sf(i,$v,1/e)}var _1=10*1e3,j0=1024,A1=1152,Nl=null,ih=null,na=class{constructor(e,t,r,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,Nl===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Nl=a?parseInt(a[1]):0}if(ih===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);ih=n?parseInt(n[1]):0}}destroy(){}resetTimeStamp(e){C.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){C.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){C.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let t=!1,r=e.reduce((s,n)=>{let a=n.pts-s;return a<-4294967296?(t=!0,oi(s,n.pts)):a>0?s:n.pts},e[0].pts);return t&&C.debug("PTS rollover detected"),r}remux(e,t,r,s,n,a,o,l){let d,c,u,h,f,g,E=n,T=n,A=e.pid>-1,R=t.pid>-1,L=t.samples.length,N=e.samples.length>0,M=o&&L>0||L>1;if((!A||N)&&(!R||M)||this.ISGenerated||o){this.ISGenerated||(u=this.generateIS(e,t,n,a));let U=this.isVideoContiguous,H=-1,W;if(M&&(H=S1(t.samples),!U&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,H>0){C.warn(`[mp4-remuxer]: Dropped ${H} out of ${L} video samples due to a missing keyframe`);let O=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(H),t.dropped+=H,T+=(t.samples[0].pts-O)/t.inputTimeScale,W=T}else H===-1&&(C.warn(`[mp4-remuxer]: No keyframe found out of ${L} video samples`),g=!1);if(this.ISGenerated){if(N&&M){let O=this.getVideoStartPts(t.samples),Y=(oi(e.samples[0].pts,O)-O)/t.inputTimeScale;E+=Math.max(0,Y),T+=Math.max(0,-Y)}if(N){if(e.samplerate||(C.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(e,t,n,a)),c=this.remuxAudio(e,E,this.isAudioContiguous,a,R||M||l===fe.AUDIO?T:void 0),M){let O=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(C.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,T,U,O)}}else M&&(d=this.remuxVideo(t,T,U,0));d&&(d.firstKeyFrame=H,d.independent=H!==-1,d.firstKeyFramePTS=W)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=Hv(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=Gv(s,n,this._initPTS))),{audio:c,video:d,initSegment:u,independent:g,text:h,id3:f}}generateIS(e,t,r,s){let n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS,c=!d||s,u="audio/mp4",h,f,g;if(c&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(u="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break}l.audio={id:"audio",container:u,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):lt.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(g=e.inputTimeScale,!d||g!==d.timescale?h=f=n[0].pts-Math.round(g*r):c=!1)}if(t.sps&&t.pps&&a.length&&(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:lt.initSegment([t]),metadata:{width:t.width,height:t.height}},c))if(g=t.inputTimeScale,!d||g!==d.timescale){let E=this.getVideoStartPts(a),T=Math.round(g*r);f=Math.min(f,oi(a[0].dts,E)-T),h=Math.min(h,E-T)}else c=!1;if(Object.keys(l).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:h,timescale:g},this._initDTS={baseTime:f,timescale:g}):h=g=void 0,{tracks:l,initPTS:h,timescale:g}}remuxVideo(e,t,r,s){let n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS,c=this.nextAvcDts,u=8,h=this.videoSampleDuration,f,g,E=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,A=!1;if(!r||c===null){let Z=t*n,te=a[0].pts-oi(a[0].dts,a[0].pts);c=Z-te}let R=d.baseTime*n/d.timescale;for(let Z=0;Z<l;Z++){let te=a[Z];te.pts=oi(te.pts-R,c),te.dts=oi(te.dts-R,c),te.dts<a[Z>0?Z-1:Z].dts&&(A=!0)}A&&a.sort(function(Z,te){let re=Z.dts-te.dts,xe=Z.pts-te.pts;return re||xe}),f=a[0].dts,g=a[a.length-1].dts;let L=g-f,N=L?Math.round(L/(l-1)):h||e.inputTimeScale/30;if(r){let Z=f-c,te=Z>N,re=Z<-1;if((te||re)&&(te?C.warn(`AVC: ${ta(Z,!0)} ms (${Z}dts) hole between fragments detected, filling it`):C.warn(`AVC: ${ta(-Z,!0)} ms (${Z}dts) overlapping between fragments detected`),!re||c>=a[0].pts)){f=c;let xe=a[0].pts-Z;a[0].dts=f,a[0].pts=xe,C.log(`Video: First PTS/DTS adjusted: ${ta(xe,!0)}/${ta(f,!0)}, delta: ${ta(Z,!0)} ms`)}}f=Math.max(0,f);let M=0,$=0;for(let Z=0;Z<l;Z++){let te=a[Z],re=te.units,xe=re.length,Ie=0;for(let ze=0;ze<xe;ze++)Ie+=re[ze].data.length;$+=Ie,M+=xe,te.length=Ie,te.dts=Math.max(te.dts,f),E=Math.min(te.pts,E),T=Math.max(te.pts,T)}g=a[l-1].dts;let U=$+4*M+8,H;try{H=new Uint8Array(U)}catch(Z){this.observer.emit(b.ERROR,b.ERROR,{type:he.MUX_ERROR,details:B.REMUX_ALLOC_ERROR,fatal:!1,error:Z,bytes:U,reason:`fail allocating video mdat ${U}`});return}let W=new DataView(H.buffer);W.setUint32(0,U),H.set(lt.types.mdat,4);let O=!1,z=Number.POSITIVE_INFINITY,Y=Number.POSITIVE_INFINITY,ye=Number.NEGATIVE_INFINITY,Ee=Number.NEGATIVE_INFINITY;for(let Z=0;Z<l;Z++){let te=a[Z],re=te.units,xe=0;for(let kt=0,Pt=re.length;kt<Pt;kt++){let Ot=re[kt],Wi=Ot.data,As=Ot.data.byteLength;W.setUint32(u,As),u+=4,H.set(Wi,u),u+=As,xe+=4+As}let Ie;if(Z<l-1)h=a[Z+1].dts-te.dts,Ie=a[Z+1].pts-te.pts;else{let kt=this.config,Pt=Z>0?te.dts-a[Z-1].dts:N;if(Ie=Z>0?te.pts-a[Z-1].pts:N,kt.stretchShortVideoTrack&&this.nextAudioPts!==null){let Ot=Math.floor(kt.maxBufferHole*n),Wi=(s?E+s*n:this.nextAudioPts)-te.pts;Wi>Ot?(h=Wi-Pt,h<0?h=Pt:O=!0,C.log(`[mp4-remuxer]: It is approximately ${Wi/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=Pt}else h=Pt}let ze=Math.round(te.pts-te.dts);z=Math.min(z,h),ye=Math.max(ye,h),Y=Math.min(Y,Ie),Ee=Math.max(Ee,Ie),o.push(new Zl(te.key,h,xe,ze))}if(o.length){if(Nl){if(Nl<70){let Z=o[0].flags;Z.dependsOn=2,Z.isNonSync=0}}else if(ih&&Ee-Y<ye-z&&N/ye<.025&&o[0].cts===0){C.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let Z=f;for(let te=0,re=o.length;te<re;te++){let xe=Z+o[te].duration,Ie=Z+o[te].cts;if(te<re-1){let ze=xe+o[te+1].cts;o[te].duration=ze-Ie}else o[te].duration=te?o[te-1].duration:N;o[te].cts=0,Z=xe}}}h=O||!h?N:h,this.nextAvcDts=c=g+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let be=lt.moof(e.sequenceNumber++,f,dt({},e,{samples:o})),ke="video",Se={data1:be,data2:H,startPTS:E/n,endPTS:(T+h)/n,startDTS:f/n,endDTS:c/n,type:ke,hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Se}remuxAudio(e,t,r,s,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=e.segmentCodec==="aac"?j0:A1,c=d*l,u=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],g=n!==void 0,E=e.samples,T=h?0:8,A=this.nextAudioPts||-1,R=t*a,L=u.baseTime*a/u.timescale;if(this.isAudioContiguous=r=r||E.length&&A>0&&(s&&Math.abs(R-A)<9e3||Math.abs(oi(E[0].pts-L,R)-A)<20*c),E.forEach(function(ke){ke.pts=oi(ke.pts-L,R)}),!r||A<0){if(E=E.filter(ke=>ke.pts>=0),!E.length)return;n===0?A=0:s&&!g?A=Math.max(0,R):A=E[0].pts}if(e.segmentCodec==="aac"){let ke=this.config.maxAudioFramesDrift;for(let Se=0,Z=A;Se<E.length;Se++){let te=E[Se],re=te.pts,xe=re-Z,Ie=Math.abs(1e3*xe/a);if(xe<=-ke*c&&g)Se===0&&(C.warn(`Audio frame @ ${(re/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*xe/a)} ms.`),this.nextAudioPts=A=Z=re);else if(xe>=ke*c&&Ie<_1&&g){let ze=Math.round(xe/c);Z=re-ze*c,Z<0&&(ze--,Z+=c),Se===0&&(this.nextAudioPts=A=Z),C.warn(`[mp4-remuxer]: Injecting ${ze} audio frame @ ${(Z/a).toFixed(3)}s due to ${Math.round(1e3*xe/a)} ms gap.`);for(let kt=0;kt<ze;kt++){let Pt=Math.max(Z,0),Ot=Ql.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Ot||(C.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ot=te.unit.subarray()),E.splice(Se,0,{unit:Ot,pts:Pt}),Z+=c,Se++}}te.pts=Z,Z+=c}}let N=null,M=null,$,U=0,H=E.length;for(;H--;)U+=E[H].unit.byteLength;for(let ke=0,Se=E.length;ke<Se;ke++){let Z=E[ke],te=Z.unit,re=Z.pts;if(M!==null){let Ie=f[ke-1];Ie.duration=Math.round((re-M)/l)}else if(r&&e.segmentCodec==="aac"&&(re=A),N=re,U>0){U+=T;try{$=new Uint8Array(U)}catch(Ie){this.observer.emit(b.ERROR,b.ERROR,{type:he.MUX_ERROR,details:B.REMUX_ALLOC_ERROR,fatal:!1,error:Ie,bytes:U,reason:`fail allocating audio mdat ${U}`});return}h||(new DataView($.buffer).setUint32(0,U),$.set(lt.types.mdat,4))}else return;$.set(te,T);let xe=te.byteLength;T+=xe,f.push(new Zl(!0,d,xe,0)),M=re}let W=f.length;if(!W)return;let O=f[f.length-1];this.nextAudioPts=A=M+l*O.duration;let z=h?new Uint8Array(0):lt.moof(e.sequenceNumber++,N/l,dt({},e,{samples:f}));e.samples=[];let Y=N/a,ye=A/a,be={data1:z,data2:$,startPTS:Y,endPTS:ye,startDTS:Y,endDTS:ye,type:"audio",hasAudio:!0,hasVideo:!1,nb:W};return this.isAudioContiguous=!0,be}remuxEmptyAudio(e,t,r,s){let n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,c=d.baseTime*9e4/d.timescale,u=(l!==null?l:s.startDTS*n)+c,h=s.endDTS*n+c,f=o*j0,g=Math.ceil((h-u)/f),E=Ql.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(C.warn("[mp4-remuxer]: remux empty Audio"),!E){C.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}let T=[];for(let A=0;A<g;A++){let R=u+A*f;T.push({unit:E,pts:R,dts:R})}return e.samples=T,this.remuxAudio(e,t,r,!1)}};function oi(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function S1(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function Hv(i,e,t,r){let s=i.samples.length;if(!s)return;let n=i.inputTimeScale;for(let o=0;o<s;o++){let l=i.samples[o];l.pts=oi(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=oi(l.dts-r.baseTime*n/r.timescale,e*n)/n}let a=i.samples;return i.samples=[],{samples:a}}function Gv(i,e,t){let r=i.samples.length;if(!r)return;let s=i.inputTimeScale;for(let a=0;a<r;a++){let o=i.samples[a];o.pts=oi(o.pts-t.baseTime*s/t.timescale,e*s)/s}i.samples.sort((a,o)=>a.pts-o.pts);let n=i.samples;return i.samples=[],{samples:n}}var Zl=class{constructor(e,t,r,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=s,this.flags=new Hh(e)}},Hh=class{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}},Gh=class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(lA(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let s=this.initData=Ev(e);t||(t=z0(s.audio,Ge.AUDIO)),r||(r=z0(s.video,Ge.VIDEO));let n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:C.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,r,s,n,a){var o,l;let{initPTS:d,lastEndTime:c}=this,u={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};oe(c)||(c=this.lastEndTime=n||0);let h=t.samples;if(!(h!=null&&h.length))return u;let f={initPTS:void 0,timescale:1},g=this.initData;if((o=g)!=null&&o.length||(this.generateInitSegment(h),g=this.initData),!((l=g)!=null&&l.length))return C.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);let E=cA(h,g),T=dA(g,h),A=T===null?n:T;(x1(d,A,n,E)||f.timescale!==d.timescale&&a)&&(f.initPTS=A-n,d&&d.timescale===1&&C.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});let R=e?A-d.baseTime/d.timescale:c,L=R+E;hA(g,h,d.baseTime/d.timescale),E>0?this.lastEndTime=L:(C.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let N=!!g.audio,M=!!g.video,$="";N&&($+="audio"),M&&($+="video");let U={data1:h,startPTS:R,startDTS:R,endPTS:L,endDTS:L,type:$,hasAudio:N,hasVideo:M,nb:1,dropped:0};return u.audio=U.type==="audio"?U:void 0,u.video=U.type!=="audio"?U:void 0,u.initSegment=f,u.id3=Hv(r,n,d,d),s.samples.length&&(u.text=Gv(s,n,d)),u}};function x1(i,e,t,r){if(i===null)return!0;let s=Math.max(r,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>s}function z0(i,e){let t=i==null?void 0:i.codec;return t&&t.length>4?t:t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":t==="avc1"||e===Ge.VIDEO?"avc1.42e01e":"mp4a.40.5"}var Qi;try{Qi=self.performance.now.bind(self.performance)}catch{C.debug("Unable to use Performance API on this environment"),Qi=typeof self!="undefined"&&self.Date.now}var rh=[{demux:Nh,remux:Gh},{demux:Fh,remux:na},{demux:Oh,remux:na},{demux:$h,remux:na}],Jl=class{constructor(e,t,r,s,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,s){let n=r.transmuxing;n.executeStart=Qi();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);let{contiguous:d,discontinuity:c,trackSwitch:u,accurateTimeOffset:h,timeOffset:f,initSegmentChange:g}=s||o,{audioCodec:E,videoCodec:T,defaultInitPts:A,duration:R,initSegmentData:L}=l,N=I1(a,t);if(N&&N.method==="AES-128"){let H=this.getDecrypter();if(H.isSync()){let W=H.softwareDecrypt(a,N.key.buffer,N.iv.buffer);if(r.part>-1&&(W=H.flush()),!W)return n.executeEnd=Qi(),sh(r);a=new Uint8Array(W)}else return this.decryptionPromise=H.webCryptoDecrypt(a,N.key.buffer,N.iv.buffer).then(W=>{let O=this.push(W,null,r);return this.decryptionPromise=null,O}),this.decryptionPromise}let M=this.needsProbing(c,u);if(M){let H=this.configureTransmuxer(a);if(H)return C.warn(`[transmuxer] ${H.message}`),this.observer.emit(b.ERROR,b.ERROR,{type:he.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:H,reason:H.message}),n.executeEnd=Qi(),sh(r)}(c||u||g||M)&&this.resetInitSegment(L,E,T,R,t),(c||g||M)&&this.resetInitialTimestamp(A),d||this.resetContiguity();let $=this.transmux(a,N,f,h,r),U=this.currentTransmuxState;return U.contiguous=!0,U.discontinuity=!1,U.trackSwitch=!1,n.executeEnd=Qi(),$}flush(e){let t=e.transmuxing;t.executeStart=Qi();let{decrypter:r,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=s;if(r){let u=r.flush();u&&a.push(this.push(u,null,e))}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=Qi(),[sh(e)];let c=l.flush(o);return Bl(c)?c.then(u=>(this.flushRemux(a,u,e),a)):(this.flushRemux(a,c,e),a)}flushRemux(e,t,r){let{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;C.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);let c=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=Qi()}resetInitialTimestamp(e){let{demuxer:t,remuxer:r}=this;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,s,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,r,s),o.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,r,s,n):a=this.transmuxUnencrypted(e,r,s,n),a}transmuxUnencrypted(e,t,r,s){let{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,r,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,r,s,n){return this.demuxer.demuxSampleAes(e,t,r).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,r,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:r,typeSupported:s,vendor:n}=this,a;for(let u=0,h=rh.length;u<h;u++)if(rh[u].demux.probe(e)){a=rh[u];break}if(!a)return new Error("Failed to find demuxer by probing fragment data");let o=this.demuxer,l=this.remuxer,d=a.remux,c=a.demux;(!l||!(l instanceof d))&&(this.remuxer=new d(r,t,s,n)),(!o||!(o instanceof c))&&(this.demuxer=new c(r,t,s),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new ua(this.config)),e}};function I1(i,e){let t=null;return i.byteLength>0&&e!=null&&e.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var sh=i=>({remuxResult:{},chunkMeta:i});function Bl(i){return"then"in i&&i.then instanceof Function}var Vh=class{constructor(e,t,r,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=s,this.defaultInitPts=n||null}},Kh=class{constructor(e,t,r,s,n,a){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=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}},Vv={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,d,c){this.fn=l,this.context=d,this.once=c||!1}function n(l,d,c,u,h){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,u||l,h),g=t?t+d:d;return l._events[g]?l._events[g].fn?l._events[g]=[l._events[g],f]:l._events[g].push(f):(l._events[g]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new r:delete l._events[d]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],c,u;if(this._eventsCount===0)return d;for(u in c=this._events)e.call(c,u)&&d.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},o.prototype.listeners=function(d){var c=t?t+d:d,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,f=u.length,g=new Array(f);h<f;h++)g[h]=u[h].fn;return g},o.prototype.listenerCount=function(d){var c=t?t+d:d,u=this._events[c];return u?u.fn?1:u.length:0},o.prototype.emit=function(d,c,u,h,f,g){var E=t?t+d:d;if(!this._events[E])return!1;var T=this._events[E],A=arguments.length,R,L;if(T.fn){switch(T.once&&this.removeListener(d,T.fn,void 0,!0),A){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,c),!0;case 3:return T.fn.call(T.context,c,u),!0;case 4:return T.fn.call(T.context,c,u,h),!0;case 5:return T.fn.call(T.context,c,u,h,f),!0;case 6:return T.fn.call(T.context,c,u,h,f,g),!0}for(L=1,R=new Array(A-1);L<A;L++)R[L-1]=arguments[L];T.fn.apply(T.context,R)}else{var N=T.length,M;for(L=0;L<N;L++)switch(T[L].once&&this.removeListener(d,T[L].fn,void 0,!0),A){case 1:T[L].fn.call(T[L].context);break;case 2:T[L].fn.call(T[L].context,c);break;case 3:T[L].fn.call(T[L].context,c,u);break;case 4:T[L].fn.call(T[L].context,c,u,h);break;default:if(!R)for(M=1,R=new Array(A-1);M<A;M++)R[M-1]=arguments[M];T[L].fn.apply(T[L].context,R)}}return!0},o.prototype.on=function(d,c,u){return n(this,d,c,u,!1)},o.prototype.once=function(d,c,u){return n(this,d,c,u,!0)},o.prototype.removeListener=function(d,c,u,h){var f=t?t+d:d;if(!this._events[f])return this;if(!c)return a(this,f),this;var g=this._events[f];if(g.fn)g.fn===c&&(!h||g.once)&&(!u||g.context===u)&&a(this,f);else{for(var E=0,T=[],A=g.length;E<A;E++)(g[E].fn!==c||h&&!g[E].once||u&&g[E].context!==u)&&T.push(g[E]);T.length?this._events[f]=T.length===1?T[0]:T:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var c;return d?(c=t?t+d:d,this._events[c]&&a(this,c)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(Vv);var L1=Vv.exports,xf=P_(L1),nh=dd()||{isTypeSupported:()=>!1},ed=class{constructor(e,t,r,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=s;let a=(d,c)=>{c=c||{},c.frag=this.frag,c.id=this.id,d===b.ERROR&&(this.error=c.error),this.hls.trigger(d,c)};this.observer=new xf,this.observer.on(b.FRAG_DECRYPTED,a),this.observer.on(b.ERROR,a);let o={mp4:nh.isTypeSupported("video/mp4"),mpeg:nh.isTypeSupported("audio/mpeg"),mp3:nh.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"&&(n.workerPath||i1())){try{n.workerPath?(C.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=s1(n.workerPath)):(C.log(`injecting Web Worker for "${t}"`),this.workerContext=r1()),this.onwmsg=u=>this.onWorkerMessage(u);let{worker:c}=this.workerContext;c.addEventListener("message",this.onwmsg),c.onerror=u=>{let h=new Error(`${u.message} (${u.filename}:${u.lineno})`);n.enableWorker=!1,C.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(b.ERROR,{type:he.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},c.postMessage({cmd:"init",typeSupported:o,vendor:l,id:t,config:JSON.stringify(n)})}catch(c){C.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.resetWorker(),this.error=null,this.transmuxer=new Jl(this.observer,o,n,l,t)}return}this.transmuxer=new Jl(this.observer,o,n,l,t)}resetWorker(){if(this.workerContext){let{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,s,n,a,o,l,d,c){var u,h;d.transmuxing.start=self.performance.now();let{transmuxer:f}=this,g=a?a.start:n.start,E=n.decryptdata,T=this.frag,A=!(T&&n.cc===T.cc),R=!(T&&d.level===T.level),L=T?d.sn-T.sn:-1,N=this.part?d.part-this.part.index:-1,M=L===0&&d.id>1&&d.id===(T==null?void 0:T.stats.chunkCount),$=!R&&(L===1||L===0&&(N===1||M&&N<=0)),U=self.performance.now();(R||L||n.stats.parsing.start===0)&&(n.stats.parsing.start=U),a&&(N||!$)&&(a.stats.parsing.start=U);let H=!(T&&((u=n.initSegment)==null?void 0:u.url)===((h=T.initSegment)==null?void 0:h.url)),W=new Kh(A,$,l,R,g,H);if(!$||A||H){C.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
1017
1053
  discontinuity: ${A}
1018
- trackSwitch: ${k}
1054
+ trackSwitch: ${R}
1019
1055
  contiguous: ${$}
1020
1056
  accurateTimeOffset: ${l}
1021
1057
  timeOffset: ${g}
1022
- initSegmentChange: ${G}`);let P=new _h(r,s,t,o,c);this.configureTransmuxer(P)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:E,chunkMeta:d,state:Y},e instanceof ArrayBuffer?[e]:[]);else if(f){let P=f.push(e,E,d,Y);wl(P)?(f.async=!0,P.then(X=>{this.handleTransmuxComplete(X)}).catch(X=>{this.transmuxerError(X,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(P))}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);wl(r)||t.async?(wl(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){!this.hls||(this.error=e,this.hls.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data,r=this.hls;switch(t.event){case"init":{var s;let n=(s=this.workerContext)==null?void 0:s.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":M[t.data.logType]&&M[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}}configureTransmuxer(e){let{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}},_A=250,$u=2,AA=.1,SA=.05,Sh=class{constructor(e,t,r,s){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=e,this.media=t,this.fragmentTracker=r,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:r,media:s,stalled:n}=this;if(s===null)return;let{currentTime:a,seeking:o}=s,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,n!==null){if(this.stallReported){let A=self.performance.now()-n;M.warn(`playback not stuck anymore @${a}, after ${Math.round(A)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!je.getBuffered(s).length)return;let c=je.bufferInfo(s,a,0),u=c.len>0,h=c.nextStart||0;if(!u&&!h)return;if(o){let A=c.len>$u,k=!h||t&&t.start<=a||h-a>$u&&!this.fragmentTracker.getPartialFragment(a);if(A||k)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var f;let A=Math.max(h,c.start||0)-a,k=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,N=(k==null||(f=k.details)==null?void 0:f.live)?k.details.targetduration*2:$u,D=this.fragmentTracker.getPartialFragment(a);if(A>0&&(A<=N||D)){this._trySkipBufferHole(D);return}}let g=self.performance.now();if(n===null){this.stalled=g;return}let E=g-n;if(!o&&E>=_A&&(this._reportStall(c),!this.media))return;let T=je.bufferInfo(s,a,r.maxBufferHole);this._tryFixBufferStall(T,E)}_tryFixBufferStall(e,t){let{config:r,fragmentTracker:s,media:n}=this;if(n===null)return;let a=n.currentTime,o=s.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(M.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:r,stallReported:s}=this;if(!s&&r){this.stallReported=!0;let n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);M.warn(n.message),t.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){let{config:t,hls:r,media:s}=this;if(s===null)return 0;let n=s.currentTime,a=je.bufferInfo(s,n,0),o=n<a.start?a.start:a.nextStart;if(o){let l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&s.readyState<3,c=o-n;if(c>0&&(l||d)){if(c>t.maxBufferHole){let{fragmentTracker:h}=this,f=!1;if(n===0){let g=h.getAppendedFrag(0,ge.MAIN);g&&o<g.end&&(f=!0)}if(!f){let g=e||h.getAppendedFrag(n,ge.MAIN);if(g){let E=!1,T=g.end;for(;T<o;){let A=h.getPartialFragment(T);if(A)T+=A.duration;else{E=!0;break}}if(E)return 0}}}let u=Math.max(o+SA,n+AA);if(M.warn(`skipping hole, adjusting currentTime from ${n} to ${u}`),this.moved=!0,this.stalled=null,s.currentTime=u,e&&!e.gap){let h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${u}`);r.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return u}}return 0}_tryNudgeBuffer(){let{config:e,hls:t,media:r,nudgeRetry:s}=this;if(r===null)return;let n=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){let a=n+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);M.warn(o.message),r.currentTime=a,t.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{let a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);M.error(a.message),t.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}},xA=100,xh=class extends sa{constructor(e,t,r){super(e,t,r,"[stream-controller]",ge.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(b.ERROR,this.onError,this),e.on(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(b.BUFFER_CREATED,this.onBufferCreated,this),e.on(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(b.ERROR,this.onError,this),e.off(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(b.BUFFER_CREATED,this.onBufferCreated,this),e.off(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(xA),this.level=-1,!this.startFragRequested){let s=r.startLevel;s===-1&&(r.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=r.nextAutoLevel),this.level=r.nextLoadLevel=s,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=W.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=W.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case W.WAITING_LEVEL:{var e;let{levels:r,level:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n&&(!n.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(n))break;this.state=W.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=W.IDLE;break}break}case W.FRAG_LOADING_WAITING_RETRY:{var t;let r=self.performance.now(),s=this.retryDate;(!s||r>=s||(t=this.media)!=null&&t.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=W.IDLE)}break}this.state===W.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:r,media:s}=this,{config:n,nextLoadLevel:a}=e;if(t===null||!s&&(this.startFragRequested||!n.startFragPrefetch)||this.altAudio&&this.audioOnly||!(r!=null&&r[a]))return;let o=r[a],l=this.getMainFwdBufferInfo();if(l===null)return;let d=this.getLevelDetails();if(d&&this._streamEnded(l,d)){let T={};this.altAudio&&(T.type="video"),this.hls.trigger(b.BUFFER_EOS,T),this.state=W.ENDED;return}e.loadLevel!==a&&e.manualLevel===-1&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=e.nextLoadLevel=a;let c=o.details;if(!c||this.state===W.WAITING_LEVEL||c.live&&this.levelLastLoaded!==a){this.level=a,this.state=W.WAITING_LEVEL;return}let u=l.len,h=this.getMaxBufferLength(o.maxBitrate);if(u>=h)return;this.backtrackFragment&&this.backtrackFragment.start>l.end&&(this.backtrackFragment=null);let f=this.backtrackFragment?this.backtrackFragment.start:l.end,g=this.getNextFragment(f,c);if(this.couldBacktrack&&!this.fragPrevious&&g&&g.sn!=="initSegment"&&this.fragmentTracker.getState(g)!==Tt.OK){var E;let A=((E=this.backtrackFragment)!=null?E:g).sn-c.startSN,k=c.fragments[A-1];k&&g.cc===k.cc&&(g=k,this.fragmentTracker.removeFragment(k))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(g&&this.isLoopLoading(g,f)){if(!g.gap){let A=this.audioOnly&&!this.altAudio?qe.AUDIO:qe.VIDEO,k=(A===qe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;k&&this.afterBufferFlushed(k,A,ge.MAIN)}g=this.getNextFragmentLoopLoading(g,c,l,ge.MAIN,h)}!g||(g.initSegment&&!g.initSegment.data&&!this.bitrateTest&&(g=g.initSegment),this.loadFragment(g,o,f))}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===Tt.NOT_LOADED||s===Tt.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,ge.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){let{levels:e,media:t}=this;if(t!=null&&t.readyState){let r,s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);let n=this.getLevelDetails();if(n!=null&&n.live){let o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){let o=this.hls.nextLoadLevel,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?r=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:r=0}else r=0;let a=this.getBufferedFrag(t.currentTime+r);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,c=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*.5),d*.75));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case W.KEY_LOADING:case W.FRAG_LOADING:case W.FRAG_LOADING_WAITING_RETRY:case W.PARSING:case W.PARSED:this.state=W.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new Sh(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){let{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){let e=this.media,t=e?e.currentTime:null;ce(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);let r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(b.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(e,t){let r=!1,s=!1,n;t.levels.forEach(a=>{n=a.audioCodec,n&&(n.indexOf("mp4a.40.2")!==-1&&(r=!0),n.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=r&&s&&!z_(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:r}=this;if(!r||this.state!==W.IDLE)return;let s=r[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(s.details))&&(this.state=W.WAITING_LEVEL)}onLevelLoaded(e,t){var r;let{levels:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);let l=s[n],d=this.fragCurrent;d&&(this.state===W.FRAG_LOADING||this.state===W.FRAG_LOADING_WAITING_RETRY)&&(d.level!==t.level||d.urlId!==l.urlId)&&d.loader&&this.abortCurrentFrag();let c=0;if(a.live||(r=l.details)!=null&&r.live){if(a.fragments[0]||(a.deltaUpdateFailed=!0),a.deltaUpdateFailed)return;c=this.alignPlaylists(a,l.details)}if(l.details=a,this.levelLastLoaded=n,this.hls.trigger(b.LEVEL_UPDATED,{details:a,level:n}),this.state===W.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=W.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,c),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let o=a[r.level],l=o.details;if(!l){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}let d=o.videoCodec,c=l.PTSKnown||!l.live,u=(t=r.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new Wl(this.hls,ge.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=s?s.index:-1,E=g!==-1,T=new ia(r.level,r.sn,r.stats.chunkCount,n.byteLength,g,E),A=this.initPTS[r.cc];f.push(n,u,h,d,r,s,l.totalduration,c,T,A)}onAudioTrackSwitching(e,t){let r=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();let n=this.hls;r&&(n.trigger(b.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(b.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let r=t.id,s=!!this.hls.audioTracks[r].url;if(s){let n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=s,this.tick()}onBufferCreated(e,t){let r=t.tracks,s,n,a=!1;for(let o in r){let l=r[o];if(l.id==="main"){if(n=o,s=l,o==="video"){let d=r[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r&&r.type!==ge.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===W.PARSED&&(this.state=W.IDLE);return}let n=s?s.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=W.ERROR;return}switch(t.details){case B.FRAG_GAP:case B.FRAG_PARSING_ERROR:case B.FRAG_DECRYPT_ERROR:case B.FRAG_LOAD_ERROR:case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_ERROR:case B.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ge.MAIN,t);break;case B.LEVEL_LOAD_ERROR:case B.LEVEL_LOAD_TIMEOUT:case B.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===W.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===Ue.LEVEL&&(this.state=W.IDLE);break;case B.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case B.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){let{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!je.getBuffered(e).length){let r=this.state!==W.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=W.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==qe.AUDIO||this.audioOnly&&!this.altAudio){let r=(t===qe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,t,ge.MAIN)}}onLevelsUpdated(e,t){this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${t}`);return}let s=je.getBuffered(e),a=(s.length?s.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),r+=a,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{let{hls:s}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=W.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;let n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(b.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let r="main",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:c}=o,{video:u,text:h,id3:f,initSegment:g}=n,{details:E}=c,T=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=W.PARSING,g){if(g!=null&&g.tracks){let L=l.initSegment||l;this._bufferInitSegment(c,g.tracks,L,a),s.trigger(b.FRAG_PARSING_INIT_SEGMENT,{frag:L,id:r,tracks:g.tracks})}let A=g.initPTS,k=g.timescale;ce(A)&&(this.initPTS[l.cc]={baseTime:A,timescale:k},s.trigger(b.INIT_PTS_FOUND,{frag:l,id:r,initPTS:A,timescale:k}))}if(u&&E&&l.sn!=="initSegment"){let A=E.fragments[l.sn-1-E.startSN],k=l.sn===E.startSN,L=!A||l.cc>A.cc;if(n.independent!==!1){let{startPTS:N,endPTS:D,startDTS:$,endDTS:O}=u;if(d)d.elementaryStreams[u.type]={startPTS:N,endPTS:D,startDTS:$,endDTS:O};else if(u.firstKeyFrame&&u.independent&&a.id===1&&!L&&(this.couldBacktrack=!0),u.dropped&&u.independent){let G=this.getMainFwdBufferInfo(),Y=(G?G.end:this.getLoadPosition())+this.config.maxBufferHole,P=u.firstKeyFramePTS?u.firstKeyFramePTS:N;if(!k&&Y<P-this.config.maxBufferHole&&!L){this.backtrack(l);return}else L&&(l.gap=!0);l.setElementaryStreamInfo(u.type,l.start,D,l.start,O,!0)}l.setElementaryStreamInfo(u.type,N,D,$,O),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(u,l,d,a,k||L)}else if(k||L)l.gap=!0;else{this.backtrack(l);return}}if(T){let{startPTS:A,endPTS:k,startDTS:L,endDTS:N}=T;d&&(d.elementaryStreams[qe.AUDIO]={startPTS:A,endPTS:k,startDTS:L,endDTS:N}),l.setElementaryStreamInfo(qe.AUDIO,A,k,L,N),this.bufferFragmentData(T,l,d,a)}if(E&&f!=null&&(t=f.samples)!=null&&t.length){let A={id:r,frag:l,details:E,samples:f.samples};s.trigger(b.FRAG_PARSING_METADATA,A)}if(E&&h){let A={id:r,frag:l,details:E,samples:h.samples};s.trigger(b.FRAG_PARSING_USERDATA,A)}}_bufferInitSegment(e,t,r,s){if(this.state!==W.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,d=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),n.metadata.channelCount!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")),d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.attrs.CODECS||""}/${o.codec}]`),this.hls.trigger(b.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let c=t[l].initSegment;c!=null&&c.byteLength&&this.hls.trigger(b.BUFFER_APPENDING,{type:l,data:c,frag:r,part:null,chunkMeta:s,parent:r.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,ge.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=W.IDLE}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===!1){let r=e.currentTime;if(je.isBuffered(e,r)?t=this.getAppendedFrag(r):je.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;let s=this.fragPlaying,n=t.level;(!s||t.sn!==s.sn||s.level!==n||t.urlId!==s.urlId)&&(this.fragPlaying=t,this.hls.trigger(b.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(b.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){let e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){let e=this.media;if(e){let t=e.currentTime,r=this.currentFrag;if(r&&ce(t)&&ce(r.programDateTime)){let s=r.programDateTime+(t-r.start)*1e3;return new Date(s)}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}},_r=class{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){let r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}},Ih=class{constructor(e,t,r,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new _r(e),this.fast_=new _r(t),this.defaultTTFB_=s,this.ttfb_=new _r(e)}update(e,t){let{slow_:r,fast_:s,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new _r(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new _r(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new _r(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);let r=8*t,s=e/1e3,n=r/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){let t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}},Lh=class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;let t=e.config;this.bwEstimator=new Ih(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(b.FRAG_LOADING,this.onFragLoading,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this),e.on(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){let{hls:e}=this;e.off(b.FRAG_LOADING,this.onFragLoading,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this),e.off(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var r;let s=t.frag;this.ignoreFragment(s)||(this.fragCurrent=s,this.partCurrent=(r=t.part)!=null?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,r,s){let n=e+r/t,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let r=this.hls.config,{total:s,bwEstimate:n}=t.stats;ce(s)&&ce(n)&&(this.lastLevelLoadSec=8*s/n),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}_abandonRulesCheck(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{autoLevelEnabled:s,media:n}=r;if(!e||!n)return;let a=performance.now(),o=t?t.stats:e.stats,l=t?t.duration:e.duration,d=a-o.loading.start;if(o.aborted||o.loaded&&o.loaded===o.total||e.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!s||n.paused||!n.playbackRate||!n.readyState)return;let c=r.mainForwardBufferInfo;if(c===null)return;let u=this.bwEstimator.getEstimateTTFB(),h=Math.abs(n.playbackRate);if(d<=Math.max(u,1e3*(l/(h*2))))return;let f=c.len/h;if(f>=2*l/h)return;let g=o.loading.first?o.loading.first-o.loading.start:-1,E=o.loaded&&g>-1,T=this.bwEstimator.getEstimate(),{levels:A,minAutoLevel:k}=r,L=A[e.level],N=o.total||Math.max(o.loaded,Math.round(l*L.maxBitrate/8)),D=d-g;D<1&&E&&(D=Math.min(d,o.loaded*8/T));let $=E?o.loaded*1e3/D:0,O=$?(N-o.loaded)/$:N*8/T+u/1e3;if(O<=f)return;let G=$?$*8:T,Y=Number.POSITIVE_INFINITY,P;for(P=e.level-1;P>k;P--){let X=A[P].maxBitrate;if(Y=this.getTimeToLoadFrag(u/1e3,G,l*X,!A[P].details),Y<f)break}Y>=O||Y>l*10||(r.nextLoadLevel=P,E?this.bwEstimator.sample(d-Math.min(u,g),o.loaded):this.bwEstimator.sampleTTFB(d),this.clearTimer(),M.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;
1058
+ initSegmentChange: ${H}`);let O=new Vh(r,s,t,o,c);this.configureTransmuxer(O)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:E,chunkMeta:d,state:W},e instanceof ArrayBuffer?[e]:[]);else if(f){let O=f.push(e,E,d,W);Bl(O)?(f.async=!0,O.then(z=>{this.handleTransmuxComplete(z)}).catch(z=>{this.transmuxerError(z,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(O))}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);Bl(r)||t.async?(Bl(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data,r=this.hls;switch(t.event){case"init":{var s;let n=(s=this.workerContext)==null?void 0:s.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":C[t.data.logType]&&C[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}}configureTransmuxer(e){let{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}},R1=250,ah=2,k1=.1,w1=.05,Wh=class{constructor(e,t,r,s){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=e,this.media=t,this.fragmentTracker=r,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:r,media:s,stalled:n}=this;if(s===null)return;let{currentTime:a,seeking:o}=s,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,n!==null){if(this.stallReported){let A=self.performance.now()-n;C.warn(`playback not stuck anymore @${a}, after ${Math.round(A)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!je.getBuffered(s).length)return;let c=je.bufferInfo(s,a,0),u=c.len>0,h=c.nextStart||0;if(!u&&!h)return;if(o){let A=c.len>ah,R=!h||t&&t.start<=a||h-a>ah&&!this.fragmentTracker.getPartialFragment(a);if(A||R)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var f;let A=Math.max(h,c.start||0)-a,R=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,N=(R==null||(f=R.details)==null?void 0:f.live)?R.details.targetduration*2:ah,M=this.fragmentTracker.getPartialFragment(a);if(A>0&&(A<=N||M)){this._trySkipBufferHole(M);return}}let g=self.performance.now();if(n===null){this.stalled=g;return}let E=g-n;if(!o&&E>=R1&&(this._reportStall(c),!this.media))return;let T=je.bufferInfo(s,a,r.maxBufferHole);this._tryFixBufferStall(T,E)}_tryFixBufferStall(e,t){let{config:r,fragmentTracker:s,media:n}=this;if(n===null)return;let a=n.currentTime,o=s.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(C.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:r,stallReported:s}=this;if(!s&&r){this.stallReported=!0;let n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);C.warn(n.message),t.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){let{config:t,hls:r,media:s}=this;if(s===null)return 0;let n=s.currentTime,a=je.bufferInfo(s,n,0),o=n<a.start?a.start:a.nextStart;if(o){let l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&s.readyState<3,c=o-n;if(c>0&&(l||d)){if(c>t.maxBufferHole){let{fragmentTracker:h}=this,f=!1;if(n===0){let g=h.getAppendedFrag(0,fe.MAIN);g&&o<g.end&&(f=!0)}if(!f){let g=e||h.getAppendedFrag(n,fe.MAIN);if(g){let E=!1,T=g.end;for(;T<o;){let A=h.getPartialFragment(T);if(A)T+=A.duration;else{E=!0;break}}if(E)return 0}}}let u=Math.max(o+w1,n+k1);if(C.warn(`skipping hole, adjusting currentTime from ${n} to ${u}`),this.moved=!0,this.stalled=null,s.currentTime=u,e&&!e.gap){let h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${u}`);r.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return u}}return 0}_tryNudgeBuffer(){let{config:e,hls:t,media:r,nudgeRetry:s}=this;if(r===null)return;let n=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){let a=n+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);C.warn(o.message),r.currentTime=a,t.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{let a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);C.error(a.message),t.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}},D1=100,qh=class extends ha{constructor(e,t,r){super(e,t,r,"[stream-controller]",fe.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(b.ERROR,this.onError,this),e.on(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(b.BUFFER_CREATED,this.onBufferCreated,this),e.on(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(b.ERROR,this.onError,this),e.off(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(b.BUFFER_CREATED,this.onBufferCreated,this),e.off(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(D1),this.level=-1,!this.startFragRequested){let s=r.startLevel;s===-1&&(r.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=r.nextAutoLevel),this.level=r.nextLoadLevel=s,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=V.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=V.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case V.WAITING_LEVEL:{var e;let{levels:r,level:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n&&(!n.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(n))break;this.state=V.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=V.IDLE;break}break}case V.FRAG_LOADING_WAITING_RETRY:{var t;let r=self.performance.now(),s=this.retryDate;(!s||r>=s||(t=this.media)!=null&&t.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=V.IDLE)}break}this.state===V.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:r,media:s}=this,{config:n,nextLoadLevel:a}=e;if(t===null||!s&&(this.startFragRequested||!n.startFragPrefetch)||this.altAudio&&this.audioOnly||!(r!=null&&r[a]))return;let o=r[a],l=this.getMainFwdBufferInfo();if(l===null)return;let d=this.getLevelDetails();if(d&&this._streamEnded(l,d)){let T={};this.altAudio&&(T.type="video"),this.hls.trigger(b.BUFFER_EOS,T),this.state=V.ENDED;return}e.loadLevel!==a&&e.manualLevel===-1&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=e.nextLoadLevel=a;let c=o.details;if(!c||this.state===V.WAITING_LEVEL||c.live&&this.levelLastLoaded!==a){this.level=a,this.state=V.WAITING_LEVEL;return}let u=l.len,h=this.getMaxBufferLength(o.maxBitrate);if(u>=h)return;this.backtrackFragment&&this.backtrackFragment.start>l.end&&(this.backtrackFragment=null);let f=this.backtrackFragment?this.backtrackFragment.start:l.end,g=this.getNextFragment(f,c);if(this.couldBacktrack&&!this.fragPrevious&&g&&g.sn!=="initSegment"&&this.fragmentTracker.getState(g)!==gt.OK){var E;let A=((E=this.backtrackFragment)!=null?E:g).sn-c.startSN,R=c.fragments[A-1];R&&g.cc===R.cc&&(g=R,this.fragmentTracker.removeFragment(R))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(g&&this.isLoopLoading(g,f)){if(!g.gap){let A=this.audioOnly&&!this.altAudio?Ge.AUDIO:Ge.VIDEO,R=(A===Ge.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;R&&this.afterBufferFlushed(R,A,fe.MAIN)}g=this.getNextFragmentLoopLoading(g,c,l,fe.MAIN,h)}g&&(g.initSegment&&!g.initSegment.data&&!this.bitrateTest&&(g=g.initSegment),this.loadFragment(g,o,f))}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===gt.NOT_LOADED||s===gt.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,fe.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){let{levels:e,media:t}=this;if(t!=null&&t.readyState){let r,s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);let n=this.getLevelDetails();if(n!=null&&n.live){let o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){let o=this.hls.nextLoadLevel,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?r=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:r=0}else r=0;let a=this.getBufferedFrag(t.currentTime+r);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,c=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*.5),d*.75));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case V.KEY_LOADING:case V.FRAG_LOADING:case V.FRAG_LOADING_WAITING_RETRY:case V.PARSING:case V.PARSED:this.state=V.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new Wh(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){let{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){let e=this.media,t=e?e.currentTime:null;oe(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);let r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(b.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(e,t){let r=!1,s=!1,n;t.levels.forEach(a=>{n=a.audioCodec,n&&(n.indexOf("mp4a.40.2")!==-1&&(r=!0),n.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=r&&s&&!t1(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:r}=this;if(!r||this.state!==V.IDLE)return;let s=r[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(s.details))&&(this.state=V.WAITING_LEVEL)}onLevelLoaded(e,t){var r;let{levels:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);let l=s[n],d=this.fragCurrent;d&&(this.state===V.FRAG_LOADING||this.state===V.FRAG_LOADING_WAITING_RETRY)&&(d.level!==t.level||d.urlId!==l.urlId)&&d.loader&&this.abortCurrentFrag();let c=0;if(a.live||(r=l.details)!=null&&r.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;c=this.alignPlaylists(a,l.details)}if(l.details=a,this.levelLastLoaded=n,this.hls.trigger(b.LEVEL_UPDATED,{details:a,level:n}),this.state===V.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=V.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,c),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let o=a[r.level],l=o.details;if(!l){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}let d=o.videoCodec,c=l.PTSKnown||!l.live,u=(t=r.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new ed(this.hls,fe.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=s?s.index:-1,E=g!==-1,T=new ca(r.level,r.sn,r.stats.chunkCount,n.byteLength,g,E),A=this.initPTS[r.cc];f.push(n,u,h,d,r,s,l.totalduration,c,T,A)}onAudioTrackSwitching(e,t){let r=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();let n=this.hls;r&&(n.trigger(b.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(b.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let r=t.id,s=!!this.hls.audioTracks[r].url;if(s){let n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=s,this.tick()}onBufferCreated(e,t){let r=t.tracks,s,n,a=!1;for(let o in r){let l=r[o];if(l.id==="main"){if(n=o,s=l,o==="video"){let d=r[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r&&r.type!==fe.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===V.PARSED&&(this.state=V.IDLE);return}let n=s?s.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=V.ERROR;return}switch(t.details){case B.FRAG_GAP:case B.FRAG_PARSING_ERROR:case B.FRAG_DECRYPT_ERROR:case B.FRAG_LOAD_ERROR:case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_ERROR:case B.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(fe.MAIN,t);break;case B.LEVEL_LOAD_ERROR:case B.LEVEL_LOAD_TIMEOUT:case B.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===V.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===Me.LEVEL&&(this.state=V.IDLE);break;case B.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case B.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){let{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!je.getBuffered(e).length){let r=this.state!==V.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=V.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Ge.AUDIO||this.audioOnly&&!this.altAudio){let r=(t===Ge.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,t,fe.MAIN)}}onLevelsUpdated(e,t){this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${t}`);return}let s=je.getBuffered(e),a=(s.length?s.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),r+=a,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{let{hls:s}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=V.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;let n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(b.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let r="main",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:c}=o,{video:u,text:h,id3:f,initSegment:g}=n,{details:E}=c,T=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=V.PARSING,g){if(g!=null&&g.tracks){let L=l.initSegment||l;this._bufferInitSegment(c,g.tracks,L,a),s.trigger(b.FRAG_PARSING_INIT_SEGMENT,{frag:L,id:r,tracks:g.tracks})}let A=g.initPTS,R=g.timescale;oe(A)&&(this.initPTS[l.cc]={baseTime:A,timescale:R},s.trigger(b.INIT_PTS_FOUND,{frag:l,id:r,initPTS:A,timescale:R}))}if(u&&E&&l.sn!=="initSegment"){let A=E.fragments[l.sn-1-E.startSN],R=l.sn===E.startSN,L=!A||l.cc>A.cc;if(n.independent!==!1){let{startPTS:N,endPTS:M,startDTS:$,endDTS:U}=u;if(d)d.elementaryStreams[u.type]={startPTS:N,endPTS:M,startDTS:$,endDTS:U};else if(u.firstKeyFrame&&u.independent&&a.id===1&&!L&&(this.couldBacktrack=!0),u.dropped&&u.independent){let H=this.getMainFwdBufferInfo(),W=(H?H.end:this.getLoadPosition())+this.config.maxBufferHole,O=u.firstKeyFramePTS?u.firstKeyFramePTS:N;if(!R&&W<O-this.config.maxBufferHole&&!L){this.backtrack(l);return}else L&&(l.gap=!0);l.setElementaryStreamInfo(u.type,l.start,M,l.start,U,!0)}l.setElementaryStreamInfo(u.type,N,M,$,U),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(u,l,d,a,R||L)}else if(R||L)l.gap=!0;else{this.backtrack(l);return}}if(T){let{startPTS:A,endPTS:R,startDTS:L,endDTS:N}=T;d&&(d.elementaryStreams[Ge.AUDIO]={startPTS:A,endPTS:R,startDTS:L,endDTS:N}),l.setElementaryStreamInfo(Ge.AUDIO,A,R,L,N),this.bufferFragmentData(T,l,d,a)}if(E&&f!=null&&(t=f.samples)!=null&&t.length){let A={id:r,frag:l,details:E,samples:f.samples};s.trigger(b.FRAG_PARSING_METADATA,A)}if(E&&h){let A={id:r,frag:l,details:E,samples:h.samples};s.trigger(b.FRAG_PARSING_USERDATA,A)}}_bufferInitSegment(e,t,r,s){if(this.state!==V.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,d=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),n.metadata.channelCount!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")),d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.attrs.CODECS||""}/${o.codec}]`),this.hls.trigger(b.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let c=t[l].initSegment;c!=null&&c.byteLength&&this.hls.trigger(b.BUFFER_APPENDING,{type:l,data:c,frag:r,part:null,chunkMeta:s,parent:r.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,fe.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=V.IDLE}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===!1){let r=e.currentTime;if(je.isBuffered(e,r)?t=this.getAppendedFrag(r):je.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;let s=this.fragPlaying,n=t.level;(!s||t.sn!==s.sn||s.level!==n||t.urlId!==s.urlId)&&(this.fragPlaying=t,this.hls.trigger(b.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(b.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){let e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){let e=this.media;if(e){let t=e.currentTime,r=this.currentFrag;if(r&&oe(t)&&oe(r.programDateTime)){let s=r.programDateTime+(t-r.start)*1e3;return new Date(s)}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}},gr=class{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){let r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}},Yh=class{constructor(e,t,r,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new gr(e),this.fast_=new gr(t),this.defaultTTFB_=s,this.ttfb_=new gr(e)}update(e,t){let{slow_:r,fast_:s,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new gr(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new gr(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new gr(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);let r=8*t,s=e/1e3,n=r/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){let t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}},jh=class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;let t=e.config;this.bwEstimator=new Yh(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(b.FRAG_LOADING,this.onFragLoading,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this),e.on(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){let{hls:e}=this;e.off(b.FRAG_LOADING,this.onFragLoading,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this),e.off(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var r;let s=t.frag;this.ignoreFragment(s)||(this.fragCurrent=s,this.partCurrent=(r=t.part)!=null?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,r,s){let n=e+r/t,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let r=this.hls.config,{total:s,bwEstimate:n}=t.stats;oe(s)&&oe(n)&&(this.lastLevelLoadSec=8*s/n),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}_abandonRulesCheck(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{autoLevelEnabled:s,media:n}=r;if(!e||!n)return;let a=performance.now(),o=t?t.stats:e.stats,l=t?t.duration:e.duration,d=a-o.loading.start;if(o.aborted||o.loaded&&o.loaded===o.total||e.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!s||n.paused||!n.playbackRate||!n.readyState)return;let c=r.mainForwardBufferInfo;if(c===null)return;let u=this.bwEstimator.getEstimateTTFB(),h=Math.abs(n.playbackRate);if(d<=Math.max(u,1e3*(l/(h*2))))return;let f=c.len/h;if(f>=2*l/h)return;let g=o.loading.first?o.loading.first-o.loading.start:-1,E=o.loaded&&g>-1,T=this.bwEstimator.getEstimate(),{levels:A,minAutoLevel:R}=r,L=A[e.level],N=o.total||Math.max(o.loaded,Math.round(l*L.maxBitrate/8)),M=d-g;M<1&&E&&(M=Math.min(d,o.loaded*8/T));let $=E?o.loaded*1e3/M:0,U=$?(N-o.loaded)/$:N*8/T+u/1e3;if(U<=f)return;let H=$?$*8:T,W=Number.POSITIVE_INFINITY,O;for(O=e.level-1;O>R;O--){let z=A[O].maxBitrate;if(W=this.getTimeToLoadFrag(u/1e3,H,l*z,!A[O].details),W<f)break}W>=U||W>l*10||(r.nextLoadLevel=O,E?this.bwEstimator.sample(d-Math.min(u,g),o.loaded):this.bwEstimator.sampleTTFB(d),this.clearTimer(),C.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;
1023
1059
  Time to underbuffer: ${f.toFixed(3)} s
1024
- Estimated load time for current fragment: ${O.toFixed(3)} s
1025
- Estimated load time for down switch fragment: ${Y.toFixed(3)} s
1060
+ Estimated load time for current fragment: ${U.toFixed(3)} s
1061
+ Estimated load time for down switch fragment: ${W.toFixed(3)} s
1026
1062
  TTFB estimate: ${g}
1027
- Current BW estimate: ${ce(T)?(T/1024).toFixed(3):"Unknown"} Kb/s
1063
+ Current BW estimate: ${oe(T)?(T/1024).toFixed(3):"Unknown"} Kb/s
1028
1064
  New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
1029
- Aborting and switching to level ${P}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),r.trigger(b.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}onFragLoaded(e,{frag:t,part:r}){let s=r?r.stats:t.stats;if(t.type===ge.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){let n=r?r.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+s.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){let n={stats:s,frag:t,part:r,id:t.type};this.onFragBuffered(b.FRAG_BUFFERED,n),t.bitrateTest=!1}}}onFragBuffered(e,t){let{frag:r,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:r.stats;if(n.aborted||this.ignoreFragment(r))return;let a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==ge.MAIN||e.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){let e=this._nextAutoLevel,t=this.bwEstimator;if(e!==-1&&!t.canEstimate())return e;let r=this.getNextABRAutoLevel();if(e!==-1){let s=this.hls.levels;if(s.length>Math.max(e,r)&&s[e].loadError<=s[r].loadError)return e}return e!==-1&&(r=Math.min(e,r)),r}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:s,config:n,minAutoLevel:a,media:o}=r,l=t?t.duration:e?e.duration:0,d=o&&o.playbackRate!==0?Math.abs(o.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,u=r.mainForwardBufferInfo,h=(u?u.len:0)/d,f=this.findBestLevel(c,a,s,h,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(f>=0)return f;M.trace(`[abr] ${h?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let g=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay,E=n.abrBandWidthFactor,T=n.abrBandWidthUpFactor;if(!h){let A=this.bitrateTestDelay;A&&(g=(l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay)-A,M.trace(`[abr] bitrate test took ${Math.round(1e3*A)}ms, set first fragment max fetchDuration to ${Math.round(1e3*g)} ms`),E=T=1)}return f=this.findBestLevel(c,a,s,h+g,E,T),Math.max(f,0)}findBestLevel(e,t,r,s,n,a){var o;let{fragCurrent:l,partCurrent:d,lastLoadedFragLevel:c}=this,{levels:u}=this.hls,h=u[c],f=!!(h!=null&&(o=h.details)!=null&&o.live),g=h==null?void 0:h.codecSet,E=d?d.duration:l?l.duration:0,T=this.bwEstimator.getEstimateTTFB()/1e3,A=t,k=-1;for(let L=r;L>=t;L--){let N=u[L];if(!N||g&&N.codecSet!==g){N&&(A=Math.min(L,A),k=Math.max(L,k));continue}k!==-1&&M.trace(`[abr] Skipped level(s) ${A}-${k} with CODECS:"${u[k].attrs.CODECS}"; not compatible with "${h.attrs.CODECS}"`);let D=N.details,$=(d?D==null?void 0:D.partTarget:D==null?void 0:D.averagetargetduration)||E,O;L<=c?O=n*e:O=a*e;let G=u[L].maxBitrate,Y=this.getTimeToLoadFrag(T,O,G*$,D===void 0);if(M.trace(`[abr] level:${L} adjustedbw-bitrate:${Math.round(O-G)} avgDuration:${$.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:${Y.toFixed(1)}`),O>G&&(Y===0||!ce(Y)||f&&!this.bitrateTestDelay||Y<s))return L}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}},ql=class{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let{chunks:e,dataLength:t}=this,r;if(e.length)e.length===1?r=e[0]:r=IA(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}};function IA(i,e){let t=new Uint8Array(e),r=0;for(let s=0;s<i.length;s++){let n=i[s];t.set(n,r),r+=n.length}return t}var s0=100,kh=class extends sa{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",ge.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(b.ERROR,this.onError,this),e.on(b.BUFFER_RESET,this.onBufferReset,this),e.on(b.BUFFER_CREATED,this.onBufferCreated,this),e.on(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(b.ERROR,this.onError,this),e.off(b.BUFFER_RESET,this.onBufferReset,this),e.off(b.BUFFER_CREATED,this.onBufferCreated,this),e.off(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){if(r==="main"){let a=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${s}`),this.videoTrackCC=a,this.state===W.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=W.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(s0),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=W.IDLE):(this.loadedmetadata=!1,this.state=W.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case W.IDLE:this.doTickIdle();break;case W.WAITING_TRACK:{var e;let{levels:r,trackId:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=W.WAITING_INIT_PTS}break}case W.FRAG_LOADING_WAITING_RETRY:{var t;let r=performance.now(),s=this.retryDate;(!s||r>=s||(t=this.media)!=null&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=W.IDLE);break}case W.WAITING_INIT_PTS:{let r=this.waitingData;if(r){let{frag:s,part:n,cache:a,complete:o}=r;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=W.FRAG_LOADING;let l=a.flush(),d={frag:s,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{let l=this.getLoadPosition(),d=je.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);nh(d.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=W.IDLE}}this.onTickEnd()}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=W.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){let{media:e}=this;!(e!=null&&e.readyState)||(this.lastCurrentTime=e.currentTime)}doTickIdle(){let{hls:e,levels:t,media:r,trackId:s}=this,n=e.config;if(!(t!=null&&t[s])||!r&&(this.startFragRequested||!n.startFragPrefetch))return;let a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(o)){this.state=W.WAITING_TRACK;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,qe.AUDIO,ge.AUDIO));let d=this.getFwdBufferInfo(l,ge.AUDIO);if(d===null)return;let{bufferedTrack:c,switchingTrack:u}=this;if(!u&&this._streamEnded(d,o)){e.trigger(b.BUFFER_EOS,{type:"audio"}),this.state=W.ENDED;return}let h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,ge.MAIN),f=d.len,g=this.getMaxBufferLength(h==null?void 0:h.len);if(f>=g&&!u)return;let T=o.fragments[0].start,A=d.end;if(u&&r){let D=this.getLoadPosition();c&&u.attrs!==c.attrs&&(A=D),o.PTSKnown&&D<T&&(d.end>T||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=T+.05)}let k=this.getNextFragment(A,o),L=!1;if(k&&this.isLoopLoading(k,A)&&(L=!!k.gap,k=this.getNextFragmentLoopLoading(k,o,d,ge.MAIN,g)),!k){this.bufferFlushed=!0;return}let N=h&&k.start>h.end+o.targetduration;if(N||!(h!=null&&h.len)&&d.len){let D=this.getAppendedFrag(k.start,ge.MAIN);if(D===null||(L||(L=!!D.gap||!!N&&h.len===0),N&&!L||L&&d.nextStart&&d.nextStart<D.end))return}this.loadFragment(k,a,A)}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(r=>new Jr(r))}onAudioTrackSwitching(e,t){let r=!!t.url;this.trackId=t.id;let{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),r?this.setInterval(s0):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=W.IDLE):(this.switchingTrack=null,this.bufferedTrack=t,this.state=W.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(b.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}let{levels:s}=this,{details:n,id:a}=t;if(!s){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let o=s[a],l=0;if(n.live||(r=o.details)!=null&&r.live){let d=this.mainDetails;if(n.fragments[0]||(n.deltaUpdateFailed=!0),n.deltaUpdateFailed||!d)return;!o.details&&n.hasProgramDateTime&&d.hasProgramDateTime?(F0(n,d),l=n.fragments[0].start):l=this.alignPlaylists(n,o.details)}o.details=n,this.levelLastLoaded=a,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(o.details,l),this.state===W.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=W.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}let c=d.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}let u=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new Wl(this.hls,ge.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let f=this.initPTS[r.cc],g=(t=r.initSegment)==null?void 0:t.data;if(f!==void 0){let T=s?s.index:-1,A=T!==-1,k=new ia(r.level,r.sn,r.stats.chunkCount,n.byteLength,T,A);h.push(n,g,u,"",r,s,c.totalduration,!1,k,f)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);let{cache:E}=this.waitingData=this.waitingData||{frag:r,part:s,cache:new ql,complete:!1};E.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=W.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){let r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r.type!==ge.AUDIO){if(!this.loadedmetadata&&r.type===ge.MAIN){let n=this.videoBuffer||this.media;n&&je.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(b.AUDIO_TRACK_SWITCHED,Yt({},n)))}this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=W.ERROR;return}switch(t.details){case B.FRAG_GAP:case B.FRAG_PARSING_ERROR:case B.FRAG_DECRYPT_ERROR:case B.FRAG_LOAD_ERROR:case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_ERROR:case B.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ge.AUDIO,t);break;case B.AUDIO_TRACK_LOAD_ERROR:case B.AUDIO_TRACK_LOAD_TIMEOUT:case B.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===W.WAITING_TRACK&&((r=t.context)==null?void 0:r.type)===Ue.AUDIO_TRACK&&(this.state=W.IDLE);break;case B.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case B.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushed(e,{type:t}){t===qe.AUDIO&&(this.bufferFlushed=!0,this.state===W.ENDED&&(this.state=W.IDLE))}_handleTransmuxComplete(e){var t;let r="audio",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:c}=o,{details:u}=c,{audio:h,text:f,id3:g,initSegment:E}=n;if(this.fragContextChanged(l)||!u){this.fragmentTracker.removeFragment(l);return}if(this.state=W.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),E!=null&&E.tracks){let T=l.initSegment||l;this._bufferInitSegment(E.tracks,T,a),s.trigger(b.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:r,tracks:E.tracks})}if(h){let{startPTS:T,endPTS:A,startDTS:k,endDTS:L}=h;d&&(d.elementaryStreams[qe.AUDIO]={startPTS:T,endPTS:A,startDTS:k,endDTS:L}),l.setElementaryStreamInfo(qe.AUDIO,T,A,k,L),this.bufferFragmentData(h,l,d,a)}if(g!=null&&(t=g.samples)!=null&&t.length){let T=mt({id:r,frag:l,details:u},g);s.trigger(b.FRAG_PARSING_METADATA,T)}if(f){let T=mt({id:r,frag:l,details:u},f);s.trigger(b.FRAG_PARSING_USERDATA,T)}}_bufferInitSegment(e,t,r){if(this.state!==W.PARSING)return;e.video&&delete e.video;let s=e.audio;if(!s)return;s.levelCodec=s.codec,s.id="audio",this.log(`Init audio buffer, container:${s.container}, codecs[parsed]=[${s.codec}]`),this.hls.trigger(b.BUFFER_CODECS,e);let n=s.initSegment;if(n!=null&&n.byteLength){let a={type:"audio",frag:t,part:null,chunkMeta:r,parent:t.type,data:n};this.hls.trigger(b.BUFFER_APPENDING,a)}this.tick()}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||s===Tt.NOT_LOADED||s===Tt.PARTIAL){var n;e.sn==="initSegment"?this._loadInitSegment(e,t):(n=t.details)!=null&&n.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=W.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(e,t,r))}else this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){let{hls:t,media:r,bufferedTrack:s}=this,n=s==null?void 0:s.attrs,a=e.attrs;r&&n&&(n.CHANNELS!==a.CHANNELS||n.NAME!==a.NAME||n.LANGUAGE!==a.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(b.AUDIO_TRACK_SWITCHED,Yt({},e))}},Rh=class extends ta{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(b.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.LEVEL_LOADING,this.onLevelLoading,this),e.off(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(b.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Track with id:${r} and group:${s} not found in active group ${a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`audio-track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!(t!=null&&t.audioGroupIds))return;let r=t.audioGroupIds[t.urlId];if(this.groupId!==r){this.groupId=r||null;let s=this.tracks.filter(a=>!r||a.groupId===r);this.selectDefaultTrack&&!s.some(a=>a.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=s;let n={audioTracks:s};this.log(`Updating audio tracks, ${s.length} track(s) found in group:${r}`),this.hls.trigger(b.AUDIO_TRACKS_UPDATED,n),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===Ue.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();let r=this.currentTrack;t[this.trackId];let s=t[e],{groupId:n,name:a}=s;if(this.log(`Switching to audio-track ${e} "${a}" lang:${s.lang} group:${n}`),this.trackId=e,this.currentTrack=s,this.selectDefaultTrack=!1,this.hls.trigger(b.AUDIO_TRACK_SWITCHING,Yt({},s)),s.details&&!s.details.live)return;let o=this.switchParams(s.url,r==null?void 0:r.details);this.loadPlaylist(o)}selectInitialTrack(){let e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(t!==-1)this.setAudioTrack(t);else{let r=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(r.message),this.hls.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:r})}}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if((!this.selectDefaultTrack||s.default)&&(!e||e.attrs["STABLE-RENDITION-ID"]!==void 0&&e.attrs["STABLE-RENDITION-ID"]===s.attrs["STABLE-RENDITION-ID"]||e.name===s.name&&e.lang===s.lang))return s.id}return-1}loadPlaylist(e){super.loadPlaylist();let t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(b.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}};function Z0(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!LA(i[t].attrs,e[t].attrs))return!1;return!0}function LA(i,e){let t=i["STABLE-RENDITION-ID"];return t?t===e["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(r=>i[r]!==e[r])}var n0=500,wh=class extends sa{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",ge.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.ERROR,this.onError,this),e.on(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(b.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(b.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.ERROR,this.onError,this),e.off(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(b.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(b.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=W.IDLE,this.setInterval(n0),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let{frag:r,success:s}=t;if(this.fragPrevious=r,this.state=W.IDLE,!s)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=r.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}let l=r.start+r.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r)}onBufferFlushing(e,t){let{startOffset:r,endOffset:s}=t;if(r===0&&s!==Number.POSITIVE_INFINITY){let n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(r,n,ge.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===ge.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let r=t.frag;(r==null?void 0:r.type)===ge.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==W.STOPPED&&(this.state=W.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(Z0(this.levels,t)){this.levels=t.map(r=>new Jr(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{let s=new Jr(r);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,ge.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){if(this.currentTrackId=t.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}let r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(n0)}onSubtitleTrackLoaded(e,t){var r;let{details:s,id:n}=t,{currentTrackId:a,levels:o}=this;if(!o.length)return;let l=o[a];if(n>=o.length||n!==a||!l)return;this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(s.live||(r=l.details)!=null&&r.live){let c=this.mainDetails;if(s.deltaUpdateFailed||!c)return;let u=c.fragments[0];l.details?(d=this.alignPlaylists(s,l.details),d===0&&u&&(d=u.start,sh(s,d))):s.hasProgramDateTime&&c.hasProgramDateTime?(F0(s,c),d=s.fragments[0].start):u&&(d=u.start,sh(s,d))}l.details=s,this.levelLastLoaded=n,!this.startFragRequested&&(this.mainDetails||!s.live)&&this.setStartPosition(l.details,d),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===W.IDLE&&(ea(null,s.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0))}_handleFragmentLoadComplete(e){let{frag:t,payload:r}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){let a=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{let l=performance.now();n.trigger(b.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=W.IDLE})}}doTick(){if(!this.media){this.state=W.IDLE;return}if(this.state===W.IDLE){let{currentTrackId:e,levels:t}=this,r=t[e];if(!t.length||!r||!r.details)return;let{config:s}=this,n=this.getLoadPosition(),a=je.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,ge.MAIN),c=r.details,u=this.getMaxBufferLength(d==null?void 0:d.len)+c.levelTargetDuration;if(l>u)return;let h=c.fragments,f=h.length,g=c.edge,E=null,T=this.fragPrevious;if(o<g){let A=s.maxFragLookUpTolerance,k=o>g-A?0:A;E=ea(T,h,Math.max(h[0].start,o),k),!E&&T&&T.start<h[0].start&&(E=h[0])}else E=h[f-1];if(!E)return;if(E=this.mapToInitFragWhenRequired(E),E.sn!=="initSegment"){let A=E.sn-c.startSN,k=h[A-1];k&&k.cc===E.cc&&this.fragmentTracker.getState(k)===Tt.NOT_LOADED&&(E=k)}this.fragmentTracker.getState(E)===Tt.NOT_LOADED&&this.loadFragment(E,r,o)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new Dh(this.tracksBuffered[this.currentTrackId]||[])}},Dh=class{constructor(e){this.buffered=void 0;let t=(r,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][r]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}},Ch=class extends ta{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(b.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.LEVEL_LOADING,this.onLevelLoading,this),e.off(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(b.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.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))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Hu(this.media.textTracks).forEach(t=>{Js(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:r,details:s}=t,{trackId:n}=this,a=this.tracksInGroup[n];if(!a){this.warn(`Invalid subtitle track id ${r}`);return}let o=a.details;a.details=t.details,this.log(`subtitle track ${r} loaded [${s.startSN}-${s.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!(t!=null&&t.textGroupIds))return;let r=t.textGroupIds[t.urlId],s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==r){let n=this.tracks.filter(l=>!r||l.groupId===r);this.tracksInGroup=n;let a=this.findTrackId(s==null?void 0:s.name)||this.findTrackId();this.groupId=r||null;let o={subtitleTracks:n};this.log(`Updating subtitle tracks, ${n.length} track(s) found in "${r}" group-id`),this.hls.trigger(b.SUBTITLE_TRACKS_UPDATED,o),a!==-1&&this.setSubtitleTrack(a,s)}else this.shouldReloadPlaylist(s)&&this.setSubtitleTrack(this.trackId,s)}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if((!this.selectDefaultTrack||s.default)&&(!e||e===s.name))return s.id}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Ue.SUBTITLE_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.checkRetry(t)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1;let t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}loadPlaylist(e){super.loadPlaylist();let t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(b.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(e){let{media:t,trackId:r}=this;if(!t)return;let s=Hu(t.textTracks),n=s.filter(o=>o.groupId===this.groupId);if(e===-1)[].slice.call(s).forEach(o=>{o.mode="disabled"});else{let o=n[r];o&&(o.mode="disabled")}let a=n[e];a&&(a.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var r;let s=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(e===-1||(r=s[e])!=null&&r.details)||e<-1||e>=s.length)return;this.clearTimer();let n=s[e];if(this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:"")),this.trackId=e,n){let{id:a,groupId:o="",name:l,type:d,url:c}=n;this.hls.trigger(b.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:c});let u=this.switchParams(n.url,t==null?void 0:t.details);this.loadPlaylist(u)}else this.hls.trigger(b.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1,t=Hu(this.media.textTracks);for(let r=0;r<t.length;r++)if(t[r].mode==="hidden")e=r;else if(t[r].mode==="showing"){e=r;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}};function Hu(i){let e=[];for(let t=0;t<i.length;t++){let r=i[t];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&e.push(i[t])}return e}var Mh=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t){let r=this.queues[t];r.push(e),r.length===1&&this.buffers[t]&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,r=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),r}executeNext(e){let{buffers:t,queues:r}=this,s=t[e],n=r[e];if(n.length){let a=n[0];try{a.execute()}catch(o){M.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),a.onError(o),s!=null&&s.updating||(n.shift(),this.executeNext(e))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}},a0=Jl(),o0=/([ha]vc.)(?:\.[^.,]+)+/,Oh=class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{let{media:t,mediaSource:r}=this;M.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(b.MEDIA_ATTACHED,{media:t})),r&&r.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{M.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{M.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{let{media:t,_objectUrl:r}=this;t&&t.src!==r&&M.error(`Media element src was set while attaching MediaSource (${r} > ${t.src})`)},this.hls=e,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.BUFFER_RESET,this.onBufferReset,this),e.on(b.BUFFER_APPENDING,this.onBufferAppending,this),e.on(b.BUFFER_CODECS,this.onBufferCodecs,this),e.on(b.BUFFER_EOS,this.onBufferEos,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(b.FRAG_PARSED,this.onFragParsed,this),e.on(b.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.BUFFER_RESET,this.onBufferReset,this),e.off(b.BUFFER_APPENDING,this.onBufferAppending,this),e.off(b.BUFFER_CODECS,this.onBufferCodecs,this),e.off(b.BUFFER_EOS,this.onBufferEos,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(b.FRAG_PARSED,this.onFragParsed,this),e.off(b.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Mh(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,M.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let r=this.media=t.media;if(r&&a0){let s=this.mediaSource=new a0;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(s),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(M.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){M.warn(`[buffer-controller]: onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):M.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(b.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{let t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(r){M.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,r)}}),this._initSourceBuffer()}onBufferCodecs(e,t){let r=this.getSourceBufferTypes().length;Object.keys(t).forEach(s=>{if(r){let n=this.tracks[s];if(n&&typeof n.buffer.changeType=="function"){let{id:a,codec:o,levelCodec:l,container:d,metadata:c}=t[s],u=(n.levelCodec||n.codec).replace(o0,"$1"),h=(l||o).replace(o0,"$1");if(u!==h){let f=`${d};codecs=${l||o}`;this.appendChangeType(s,f),M.log(`[buffer-controller]: switching codec ${u} to ${h}`),this.tracks[s]={buffer:n.buffer,codec:o,container:d,levelCodec:l,metadata:c,id:a}}}}else this.pendingTracks[s]=t[s]}),!r&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(e,t){let{operationQueue:r}=this,s={execute:()=>{let n=this.sourceBuffer[e];n&&(M.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{M.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,n)}};r.append(s,e)}onBufferAppending(e,t){let{hls:r,operationQueue:s,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:c}=t,u=c.buffering[o],h=self.performance.now();u.start=h;let f=l.stats.buffering,g=d?d.stats.buffering:null;f.start===0&&(f.start=h),g&&g.start===0&&(g.start=h);let E=n.audio,T=!1;o==="audio"&&(E==null?void 0:E.container)==="audio/mpeg"&&(T=!this.lastMpegAudioChunk||c.id===1||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);let A=l.start,k={execute:()=>{if(u.executeStart=self.performance.now(),T){let L=this.sourceBuffer[o];if(L){let N=A-L.timestampOffset;Math.abs(N)>=.1&&(M.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${A} (delta: ${N}) sn: ${l.sn})`),L.timestampOffset=A)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let L=self.performance.now();u.executeEnd=u.end=L,f.first===0&&(f.first=L),g&&g.first===0&&(g.first=L);let{sourceBuffer:N}=this,D={};for(let $ in N)D[$]=je.getBuffered(N[$]);this.appendError=0,this.hls.trigger(b.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:c,parent:l.type,timeRanges:D})},onError:L=>{M.error(`[buffer-controller]: Error encountered while trying to append to the ${o} SourceBuffer`,L);let N={type:pe.MEDIA_ERROR,parent:l.type,details:B.BUFFER_APPEND_ERROR,frag:l,part:d,chunkMeta:c,error:L,err:L,fatal:!1};L.code===DOMException.QUOTA_EXCEEDED_ERR?N.details=B.BUFFER_FULL_ERROR:(this.appendError++,N.details=B.BUFFER_APPEND_ERROR,this.appendError>r.config.appendErrorMaxRetry&&(M.error(`[buffer-controller]: Failed ${r.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),N.fatal=!0)),r.trigger(b.ERROR,N)}};s.append(k,o)}onBufferFlushing(e,t){let{operationQueue:r}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(b.BUFFER_FLUSHED,{type:n})},onError:a=>{M.warn(`[buffer-controller]: Failed to remove from ${n} SourceBuffer`,a)}});t.type?r.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{r.append(s(n),n)})}onFragParsed(e,t){let{frag:r,part:s}=t,n=[],a=s?s.elementaryStreams:r.elementaryStreams;a[qe.AUDIOVIDEO]?n.push("audiovideo"):(a[qe.AUDIO]&&n.push("audio"),a[qe.VIDEO]&&n.push("video"));let o=()=>{let l=self.performance.now();r.stats.buffering.end=l,s&&(s.stats.buffering.end=l);let d=s?s.stats:r.stats;this.hls.trigger(b.FRAG_BUFFERED,{frag:r,part:s,stats:d,id:r.type})};n.length===0&&M.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,n)=>{let a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,M.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),s&&!!(!a||a.ended)},!0)&&(M.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{let a=this.sourceBuffer[n];a&&(a.ending=!1)});let{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&M.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}M.log("[buffer-controller]: Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){!t.fragments.length||(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){let{hls:e,details:t,media:r,sourceBuffer:s}=this;if(!r||t===null)return;let n=this.getSourceBufferTypes();if(!n.length)return;let a=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!ce(a)||a<0)return;let o=r.currentTime,l=t.levelTargetDuration,d=Math.max(a,l),c=Math.floor(o/l)*l-d;n.forEach(u=>{let h=s[u];if(h){let f=je.getBuffered(h);if(f.length>0&&c>f.start(0)){if(e.trigger(b.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(b.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(h.ended&&f.end(f.length-1)-o<l*2){M.info(`[buffer-controller]: Cannot flush ${u} back buffer while SourceBuffer is in ended state`);return}e.trigger(b.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:u})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;let{details:e,hls:t,media:r,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=r.duration,o=ce(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(M.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!ce(a))&&(M.log(`[buffer-controller]: Updating Media Source duration to ${n.toFixed(3)}`),s.duration=n)}updateSeekableRange(e){let t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){let n=Math.max(0,r[0].start),a=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,a)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,s=Object.keys(r).length;if(s&&!e||s===2){this.createSourceBuffers(r),this.pendingTracks={};let n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(b.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{let a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(let s in e)if(!t[s]){let n=e[s];if(!n)throw Error(`source buffer exists for track ${s}, however track does not`);let a=n.levelCodec||n.codec,o=`${n.container};codecs=${a}`;M.log(`[buffer-controller]: creating sourceBuffer(${o})`);try{let l=t[s]=r.addSourceBuffer(o),d=s;this.addBufferListener(d,"updatestart",this._onSBUpdateStart),this.addBufferListener(d,"updateend",this._onSBUpdateEnd),this.addBufferListener(d,"error",this._onSBUpdateError),this.tracks[s]={buffer:l,codec:a,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(l){M.error(`[buffer-controller]: error while trying to add sourceBuffer: ${l.message}`),this.hls.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:o})}}}_onSBUpdateStart(e){let{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){let{operationQueue:t}=this;t.current(e).onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){let r=new Error(`${e} SourceBuffer error`);M.error(`[buffer-controller]: ${r}`,t),this.hls.trigger(b.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_APPENDING_ERROR,error:r,fatal:!1});let s=this.operationQueue.current(e);s&&s.onError(t)}removeExecutor(e,t,r){let{media:s,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!s||!n||!l){M.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}let d=ce(s.duration)?s.duration:1/0,c=ce(n.duration)?n.duration:1/0,u=Math.max(0,t),h=Math.min(r,d,c);h>u&&!l.ending?(l.ended=!1,M.log(`[buffer-controller]: Removing [${u},${h}] from the ${e} SourceBuffer`),l.remove(u,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){let{operationQueue:r,sourceBuffer:s}=this,n=s[t];if(!n){M.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),r.shiftAndExecuteNext(t);return}n.ended=!1,n.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){M.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}let{operationQueue:r}=this,s=t.map(n=>r.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{let a=this.sourceBuffer[n];a!=null&&a.updating||r.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){let s=this.sourceBuffer[e];if(!s)return;let n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){let t=this.sourceBuffer[e];!t||this.listeners[e].forEach(r=>{t.removeEventListener(r.event,r.listener)})}},l0={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},J0=function(e){let t=e;return l0.hasOwnProperty(e)&&(t=l0[e]),String.fromCharCode(t)},Ti=15,rr=100,kA={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},RA={17:2,18:4,21:6,22:8,23:10,19:13,20:15},wA={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},DA={25:2,26:4,29:6,30:8,31:10,27:13,28:15},CA=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Ph=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let r=typeof t=="function"?t():t;M.log(`${this.time} [${e}] ${r}`)}}},jr=function(e){let t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t},Yl=class{constructor(e,t,r,s,n){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=s||"black",this.flash=n||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){let s=t[r];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}},Nh=class{constructor(e,t,r,s,n,a){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new Yl(t,r,s,n,a)}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}},Uh=class{constructor(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let t=0;t<rr;t++)this.chars.push(new Nh);this.logger=e,this.pos=0,this.currPenState=new Yl}equals(e){let t=!0;for(let r=0;r<rr;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t}copy(e){for(let t=0;t<rr;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<rr;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>rr&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=rr)}moveCursor(e){let t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=J0(e);if(this.pos>=rr){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<rr;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let r=0;r<rr;r++){let s=this.chars[r].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}},Jn=class{constructor(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let t=0;t<Ti;t++)this.rows.push(new Uh(e));this.logger=e,this.currRow=Ti-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<Ti;e++)this.rows[e].clear();this.currRow=Ti-1}equals(e){let t=!0;for(let r=0;r<Ti;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<Ti;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Ti;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<Ti;o++)this.rows[o].clear();let n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){let o=a.rows[n].cueStartTime,l=this.logger.time;if(o&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;let r=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);r.setCursor(e.indent),e.color=r.chars[a].penState.foreground}let s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],r="",s=-1;for(let n=0;n<Ti;n++){let a=this.rows[n].getTextString();a&&(s=n+1,e?t.push("Row "+s+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?r="["+t.join(" | ")+"]":r=t.join(`
1030
- `)),r}getTextAndFormat(){return this.rows}},jl=class{constructor(e,t,r){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=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Jn(r),this.nonDisplayedMemory=new Jn(r),this.lastOutputScreen=new Jn(r),this.currRollUpRow=this.displayedMemory.rows[Ti-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[Ti-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),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=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{let r=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}},zl=class{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;let s=new Ph;this.channels=[null,new jl(e,t,s),new jl(e+1,r,s)],this.cmdHistory=c0(),this.logger=s}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let r,s,n,a=!1;this.logger.time=e;for(let o=0;o<t.length;o+=2)if(s=t[o]&127,n=t[o+1]&127,!(s===0&&n===0)){if(this.logger.log(3,"["+jr([t[o],t[o+1]])+"] -> ("+jr([s,n])+")"),r=this.parseCmd(s,n),r||(r=this.parseMidrow(s,n)),r||(r=this.parsePAC(s,n)),r||(r=this.parseBackgroundAttributes(s,n)),!r&&(a=this.parseChars(s,n),a)){let l=this.currentChannel;l&&l>0?this.channels[l].insertChars(a):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!r&&!a&&this.logger.log(2,"Couldn't parse cleaned data "+jr([s,n])+" orig: "+jr([t[o],t[o+1]]))}}parseCmd(e,t){let{cmdHistory:r}=this,s=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,n=(e===23||e===31)&&t>=33&&t<=35;if(!(s||n))return!1;if(d0(e,t,r))return Zs(null,null,r),this.logger.log(3,"Repeated command ("+jr([e,t])+") is dropped"),!0;let a=e===20||e===21||e===23?1:2,o=this.channels[a];return e===20||e===21||e===28||e===29?t===32?o.ccRCL():t===33?o.ccBS():t===34?o.ccAOF():t===35?o.ccAON():t===36?o.ccDER():t===37?o.ccRU(2):t===38?o.ccRU(3):t===39?o.ccRU(4):t===40?o.ccFON():t===41?o.ccRDC():t===42?o.ccTR():t===43?o.ccRTD():t===44?o.ccEDM():t===45?o.ccCR():t===46?o.ccENM():t===47&&o.ccEOC():o.ccTO(t-32),Zs(e,t,r),this.currentChannel=a,!0}parseMidrow(e,t){let r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let s=this.channels[r];return s?(s.ccMIDROW(t),this.logger.log(3,"MIDROW ("+jr([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let r,s=this.cmdHistory,n=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,a=(e===16||e===24)&&t>=64&&t<=95;if(!(n||a))return!1;if(d0(e,t,s))return Zs(null,null,s),!0;let o=e<=23?1:2;t>=64&&t<=95?r=o===1?kA[e]:wA[e]:r=o===1?RA[e]:DA[e];let l=this.channels[o];return l?(l.setPAC(this.interpretPAC(r,t)),Zs(e,t,s),this.currentChannel=o,!0):!1}interpretPAC(e,t){let r,s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?r=t-96:r=t-64,s.underline=(r&1)===1,r<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((r-16)/2)*4,s}parseChars(e,t){let r,s=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,"Special char '"+J0(a)+"' in channel "+r),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);if(s){let a=jr(s);this.logger.log(3,"Char codes = "+a.join(",")),Zs(e,t,this.cmdHistory)}return s}parseBackgroundAttributes(e,t){let r=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(r||s))return!1;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=CA[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));let o=e<=23?1:2;return this.channels[o].setBkgData(a),Zs(e,t,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}this.cmdHistory=c0()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let r=this.channels[t];r&&r.cueSplitAtTime(e)}}};function Zs(i,e,t){t.a=i,t.b=e}function d0(i,e,t){return t.a===i&&t.b===e}function c0(){return{a:null,b:null}}var en=class{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}},rf=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;let i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;let d=l.toLowerCase();return~o.indexOf(d)?d:!1}function r(o){return t(i,o)}function s(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){let c=arguments[d];for(let u in c)o[u]=c[u]}return o}function a(o,l,d){let c=this,u={enumerable:!0};c.hasBeenReset=!1;let h="",f=!1,g=o,E=l,T=d,A=null,k="",L=!0,N="auto",D="start",$=50,O="middle",G=50,Y="middle";Object.defineProperty(c,"id",n({},u,{get:function(){return h},set:function(P){h=""+P}})),Object.defineProperty(c,"pauseOnExit",n({},u,{get:function(){return f},set:function(P){f=!!P}})),Object.defineProperty(c,"startTime",n({},u,{get:function(){return g},set:function(P){if(typeof P!="number")throw new TypeError("Start time must be set to a number.");g=P,this.hasBeenReset=!0}})),Object.defineProperty(c,"endTime",n({},u,{get:function(){return E},set:function(P){if(typeof P!="number")throw new TypeError("End time must be set to a number.");E=P,this.hasBeenReset=!0}})),Object.defineProperty(c,"text",n({},u,{get:function(){return T},set:function(P){T=""+P,this.hasBeenReset=!0}})),Object.defineProperty(c,"region",n({},u,{get:function(){return A},set:function(P){A=P,this.hasBeenReset=!0}})),Object.defineProperty(c,"vertical",n({},u,{get:function(){return k},set:function(P){let X=r(P);if(X===!1)throw new SyntaxError("An invalid or illegal string was specified.");k=X,this.hasBeenReset=!0}})),Object.defineProperty(c,"snapToLines",n({},u,{get:function(){return L},set:function(P){L=!!P,this.hasBeenReset=!0}})),Object.defineProperty(c,"line",n({},u,{get:function(){return N},set:function(P){if(typeof P!="number"&&P!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");N=P,this.hasBeenReset=!0}})),Object.defineProperty(c,"lineAlign",n({},u,{get:function(){return D},set:function(P){let X=s(P);if(!X)throw new SyntaxError("An invalid or illegal string was specified.");D=X,this.hasBeenReset=!0}})),Object.defineProperty(c,"position",n({},u,{get:function(){return $},set:function(P){if(P<0||P>100)throw new Error("Position must be between 0 and 100.");$=P,this.hasBeenReset=!0}})),Object.defineProperty(c,"positionAlign",n({},u,{get:function(){return O},set:function(P){let X=s(P);if(!X)throw new SyntaxError("An invalid or illegal string was specified.");O=X,this.hasBeenReset=!0}})),Object.defineProperty(c,"size",n({},u,{get:function(){return G},set:function(P){if(P<0||P>100)throw new Error("Size must be between 0 and 100.");G=P,this.hasBeenReset=!0}})),Object.defineProperty(c,"align",n({},u,{get:function(){return Y},set:function(P){let X=s(P);if(!X)throw new SyntaxError("An invalid or illegal string was specified.");Y=X,this.hasBeenReset=!0}})),c.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),Fh=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function ev(i){function e(r,s,n,a){return(r|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}let t=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}var Bh=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let s=0;s<r.length;++s)if(t===r[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}};function tv(i,e,t,r){let s=r?i.split(r):[i];for(let n in s){if(typeof s[n]!="string")continue;let a=s[n].split(t);if(a.length!==2)continue;let o=a[0],l=a[1];e(o,l)}}var $h=new rf(0,0,""),kl=$h.align==="middle"?"middle":"center";function MA(i,e,t){let r=i;function s(){let o=ev(i);if(o===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){let d=new Bh;tv(o,function(h,f){let g;switch(h){case"region":for(let E=t.length-1;E>=0;E--)if(t[E].id===f){d.set(h,t[E].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":g=f.split(","),d.integer(h,g[0]),d.percent(h,g[0])&&d.set("snapToLines",!1),d.alt(h,g[0],["auto"]),g.length===2&&d.alt("lineAlign",g[1],["start",kl,"end"]);break;case"position":g=f.split(","),d.percent(h,g[0]),g.length===2&&d.alt("positionAlign",g[1],["start",kl,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",kl,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let c=d.get("line","auto");c==="auto"&&$h.line===-1&&(c=-1),l.line=c,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",kl);let u=d.get("position","auto");u==="auto"&&$h.position===50&&(u=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=u}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),a(),e.endTime=s(),a(),n(i,e)}function iv(i){return i.replace(/<br(?: \/)?>/gi,`
1031
- `)}var Hh=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Fh,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){let t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function r(){let n=t.buffer,a=0;for(n=iv(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
1065
+ Aborting and switching to level ${O}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),r.trigger(b.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}onFragLoaded(e,{frag:t,part:r}){let s=r?r.stats:t.stats;if(t.type===fe.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){let n=r?r.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+s.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){let n={stats:s,frag:t,part:r,id:t.type};this.onFragBuffered(b.FRAG_BUFFERED,n),t.bitrateTest=!1}}}onFragBuffered(e,t){let{frag:r,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:r.stats;if(n.aborted||this.ignoreFragment(r))return;let a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==fe.MAIN||e.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){let e=this._nextAutoLevel,t=this.bwEstimator;if(e!==-1&&!t.canEstimate())return e;let r=this.getNextABRAutoLevel();if(e!==-1){let s=this.hls.levels;if(s.length>Math.max(e,r)&&s[e].loadError<=s[r].loadError)return e}return e!==-1&&(r=Math.min(e,r)),r}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:s,config:n,minAutoLevel:a,media:o}=r,l=t?t.duration:e?e.duration:0,d=o&&o.playbackRate!==0?Math.abs(o.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,u=r.mainForwardBufferInfo,h=(u?u.len:0)/d,f=this.findBestLevel(c,a,s,h,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(f>=0)return f;C.trace(`[abr] ${h?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let g=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay,E=n.abrBandWidthFactor,T=n.abrBandWidthUpFactor;if(!h){let A=this.bitrateTestDelay;A&&(g=(l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay)-A,C.trace(`[abr] bitrate test took ${Math.round(1e3*A)}ms, set first fragment max fetchDuration to ${Math.round(1e3*g)} ms`),E=T=1)}return f=this.findBestLevel(c,a,s,h+g,E,T),Math.max(f,0)}findBestLevel(e,t,r,s,n,a){var o;let{fragCurrent:l,partCurrent:d,lastLoadedFragLevel:c}=this,{levels:u}=this.hls,h=u[c],f=!!(h!=null&&(o=h.details)!=null&&o.live),g=h==null?void 0:h.codecSet,E=d?d.duration:l?l.duration:0,T=this.bwEstimator.getEstimateTTFB()/1e3,A=t,R=-1;for(let L=r;L>=t;L--){let N=u[L];if(!N||g&&N.codecSet!==g){N&&(A=Math.min(L,A),R=Math.max(L,R));continue}R!==-1&&C.trace(`[abr] Skipped level(s) ${A}-${R} with CODECS:"${u[R].attrs.CODECS}"; not compatible with "${h.attrs.CODECS}"`);let M=N.details,$=(d?M==null?void 0:M.partTarget:M==null?void 0:M.averagetargetduration)||E,U;L<=c?U=n*e:U=a*e;let H=u[L].maxBitrate,W=this.getTimeToLoadFrag(T,U,H*$,M===void 0);if(C.trace(`[abr] level:${L} adjustedbw-bitrate:${Math.round(U-H)} avgDuration:${$.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:${W.toFixed(1)}`),U>H&&(W===0||!oe(W)||f&&!this.bitrateTestDelay||W<s))return L}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}},td=class{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let{chunks:e,dataLength:t}=this,r;if(e.length)e.length===1?r=e[0]:r=C1(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}};function C1(i,e){let t=new Uint8Array(e),r=0;for(let s=0;s<i.length;s++){let n=i[s];t.set(n,r),r+=n.length}return t}var X0=100,zh=class extends ha{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",fe.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(b.ERROR,this.onError,this),e.on(b.BUFFER_RESET,this.onBufferReset,this),e.on(b.BUFFER_CREATED,this.onBufferCreated,this),e.on(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(b.ERROR,this.onError,this),e.off(b.BUFFER_RESET,this.onBufferReset,this),e.off(b.BUFFER_CREATED,this.onBufferCreated,this),e.off(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){if(r==="main"){let a=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${s}`),this.videoTrackCC=a,this.state===V.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=V.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(X0),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=V.IDLE):(this.loadedmetadata=!1,this.state=V.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case V.IDLE:this.doTickIdle();break;case V.WAITING_TRACK:{var e;let{levels:r,trackId:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=V.WAITING_INIT_PTS}break}case V.FRAG_LOADING_WAITING_RETRY:{var t;let r=performance.now(),s=this.retryDate;(!s||r>=s||(t=this.media)!=null&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=V.IDLE);break}case V.WAITING_INIT_PTS:{let r=this.waitingData;if(r){let{frag:s,part:n,cache:a,complete:o}=r;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=V.FRAG_LOADING;let l=a.flush(),d={frag:s,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{let l=this.getLoadPosition(),d=je.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);xh(d.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=V.IDLE}}this.onTickEnd()}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=V.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){let{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){let{hls:e,levels:t,media:r,trackId:s}=this,n=e.config;if(!(t!=null&&t[s])||!r&&(this.startFragRequested||!n.startFragPrefetch))return;let a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(o)){this.state=V.WAITING_TRACK;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Ge.AUDIO,fe.AUDIO));let d=this.getFwdBufferInfo(l,fe.AUDIO);if(d===null)return;let{bufferedTrack:c,switchingTrack:u}=this;if(!u&&this._streamEnded(d,o)){e.trigger(b.BUFFER_EOS,{type:"audio"}),this.state=V.ENDED;return}let h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,fe.MAIN),f=d.len,g=this.getMaxBufferLength(h==null?void 0:h.len);if(f>=g&&!u)return;let T=o.fragments[0].start,A=d.end;if(u&&r){let M=this.getLoadPosition();c&&u.attrs!==c.attrs&&(A=M),o.PTSKnown&&M<T&&(d.end>T||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=T+.05)}let R=this.getNextFragment(A,o),L=!1;if(R&&this.isLoopLoading(R,A)&&(L=!!R.gap,R=this.getNextFragmentLoopLoading(R,o,d,fe.MAIN,g)),!R){this.bufferFlushed=!0;return}let N=h&&R.start>h.end+o.targetduration;if(N||!(h!=null&&h.len)&&d.len){let M=this.getAppendedFrag(R.start,fe.MAIN);if(M===null||(L||(L=!!M.gap||!!N&&h.len===0),N&&!L||L&&d.nextStart&&d.nextStart<M.end))return}this.loadFragment(R,a,A)}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(r=>new zr(r))}onAudioTrackSwitching(e,t){let r=!!t.url;this.trackId=t.id;let{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),r?this.setInterval(X0):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=V.IDLE):(this.switchingTrack=null,this.bufferedTrack=t,this.state=V.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(b.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}let{levels:s}=this,{details:n,id:a}=t;if(!s){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let o=s[a],l=0;if(n.live||(r=o.details)!=null&&r.live){this.checkLiveUpdate(n);let d=this.mainDetails;if(n.deltaUpdateFailed||!d)return;!o.details&&n.hasProgramDateTime&&d.hasProgramDateTime?(wv(n,d),l=n.fragments[0].start):l=this.alignPlaylists(n,o.details)}o.details=n,this.levelLastLoaded=a,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(o.details,l),this.state===V.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=V.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}let c=d.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}let u=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new ed(this.hls,fe.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let f=this.initPTS[r.cc],g=(t=r.initSegment)==null?void 0:t.data;if(f!==void 0){let T=s?s.index:-1,A=T!==-1,R=new ca(r.level,r.sn,r.stats.chunkCount,n.byteLength,T,A);h.push(n,g,u,"",r,s,c.totalduration,!1,R,f)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);let{cache:E}=this.waitingData=this.waitingData||{frag:r,part:s,cache:new td,complete:!1};E.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=V.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){let r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r.type!==fe.AUDIO){if(!this.loadedmetadata&&r.type===fe.MAIN){let n=this.videoBuffer||this.media;n&&je.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(b.AUDIO_TRACK_SWITCHED,qt({},n)))}this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=V.ERROR;return}switch(t.details){case B.FRAG_GAP:case B.FRAG_PARSING_ERROR:case B.FRAG_DECRYPT_ERROR:case B.FRAG_LOAD_ERROR:case B.FRAG_LOAD_TIMEOUT:case B.KEY_LOAD_ERROR:case B.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(fe.AUDIO,t);break;case B.AUDIO_TRACK_LOAD_ERROR:case B.AUDIO_TRACK_LOAD_TIMEOUT:case B.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===V.WAITING_TRACK&&((r=t.context)==null?void 0:r.type)===Me.AUDIO_TRACK&&(this.state=V.IDLE);break;case B.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case B.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushed(e,{type:t}){t===Ge.AUDIO&&(this.bufferFlushed=!0,this.state===V.ENDED&&(this.state=V.IDLE))}_handleTransmuxComplete(e){var t;let r="audio",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:c}=o,{details:u}=c,{audio:h,text:f,id3:g,initSegment:E}=n;if(this.fragContextChanged(l)||!u){this.fragmentTracker.removeFragment(l);return}if(this.state=V.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),E!=null&&E.tracks){let T=l.initSegment||l;this._bufferInitSegment(E.tracks,T,a),s.trigger(b.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:r,tracks:E.tracks})}if(h){let{startPTS:T,endPTS:A,startDTS:R,endDTS:L}=h;d&&(d.elementaryStreams[Ge.AUDIO]={startPTS:T,endPTS:A,startDTS:R,endDTS:L}),l.setElementaryStreamInfo(Ge.AUDIO,T,A,R,L),this.bufferFragmentData(h,l,d,a)}if(g!=null&&(t=g.samples)!=null&&t.length){let T=dt({id:r,frag:l,details:u},g);s.trigger(b.FRAG_PARSING_METADATA,T)}if(f){let T=dt({id:r,frag:l,details:u},f);s.trigger(b.FRAG_PARSING_USERDATA,T)}}_bufferInitSegment(e,t,r){if(this.state!==V.PARSING)return;e.video&&delete e.video;let s=e.audio;if(!s)return;s.levelCodec=s.codec,s.id="audio",this.log(`Init audio buffer, container:${s.container}, codecs[parsed]=[${s.codec}]`),this.hls.trigger(b.BUFFER_CODECS,e);let n=s.initSegment;if(n!=null&&n.byteLength){let a={type:"audio",frag:t,part:null,chunkMeta:r,parent:t.type,data:n};this.hls.trigger(b.BUFFER_APPENDING,a)}this.tick()}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||s===gt.NOT_LOADED||s===gt.PARTIAL){var n;e.sn==="initSegment"?this._loadInitSegment(e,t):(n=t.details)!=null&&n.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=V.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(e,t,r))}else this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){let{hls:t,media:r,bufferedTrack:s}=this,n=s==null?void 0:s.attrs,a=e.attrs;r&&n&&(n.CHANNELS!==a.CHANNELS||n.NAME!==a.NAME||n.LANGUAGE!==a.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(b.AUDIO_TRACK_SWITCHED,qt({},e))}},Xh=class extends da{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(b.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.LEVEL_LOADING,this.onLevelLoading,this),e.off(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(b.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Track with id:${r} and group:${s} not found in active group ${a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`audio-track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!(t!=null&&t.audioGroupIds))return;let r=t.audioGroupIds[t.urlId];if(this.groupId!==r){this.groupId=r||null;let s=this.tracks.filter(a=>!r||a.groupId===r);this.selectDefaultTrack&&!s.some(a=>a.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=s;let n={audioTracks:s};this.log(`Updating audio tracks, ${s.length} track(s) found in group:${r}`),this.hls.trigger(b.AUDIO_TRACKS_UPDATED,n),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===Me.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();let r=this.currentTrack;t[this.trackId];let s=t[e],{groupId:n,name:a}=s;if(this.log(`Switching to audio-track ${e} "${a}" lang:${s.lang} group:${n}`),this.trackId=e,this.currentTrack=s,this.selectDefaultTrack=!1,this.hls.trigger(b.AUDIO_TRACK_SWITCHING,qt({},s)),s.details&&!s.details.live)return;let o=this.switchParams(s.url,r==null?void 0:r.details);this.loadPlaylist(o)}selectInitialTrack(){let e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(t!==-1)this.setAudioTrack(t);else{let r=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(r.message),this.hls.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:r})}}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if((!this.selectDefaultTrack||s.default)&&(!e||e.attrs["STABLE-RENDITION-ID"]!==void 0&&e.attrs["STABLE-RENDITION-ID"]===s.attrs["STABLE-RENDITION-ID"]||e.name===s.name&&e.lang===s.lang))return s.id}return-1}loadPlaylist(e){super.loadPlaylist();let t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(b.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}};function Kv(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!M1(i[t].attrs,e[t].attrs))return!1;return!0}function M1(i,e){let t=i["STABLE-RENDITION-ID"];return t?t===e["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(r=>i[r]!==e[r])}var Q0=500,Qh=class extends ha{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",fe.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.ERROR,this.onError,this),e.on(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(b.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(b.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.ERROR,this.onError,this),e.off(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(b.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(b.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=V.IDLE,this.setInterval(Q0),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let{frag:r,success:s}=t;if(this.fragPrevious=r,this.state=V.IDLE,!s)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=r.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}let l=r.start+r.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r)}onBufferFlushing(e,t){let{startOffset:r,endOffset:s}=t;if(r===0&&s!==Number.POSITIVE_INFINITY){let n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(r,n,fe.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===fe.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let r=t.frag;(r==null?void 0:r.type)===fe.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==V.STOPPED&&(this.state=V.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(Kv(this.levels,t)){this.levels=t.map(r=>new zr(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{let s=new zr(r);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,fe.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){if(this.currentTrackId=t.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}let r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(Q0)}onSubtitleTrackLoaded(e,t){var r;let{details:s,id:n}=t,{currentTrackId:a,levels:o}=this;if(!o.length)return;let l=o[a];if(n>=o.length||n!==a||!l)return;this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(s.live||(r=l.details)!=null&&r.live){let c=this.mainDetails;if(s.deltaUpdateFailed||!c)return;let u=c.fragments[0];l.details?(d=this.alignPlaylists(s,l.details),d===0&&u&&(d=u.start,Sh(s,d))):s.hasProgramDateTime&&c.hasProgramDateTime?(wv(s,c),d=s.fragments[0].start):u&&(d=u.start,Sh(s,d))}l.details=s,this.levelLastLoaded=n,!this.startFragRequested&&(this.mainDetails||!s.live)&&this.setStartPosition(l.details,d),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===V.IDLE&&(la(null,s.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0))}_handleFragmentLoadComplete(e){let{frag:t,payload:r}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){let a=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{let l=performance.now();n.trigger(b.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=V.IDLE})}}doTick(){if(!this.media){this.state=V.IDLE;return}if(this.state===V.IDLE){let{currentTrackId:e,levels:t}=this,r=t[e];if(!t.length||!r||!r.details)return;let{config:s}=this,n=this.getLoadPosition(),a=je.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,fe.MAIN),c=r.details,u=this.getMaxBufferLength(d==null?void 0:d.len)+c.levelTargetDuration;if(l>u)return;let h=c.fragments,f=h.length,g=c.edge,E=null,T=this.fragPrevious;if(o<g){let A=s.maxFragLookUpTolerance,R=o>g-A?0:A;E=la(T,h,Math.max(h[0].start,o),R),!E&&T&&T.start<h[0].start&&(E=h[0])}else E=h[f-1];if(!E)return;if(E=this.mapToInitFragWhenRequired(E),E.sn!=="initSegment"){let A=E.sn-c.startSN,R=h[A-1];R&&R.cc===E.cc&&this.fragmentTracker.getState(R)===gt.NOT_LOADED&&(E=R)}this.fragmentTracker.getState(E)===gt.NOT_LOADED&&this.loadFragment(E,r,o)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new Zh(this.tracksBuffered[this.currentTrackId]||[])}},Zh=class{constructor(e){this.buffered=void 0;let t=(r,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][r]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}},Jh=class extends da{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(b.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.LEVEL_LOADING,this.onLevelLoading,this),e.off(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(b.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.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))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),oh(this.media.textTracks).forEach(t=>{sn(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:r,details:s}=t,{trackId:n}=this,a=this.tracksInGroup[n];if(!a){this.warn(`Invalid subtitle track id ${r}`);return}let o=a.details;a.details=t.details,this.log(`subtitle track ${r} loaded [${s.startSN}-${s.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!(t!=null&&t.textGroupIds))return;let r=t.textGroupIds[t.urlId],s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==r){let n=this.tracks.filter(l=>!r||l.groupId===r);this.tracksInGroup=n;let a=this.findTrackId(s==null?void 0:s.name)||this.findTrackId();this.groupId=r||null;let o={subtitleTracks:n};this.log(`Updating subtitle tracks, ${n.length} track(s) found in "${r}" group-id`),this.hls.trigger(b.SUBTITLE_TRACKS_UPDATED,o),a!==-1&&this.setSubtitleTrack(a,s)}else this.shouldReloadPlaylist(s)&&this.setSubtitleTrack(this.trackId,s)}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if((!this.selectDefaultTrack||s.default)&&(!e||e===s.name))return s.id}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Me.SUBTITLE_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.checkRetry(t)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1;let t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}loadPlaylist(e){super.loadPlaylist();let t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(b.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(e){let{media:t,trackId:r}=this;if(!t)return;let s=oh(t.textTracks),n=s.filter(o=>o.groupId===this.groupId);if(e===-1)[].slice.call(s).forEach(o=>{o.mode="disabled"});else{let o=n[r];o&&(o.mode="disabled")}let a=n[e];a&&(a.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var r;let s=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(e===-1||(r=s[e])!=null&&r.details)||e<-1||e>=s.length)return;this.clearTimer();let n=s[e];if(this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:"")),this.trackId=e,n){let{id:a,groupId:o="",name:l,type:d,url:c}=n;this.hls.trigger(b.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:c});let u=this.switchParams(n.url,t==null?void 0:t.details);this.loadPlaylist(u)}else this.hls.trigger(b.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1,t=oh(this.media.textTracks);for(let r=0;r<t.length;r++)if(t[r].mode==="hidden")e=r;else if(t[r].mode==="showing"){e=r;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}};function oh(i){let e=[];for(let t=0;t<i.length;t++){let r=i[t];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&e.push(i[t])}return e}var ef=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t){let r=this.queues[t];r.push(e),r.length===1&&this.buffers[t]&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,r=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),r}executeNext(e){let{buffers:t,queues:r}=this,s=t[e],n=r[e];if(n.length){let a=n[0];try{a.execute()}catch(o){C.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),a.onError(o),s!=null&&s.updating||(n.shift(),this.executeNext(e))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}},Z0=dd(),J0=/([ha]vc.)(?:\.[^.,]+)+/,tf=class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{let{media:t,mediaSource:r}=this;C.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(b.MEDIA_ATTACHED,{media:t})),r&&r.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{C.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{C.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{let{media:t,_objectUrl:r}=this;t&&t.src!==r&&C.error(`Media element src was set while attaching MediaSource (${r} > ${t.src})`)},this.hls=e,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){let{hls:e}=this;e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.BUFFER_RESET,this.onBufferReset,this),e.on(b.BUFFER_APPENDING,this.onBufferAppending,this),e.on(b.BUFFER_CODECS,this.onBufferCodecs,this),e.on(b.BUFFER_EOS,this.onBufferEos,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(b.FRAG_PARSED,this.onFragParsed,this),e.on(b.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.BUFFER_RESET,this.onBufferReset,this),e.off(b.BUFFER_APPENDING,this.onBufferAppending,this),e.off(b.BUFFER_CODECS,this.onBufferCodecs,this),e.off(b.BUFFER_EOS,this.onBufferEos,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(b.FRAG_PARSED,this.onFragParsed,this),e.off(b.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new ef(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,C.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let r=this.media=t.media;if(r&&Z0){let s=this.mediaSource=new Z0;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(s),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(C.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){C.warn(`[buffer-controller]: onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):C.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(b.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{let t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(r){C.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,r)}}),this._initSourceBuffer()}onBufferCodecs(e,t){let r=this.getSourceBufferTypes().length;Object.keys(t).forEach(s=>{if(r){let n=this.tracks[s];if(n&&typeof n.buffer.changeType=="function"){let{id:a,codec:o,levelCodec:l,container:d,metadata:c}=t[s],u=(n.levelCodec||n.codec).replace(J0,"$1"),h=(l||o).replace(J0,"$1");if(u!==h){let f=`${d};codecs=${l||o}`;this.appendChangeType(s,f),C.log(`[buffer-controller]: switching codec ${u} to ${h}`),this.tracks[s]={buffer:n.buffer,codec:o,container:d,levelCodec:l,metadata:c,id:a}}}}else this.pendingTracks[s]=t[s]}),!r&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(e,t){let{operationQueue:r}=this,s={execute:()=>{let n=this.sourceBuffer[e];n&&(C.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{C.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,n)}};r.append(s,e)}onBufferAppending(e,t){let{hls:r,operationQueue:s,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:c}=t,u=c.buffering[o],h=self.performance.now();u.start=h;let f=l.stats.buffering,g=d?d.stats.buffering:null;f.start===0&&(f.start=h),g&&g.start===0&&(g.start=h);let E=n.audio,T=!1;o==="audio"&&(E==null?void 0:E.container)==="audio/mpeg"&&(T=!this.lastMpegAudioChunk||c.id===1||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);let A=l.start,R={execute:()=>{if(u.executeStart=self.performance.now(),T){let L=this.sourceBuffer[o];if(L){let N=A-L.timestampOffset;Math.abs(N)>=.1&&(C.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${A} (delta: ${N}) sn: ${l.sn})`),L.timestampOffset=A)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let L=self.performance.now();u.executeEnd=u.end=L,f.first===0&&(f.first=L),g&&g.first===0&&(g.first=L);let{sourceBuffer:N}=this,M={};for(let $ in N)M[$]=je.getBuffered(N[$]);this.appendError=0,this.hls.trigger(b.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:c,parent:l.type,timeRanges:M})},onError:L=>{C.error(`[buffer-controller]: Error encountered while trying to append to the ${o} SourceBuffer`,L);let N={type:he.MEDIA_ERROR,parent:l.type,details:B.BUFFER_APPEND_ERROR,frag:l,part:d,chunkMeta:c,error:L,err:L,fatal:!1};L.code===DOMException.QUOTA_EXCEEDED_ERR?N.details=B.BUFFER_FULL_ERROR:(this.appendError++,N.details=B.BUFFER_APPEND_ERROR,this.appendError>r.config.appendErrorMaxRetry&&(C.error(`[buffer-controller]: Failed ${r.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),N.fatal=!0)),r.trigger(b.ERROR,N)}};s.append(R,o)}onBufferFlushing(e,t){let{operationQueue:r}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(b.BUFFER_FLUSHED,{type:n})},onError:a=>{C.warn(`[buffer-controller]: Failed to remove from ${n} SourceBuffer`,a)}});t.type?r.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{r.append(s(n),n)})}onFragParsed(e,t){let{frag:r,part:s}=t,n=[],a=s?s.elementaryStreams:r.elementaryStreams;a[Ge.AUDIOVIDEO]?n.push("audiovideo"):(a[Ge.AUDIO]&&n.push("audio"),a[Ge.VIDEO]&&n.push("video"));let o=()=>{let l=self.performance.now();r.stats.buffering.end=l,s&&(s.stats.buffering.end=l);let d=s?s.stats:r.stats;this.hls.trigger(b.FRAG_BUFFERED,{frag:r,part:s,stats:d,id:r.type})};n.length===0&&C.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,n)=>{let a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,C.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),s&&!!(!a||a.ended)},!0)&&(C.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{let a=this.sourceBuffer[n];a&&(a.ending=!1)});let{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&C.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}C.log("[buffer-controller]: Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){let{hls:e,details:t,media:r,sourceBuffer:s}=this;if(!r||t===null)return;let n=this.getSourceBufferTypes();if(!n.length)return;let a=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!oe(a)||a<0)return;let o=r.currentTime,l=t.levelTargetDuration,d=Math.max(a,l),c=Math.floor(o/l)*l-d;n.forEach(u=>{let h=s[u];if(h){let f=je.getBuffered(h);if(f.length>0&&c>f.start(0)){if(e.trigger(b.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(b.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(h.ended&&f.end(f.length-1)-o<l*2){C.info(`[buffer-controller]: Cannot flush ${u} back buffer while SourceBuffer is in ended state`);return}e.trigger(b.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:u})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;let{details:e,hls:t,media:r,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=r.duration,o=oe(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(C.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!oe(a))&&(C.log(`[buffer-controller]: Updating Media Source duration to ${n.toFixed(3)}`),s.duration=n)}updateSeekableRange(e){let t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){let n=Math.max(0,r[0].start),a=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,a)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,s=Object.keys(r).length;if(s&&!e||s===2){this.createSourceBuffers(r),this.pendingTracks={};let n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(b.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{let a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(let s in e)if(!t[s]){let n=e[s];if(!n)throw Error(`source buffer exists for track ${s}, however track does not`);let a=n.levelCodec||n.codec,o=`${n.container};codecs=${a}`;C.log(`[buffer-controller]: creating sourceBuffer(${o})`);try{let l=t[s]=r.addSourceBuffer(o),d=s;this.addBufferListener(d,"updatestart",this._onSBUpdateStart),this.addBufferListener(d,"updateend",this._onSBUpdateEnd),this.addBufferListener(d,"error",this._onSBUpdateError),this.tracks[s]={buffer:l,codec:a,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(l){C.error(`[buffer-controller]: error while trying to add sourceBuffer: ${l.message}`),this.hls.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:o})}}}_onSBUpdateStart(e){let{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){let{operationQueue:t}=this;t.current(e).onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){let r=new Error(`${e} SourceBuffer error`);C.error(`[buffer-controller]: ${r}`,t),this.hls.trigger(b.ERROR,{type:he.MEDIA_ERROR,details:B.BUFFER_APPENDING_ERROR,error:r,fatal:!1});let s=this.operationQueue.current(e);s&&s.onError(t)}removeExecutor(e,t,r){let{media:s,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!s||!n||!l){C.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}let d=oe(s.duration)?s.duration:1/0,c=oe(n.duration)?n.duration:1/0,u=Math.max(0,t),h=Math.min(r,d,c);h>u&&!l.ending?(l.ended=!1,C.log(`[buffer-controller]: Removing [${u},${h}] from the ${e} SourceBuffer`),l.remove(u,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){let{operationQueue:r,sourceBuffer:s}=this,n=s[t];if(!n){C.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),r.shiftAndExecuteNext(t);return}n.ended=!1,n.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){C.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}let{operationQueue:r}=this,s=t.map(n=>r.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{let a=this.sourceBuffer[n];a!=null&&a.updating||r.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){let s=this.sourceBuffer[e];if(!s)return;let n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){let t=this.sourceBuffer[e];t&&this.listeners[e].forEach(r=>{t.removeEventListener(r.event,r.listener)})}},ev={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},Wv=function(e){let t=e;return ev.hasOwnProperty(e)&&(t=ev[e]),String.fromCharCode(t)},bi=15,Xi=100,P1={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},O1={17:2,18:4,21:6,22:8,23:10,19:13,20:15},N1={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},U1={25:2,26:4,29:6,30:8,31:10,27:13,28:15},F1=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],rf=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let r=typeof t=="function"?t():t;C.log(`${this.time} [${e}] ${r}`)}}},Kr=function(e){let t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t},id=class{constructor(e,t,r,s,n){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=s||"black",this.flash=n||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){let s=t[r];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}},sf=class{constructor(e,t,r,s,n,a){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new id(t,r,s,n,a)}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}},nf=class{constructor(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let t=0;t<Xi;t++)this.chars.push(new sf);this.logger=e,this.pos=0,this.currPenState=new id}equals(e){let t=!0;for(let r=0;r<Xi;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t}copy(e){for(let t=0;t<Xi;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Xi;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Xi&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Xi)}moveCursor(e){let t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=Wv(e);if(this.pos>=Xi){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<Xi;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let r=0;r<Xi;r++){let s=this.chars[r].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}},aa=class{constructor(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let t=0;t<bi;t++)this.rows.push(new nf(e));this.logger=e,this.currRow=bi-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<bi;e++)this.rows[e].clear();this.currRow=bi-1}equals(e){let t=!0;for(let r=0;r<bi;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<bi;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<bi;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<bi;o++)this.rows[o].clear();let n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){let o=a.rows[n].cueStartTime,l=this.logger.time;if(o&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;let r=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);r.setCursor(e.indent),e.color=r.chars[a].penState.foreground}let s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],r="",s=-1;for(let n=0;n<bi;n++){let a=this.rows[n].getTextString();a&&(s=n+1,e?t.push("Row "+s+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?r="["+t.join(" | ")+"]":r=t.join(`
1066
+ `)),r}getTextAndFormat(){return this.rows}},rd=class{constructor(e,t,r){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=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new aa(r),this.nonDisplayedMemory=new aa(r),this.lastOutputScreen=new aa(r),this.currRollUpRow=this.displayedMemory.rows[bi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[bi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),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=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{let r=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}},sd=class{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;let s=new rf;this.channels=[null,new rd(e,t,s),new rd(e+1,r,s)],this.cmdHistory=iv(),this.logger=s}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let r,s,n,a=!1;this.logger.time=e;for(let o=0;o<t.length;o+=2)if(s=t[o]&127,n=t[o+1]&127,!(s===0&&n===0)){if(this.logger.log(3,"["+Kr([t[o],t[o+1]])+"] -> ("+Kr([s,n])+")"),r=this.parseCmd(s,n),r||(r=this.parseMidrow(s,n)),r||(r=this.parsePAC(s,n)),r||(r=this.parseBackgroundAttributes(s,n)),!r&&(a=this.parseChars(s,n),a)){let l=this.currentChannel;l&&l>0?this.channels[l].insertChars(a):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!r&&!a&&this.logger.log(2,"Couldn't parse cleaned data "+Kr([s,n])+" orig: "+Kr([t[o],t[o+1]]))}}parseCmd(e,t){let{cmdHistory:r}=this,s=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,n=(e===23||e===31)&&t>=33&&t<=35;if(!(s||n))return!1;if(tv(e,t,r))return rn(null,null,r),this.logger.log(3,"Repeated command ("+Kr([e,t])+") is dropped"),!0;let a=e===20||e===21||e===23?1:2,o=this.channels[a];return e===20||e===21||e===28||e===29?t===32?o.ccRCL():t===33?o.ccBS():t===34?o.ccAOF():t===35?o.ccAON():t===36?o.ccDER():t===37?o.ccRU(2):t===38?o.ccRU(3):t===39?o.ccRU(4):t===40?o.ccFON():t===41?o.ccRDC():t===42?o.ccTR():t===43?o.ccRTD():t===44?o.ccEDM():t===45?o.ccCR():t===46?o.ccENM():t===47&&o.ccEOC():o.ccTO(t-32),rn(e,t,r),this.currentChannel=a,!0}parseMidrow(e,t){let r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let s=this.channels[r];return s?(s.ccMIDROW(t),this.logger.log(3,"MIDROW ("+Kr([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let r,s=this.cmdHistory,n=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,a=(e===16||e===24)&&t>=64&&t<=95;if(!(n||a))return!1;if(tv(e,t,s))return rn(null,null,s),!0;let o=e<=23?1:2;t>=64&&t<=95?r=o===1?P1[e]:N1[e]:r=o===1?O1[e]:U1[e];let l=this.channels[o];return l?(l.setPAC(this.interpretPAC(r,t)),rn(e,t,s),this.currentChannel=o,!0):!1}interpretPAC(e,t){let r,s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?r=t-96:r=t-64,s.underline=(r&1)===1,r<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((r-16)/2)*4,s}parseChars(e,t){let r,s=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,"Special char '"+Wv(a)+"' in channel "+r),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);if(s){let a=Kr(s);this.logger.log(3,"Char codes = "+a.join(",")),rn(e,t,this.cmdHistory)}return s}parseBackgroundAttributes(e,t){let r=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(r||s))return!1;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=F1[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));let o=e<=23?1:2;return this.channels[o].setBkgData(a),rn(e,t,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}this.cmdHistory=iv()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let r=this.channels[t];r&&r.cueSplitAtTime(e)}}};function rn(i,e,t){t.a=i,t.b=e}function tv(i,e,t){return t.a===i&&t.b===e}function iv(){return{a:null,b:null}}var nn=class{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}},If=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;let i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;let d=l.toLowerCase();return~o.indexOf(d)?d:!1}function r(o){return t(i,o)}function s(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){let c=arguments[d];for(let u in c)o[u]=c[u]}return o}function a(o,l,d){let c=this,u={enumerable:!0};c.hasBeenReset=!1;let h="",f=!1,g=o,E=l,T=d,A=null,R="",L=!0,N="auto",M="start",$=50,U="middle",H=50,W="middle";Object.defineProperty(c,"id",n({},u,{get:function(){return h},set:function(O){h=""+O}})),Object.defineProperty(c,"pauseOnExit",n({},u,{get:function(){return f},set:function(O){f=!!O}})),Object.defineProperty(c,"startTime",n({},u,{get:function(){return g},set:function(O){if(typeof O!="number")throw new TypeError("Start time must be set to a number.");g=O,this.hasBeenReset=!0}})),Object.defineProperty(c,"endTime",n({},u,{get:function(){return E},set:function(O){if(typeof O!="number")throw new TypeError("End time must be set to a number.");E=O,this.hasBeenReset=!0}})),Object.defineProperty(c,"text",n({},u,{get:function(){return T},set:function(O){T=""+O,this.hasBeenReset=!0}})),Object.defineProperty(c,"region",n({},u,{get:function(){return A},set:function(O){A=O,this.hasBeenReset=!0}})),Object.defineProperty(c,"vertical",n({},u,{get:function(){return R},set:function(O){let z=r(O);if(z===!1)throw new SyntaxError("An invalid or illegal string was specified.");R=z,this.hasBeenReset=!0}})),Object.defineProperty(c,"snapToLines",n({},u,{get:function(){return L},set:function(O){L=!!O,this.hasBeenReset=!0}})),Object.defineProperty(c,"line",n({},u,{get:function(){return N},set:function(O){if(typeof O!="number"&&O!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");N=O,this.hasBeenReset=!0}})),Object.defineProperty(c,"lineAlign",n({},u,{get:function(){return M},set:function(O){let z=s(O);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");M=z,this.hasBeenReset=!0}})),Object.defineProperty(c,"position",n({},u,{get:function(){return $},set:function(O){if(O<0||O>100)throw new Error("Position must be between 0 and 100.");$=O,this.hasBeenReset=!0}})),Object.defineProperty(c,"positionAlign",n({},u,{get:function(){return U},set:function(O){let z=s(O);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");U=z,this.hasBeenReset=!0}})),Object.defineProperty(c,"size",n({},u,{get:function(){return H},set:function(O){if(O<0||O>100)throw new Error("Size must be between 0 and 100.");H=O,this.hasBeenReset=!0}})),Object.defineProperty(c,"align",n({},u,{get:function(){return W},set:function(O){let z=s(O);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");W=z,this.hasBeenReset=!0}})),c.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),af=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function qv(i){function e(r,s,n,a){return(r|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}let t=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}var of=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let s=0;s<r.length;++s)if(t===r[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}};function Yv(i,e,t,r){let s=r?i.split(r):[i];for(let n in s){if(typeof s[n]!="string")continue;let a=s[n].split(t);if(a.length!==2)continue;let o=a[0],l=a[1];e(o,l)}}var lf=new If(0,0,""),Ul=lf.align==="middle"?"middle":"center";function B1(i,e,t){let r=i;function s(){let o=qv(i);if(o===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){let d=new of;Yv(o,function(h,f){let g;switch(h){case"region":for(let E=t.length-1;E>=0;E--)if(t[E].id===f){d.set(h,t[E].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":g=f.split(","),d.integer(h,g[0]),d.percent(h,g[0])&&d.set("snapToLines",!1),d.alt(h,g[0],["auto"]),g.length===2&&d.alt("lineAlign",g[1],["start",Ul,"end"]);break;case"position":g=f.split(","),d.percent(h,g[0]),g.length===2&&d.alt("positionAlign",g[1],["start",Ul,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",Ul,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let c=d.get("line","auto");c==="auto"&&lf.line===-1&&(c=-1),l.line=c,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",Ul);let u=d.get("position","auto");u==="auto"&&lf.position===50&&(u=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=u}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),a(),e.endTime=s(),a(),n(i,e)}function jv(i){return i.replace(/<br(?: \/)?>/gi,`
1067
+ `)}var df=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new af,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){let t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function r(){let n=t.buffer,a=0;for(n=jv(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
1032
1068
  `;)++a;let o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
1033
- `&&++a,t.buffer=n.slice(a),o}function s(n){tv(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=r();let o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=r(),t.state){case"HEADER":/:/.test(n)?s(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new rf(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{MA(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let o=n.indexOf("-->")!==-1;if(!n||o&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
1069
+ `&&++a,t.buffer=n.slice(a),o}function s(n){Yv(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=r();let o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=r(),t.state){case"HEADER":/:/.test(n)?s(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new If(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{B1(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let o=n.indexOf("-->")!==-1;if(!n||o&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
1034
1070
  `),t.cue.text+=n}continue;case"BADCUE":n||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){let e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
1035
1071
 
1036
- `,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}},OA=/\r\n|\n\r|\n|\r/g,Gu=function(e,t,r=0){return e.slice(r,r+t.length)===t},PA=function(e){let t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!ce(t)||!ce(r)||!ce(s)||!ce(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=60*1e3*s,t+=60*60*1e3*n,t},Vu=function(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0).toString()};function sf(i,e,t){return Vu(i.toString())+Vu(e.toString())+Vu(t)}var NA=function(e,t,r){let s=e[t],n=e[s.prevCC];if(!n||!n.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=s.start-n.start,s.new=!1,s=n,n=e[s.prevCC]}e.presentationOffset=r};function UA(i,e,t,r,s,n,a){let o=new Hh,l=ji(new Uint8Array(i)).trim().replace(OA,`
1072
+ `,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}},$1=/\r\n|\n\r|\n|\r/g,lh=function(e,t,r=0){return e.slice(r,r+t.length)===t},H1=function(e){let t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!oe(t)||!oe(r)||!oe(s)||!oe(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=60*1e3*s,t+=60*60*1e3*n,t},dh=function(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0).toString()};function Lf(i,e,t){return dh(i.toString())+dh(e.toString())+dh(t)}var G1=function(e,t,r){let s=e[t],n=e[s.prevCC];if(!n||!n.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=s.start-n.start,s.new=!1,s=n,n=e[s.prevCC]}e.presentationOffset=r};function V1(i,e,t,r,s,n,a){let o=new df,l=Hi(new Uint8Array(i)).trim().replace($1,`
1037
1073
  `).split(`
1038
- `),d=[],c=e?pA(e.baseTime,e.timescale):0,u="00:00.000",h=0,f=0,g,E=!0;o.oncue=function(T){let A=t[r],k=t.ccOffset,L=(h-c)/9e4;if(A!=null&&A.new&&(f!==void 0?k=t.ccOffset=A.start:NA(t,r,L)),L){if(!e){g=new Error("Missing initPTS for VTT MPEGTS");return}k=L-t.presentationOffset}let N=T.endTime-T.startTime,D=ci((T.startTime+k-f)*9e4,s*9e4)/9e4;T.startTime=Math.max(D,0),T.endTime=Math.max(D+N,0);let $=T.text.trim();T.text=decodeURIComponent(encodeURIComponent($)),T.id||(T.id=sf(T.startTime,T.endTime,$)),T.endTime>0&&d.push(T)},o.onparsingerror=function(T){g=T},o.onflush=function(){if(g){a(g);return}n(d)},l.forEach(T=>{if(E)if(Gu(T,"X-TIMESTAMP-MAP=")){E=!1,T.slice(16).split(",").forEach(A=>{Gu(A,"LOCAL:")?u=A.slice(6):Gu(A,"MPEGTS:")&&(h=parseInt(A.slice(7)))});try{f=PA(u)/1e3}catch(A){g=A}return}else T===""&&(E=!1);o.parse(T+`
1039
- `)}),o.flush()}var Ku="stpp.ttml.im1t",rv=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,sv=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,FA={left:"start",center:"center",right:"end",start:"start",end:"end"};function u0(i,e,t,r){let s=Pe(new Uint8Array(i),["mdat"]);if(s.length===0){r(new Error("Could not parse IMSC1 mdat"));return}let n=s.map(o=>ji(o)),a=mA(e.baseTime,1,e.timescale);try{n.forEach(o=>t(BA(o,a)))}catch(o){r(o)}}function BA(i,e){let s=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");let n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((u,h)=>(u[h]=s.getAttribute(`ttp:${h}`)||n[h],u),{}),o=s.getAttribute("xml:space")!=="preserve",l=h0(Wu(s,"styling","style")),d=h0(Wu(s,"layout","region")),c=Wu(s,"body","[begin]");return[].map.call(c,u=>{let h=nv(u,o);if(!h||!u.hasAttribute("begin"))return null;let f=Yu(u.getAttribute("begin"),a),g=Yu(u.getAttribute("dur"),a),E=Yu(u.getAttribute("end"),a);if(f===null)throw f0(u);if(E===null){if(g===null)throw f0(u);E=f+g}let T=new rf(f-e,E-e,h);T.id=sf(T.startTime,T.endTime,T.text);let A=d[u.getAttribute("region")],k=l[u.getAttribute("style")],L=$A(A,k,l),{textAlign:N}=L;if(N){let D=FA[N];D&&(T.lineAlign=D),T.align=N}return mt(T,L),T}).filter(u=>u!==null)}function Wu(i,e,t){let r=i.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function h0(i){return i.reduce((e,t)=>{let r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function nv(i,e){return[].slice.call(i.childNodes).reduce((t,r,s)=>{var n;return r.nodeName==="br"&&s?t+`
1040
- `:(n=r.childNodes)!=null&&n.length?nv(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function $A(i,e,t){let r="http://www.w3.org/ns/ttml#styling",s=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{let d=qu(e,r,l)||qu(i,r,l)||qu(s,r,l);return d&&(o[l]=d),o},{})}function qu(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function f0(i){return new Error(`Could not parse ttml timestamp ${i}`)}function Yu(i,e){if(!i)return null;let t=ev(i);return t===null&&(rv.test(i)?t=HA(i,e):sv.test(i)&&(t=GA(i,e))),t}function HA(i,e){let t=rv.exec(i),r=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+r/e.frameRate}function GA(i,e){let t=sv.exec(i),r=Number(t[1]);switch(t[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}var Gh=class{constructor(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=m0(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){let t=new en(this,"textTrack1"),r=new en(this,"textTrack2"),s=new en(this,"textTrack3"),n=new en(this,"textTrack4");this.cea608Parser1=new zl(1,t,r),this.cea608Parser2=new zl(3,s,n)}e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(b.FRAG_LOADING,this.onFragLoading,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(b.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(b.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(b.FRAG_LOADING,this.onFragLoading,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(b.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(b.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,r,s,n){let a=!1;for(let o=n.length;o--;){let l=n[o],d=KA(l[0],l[1],t,r);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),a=!0,d/(r-t)>.5))return}if(a||n.push([t,r]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,r,s)}else{let o=this.Cues.newCue(null,t,r,s);this.hls.trigger(b.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){let{unparsedVttFrags:a}=this;r==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(b.FRAG_LOADED,o)}))}getExistingTrack(e){let{media:t}=this;if(t)for(let r=0;r<t.textTracks.length;r++){let s=t.textTracks[r];if(s[e])return s}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:r,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(e);if(o)r[e]=o,Js(r[e]),D0(r[e],s);else{let l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,r[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let r=t.label,s={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(b.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,r){let s=this.media;if(!!s)return s.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{Js(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=m0(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let r=0;r<t.length;r++)Js(t[r])}onSubtitleTracksUpdated(e,t){let r=t.subtitleTracks||[],s=r.some(n=>n.textCodec===Ku);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(Z0(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){let a=this.media?this.media.textTracks:null;this.tracks.forEach((o,l)=>{let d;if(a&&l<a.length){let c=null;for(let u=0;u<a.length;u++)if(VA(a[u],o)){c=a[u];break}c&&(d=c)}if(d)Js(d);else{let c=this._captionsOrSubtitlesFromCharacteristics(o);d=this.createTextTrack(c,o.name,o.lang),d&&(d.mode="disabled")}d&&(d.groupId=o.groupId,this.textTracks.push(d))})}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(b.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){let t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),r=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&r)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(r=>{let s=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!s)return;let n=`textTrack${s[1]}`,a=this.captionsProperties[n];!a||(a.label=r.name,r.lang&&(a.languageCode=r.lang),a.media=r)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){let{cea608Parser1:r,cea608Parser2:s,lastSn:n,lastPartIndex:a}=this;if(!(!this.enabled||!(r&&s))&&t.frag.type===ge.MAIN){var o,l;let d=t.frag.sn,c=(o=t==null||(l=t.part)==null?void 0:l.index)!=null?o:-1;d===n+1||d===n&&c===a+1||(r.reset(),s.reset()),this.lastSn=d,this.lastPartIndex=c}}onFragLoaded(e,t){let{frag:r,payload:s}=t;if(r.type===ge.SUBTITLE)if(s.byteLength){let n=r.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),o&&o.textCodec===Ku?this._parseIMSC1(r,s):this._parseVTTs(t)}}else this.hls.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){let r=this.hls;u0(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),r.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{M.log(`Failed to parse IMSC1: ${s}`),r.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;let{frag:r,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[r.cc]&&o===-1){a.push(e);return}let l=this.hls,d=(t=r.initSegment)!=null&&t.data?Qr(r.initSegment.data,new Uint8Array(s)):s;UA(d,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,c=>{this._appendCues(c,r.level),l.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},c=>{let u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(r,s),M.log(`Failed to parse VTT cue: ${c}`),!(u&&o>r.cc)&&l.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:c})})}_fallbackToIMSC1(e,t){let r=this.tracks[e.level];r.textCodec||u0(t,this.initPTS[e.cc],()=>{r.textCodec=Ku,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){let r=this.hls;if(this.config.renderTextTracksNatively){let s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>C0(s,n))}else{let s=this.tracks[t];if(!s)return;let n=s.default?"default":"subtitles"+t;r.trigger(b.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){let{frag:r}=t;r.type===ge.SUBTITLE&&this.onFragLoaded(b.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){let{cea608Parser1:r,cea608Parser2:s}=this;if(!this.enabled||!(r&&s))return;let{frag:n,samples:a}=t;if(!(n.type===ge.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){let l=a[o].bytes;if(l){let d=this.extractCea608Data(l);r.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:s,type:n}){let{media:a}=this;if(!(!a||a.currentTime<r)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>Ju(o[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>Ju(o[l],t,s))}}}extractCea608Data(e){let t=[[],[]],r=e[0]&31,s=2;for(let n=0;n<r;n++){let a=e[s++],o=127&e[s++],l=127&e[s++];if(o===0&&l===0)continue;if((4&a)!==0){let c=3&a;(c===0||c===1)&&(t[c].push(o),t[c].push(l))}}return t}};function VA(i,e){return!!i&&i.label===e.name&&!(i.textTrack1||i.textTrack2)}function KA(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function m0(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var na=class{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(b.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.BUFFER_CODECS,this.onBufferCodecs,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(b.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.BUFFER_CODECS,this.onBufferCodecs,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){let r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){let e=this.hls.levels;if(e.length){let t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return-1;let r=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,na.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){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())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(r=>e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height)}static getMaxLevelByMediaSize(e,t,r){if(!(e!=null&&e.length))return-1;let s=(a,o)=>o?a.width!==o.width||a.height!==o.height:!0,n=e.length-1;for(let a=0;a<e.length;a+=1){let o=e[a];if((o.width>=t||o.height>=r)&&s(o,e[a+1])){n=a;break}}return n}},Vh=class{constructor(e){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=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let r=this.hls.config;if(r.capLevelOnFPSDrop){let s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){let s=performance.now();if(t){if(this.lastTime){let n=s-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(b.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let c=d.currentLevel;M.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=c)&&(c=c-1,d.trigger(b.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},Rl="[eme]",Ar=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Ar.CDMCleanupPromise?[Ar.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=M.debug.bind(M,Rl),this.log=M.log.bind(M,Rl),this.warn=M.warn.bind(M,Rl),this.error=M.error.bind(M,Rl),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(b.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(b.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(b.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(b.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:r}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===nt.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){let{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,r=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(r),n=t.map(a=>a.videoCodec).filter(r);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{let l=d=>{let c=d.shift();this.getMediaKeysPromise(c,s,n).then(u=>a({keySystem:c,mediaKeys:u})).catch(u=>{d.length?l(d):u instanceof Wt?o(u):o(new Wt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_ACCESS,error:u,fatal:!0},u.message))})};l(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${r}`;return b0===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return r(e,t)}getMediaKeysPromise(e,t,r){let s=VT(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e],a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);let o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);let d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(c=>(this.log(`Media-keys created for "${e}"`),d.then(u=>u?this.setMediaKeysServerCertificate(c,e,u):c))),o.mediaKeys.catch(c=>{this.error(`Failed to create media-keys for "${e}"}: ${c}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${Vi.hexDump(e.keyId||[])}`);let s=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let r=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(r,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Vi.hexDump(e.keyId)}updateKeySession(e,t){var r;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Vi.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[])}
1041
- } (data length: ${t&&t.byteLength})`),s.update(t)}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{let s=ku(this.config),n=e.map(Cg).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=Mg(a);o?t(o):r(new Error(`Unable to find format for key-system "${a}"`))}).catch(r)})}loadKey(e){let t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[r];return n||(n=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();let l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t}),d="cenc";return this.generateRequestWithPreferredKeySession(l,d,t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){!this.hls||(this.error(e.message),e instanceof Wt?this.hls.trigger(b.ERROR,e.data):this.hls.trigger(b.ERROR,{type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){let s=Cg(e.keyFormat),n=s?[s]:ku(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=ku(this.config)),e.length===0)throw new Wt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){let{initDataType:t,initData:r}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),r===null)return;let s,n;if(t==="sinf"&&this.config.drmSystems[nt.FAIRPLAY]){let c=Lt(new Uint8Array(r));try{let u=jh(JSON.parse(c).sinf),h=L0(new Uint8Array(u));if(!h)return;s=h.subarray(8,24),n=nt.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{let c=f_(r);if(c===null)return;c.version===0&&c.systemId===E0.WIDEVINE&&c.data&&(s=c.data.subarray(8,24)),n=GT(c.systemId)}if(!n||!s)return;let a=Vi.hexDump(s),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this,d=o[a];for(let c=0;c<l.length;c++){let u=l[c],h=u.decryptdata;if(h.pssh||!h.keyId)continue;let f=Vi.hexDump(h.keyId);if(a===f||h.uri.replace(/-/g,"").indexOf(a)!==-1){d=o[f],delete o[f],h.pssh=new Uint8Array(r),h.keyId=s,d=o[a]=d.then(()=>this.generateRequestWithPreferredKeySession(u,t,r,"encrypted-event-key-match"));break}}d||(d=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:c,mediaKeys:u})=>{var h;this.throwIfDestroyed();let f=new Zr("ISO-23001-7",a,(h=Mg(c))!=null?h:"");return f.pssh=new Uint8Array(r),f.keyId=s,this.attemptSetMediaKeys(c,u).then(()=>{this.throwIfDestroyed();let g=this.createMediaKeySessionContext({decryptdata:f,keySystem:c,mediaKeys:u});return this.generateRequestWithPreferredKeySession(g,t,r,"encrypted-event-no-match")})})),d.catch(c=>this.handleError(c))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){let r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let s=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>r.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,r,s){var n,a;let o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{let h=o.call(this.hls,t,r,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,r=e.decryptdata.pssh=h.initData?new Uint8Array(h.initData):null}catch(h){var l;if(this.warn(h.message),(l=this.hls)!=null&&l.config.debug)throw h}if(r===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);let d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${d} (init data type: ${t} length: ${r?r.byteLength:null})`);let c=new tf;e.mediaKeysSession.onmessage=h=>{let f=e.mediaKeysSession;if(!f){c.emit("error",new Error("invalid state"));return}let{messageType:g,message:E}=h;this.log(`"${g}" message event for session "${f.sessionId}" message size: ${E.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,E).catch(T=>{this.handleError(T),c.emit("error",T)}):g==="license-release"?e.keySystem===nt.FAIRPLAY&&(this.updateKeySession(e,v0("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},e.mediaKeysSession.onkeystatuseschange=h=>{if(!e.mediaKeysSession){c.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let g=e.keyStatus;c.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};let u=new Promise((h,f)=>{c.on("error",f),c.on("keyStatus",g=>{g.startsWith("usable")?h():g==="output-restricted"?f(new Wt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?f(new Wt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?f(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var h;this.log(`Request generated for key-session "${(h=e.mediaKeysSession)==null?void 0:h.sessionId}" keyId: ${d}`)}).catch(h=>{throw new Wt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_SESSION,error:h,fatal:!1},`Error generating key-session request: ${h}`)}).then(()=>u).catch(h=>{throw c.removeAllListeners(),this.removeSession(e),h}).then(()=>(c.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Vi.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${Vi.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,r=t.loader,s=new r(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching serverCertificate for "${e}"`),new Promise((a,o)=>{let l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,E)=>{a(h.data)},onError:(h,f,g,E)=>{o(new Wt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:Yt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,g)=>{o(new Wt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,g)=>{o(new Error("aborted"))}};s.load(l,c,u)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((s,n)=>{e.setServerCertificate(r).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new Wt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(r=>this.updateKeySession(e,new Uint8Array(r)).catch(s=>{throw new Wt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}setupLicenseXHR(e,t,r,s){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,s)}).catch(a=>{if(!r.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,r,s)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){let r=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{let a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);let d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(c){this.error(c)}s(l)}else{let l=r.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new Wt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{let c=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${c} attempts left`),this.requestLicense(e,t).then(s,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){let e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Zr.clearKeyUriToKeyIdMap();let r=t.length;Ar.CDMCleanupPromise=Promise.all(t.map(s=>this.removeSession(s)).concat(e==null?void 0:e.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}. media.src: ${e==null?void 0:e.src}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}. media.src: ${e==null?void 0:e.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){let r=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),t.onmessage=null,t.onkeystatuseschange=null,r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}};Ar.CDMCleanupPromise=void 0;var Wt=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}},WA=1,Vt={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},qA="h",qi=class{constructor(e){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=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:Vt.MANIFEST,su:!this.initialized})}catch(n){M.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{let n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===Vt.VIDEO||o===Vt.AUDIO||o==Vt.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){M.warn("Could not generate segment CMCD data.",n)}},this.hls=e;let t=this.config=e.config,{cmcd:r}=t;r!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||qi.uuid(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.registerListeners())}registerListeners(){let e=this.hls;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHED,this.onMediaDetached,this),e.on(b.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHED,this.onMediaDetached,this),e.off(b.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,s;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:WA,sf:qA,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){mt(t,this.createData());let r=t.ot===Vt.INIT||t.ot===Vt.VIDEO||t.ot===Vt.MUXED;if(this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){let s=qi.toHeaders(t);if(!Object.keys(s).length)return;e.headers||(e.headers={}),mt(e.headers,s)}else{let s=qi.toQuery(t);if(!s)return;e.url=qi.appendQueryToUri(e.url,s)}}getObjectType(e){let{type:t}=e;if(t==="subtitle")return Vt.TIMED_TEXT;if(e.sn==="initSegment")return Vt.INIT;if(t==="audio")return Vt.AUDIO;if(t==="main")return this.hls.audioTracks.length?Vt.VIDEO:Vt.MUXED}getTopBandwidth(e){let t=0,r,s=this.hls;if(e===Vt.AUDIO)r=s.audioTracks;else{let n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;r=s.levels.slice(0,a)}for(let n of r)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,r=e===Vt.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!t?NaN:je.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}static uuid(){let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}static serialize(e){let t=[],r=d=>!Number.isNaN(d)&&d!=null&&d!==""&&d!==!1,s=d=>Math.round(d),n=d=>s(d/100)*100,o={br:s,d:s,bl:n,dl:n,mtp:n,nor:d=>encodeURIComponent(d),rtp:n,tb:s},l=Object.keys(e||{}).sort();for(let d of l){let c=e[d];if(!r(c)||d==="v"&&c===1||d=="pr"&&c===1)continue;let u=o[d];u&&(c=u(c));let h=typeof c,f;d==="ot"||d==="sf"||d==="st"?f=`${d}=${c}`:h==="boolean"?f=d:h==="number"?f=`${d}=${c}`:f=`${d}=${JSON.stringify(c)}`,t.push(f)}return t.join(",")}static toHeaders(e){let t=Object.keys(e),r={},s=["Object","Request","Session","Status"],n=[{},{},{},{}],a={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};for(let o of t){let l=a[o]!=null?a[o]:1;n[l][o]=e[o]}for(let o=0;o<n.length;o++){let l=qi.serialize(n[o]);l&&(r[`CMCD-${s[o]}`]=l)}return r}static toQuery(e){return`CMCD=${encodeURIComponent(qi.serialize(e))}`}static appendQueryToUri(e,t){if(!t)return e;let r=e.includes("?")?"&":"?";return`${e}${r}${t}`}},YA=3e5,Kh=class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=M.log.bind(M,"[content-steering]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;!e||(e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){let e=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(r=>r!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:r}=t;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:r}=t;if((r==null?void 0:r.action)===Ct.SendAlternateToPenaltyBox&&r.flags===di.MoveAllAlternatesMatchingHost){let s=this.pathwayPriority,n=this.pathwayId;this.penalizedPathways[n]||(this.penalizedPathways[n]=performance.now()),!s&&this.levels&&(s=this.levels.reduce((a,o)=>(a.indexOf(o.pathwayId)===-1&&a.push(o.pathwayId),a),[])),s&&s.length>1&&(this.updatePathwayPriority(s),r.resolved=this.pathwayId!==n)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t,r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(n=>{s-r[n]>YA&&delete r[n]});for(let n=0;n<e.length;n++){let a=e[n];if(r[a])continue;if(a===this.pathwayId)return;let o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,this.hls.trigger(b.LEVELS_UPDATED,{levels:t});let d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}clonePathways(e){let t=this.levels;if(!t)return;let r={},s={};e.forEach(n=>{let{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(c=>c.pathwayId===a))return;let d=this.getLevelsForPathway(o).map(c=>{let u=mt({},c);u.details=void 0,u.url=av(c.uri,c.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l);let h=new Qe(c.attrs);h["PATHWAY-ID"]=a;let f=h.AUDIO&&`${h.AUDIO}_clone_${a}`,g=h.SUBTITLES&&`${h.SUBTITLES}_clone_${a}`;f&&(r[h.AUDIO]=f,h.AUDIO=f),g&&(s[h.SUBTITLES]=g,h.SUBTITLES=g),u.attrs=h;let E=new Jr(u);return Fl(E,"audio",f),Fl(E,"text",g),E});t.push(...d),p0(this.audioTracks,r,l,a),p0(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){let t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){let c=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+c)}let n={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(c,u,h,f)=>{this.log(`Loaded steering manifest: "${s}"`);let g=c.data;if(g.VERSION!==1){this.log(`Steering VERSION ${g.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=g.TTL;let{"RELOAD-URI":E,"PATHWAY-CLONES":T,"PATHWAY-PRIORITY":A}=g;if(E)try{this.uri=new self.URL(E,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${E}`);return}this.scheduleRefresh(this.uri||h.url),T&&this.clonePathways(T),A&&this.updatePathwayPriority(A)},onError:(c,u,h,f)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${u.url})`),this.stopLoad(),c.code===410){this.enabled=!1,this.log(`Steering manifest ${u.url} no longer available`);return}let g=this.timeToLoad*1e3;if(c.code===429){let E=this.loader;if(typeof(E==null?void 0:E.getResponseHeader)=="function"){let T=E.getResponseHeader("Retry-After");T&&(g=parseFloat(T)*1e3)}this.log(`Steering manifest ${u.url} rate limited`);return}this.scheduleRefresh(this.uri||u.url,g)},onTimeout:(c,u,h)=>{this.log(`Timeout loading steering manifest (${u.url})`),this.scheduleRefresh(this.uri||u.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},t)}};function p0(i,e,t,r){!i||Object.keys(e).forEach(s=>{let n=i.filter(a=>a.groupId===s).map(a=>{let o=mt({},a);return o.details=void 0,o.attrs=new Qe(o.attrs),o.url=o.attrs.URI=av(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=r,o});i.push(...n)})}function av(i,e,t,r){let{HOST:s,PARAMS:n,[t]:a}=r,o;e&&(o=a==null?void 0:a[e],o&&(i=o));let l=new self.URL(i);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}var jA=/^age:\s*[\d.]+\s*$/im,Xl=class{constructor(e){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=e&&e.xhrSetup||null,this.stats=new tn,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e)return;let r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!this.stats.aborted)return n(r,t.url)}).catch(a=>(r.open("GET",t.url,!0),n(r,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(a=>{this.callbacks.onError({code:r.status,text:a.message},t,r,s)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);let s=this.context.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=r.loadPolicy;if(s)for(let o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&ce(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:r}=this;if(!e||!t)return;let s=t.readyState,n=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let a=t.status,o=t.responseType!=="text";if(a>=200&&a<300&&(o&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);let l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(r.loaded=r.total=d,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;let c=this.callbacks.onProgress;if(c&&c(r,e,l,t),!this.callbacks)return;let u={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(u,r,e,t)}else{let l=n.loadPolicy.errorRetry,d=r.retry;Ul(l,d,!1,a)?this.retry(l):(M.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}}loadtimeout(){var e;let t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,r=this.stats.retry;if(Ul(t,r,!0))this.retry(t);else{M.warn(`timeout while loading ${this.context.url}`);let s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:r}=this;this.retryDelay=Xh(e,r.retry),r.retry++,M.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&jA.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}};function zA(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var XA=/(\d+)-(\d+)\/(\d+)/,Ql=class{constructor(e){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=e.fetchSetup||e1,this.controller=new self.AbortController,this.stats=new tn}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){let e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){let s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();let n=QA(e,this.controller.signal),a=r.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:c}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&ce(d)?d:c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(u=>{this.response=this.loader=u;let h=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},c-(h-s.loading.start)),!u.ok){let{status:f,statusText:g}=u;throw new Wh(g||"fetch, bad network response",f,u)}return s.loading.first=h,s.total=JA(u.headers)||s.total,a&&ce(t.highWaterMark)?this.loadProgressively(u,s,e,t.highWaterMark,a):o?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{let{response:h}=this;self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);let f=u[l];f&&(s.loaded=s.total=f);let g={url:h.url,data:u,code:h.status};a&&!ce(t.highWaterMark)&&a(s,e,u,h),r.onSuccess(g,s,e,h)}).catch(u=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;let h=u&&u.code||0,f=u?u.message:null;r.onError({code:h,text:f},e,u?u.details:null,s)})}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,s=0,n){let a=new ql,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));let c=d.value,u=c.length;return t.loaded+=u,u<s||a.dataLength?(a.push(c),a.dataLength>=s&&n(t,r,a.flush(),e)):n(t,r,c,e),l()}).catch(()=>Promise.reject());return l()}};function QA(i,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(mt({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function ZA(i){let e=XA.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function JA(i){let e=i.get("Content-Range");if(e){let r=ZA(e);if(ce(r))return r}let t=i.get("Content-Length");if(t)return parseInt(t)}function e1(i,e){return new self.Request(i.url,e)}var Wh=class extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}},t1=/\s/,i1={newCue(i,e,t,r){let s=[],n,a,o,l,d,c=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(n=r.rows[h],o=!0,l=0,d="",!n.isEmpty()){var u;for(let E=0;E<n.chars.length;E++)t1.test(n.chars[E].uchar)&&o?l++:(d+=n.chars[E].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;let f=iv(d.trim()),g=sf(e,t,f);i!=null&&(u=i.cues)!=null&&u.getCueById(g)||(a=new c(e,t,f),a.id=g,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return i&&s.length&&(s.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),s.forEach(h=>C0(i,h))),s}},r1={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},s1=Yt(Yt({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,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Xl,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Lh,bufferController:Oh,capLevelController:na,errorController:ah,fpsController:Vh,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:b0,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:r1},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},n1()),{},{subtitleStreamController:wh,subtitleTrackController:Ch,timelineController:Gh,audioStreamController:kh,audioTrackController:Rh,emeController:Ar,cmcdController:qi,contentSteeringController:Kh});function n1(){return{cueHandler:i1,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 a1(i,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let t=qh(i),r=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(n=>{let a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];s.forEach(d=>{let c=`${n}Loading${d}`,u=e[c];if(u!==void 0&&o){l.push(c);let h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=u,h.maxTimeToFirstByteMs=u;break;case"MaxRetry":h.errorRetry.maxNumRetry=u,h.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":h.errorRetry.retryDelayMs=u,h.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=u,h.timeoutRetry.maxRetryDelayMs=u;break}}}),l.length&&M.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),Yt(Yt({},t),e)}function qh(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(qh):Object.keys(i).reduce((e,t)=>(e[t]=qh(i[t]),e),{}):i}function o1(i){let e=i.loader;e!==Ql&&e!==Xl?(M.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):zA()&&(i.loader=Ql,i.progressive=!0,i.enableSoftwareAES=!0,M.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Yi=class{static get version(){return"1.4.10"}static isSupported(){return j_()}static get Events(){return b}static get ErrorTypes(){return pe}static get ErrorDetails(){return B}static get DefaultConfig(){return Yi.defaultConfig?Yi.defaultConfig:s1}static set DefaultConfig(e){Yi.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new tf,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,OT(e.debug||!1,"Hls instance");let t=this.config=a1(Yi.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&o1(t);let{abrController:r,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new r(this),c=this.bufferController=new s(this),u=this.capLevelController=new n(this),h=new o(this),f=new Zu(this),g=new th(this),E=t.contentSteeringController,T=E?new E(this):null,A=this.levelController=new oh(this,T),k=new lh(this),L=new ch(this.config),N=this.streamController=new xh(this,k,L);u.setStreamController(N),h.setStreamController(N);let D=[f,A,N];T&&D.splice(1,0,T),this.networkControllers=D;let $=[d,c,u,h,g,k];this.audioTrackController=this.createController(t.audioTrackController,D);let O=t.audioStreamController;O&&D.push(new O(this,k,L)),this.subtitleTrackController=this.createController(t.subtitleTrackController,D);let G=t.subtitleStreamController;G&&D.push(new G(this,k,L)),this.createController(t.timelineController,$),L.emeController=this.emeController=this.createController(t.emeController,$),this.cmcdController=this.createController(t.cmcdController,$),this.latencyController=this.createController(ih,$),this.coreComponents=$,D.push(l);let Y=l.onErrorOut;typeof Y=="function"&&this.on(b.ERROR,Y,l)}createController(e,t){if(e){let r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,s){this._emitter.off(e,t,r,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){M.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(b.ERROR,{type:pe.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,fatal:!1,event:e,error:r})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){M.log("destroy"),this.trigger(b.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){M.log("attachMedia"),this._media=e,this.trigger(b.MEDIA_ATTACHING,{media:e})}detachMedia(){M.log("detachMedia"),this.trigger(b.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,r=this.url,s=this.url=Yh.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});M.log(`loadSource:${s}`),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(b.MANIFEST_LOADING,{url:e})}startLoad(e=-1){M.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){M.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){M.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){M.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){let e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){M.log(`set currentLevel:${e}`),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){M.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){M.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){M.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){M.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(M.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){rh.indexOf(e)>-1&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let r=e.length;for(let s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this,s;if(t===-1&&e&&e.length?s=e.length-1:s=t,r)for(let n=s;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=r)return n}return s}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}};Yi.defaultConfig=void 0;var dt=Yi,aa=class extends Error{constructor(i,e=aa.MEDIA_ERR_CUSTOM,t,r){var s;super(i),this.name="MediaError",this.code=e,this.context=r,this.fatal=t!=null?t:e>=aa.MEDIA_ERR_NETWORK&&e<=aa.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(s=aa.defaultMessages[this.code])!=null?s:"")}},tt=aa;tt.MEDIA_ERR_ABORTED=1,tt.MEDIA_ERR_NETWORK=2,tt.MEDIA_ERR_DECODE=3,tt.MEDIA_ERR_SRC_NOT_SUPPORTED=4,tt.MEDIA_ERR_ENCRYPTED=5,tt.MEDIA_ERR_CUSTOM=100,tt.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 l1=i=>i==null,fv=(i,e)=>l1(e)?!1:i in e,af={ANY:"any",MUTED:"muted"},Ze={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},ui={MSE:"mse",NATIVE:"native"},of={HEADER:"header",QUERY:"query",NONE:"none"},rn=Object.values(of),Sr={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},lf={HLS:Sr.M3U8},Yw=Object.keys(lf),jw=[...Object.values(Sr),"hls","HLS"];var Si=(i,e,t,r,s=i)=>{s.addEventListener(e,t,r),i.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function d1(i,e,t){e&&t>e&&(t=e);for(let r=0;r<i.length;r++)if(i.start(r)<=t&&i.end(r)>=t)return!0;return!1}var c1=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),r=i.slice(e);return[t,r]},td=i=>{let e=i.type;if(e){let r=e.toUpperCase();return fv(r,lf)?lf[r]:e}let{src:t}=i;return t?u1(t):""},mv=i=>i==="VOD"?Ze.ON_DEMAND:Ze.LIVE,pv=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,u1=i=>{let e="";try{e=new URL(i).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let r=e.slice(t+1).toUpperCase();return fv(r,Sr)?Sr[r]:""},h1=Object.values(af),ov=i=>typeof i=="boolean"||typeof i=="string"&&h1.includes(i),f1=({autoplay:i},e,t)=>{let r=!1,s=!1,n=ov(i)?i:!!i,a=()=>{r||Si(e,"playing",()=>{r=!0},{once:!0})};if(a(),Si(e,"loadstart",()=>{r=!1,a(),nf(e,n)},{once:!0}),Si(e,"loadstart",()=>{t||(s=!Number.isFinite(e.duration)),nf(e,n)},{once:!0}),t&&t.once(dt.Events.LEVEL_LOADED,(o,l)=>{var d;s=(d=l.details.live)!=null?d:!1}),!n){let o=()=>{!s||(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&Si(e,"play",()=>{e.preload==="metadata"?t.once(dt.Events.LEVEL_UPDATED,o):o()},{once:!0})}return o=>{r||(n=ov(o)?o:!!o,nf(e,n))}},nf=(i,e)=>{if(!e)return;let t=i.muted,r=()=>i.muted=t;switch(e){case af.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(r)});break;case af.MUTED:i.muted=!0,i.play().catch(r);break;default:i.play().catch(()=>{});break}},m1=({preload:i,src:e},t,r)=>{let s=u=>{u!=null&&["","none","metadata","auto"].includes(u)?t.setAttribute("preload",u):t.removeAttribute("preload")};if(!r)return s(i),s;let n=!1,a=!1,o=r.config.maxBufferLength,l=r.config.maxBufferSize,d=u=>{s(u);let h=u!=null?u:t.preload;a||h==="none"||(h==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=o,r.config.maxBufferSize=l),c())},c=()=>{!n&&e&&(n=!0,r.loadSource(e))};return Si(t,"play",()=>{a=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,c()},{once:!0}),d(i),d};function p1(i,e){var t;if(!("videoTracks"in i))return;let r=new WeakMap;e.on(dt.Events.MANIFEST_PARSED,function(d,c){l();let u=i.addVideoTrack("main");u.selected=!0;for(let[h,f]of c.levels.entries()){let g=u.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);r.set(f,`${h}`),g.id=`${h}`}}),e.on(dt.Events.AUDIO_TRACKS_UPDATED,function(d,c){o();for(let u of c.audioTracks){let h=u.default?"main":"alternative",f=i.addAudioTrack(h,u.name,u.lang);f.id=`${u.id}`,u.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let c=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),u=e.audioTracks.map(h=>h.id);c!=e.audioTrack&&u.includes(c)&&(e.audioTrack=c)}),e.on(dt.Events.LEVELS_UPDATED,function(d,c){var u;let h=i.videoTracks[(u=i.videoTracks.selectedIndex)!=null?u:0];if(!h)return;let f=c.levels.map(g=>r.get(g));for(let g of i.videoRenditions)g.id&&!f.includes(g.id)&&h.removeRendition(g)});let s=d=>{let c=d.target.selectedIndex;c!=e.nextLevel&&n(c)},n=d=>{let c=i.currentTime,u=!1,h=(f,g)=>{u||(u=!Number.isFinite(g.endOffset))};e.on(dt.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(dt.Events.BUFFER_FLUSHING,h),u||e.trigger(dt.Events.BUFFER_FLUSHING,{startOffset:c+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",s);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(dt.Events.DESTROYING,l)}function g1(i,e){e.on(dt.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(s,{tracks:n})=>{n.forEach(a=>{var o;let l=(o=a.subtitleTrack)!=null?o:a.closedCaptions,d=e.subtitleTracks.findIndex(({lang:c,name:u,type:h})=>c==(l==null?void 0:l.lang)&&u===a.label&&h.toLowerCase()===a.kind);id(i,a.kind,a.label,l==null?void 0:l.lang,`${a.kind}${d}`)})});let t=()=>{var s;if(!e.subtitleTracks.length)return;let n=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind)),a=`${(s=e.subtitleTracks[e.subtitleTrack])==null?void 0:s.type.toLowerCase()}${e.subtitleTrack}`;if(n&&(e.subtitleTrack<0||(n==null?void 0:n.id)!==a)){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:c})=>l==n.language&&d===n.label&&c.toLowerCase()===n.kind);e.subtitleTrack=o}n&&(n==null?void 0:n.id)===a&&n.cues&&Array.from(n.cues).forEach(o=>{n.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(dt.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var c;(c=o.cues)!=null&&c.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(dt.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let r=()=>{Array.from(i.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&s.label==="thumbnails"){if(!((n=s.cues)!=null&&n.length)){let o=i.querySelector('track[label="thumbnails"]'),l=(a=o==null?void 0:o.getAttribute("src"))!=null?a:"";o==null||o.removeAttribute("src"),setTimeout(()=>{o==null||o.setAttribute("src",l)},0)}s.mode!=="hidden"&&(s.mode="hidden")}})};e.once(dt.Events.MANIFEST_LOADED,r),e.once(dt.Events.MEDIA_ATTACHED,r)}function id(i,e,t,r,s){let n=document.createElement("track");return n.kind=e,n.label=t,r&&(n.srclang=r),s&&(n.id=s),n.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),i.append(n),n.track}function gv(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),r=>r.track===e);t==null||t.remove()}var oa="cuepoints",cf=Object.freeze({label:oa}),uf=(i,{label:e=oa}=cf)=>{var t;return(t=Array.from(i.querySelectorAll("track")).find(r=>r.track.label===e&&r.track.kind==="metadata"))==null?void 0:t.track};async function hf(i,e,t=cf){let r=uf(i,t);if(!r){let{label:s=oa}=t;r=id(i,"metadata",s),r.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))}return r.mode!=="hidden"&&(r.mode="hidden"),[...e].sort(({time:s},{time:n})=>n-s).forEach(({time:s,value:n})=>{var a,o;let l=Array.prototype.findIndex.call(r==null?void 0:r.cues,f=>f.startTime>=s),d=(a=r==null?void 0:r.cues)==null?void 0:a[l],c=d?d.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,u=(o=r==null?void 0:r.cues)==null?void 0:o[l-1];u&&(u.endTime=s);let h=new VTTCue(s,c,JSON.stringify(n!=null?n:null));r.addCue(h)}),r}var vv=i=>({time:i.startTime,value:JSON.parse(i.text)});function Ev(i,e={label:oa}){let t=uf(i,e);return t!=null&&t.cues?Array.from(t.cues,r=>vv(r)):[]}function ff(i,e={label:oa}){var t,r;let s=uf(i,e);if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return vv(a)}async function v1(i,e=cf){return new Promise(t=>{Si(i,"loadstart",async()=>{let r=await hf(i,[],e);Si(i,"cuechange",()=>{let s=ff(i);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}function bv(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function yv(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var E1=async i=>fetch(i).then(e=>e.text()).then(e=>{let t=e.split(`
1074
+ `),d=[],c=e?T1(e.baseTime,e.timescale):0,u="00:00.000",h=0,f=0,g,E=!0;o.oncue=function(T){let A=t[r],R=t.ccOffset,L=(h-c)/9e4;if(A!=null&&A.new&&(f!==void 0?R=t.ccOffset=A.start:G1(t,r,L)),L){if(!e){g=new Error("Missing initPTS for VTT MPEGTS");return}R=L-t.presentationOffset}let N=T.endTime-T.startTime,M=oi((T.startTime+R-f)*9e4,s*9e4)/9e4;T.startTime=Math.max(M,0),T.endTime=Math.max(M+N,0);let $=T.text.trim();T.text=decodeURIComponent(encodeURIComponent($)),T.id||(T.id=Lf(T.startTime,T.endTime,$)),T.endTime>0&&d.push(T)},o.onparsingerror=function(T){g=T},o.onflush=function(){if(g){a(g);return}n(d)},l.forEach(T=>{if(E)if(lh(T,"X-TIMESTAMP-MAP=")){E=!1,T.slice(16).split(",").forEach(A=>{lh(A,"LOCAL:")?u=A.slice(6):lh(A,"MPEGTS:")&&(h=parseInt(A.slice(7)))});try{f=H1(u)/1e3}catch(A){g=A}return}else T===""&&(E=!1);o.parse(T+`
1075
+ `)}),o.flush()}var ch="stpp.ttml.im1t",zv=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Xv=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,K1={left:"start",center:"center",right:"end",start:"start",end:"end"};function rv(i,e,t,r){let s=Ce(new Uint8Array(i),["mdat"]);if(s.length===0){r(new Error("Could not parse IMSC1 mdat"));return}let n=s.map(o=>Hi(o)),a=y1(e.baseTime,1,e.timescale);try{n.forEach(o=>t(W1(o,a)))}catch(o){r(o)}}function W1(i,e){let s=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");let n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((u,h)=>(u[h]=s.getAttribute(`ttp:${h}`)||n[h],u),{}),o=s.getAttribute("xml:space")!=="preserve",l=sv(uh(s,"styling","style")),d=sv(uh(s,"layout","region")),c=uh(s,"body","[begin]");return[].map.call(c,u=>{let h=Qv(u,o);if(!h||!u.hasAttribute("begin"))return null;let f=fh(u.getAttribute("begin"),a),g=fh(u.getAttribute("dur"),a),E=fh(u.getAttribute("end"),a);if(f===null)throw nv(u);if(E===null){if(g===null)throw nv(u);E=f+g}let T=new If(f-e,E-e,h);T.id=Lf(T.startTime,T.endTime,T.text);let A=d[u.getAttribute("region")],R=l[u.getAttribute("style")],L=q1(A,R,l),{textAlign:N}=L;if(N){let M=K1[N];M&&(T.lineAlign=M),T.align=N}return dt(T,L),T}).filter(u=>u!==null)}function uh(i,e,t){let r=i.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function sv(i){return i.reduce((e,t)=>{let r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function Qv(i,e){return[].slice.call(i.childNodes).reduce((t,r,s)=>{var n;return r.nodeName==="br"&&s?t+`
1076
+ `:(n=r.childNodes)!=null&&n.length?Qv(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function q1(i,e,t){let r="http://www.w3.org/ns/ttml#styling",s=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{let d=hh(e,r,l)||hh(i,r,l)||hh(s,r,l);return d&&(o[l]=d),o},{})}function hh(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function nv(i){return new Error(`Could not parse ttml timestamp ${i}`)}function fh(i,e){if(!i)return null;let t=qv(i);return t===null&&(zv.test(i)?t=Y1(i,e):Xv.test(i)&&(t=j1(i,e))),t}function Y1(i,e){let t=zv.exec(i),r=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+r/e.frameRate}function j1(i,e){let t=Xv.exec(i),r=Number(t[1]);switch(t[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}var cf=class{constructor(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=av(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){let t=new nn(this,"textTrack1"),r=new nn(this,"textTrack2"),s=new nn(this,"textTrack3"),n=new nn(this,"textTrack4");this.cea608Parser1=new sd(1,t,r),this.cea608Parser2=new sd(3,s,n)}e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(b.FRAG_LOADING,this.onFragLoading,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(b.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(b.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(b.FRAG_LOADING,this.onFragLoading,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(b.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(b.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,r,s,n){let a=!1;for(let o=n.length;o--;){let l=n[o],d=X1(l[0],l[1],t,r);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),a=!0,d/(r-t)>.5))return}if(a||n.push([t,r]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,r,s)}else{let o=this.Cues.newCue(null,t,r,s);this.hls.trigger(b.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){let{unparsedVttFrags:a}=this;r==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(b.FRAG_LOADED,o)}))}getExistingTrack(e){let{media:t}=this;if(t)for(let r=0;r<t.textTracks.length;r++){let s=t.textTracks[r];if(s[e])return s}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:r,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(e);if(o)r[e]=o,sn(r[e]),Av(r[e],s);else{let l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,r[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let r=t.label,s={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(b.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,r){let s=this.media;if(s)return s.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{sn(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=av(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let r=0;r<t.length;r++)sn(t[r])}onSubtitleTracksUpdated(e,t){let r=t.subtitleTracks||[],s=r.some(n=>n.textCodec===ch);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(Kv(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){let a=this.media?this.media.textTracks:null;this.tracks.forEach((o,l)=>{let d;if(a&&l<a.length){let c=null;for(let u=0;u<a.length;u++)if(z1(a[u],o)){c=a[u];break}c&&(d=c)}if(d)sn(d);else{let c=this._captionsOrSubtitlesFromCharacteristics(o);d=this.createTextTrack(c,o.name,o.lang),d&&(d.mode="disabled")}d&&(d.groupId=o.groupId,this.textTracks.push(d))})}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(b.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){let t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),r=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&r)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(r=>{let s=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!s)return;let n=`textTrack${s[1]}`,a=this.captionsProperties[n];a&&(a.label=r.name,r.lang&&(a.languageCode=r.lang),a.media=r)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){let{cea608Parser1:r,cea608Parser2:s,lastSn:n,lastPartIndex:a}=this;if(!(!this.enabled||!(r&&s))&&t.frag.type===fe.MAIN){var o,l;let d=t.frag.sn,c=(o=t==null||(l=t.part)==null?void 0:l.index)!=null?o:-1;d===n+1||d===n&&c===a+1||(r.reset(),s.reset()),this.lastSn=d,this.lastPartIndex=c}}onFragLoaded(e,t){let{frag:r,payload:s}=t;if(r.type===fe.SUBTITLE)if(s.byteLength){let n=r.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),o&&o.textCodec===ch?this._parseIMSC1(r,s):this._parseVTTs(t)}}else this.hls.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){let r=this.hls;rv(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),r.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{C.log(`Failed to parse IMSC1: ${s}`),r.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;let{frag:r,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[r.cc]&&o===-1){a.push(e);return}let l=this.hls,d=(t=r.initSegment)!=null&&t.data?jr(r.initSegment.data,new Uint8Array(s)):s;V1(d,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,c=>{this._appendCues(c,r.level),l.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},c=>{let u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(r,s),C.log(`Failed to parse VTT cue: ${c}`),!(u&&o>r.cc)&&l.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:c})})}_fallbackToIMSC1(e,t){let r=this.tracks[e.level];r.textCodec||rv(t,this.initPTS[e.cc],()=>{r.textCodec=ch,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){let r=this.hls;if(this.config.renderTextTracksNatively){let s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>Sv(s,n))}else{let s=this.tracks[t];if(!s)return;let n=s.default?"default":"subtitles"+t;r.trigger(b.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){let{frag:r}=t;r.type===fe.SUBTITLE&&this.onFragLoaded(b.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){let{cea608Parser1:r,cea608Parser2:s}=this;if(!this.enabled||!(r&&s))return;let{frag:n,samples:a}=t;if(!(n.type===fe.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){let l=a[o].bytes;if(l){let d=this.extractCea608Data(l);r.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:s,type:n}){let{media:a}=this;if(!(!a||a.currentTime<r)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>bh(o[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>bh(o[l],t,s))}}}extractCea608Data(e){let t=[[],[]],r=e[0]&31,s=2;for(let n=0;n<r;n++){let a=e[s++],o=127&e[s++],l=127&e[s++];if(o===0&&l===0)continue;if((4&a)!==0){let c=3&a;(c===0||c===1)&&(t[c].push(o),t[c].push(l))}}return t}};function z1(i,e){return!!i&&i.label===e.name&&!(i.textTrack1||i.textTrack2)}function X1(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function av(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var uf=class i{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(b.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.BUFFER_CODECS,this.onBufferCodecs,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(b.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.BUFFER_CODECS,this.onBufferCodecs,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){let r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){let e=this.hls.levels;if(e.length){let t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return-1;let r=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,i.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){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())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(r=>e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height)}static getMaxLevelByMediaSize(e,t,r){if(!(e!=null&&e.length))return-1;let s=(a,o)=>o?a.width!==o.width||a.height!==o.height:!0,n=e.length-1;for(let a=0;a<e.length;a+=1){let o=e[a];if((o.width>=t||o.height>=r)&&s(o,e[a+1])){n=a;break}}return n}},hf=class{constructor(e){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=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let r=this.hls.config;if(r.capLevelOnFPSDrop){let s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){let s=performance.now();if(t){if(this.lastTime){let n=s-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(b.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let c=d.currentLevel;C.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=c)&&(c=c-1,d.trigger(b.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},Fl="[eme]",nd=class i{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=i.CDMCleanupPromise?[i.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=C.debug.bind(C,Fl),this.log=C.log.bind(C,Fl),this.warn=C.warn.bind(C,Fl),this.error=C.error.bind(C,Fl),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(b.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(b.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(b.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(b.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(b.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:r}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===Ze.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){let{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,r=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(r),n=t.map(a=>a.videoCodec).filter(r);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{let l=d=>{let c=d.shift();this.getMediaKeysPromise(c,s,n).then(u=>a({keySystem:c,mediaKeys:u})).catch(u=>{d.length?l(d):u instanceof Kt?o(u):o(new Kt({type:he.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_ACCESS,error:u,fatal:!0},u.message))})};l(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${r}`;return uv===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return r(e,t)}getMediaKeysPromise(e,t,r){let s=z_(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e],a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);let o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);let d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(c=>(this.log(`Media-keys created for "${e}"`),d.then(u=>u?this.setMediaKeysServerCertificate(c,e,u):c))),o.mediaKeys.catch(c=>{this.error(`Failed to create media-keys for "${e}"}: ${c}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${Bi.hexDump(e.keyId||[])}`);let s=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let r=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(r,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Bi.hexDump(e.keyId)}updateKeySession(e,t){var r;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Bi.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[])}
1077
+ } (data length: ${t&&t.byteLength})`),s.update(t)}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{let s=ju(this.config),n=e.map(S0).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=x0(a);o?t(o):r(new Error(`Unable to find format for key-system "${a}"`))}).catch(r)})}loadKey(e){let t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[r];return n||(n=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();let l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t}),d="cenc";return this.generateRequestWithPreferredKeySession(l,d,t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Kt?this.hls.trigger(b.ERROR,e.data):this.hls.trigger(b.ERROR,{type:he.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){let s=S0(e.keyFormat),n=s?[s]:ju(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=ju(this.config)),e.length===0)throw new Kt({type:he.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){let{initDataType:t,initData:r}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),r===null)return;let s,n;if(t==="sinf"&&this.config.drmSystems[Ze.FAIRPLAY]){let c=Tt(new Uint8Array(r));try{let u=Ef(JSON.parse(c).sinf),h=bv(new Uint8Array(u));if(!h)return;s=h.subarray(8,24),n=Ze.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{let c=bA(r);if(c===null)return;c.version===0&&c.systemId===cv.WIDEVINE&&c.data&&(s=c.data.subarray(8,24)),n=j_(c.systemId)}if(!n||!s)return;let a=Bi.hexDump(s),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this,d=o[a];for(let c=0;c<l.length;c++){let u=l[c],h=u.decryptdata;if(h.pssh||!h.keyId)continue;let f=Bi.hexDump(h.keyId);if(a===f||h.uri.replace(/-/g,"").indexOf(a)!==-1){d=o[f],delete o[f],h.pssh=new Uint8Array(r),h.keyId=s,d=o[a]=d.then(()=>this.generateRequestWithPreferredKeySession(u,t,r,"encrypted-event-key-match"));break}}d||(d=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:c,mediaKeys:u})=>{var h;this.throwIfDestroyed();let f=new oa("ISO-23001-7",a,(h=x0(c))!=null?h:"");return f.pssh=new Uint8Array(r),f.keyId=s,this.attemptSetMediaKeys(c,u).then(()=>{this.throwIfDestroyed();let g=this.createMediaKeySessionContext({decryptdata:f,keySystem:c,mediaKeys:u});return this.generateRequestWithPreferredKeySession(g,t,r,"encrypted-event-no-match")})})),d.catch(c=>this.handleError(c))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){let r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let s=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>r.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,r,s){var n,a;let o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{let h=o.call(this.hls,t,r,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,r=e.decryptdata.pssh=h.initData?new Uint8Array(h.initData):null}catch(h){var l;if(this.warn(h.message),(l=this.hls)!=null&&l.config.debug)throw h}if(r===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);let d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${d} (init data type: ${t} length: ${r?r.byteLength:null})`);let c=new xf;e.mediaKeysSession.onmessage=h=>{let f=e.mediaKeysSession;if(!f){c.emit("error",new Error("invalid state"));return}let{messageType:g,message:E}=h;this.log(`"${g}" message event for session "${f.sessionId}" message size: ${E.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,E).catch(T=>{this.handleError(T),c.emit("error",T)}):g==="license-release"?e.keySystem===Ze.FAIRPLAY&&(this.updateKeySession(e,dv("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},e.mediaKeysSession.onkeystatuseschange=h=>{if(!e.mediaKeysSession){c.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let g=e.keyStatus;c.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};let u=new Promise((h,f)=>{c.on("error",f),c.on("keyStatus",g=>{g.startsWith("usable")?h():g==="output-restricted"?f(new Kt({type:he.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?f(new Kt({type:he.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?f(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var h;this.log(`Request generated for key-session "${(h=e.mediaKeysSession)==null?void 0:h.sessionId}" keyId: ${d}`)}).catch(h=>{throw new Kt({type:he.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_SESSION,error:h,fatal:!1},`Error generating key-session request: ${h}`)}).then(()=>u).catch(h=>{throw c.removeAllListeners(),this.removeSession(e),h}).then(()=>(c.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Bi.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${Bi.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,r=t.loader,s=new r(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching serverCertificate for "${e}"`),new Promise((a,o)=>{let l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,E)=>{a(h.data)},onError:(h,f,g,E)=>{o(new Kt({type:he.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:qt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,g)=>{o(new Kt({type:he.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,g)=>{o(new Error("aborted"))}};s.load(l,c,u)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((s,n)=>{e.setServerCertificate(r).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new Kt({type:he.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(r=>this.updateKeySession(e,new Uint8Array(r)).catch(s=>{throw new Kt({type:he.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}setupLicenseXHR(e,t,r,s){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,s)}).catch(a=>{if(!r.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,r,s)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){let r=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{let a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);let d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(c){this.error(c)}s(l)}else{let l=r.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new Kt({type:he.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{let c=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${c} attempts left`),this.requestLicense(e,t).then(s,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){let e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},oa.clearKeyUriToKeyIdMap();let r=t.length;i.CDMCleanupPromise=Promise.all(t.map(s=>this.removeSession(s)).concat(e==null?void 0:e.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}. media.src: ${e==null?void 0:e.src}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}. media.src: ${e==null?void 0:e.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){let r=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),t.onmessage=null,t.onkeystatuseschange=null,r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}};nd.CDMCleanupPromise=void 0;var Kt=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}},Q1=1,Gt={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},Z1="h",ff=class i{constructor(e){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=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:Gt.MANIFEST,su:!this.initialized})}catch(n){C.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{let n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===Gt.VIDEO||o===Gt.AUDIO||o==Gt.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){C.warn("Could not generate segment CMCD data.",n)}},this.hls=e;let t=this.config=e.config,{cmcd:r}=t;r!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||i.uuid(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.registerListeners())}registerListeners(){let e=this.hls;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHED,this.onMediaDetached,this),e.on(b.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHED,this.onMediaDetached,this),e.off(b.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,s;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:Q1,sf:Z1,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){dt(t,this.createData());let r=t.ot===Gt.INIT||t.ot===Gt.VIDEO||t.ot===Gt.MUXED;if(this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){let s=i.toHeaders(t);if(!Object.keys(s).length)return;e.headers||(e.headers={}),dt(e.headers,s)}else{let s=i.toQuery(t);if(!s)return;e.url=i.appendQueryToUri(e.url,s)}}getObjectType(e){let{type:t}=e;if(t==="subtitle")return Gt.TIMED_TEXT;if(e.sn==="initSegment")return Gt.INIT;if(t==="audio")return Gt.AUDIO;if(t==="main")return this.hls.audioTracks.length?Gt.VIDEO:Gt.MUXED}getTopBandwidth(e){let t=0,r,s=this.hls;if(e===Gt.AUDIO)r=s.audioTracks;else{let n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;r=s.levels.slice(0,a)}for(let n of r)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,r=e===Gt.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!t?NaN:je.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}static uuid(){let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}static serialize(e){let t=[],r=d=>!Number.isNaN(d)&&d!=null&&d!==""&&d!==!1,s=d=>Math.round(d),n=d=>s(d/100)*100,o={br:s,d:s,bl:n,dl:n,mtp:n,nor:d=>encodeURIComponent(d),rtp:n,tb:s},l=Object.keys(e||{}).sort();for(let d of l){let c=e[d];if(!r(c)||d==="v"&&c===1||d=="pr"&&c===1)continue;let u=o[d];u&&(c=u(c));let h=typeof c,f;d==="ot"||d==="sf"||d==="st"?f=`${d}=${c}`:h==="boolean"?f=d:h==="number"?f=`${d}=${c}`:f=`${d}=${JSON.stringify(c)}`,t.push(f)}return t.join(",")}static toHeaders(e){let t=Object.keys(e),r={},s=["Object","Request","Session","Status"],n=[{},{},{},{}],a={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};for(let o of t){let l=a[o]!=null?a[o]:1;n[l][o]=e[o]}for(let o=0;o<n.length;o++){let l=i.serialize(n[o]);l&&(r[`CMCD-${s[o]}`]=l)}return r}static toQuery(e){return`CMCD=${encodeURIComponent(i.serialize(e))}`}static appendQueryToUri(e,t){if(!t)return e;let r=e.includes("?")?"&":"?";return`${e}${r}${t}`}},J1=3e5,mf=class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=C.log.bind(C,"[content-steering]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){let e=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(r=>r!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:r}=t;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:r}=t;if((r==null?void 0:r.action)===Lt.SendAlternateToPenaltyBox&&r.flags===ai.MoveAllAlternatesMatchingHost){let s=this.pathwayPriority,n=this.pathwayId;this.penalizedPathways[n]||(this.penalizedPathways[n]=performance.now()),!s&&this.levels&&(s=this.levels.reduce((a,o)=>(a.indexOf(o.pathwayId)===-1&&a.push(o.pathwayId),a),[])),s&&s.length>1&&(this.updatePathwayPriority(s),r.resolved=this.pathwayId!==n)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t,r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(n=>{s-r[n]>J1&&delete r[n]});for(let n=0;n<e.length;n++){let a=e[n];if(r[a])continue;if(a===this.pathwayId)return;let o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,this.hls.trigger(b.LEVELS_UPDATED,{levels:t});let d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}clonePathways(e){let t=this.levels;if(!t)return;let r={},s={};e.forEach(n=>{let{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(c=>c.pathwayId===a))return;let d=this.getLevelsForPathway(o).map(c=>{let u=dt({},c);u.details=void 0,u.url=Zv(c.uri,c.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l);let h=new Qe(c.attrs);h["PATHWAY-ID"]=a;let f=h.AUDIO&&`${h.AUDIO}_clone_${a}`,g=h.SUBTITLES&&`${h.SUBTITLES}_clone_${a}`;f&&(r[h.AUDIO]=f,h.AUDIO=f),g&&(s[h.SUBTITLES]=g,h.SUBTITLES=g),u.attrs=h;let E=new zr(u);return Yl(E,"audio",f),Yl(E,"text",g),E});t.push(...d),ov(this.audioTracks,r,l,a),ov(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){let t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){let c=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+c)}let n={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(c,u,h,f)=>{this.log(`Loaded steering manifest: "${s}"`);let g=c.data;if(g.VERSION!==1){this.log(`Steering VERSION ${g.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=g.TTL;let{"RELOAD-URI":E,"PATHWAY-CLONES":T,"PATHWAY-PRIORITY":A}=g;if(E)try{this.uri=new self.URL(E,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${E}`);return}this.scheduleRefresh(this.uri||h.url),T&&this.clonePathways(T),A&&this.updatePathwayPriority(A)},onError:(c,u,h,f)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${u.url})`),this.stopLoad(),c.code===410){this.enabled=!1,this.log(`Steering manifest ${u.url} no longer available`);return}let g=this.timeToLoad*1e3;if(c.code===429){let E=this.loader;if(typeof(E==null?void 0:E.getResponseHeader)=="function"){let T=E.getResponseHeader("Retry-After");T&&(g=parseFloat(T)*1e3)}this.log(`Steering manifest ${u.url} rate limited`);return}this.scheduleRefresh(this.uri||u.url,g)},onTimeout:(c,u,h)=>{this.log(`Timeout loading steering manifest (${u.url})`),this.scheduleRefresh(this.uri||u.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},t)}};function ov(i,e,t,r){i&&Object.keys(e).forEach(s=>{let n=i.filter(a=>a.groupId===s).map(a=>{let o=dt({},a);return o.details=void 0,o.attrs=new Qe(o.attrs),o.url=o.attrs.URI=Zv(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=r,o});i.push(...n)})}function Zv(i,e,t,r){let{HOST:s,PARAMS:n,[t]:a}=r,o;e&&(o=a==null?void 0:a[e],o&&(i=o));let l=new self.URL(i);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}var eS=/^age:\s*[\d.]+\s*$/im,ad=class{constructor(e){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=e&&e.xhrSetup||null,this.stats=new an,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e)return;let r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!this.stats.aborted)return n(r,t.url)}).catch(a=>(r.open("GET",t.url,!0),n(r,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(a=>{this.callbacks.onError({code:r.status,text:a.message},t,r,s)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);let s=this.context.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=r.loadPolicy;if(s)for(let o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&oe(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:r}=this;if(!e||!t)return;let s=t.readyState,n=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let a=t.status,o=t.responseType!=="text";if(a>=200&&a<300&&(o&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);let l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(r.loaded=r.total=d,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;let c=this.callbacks.onProgress;if(c&&c(r,e,l,t),!this.callbacks)return;let u={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(u,r,e,t)}else{let l=n.loadPolicy.errorRetry,d=r.retry;ql(l,d,!1,a)?this.retry(l):(C.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}}loadtimeout(){var e;let t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,r=this.stats.retry;if(ql(t,r,!0))this.retry(t);else{C.warn(`timeout while loading ${this.context.url}`);let s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:r}=this;this.retryDelay=yf(e,r.retry),r.retry++,C.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&eS.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}};function tS(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var iS=/(\d+)-(\d+)\/(\d+)/,od=class{constructor(e){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=e.fetchSetup||aS,this.controller=new self.AbortController,this.stats=new an}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){let e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){let s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();let n=rS(e,this.controller.signal),a=r.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:c}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&oe(d)?d:c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(u=>{this.response=this.loader=u;let h=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},c-(h-s.loading.start)),!u.ok){let{status:f,statusText:g}=u;throw new pf(g||"fetch, bad network response",f,u)}return s.loading.first=h,s.total=nS(u.headers)||s.total,a&&oe(t.highWaterMark)?this.loadProgressively(u,s,e,t.highWaterMark,a):o?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{let{response:h}=this;self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);let f=u[l];f&&(s.loaded=s.total=f);let g={url:h.url,data:u,code:h.status};a&&!oe(t.highWaterMark)&&a(s,e,u,h),r.onSuccess(g,s,e,h)}).catch(u=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;let h=u&&u.code||0,f=u?u.message:null;r.onError({code:h,text:f},e,u?u.details:null,s)})}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,s=0,n){let a=new td,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));let c=d.value,u=c.length;return t.loaded+=u,u<s||a.dataLength?(a.push(c),a.dataLength>=s&&n(t,r,a.flush(),e)):n(t,r,c,e),l()}).catch(()=>Promise.reject());return l()}};function rS(i,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(dt({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function sS(i){let e=iS.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function nS(i){let e=i.get("Content-Range");if(e){let r=sS(e);if(oe(r))return r}let t=i.get("Content-Length");if(t)return parseInt(t)}function aS(i,e){return new self.Request(i.url,e)}var pf=class extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}},oS=/\s/,lS={newCue(i,e,t,r){let s=[],n,a,o,l,d,c=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(n=r.rows[h],o=!0,l=0,d="",!n.isEmpty()){var u;for(let E=0;E<n.chars.length;E++)oS.test(n.chars[E].uchar)&&o?l++:(d+=n.chars[E].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;let f=jv(d.trim()),g=Lf(e,t,f);i!=null&&(u=i.cues)!=null&&u.getCueById(g)||(a=new c(e,t,f),a.id=g,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return i&&s.length&&(s.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),s.forEach(h=>Sv(i,h))),s}},dS={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},cS=qt(qt({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,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:ad,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:jh,bufferController:tf,capLevelController:uf,errorController:Ih,fpsController:hf,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:uv,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:dS},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},uS()),{},{subtitleStreamController:Qh,subtitleTrackController:Jh,timelineController:cf,audioStreamController:zh,audioTrackController:Xh,emeController:nd,cmcdController:ff,contentSteeringController:mf});function uS(){return{cueHandler:lS,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 hS(i,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let t=gf(i),r=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(n=>{let a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];s.forEach(d=>{let c=`${n}Loading${d}`,u=e[c];if(u!==void 0&&o){l.push(c);let h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=u,h.maxTimeToFirstByteMs=u;break;case"MaxRetry":h.errorRetry.maxNumRetry=u,h.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":h.errorRetry.retryDelayMs=u,h.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=u,h.timeoutRetry.maxRetryDelayMs=u;break}}}),l.length&&C.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),qt(qt({},t),e)}function gf(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(gf):Object.keys(i).reduce((e,t)=>(e[t]=gf(i[t]),e),{}):i}function fS(i){let e=i.loader;e!==od&&e!==ad?(C.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):tS()&&(i.loader=od,i.progressive=!0,i.enableSoftwareAES=!0,C.log("[config]: Progressive streaming enabled, using FetchLoader"))}var fa=class i{static get version(){return"1.4.12"}static isSupported(){return e1()}static get Events(){return b}static get ErrorTypes(){return he}static get ErrorDetails(){return B}static get DefaultConfig(){return i.defaultConfig?i.defaultConfig:cS}static set DefaultConfig(e){i.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new xf,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,$_(e.debug||!1,"Hls instance");let t=this.config=hS(i.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&fS(t);let{abrController:r,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new r(this),c=this.bufferController=new s(this),u=this.capLevelController=new n(this),h=new o(this),f=new Eh(this),g=new Th(this),E=t.contentSteeringController,T=E?new E(this):null,A=this.levelController=new Lh(this,T),R=new Rh(this),L=new wh(this.config),N=this.streamController=new qh(this,R,L);u.setStreamController(N),h.setStreamController(N);let M=[f,A,N];T&&M.splice(1,0,T),this.networkControllers=M;let $=[d,c,u,h,g,R];this.audioTrackController=this.createController(t.audioTrackController,M);let U=t.audioStreamController;U&&M.push(new U(this,R,L)),this.subtitleTrackController=this.createController(t.subtitleTrackController,M);let H=t.subtitleStreamController;H&&M.push(new H(this,R,L)),this.createController(t.timelineController,$),L.emeController=this.emeController=this.createController(t.emeController,$),this.cmcdController=this.createController(t.cmcdController,$),this.latencyController=this.createController(_h,$),this.coreComponents=$,M.push(l);let W=l.onErrorOut;typeof W=="function"&&this.on(b.ERROR,W,l)}createController(e,t){if(e){let r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,s){this._emitter.off(e,t,r,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){C.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(b.ERROR,{type:he.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,fatal:!1,event:e,error:r})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){C.log("destroy"),this.trigger(b.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){C.log("attachMedia"),this._media=e,this.trigger(b.MEDIA_ATTACHING,{media:e})}detachMedia(){C.log("detachMedia"),this.trigger(b.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,r=this.url,s=this.url=vf.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});C.log(`loadSource:${s}`),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(b.MANIFEST_LOADING,{url:e})}startLoad(e=-1){C.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){C.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){C.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){C.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){let e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){C.log(`set currentLevel:${e}`),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){C.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){C.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){C.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){C.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(C.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){Ah.indexOf(e)>-1&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let r=e.length;for(let s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this,s;if(t===-1&&e&&e.length?s=e.length-1:s=t,r)for(let n=s;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=r)return n}return s}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}};fa.defaultConfig=void 0;var it=fa,vr=class ma extends Error{constructor(e,t=ma.MEDIA_ERR_CUSTOM,r,s){var n;super(e),this.name="MediaError",this.code=t,this.context=s,this.fatal=r!=null?r:t>=ma.MEDIA_ERR_NETWORK&&t<=ma.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(n=ma.defaultMessages[this.code])!=null?n:"")}};vr.MEDIA_ERR_ABORTED=1,vr.MEDIA_ERR_NETWORK=2,vr.MEDIA_ERR_DECODE=3,vr.MEDIA_ERR_SRC_NOT_SUPPORTED=4,vr.MEDIA_ERR_ENCRYPTED=5,vr.MEDIA_ERR_CUSTOM=100,vr.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 At=vr,mS=i=>i==null,nE=(i,e)=>mS(e)?!1:i in e,kf={ANY:"any",MUTED:"muted"},qe={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},li={MSE:"mse",NATIVE:"native"},cd={HEADER:"header",QUERY:"query",NONE:"none"},on=Object.values(cd),Er={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},wf={HLS:Er.M3U8},mC=Object.keys(wf),pC=[...Object.values(Er),"hls","HLS"];var _i=(i,e,t,r,s=i)=>{s.addEventListener(e,t,r),i.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function pS(i,e,t){e&&t>e&&(t=e);for(let r=0;r<i.length;r++)if(i.start(r)<=t&&i.end(r)>=t)return!0;return!1}var gS=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),r=i.slice(e);return[t,r]},hd=i=>{let e=i.type;if(e){let r=e.toUpperCase();return nE(r,wf)?wf[r]:e}let{src:t}=i;return t?vS(t):""},aE=i=>i==="VOD"?qe.ON_DEMAND:qe.LIVE,oE=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,vS=i=>{let e="";try{e=new URL(i).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let r=e.slice(t+1).toUpperCase();return nE(r,Er)?Er[r]:""},ES=Object.values(kf),Jv=i=>typeof i=="boolean"||typeof i=="string"&&ES.includes(i),bS=({autoplay:i},e,t)=>{let r=!1,s=!1,n=Jv(i)?i:!!i,a=()=>{r||_i(e,"playing",()=>{r=!0},{once:!0})};if(a(),_i(e,"loadstart",()=>{r=!1,a(),Rf(e,n)},{once:!0}),_i(e,"loadstart",()=>{t||(s=!Number.isFinite(e.duration)),Rf(e,n)},{once:!0}),t&&t.once(it.Events.LEVEL_LOADED,(o,l)=>{var d;s=(d=l.details.live)!=null?d:!1}),!n){let o=()=>{s&&(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&_i(e,"play",()=>{e.preload==="metadata"?t.once(it.Events.LEVEL_UPDATED,o):o()},{once:!0})}return o=>{r||(n=Jv(o)?o:!!o,Rf(e,n))}},Rf=(i,e)=>{if(!e)return;let t=i.muted,r=()=>i.muted=t;switch(e){case kf.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(r)});break;case kf.MUTED:i.muted=!0,i.play().catch(r);break;default:i.play().catch(()=>{});break}},yS=({preload:i,src:e},t,r)=>{let s=u=>{u!=null&&["","none","metadata","auto"].includes(u)?t.setAttribute("preload",u):t.removeAttribute("preload")};if(!r)return s(i),s;let n=!1,a=!1,o=r.config.maxBufferLength,l=r.config.maxBufferSize,d=u=>{s(u);let h=u!=null?u:t.preload;a||h==="none"||(h==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=o,r.config.maxBufferSize=l),c())},c=()=>{!n&&e&&(n=!0,r.loadSource(e))};return _i(t,"play",()=>{a=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,c()},{once:!0}),d(i),d};function TS(i,e){var t;if(!("videoTracks"in i))return;let r=new WeakMap;e.on(it.Events.MANIFEST_PARSED,function(d,c){l();let u=i.addVideoTrack("main");u.selected=!0;for(let[h,f]of c.levels.entries()){let g=u.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);r.set(f,`${h}`),g.id=`${h}`}}),e.on(it.Events.AUDIO_TRACKS_UPDATED,function(d,c){o();for(let u of c.audioTracks){let h=u.default?"main":"alternative",f=i.addAudioTrack(h,u.name,u.lang);f.id=`${u.id}`,u.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let c=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),u=e.audioTracks.map(h=>h.id);c!=e.audioTrack&&u.includes(c)&&(e.audioTrack=c)}),e.on(it.Events.LEVELS_UPDATED,function(d,c){var u;let h=i.videoTracks[(u=i.videoTracks.selectedIndex)!=null?u:0];if(!h)return;let f=c.levels.map(g=>r.get(g));for(let g of i.videoRenditions)g.id&&!f.includes(g.id)&&h.removeRendition(g)});let s=d=>{let c=d.target.selectedIndex;c!=e.nextLevel&&n(c)},n=d=>{let c=i.currentTime,u=!1,h=(f,g)=>{u||(u=!Number.isFinite(g.endOffset))};e.on(it.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(it.Events.BUFFER_FLUSHING,h),u||e.trigger(it.Events.BUFFER_FLUSHING,{startOffset:c+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",s);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(it.Events.DESTROYING,l)}function _S(i,e){e.on(it.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(s,{tracks:n})=>{n.forEach(a=>{var o;let l=(o=a.subtitleTrack)!=null?o:a.closedCaptions,d=e.subtitleTracks.findIndex(({lang:c,name:u,type:h})=>c==(l==null?void 0:l.lang)&&u===a.label&&h.toLowerCase()===a.kind);fd(i,a.kind,a.label,l==null?void 0:l.lang,`${a.kind}${d}`)})});let t=()=>{var s;if(!e.subtitleTracks.length)return;let n=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind)),a=`${(s=e.subtitleTracks[e.subtitleTrack])==null?void 0:s.type.toLowerCase()}${e.subtitleTrack}`;if(n&&(e.subtitleTrack<0||(n==null?void 0:n.id)!==a)){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:c})=>l==n.language&&d===n.label&&c.toLowerCase()===n.kind);e.subtitleTrack=o}n&&(n==null?void 0:n.id)===a&&n.cues&&Array.from(n.cues).forEach(o=>{n.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(it.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var c;(c=o.cues)!=null&&c.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(it.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let r=()=>{Array.from(i.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&s.label==="thumbnails"){if(!((n=s.cues)!=null&&n.length)){let o=i.querySelector('track[label="thumbnails"]'),l=(a=o==null?void 0:o.getAttribute("src"))!=null?a:"";o==null||o.removeAttribute("src"),setTimeout(()=>{o==null||o.setAttribute("src",l)},0)}s.mode!=="hidden"&&(s.mode="hidden")}})};e.once(it.Events.MANIFEST_LOADED,r),e.once(it.Events.MEDIA_ATTACHED,r)}function fd(i,e,t,r,s){let n=document.createElement("track");return n.kind=e,n.label=t,r&&(n.srclang=r),s&&(n.id=s),n.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),i.append(n),n.track}function lE(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),r=>r.track===e);t==null||t.remove()}var pa="cuepoints",Cf=Object.freeze({label:pa}),Mf=(i,{label:e=pa}=Cf)=>{var t;return(t=Array.from(i.querySelectorAll("track")).find(r=>r.track.label===e&&r.track.kind==="metadata"))==null?void 0:t.track};async function Pf(i,e,t=Cf){let r=Mf(i,t);if(!r){let{label:s=pa}=t;r=fd(i,"metadata",s),r.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))}return r.mode!=="hidden"&&(r.mode="hidden"),[...e].sort(({time:s},{time:n})=>n-s).forEach(({time:s,value:n})=>{var a,o;let l=Array.prototype.findIndex.call(r==null?void 0:r.cues,f=>f.startTime>=s),d=(a=r==null?void 0:r.cues)==null?void 0:a[l],c=d?d.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,u=(o=r==null?void 0:r.cues)==null?void 0:o[l-1];u&&(u.endTime=s);let h=new VTTCue(s,c,JSON.stringify(n!=null?n:null));r.addCue(h)}),r}var dE=i=>({time:i.startTime,value:JSON.parse(i.text)});function cE(i,e={label:pa}){let t=Mf(i,e);return t!=null&&t.cues?Array.from(t.cues,r=>dE(r)):[]}function Of(i,e={label:pa}){var t,r;let s=Mf(i,e);if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return dE(a)}async function AS(i,e=Cf){return new Promise(t=>{_i(i,"loadstart",async()=>{let r=await Pf(i,[],e);_i(i,"cuechange",()=>{let s=Of(i);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}function uE(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function hE(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var SS=async i=>fetch(i).then(e=>e.text()).then(e=>{let t=e.split(`
1042
1078
  `).find((r,s,n)=>s&&n[s-1].startsWith("#EXT-X-STREAM-INF"));return fetch(t).then(r=>r.text()).then(r=>r.split(`
1043
- `))}),b1=i=>{var e,t,r;let s=(t=((e=i.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),n=mv(s),a=pv(s),o;if(n===Ze.LIVE){let l=i.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)o=+l.split(":")[1].split("=")[1]*2;else{let d=i.find(u=>u.startsWith("#EXT-X-TARGETDURATION")),c=(r=d==null?void 0:d.split(":"))==null?void 0:r[1];o=+(c!=null?c:6)*3}}return{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:o}},y1=async(i,e)=>{if(e===Sr.MP4)return{streamType:Ze.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===Sr.M3U8){let t=await E1(i);return b1(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},lv=async(i,e,t=td({src:i}))=>{var r,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await y1(i,t);((r=kt.get(e))!=null?r:{}).liveEdgeStartOffset=l,((s=kt.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=kt.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},T1=i=>{var e;let t=i.type,r=mv(t),s=pv(t),n,a=!!((e=i.partList)!=null&&e.length);return r===Ze.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},_1=(i,e,t)=>{var r,s,n,a,o,l,d,c;let{streamType:u,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:g}=T1(i);if(u===Ze.LIVE){g?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let E=Object.freeze({get length(){return e.seekable.length},start(T){return e.seekable.start(T)},end(T){var A;return T>this.length?e.seekable.end(T):(A=t.liveSyncPosition)!=null?A:e.seekable.end(T)}});((o=kt.get(e))!=null?o:{}).seekable=E}((l=kt.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=kt.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((c=kt.get(e))!=null?c:{}).streamType=u,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},dv,cv,A1=(cv=(dv=globalThis==null?void 0:globalThis.navigator)==null?void 0:dv.userAgent)!=null?cv:"",S1=A1.toLowerCase().indexOf("android")!==-1,kt=new WeakMap,Tv="mux.com",uv,hv,_v=(hv=(uv=dt).isSupported)==null?void 0:hv.call(uv),x1=S1,Av=()=>ed.default.utils.now(),I1=ed.default.utils.generateUUID,la=({playbackId:i,customDomain:e=Tv,maxResolution:t,minResolution:r,renditionOrder:s,tokens:{playback:n}={},extraPlaylistParams:a={}}={})=>{if(!i)return;let[o,l=""]=c1(i),d=new URL(`https://stream.${e}/${o}.m3u8${l}`);return n||d.searchParams.has("token")?(d.searchParams.forEach((c,u)=>{u!="token"&&d.searchParams.delete(u)}),n&&d.searchParams.set("token",n)):(t&&d.searchParams.set("max_resolution",t),r&&(d.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&d.searchParams.set("rendition_order",s),Object.entries(a).forEach(([c,u])=>{u!=null&&d.searchParams.set(c,u)})),d.toString()},L1=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},k1=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(".m3u8");return e||void 0},R1=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:Dv(i)&&(r=(t=L1(i.playbackId))!=null?t:k1(i.src))!=null?r:i.src},Sv=i=>{var e;return(e=kt.get(i))==null?void 0:e.error},xv=i=>{var e,t;return(t=(e=kt.get(i))==null?void 0:e.streamType)!=null?t:Ze.UNKNOWN},Iv=i=>{var e,t;return(t=(e=kt.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},mf=i=>{var e,t;return(t=(e=kt.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},Lv=i=>{var e;let t=(e=kt.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=mf(i);return r.length?r.end(r.length-1)-t:Number.NaN},w1=(i,e,t=.001)=>Math.abs(i-e)<=t,kv=(i,e,t=.001)=>i>e||w1(i,e,t),D1=i=>i.paused&&kv(i.currentTime,i.duration),pf=(i,e)=>i.loop||!!e?i.ended:i.ended||D1(i),Rv=(i,e,t)=>{gf(e,t);let{metadata:r={}}=i,{view_session_id:s=I1()}=r,n=R1(i);r.view_session_id=s,r.video_id=n,i.metadata=r,kt.set(e,{});let a=C1(i,e);O1(i,e,a),P1(i,e,a),v1(e);let o=f1(i,e,a),l=m1(i,e,a);return{engine:a,setAutoplay:o,setPreload:l}},gf=(i,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),(i==null?void 0:i.mux)&&!i.mux.deleted&&(i.mux.destroy(),delete i.mux),i&&(i.removeAttribute("src"),i.load(),i.removeEventListener("error",Mv),i.removeEventListener("error",df),i.removeEventListener("durationchange",Cv),kt.delete(i),i.dispatchEvent(new Event("teardown")))};function wv(i,e){var t;let r=td(i);if(r!==Sr.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===ui.MSE,o=n===ui.NATIVE;return s&&(o||!(_v&&(a||x1)))}var C1=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a}=i,o=td(i)===Sr.M3U8,l=wv(i,e);if(o&&!l&&_v){let d={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=M1(r),u=a!==of.NONE?{useHeaders:a===of.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new dt({debug:t,startPosition:s,cmcd:u,...d,...c})}},M1=i=>i===Ze.LIVE?{backBufferLength:8}:{},Dv=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(Tv)||!!t&&s.includes(t.toLocaleLowerCase())},O1=(i,e,t)=>{var r;let{envKey:s}=i,n=Dv(i);if(s||n){let{playerInitTime:a,playerSoftwareName:o,playerSoftwareVersion:l,beaconCollectionDomain:d,debug:c,disableCookies:u}=i,h={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},f=g=>typeof g.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(g):g;ed.default.monitor(e,{debug:c,beaconCollectionDomain:d,hlsjs:t,Hls:t?dt:void 0,automaticErrorTracking:!1,errorTranslator:f,disableCookies:u,data:{...s?{env_key:s}:{},player_software_name:o,player_software:o,player_software_version:l,player_init_time:a,...h}})}},P1=(i,e,t)=>{var r;let s=wv(i,e),{src:n}=i;if(e&&s){let a=td(i);typeof n=="string"?(e.preload==="none"?Si(e,"loadstart",()=>lv(n,e,a)):lv(n,e,a),e.setAttribute("src",n),i.startTime&&(((r=kt.get(e))!=null?r:{}).startTime=i.startTime,e.addEventListener("durationchange",Cv,{once:!0}))):e.removeAttribute("src"),e.addEventListener("error",Mv),e.addEventListener("error",df),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(l=>{l.remove()})},{once:!0});let o=()=>{e.ended||!pf(e)||e.dispatchEvent(new Event("ended"))};Si(e,"pause",o),Si(e,"seeked",o),Si(e,"play",()=>{e.ended||!kv(e.currentTime,e.duration)||(e.currentTime=e.seekable.start(0))})}else t&&n?(t.once(dt.Events.LEVEL_LOADED,(a,o)=>{_1(o.details,e,t)}),t.on(dt.Events.ERROR,(a,o)=>{let l={[dt.ErrorTypes.NETWORK_ERROR]:tt.MEDIA_ERR_NETWORK,[dt.ErrorTypes.MEDIA_ERROR]:tt.MEDIA_ERR_DECODE},d=new tt("",l[o.type]);d.fatal=o.fatal,d.data=o,e.dispatchEvent(new CustomEvent("error",{detail:d}))}),e.addEventListener("error",df),p1(i,t),g1(e,t),t.attachMedia(e)):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 Cv(i){var e;let t=i.target,r=(e=kt.get(t))==null?void 0:e.startTime;if(!!r&&d1(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function Mv(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new tt(t,r);if(e.src&&(r!==tt.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:s}))}function df(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof tt))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=kt.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var N1=Object.defineProperty,U1=(i,e,t)=>e in i?N1(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ge=(i,e,t)=>(U1(i,typeof e!="symbol"?e+"":e,t),t),Df=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},H=(i,e,t)=>(Df(i,e,"read from private field"),t?t.call(i):e.get(i)),le=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ue=(i,e,t,r)=>(Df(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),it=(i,e,t)=>(Df(i,e,"access private method"),t),hd=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment=="undefined"){class i extends hd{}globalThis.DocumentFragment=i}var Cf=class extends hd{},F1=class extends hd{},B1={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(Cf)}},rd,$1=class{constructor(i,e={}){le(this,rd,void 0),ue(this,rd,e==null?void 0:e.detail)}get detail(){return H(this,rd)}initCustomEvent(){}};rd=new WeakMap;function H1(i,e){return new Cf}var Bv={document:{createElement:H1},DocumentFragment,customElements:B1,CustomEvent:$1,EventTarget:hd,HTMLElement:Cf,HTMLVideoElement:F1},$v=typeof window=="undefined"||typeof globalThis.customElements=="undefined",sd=$v?Bv:globalThis,Qw=$v?Bv.document:globalThis.document,G1=()=>{try{return"0.17.0"}catch{}return"UNKNOWN"},V1=G1(),K1=()=>V1,Ov=i=>{var e,t,r,s,n,a,o,l,d,c,u,h,f,g,E,T,A,k,L,N,D,$,O,G,Y,P,X,z,Ae,Ee,be,we,Se,Z,ne,se,xe,Ie,Ve,ht;return e=class extends i{constructor(){super(),le(this,X),le(this,Ae),le(this,be),le(this,Se),le(this,ne),le(this,xe),le(this,Ve),Ge(this,"castEnabled",!1),le(this,D,{paused:!1}),le(this,$,void 0),le(this,O,{}),le(this,G,void 0),le(this,Y,void 0),le(this,P,void 0),e.instances.add(this),it(this,ne,se).call(this)}static get castElement(){return H(e,t)}static get castEnabled(){return H(e,r)}static get castState(){var V;return(V=H(e,d,c))==null?void 0:V.getCastState()}static async exitCast(){try{await H(e,d,c).endCurrentSession(!0)}catch(V){console.error(V);return}}get castPlayer(){if(e.castElement===this)return H(this,$)}attributeChangedCallback(V){if(this.castPlayer)switch(V){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(V={}){var ee;it(ee=e,L,N).call(ee,V),ue(e,t,this),Object.entries(H(this,O)).forEach(([ke,Je])=>{H(this,$).controller.addEventListener(ke,Je)});try{await H(e,d,c).requestSession()}catch{ue(e,t,void 0);return}H(this,D).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(ke){console.error(ke)}}async load(){var V,ee;if(!this.castPlayer)return super.load();let ke=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),Je=[...this.querySelectorAll("track")].filter(({kind:ti,src:Li})=>Li&&(ti==="subtitles"||ti==="captions")),_t=[],jt=0;Je.length&&(ke.tracks=Je.map(ti=>{let Li=++jt;_t.length===0&&ti.track.mode==="showing"&&_t.push(Li);let ki=new chrome.cast.media.Track(Li,chrome.cast.media.TrackType.TEXT);return ki.trackContentId=ti.src,ki.trackContentType="text/vtt",ki.subtype=ti.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,ki.name=ti.label,ki.language=ti.srclang,ki})),this.castStreamType==="live"?ke.streamType=chrome.cast.media.StreamType.LIVE:ke.streamType=chrome.cast.media.StreamType.BUFFERED,ke.metadata=new chrome.cast.media.GenericMediaMetadata,ke.metadata.title=this.title,ke.metadata.images=[{url:this.poster}];let hr=new chrome.cast.media.LoadRequest(ke);hr.currentTime=(V=super.currentTime)!=null?V:0,hr.autoplay=!H(this,D).paused,hr.activeTrackIds=_t,await((ee=H(e,u,h))==null?void 0:ee.loadMedia(hr)),this.dispatchEvent(new Event("volumechange"))}play(){var V;if(this.castPlayer){this.castPlayer.isPaused&&((V=this.castPlayer.controller)==null||V.playOrPause());return}return super.play()}pause(){var V;if(this.castPlayer){this.castPlayer.isPaused||(V=this.castPlayer.controller)==null||V.playOrPause();return}super.pause()}get castSrc(){var V,ee,ke;return(ke=(ee=this.getAttribute("cast-src"))!=null?ee:(V=this.querySelector("source"))==null?void 0:V.src)!=null?ke:this.currentSrc}set castSrc(V){this.castSrc!=V&&this.setAttribute("cast-src",`${V}`)}get castContentType(){var V;return(V=this.getAttribute("cast-content-type"))!=null?V:void 0}set castContentType(V){this.setAttribute("cast-content-type",`${V}`)}get castStreamType(){var V,ee;return(ee=(V=this.getAttribute("cast-stream-type"))!=null?V:this.streamType)!=null?ee:void 0}set castStreamType(V){this.setAttribute("cast-stream-type",`${V}`)}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 V;return this.castPlayer?(V=this.castPlayer)==null?void 0:V.isMuted:super.muted}set muted(V){var ee;if(this.castPlayer){(V&&!this.castPlayer.isMuted||!V&&this.castPlayer.isMuted)&&((ee=this.castPlayer.controller)==null||ee.muteOrUnmute());return}super.muted=V}get volume(){var V,ee;return this.castPlayer?(ee=(V=this.castPlayer)==null?void 0:V.volumeLevel)!=null?ee:1:super.volume}set volume(V){var ee;if(this.castPlayer){this.castPlayer.volumeLevel=V,(ee=this.castPlayer.controller)==null||ee.setVolumeLevel();return}super.volume=V}get duration(){var V,ee;return this.castPlayer&&H(this,X,z)?(ee=(V=this.castPlayer)==null?void 0:V.duration)!=null?ee:NaN:super.duration}get currentTime(){var V,ee;return this.castPlayer&&H(this,X,z)?(ee=(V=this.castPlayer)==null?void 0:V.currentTime)!=null?ee:0:super.currentTime}set currentTime(V){var ee;if(this.castPlayer){this.castPlayer.currentTime=V,(ee=this.castPlayer.controller)==null||ee.seek();return}super.currentTime=V}get onentercast(){return H(this,G)}set onentercast(V){H(this,G)&&(this.removeEventListener("entercast",H(this,G)),ue(this,G,null)),typeof V=="function"&&(ue(this,G,V),this.addEventListener("entercast",V))}get onleavecast(){return H(this,Y)}set onleavecast(V){H(this,Y)&&(this.removeEventListener("leavecast",H(this,Y)),ue(this,Y,null)),typeof V=="function"&&(ue(this,Y,V),this.addEventListener("leavecast",V))}get oncastchange(){return H(this,P)}set oncastchange(V){H(this,P)&&(this.removeEventListener("castchange",H(this,P)),ue(this,P,null)),typeof V=="function"&&(ue(this,P,V),this.addEventListener("castchange",V))}},t=new WeakMap,r=new WeakMap,s=new WeakMap,n=new WeakSet,a=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},o=new WeakSet,l=function(){return typeof cast!="undefined"&&cast.framework},d=new WeakSet,c=function(){if(H(e,o,l))return cast.framework.CastContext.getInstance()},u=new WeakSet,h=function(){var V;return(V=H(e,d,c))==null?void 0:V.getCurrentSession()},f=new WeakSet,g=function(){var V;return(V=H(e,u,h))==null?void 0:V.getSessionObj().media[0]},E=new WeakSet,T=function(V){return new Promise((ee,ke)=>{H(e,f,g).editTracksInfo(V,ee,ke)})},A=new WeakSet,k=function(V){return new Promise((ee,ke)=>{H(e,f,g).getStatus(V,ee,ke)})},L=new WeakSet,N=function(V){return H(e,d,c).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...V})},D=new WeakMap,$=new WeakMap,O=new WeakMap,G=new WeakMap,Y=new WeakMap,P=new WeakMap,X=new WeakSet,z=function(){var V;return(V=this.castPlayer)==null?void 0:V.isMediaLoaded},Ae=new WeakSet,Ee=function(){H(e,t)===this&&(Object.entries(H(this,O)).forEach(([V,ee])=>{H(this,$).controller.removeEventListener(V,ee)}),ue(e,t,void 0),this.muted=H(this,$).isMuted,this.currentTime=H(this,$).savedPlayerState.currentTime,H(this,$).savedPlayerState.isPaused===!1&&this.play())},be=new WeakSet,we=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:H(e,d,c).getCastState()}))},Se=new WeakSet,Z=async function(){var V,ee;let{SESSION_RESUMED:ke}=cast.framework.SessionState;if(H(e,d,c).getSessionState()===ke&&this.castSrc===((V=H(e,f,g))==null?void 0:V.media.contentId)){ue(e,t,this),Object.entries(H(this,O)).forEach(([Je,_t])=>{H(this,$).controller.addEventListener(Je,_t)});try{await it(ee=e,A,k).call(ee,new chrome.cast.media.GetStatusRequest)}catch(Je){console.error(Je)}H(this,O)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),H(this,O)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},ne=new WeakSet,se=function(){var V;!H(e,o,l)||this.castEnabled||(this.castEnabled=!0,it(V=e,L,N).call(V),this.textTracks.addEventListener("change",it(this,Ve,ht).bind(this)),it(this,be,we).call(this),ue(this,$,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(H(this,$)),ue(this,O,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:ee})=>{ee===!1&&it(this,Ae,Ee).call(this),this.dispatchEvent(new Event(ee?"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]:()=>{!H(this,X,z)||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 ee,ke;((ee=this.castPlayer)==null?void 0:ee.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"}[(ke=this.castPlayer)==null?void 0:ke.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!H(this,X,z)||(await Promise.resolve(),it(this,xe,Ie).call(this))}}))},xe=new WeakSet,Ie=function(){it(this,Ve,ht).call(this)},Ve=new WeakSet,ht=async function(){var V,ee,ke,Je,_t,jt;if(!this.castPlayer)return;let hr=((ee=(V=H(this,$).mediaInfo)==null?void 0:V.tracks)!=null?ee:[]).filter(({type:rt})=>rt===chrome.cast.media.TrackType.TEXT),ti=[...this.textTracks].filter(({kind:rt})=>rt==="subtitles"||rt==="captions"),Li=hr.map(({language:rt,name:Or,trackId:pn})=>{var gn;let{mode:Oa}=(gn=ti.find(vn=>vn.language===rt&&vn.label===Or))!=null?gn:{};return Oa?{mode:Oa,trackId:pn}:!1}).filter(Boolean),ki=Li.filter(({mode:rt})=>rt!=="showing").map(({trackId:rt})=>rt),_s=Li.find(({mode:rt})=>rt==="showing"),mn=(_t=(Je=(ke=H(e,u,h))==null?void 0:ke.getSessionObj().media[0])==null?void 0:Je.activeTrackIds)!=null?_t:[],hi=mn;if(mn.length&&(hi=hi.filter(rt=>!ki.includes(rt))),_s!=null&&_s.trackId&&(hi=[...hi,_s.trackId]),hi=[...new Set(hi)],!((rt,Or)=>rt.length===Or.length&&rt.every(pn=>Or.includes(pn)))(mn,hi))try{let rt=new chrome.cast.media.EditTracksInfoRequest(hi);await it(jt=e,E,T).call(jt,rt)}catch(rt){console.error(rt)}},le(e,n),le(e,o),le(e,d),le(e,u),le(e,f),le(e,E),le(e,A),le(e,L),Ge(e,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Ge(e,"instances",new Set),le(e,t,void 0),le(e,r,!1),Ge(e,"initCast",()=>{var V;H(e,n,a)?H(e,o,l)?H(V=e,s).call(V,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var ee;return H(ee=e,s).call(ee,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var ee;return H(ee=e,s).call(ee,chrome.cast.isAvailable)})}}),le(e,s,V=>{if(V){ue(e,r,!0);let{CAST_STATE_CHANGED:ee}=cast.framework.CastContextEventType;H(e,d,c).addEventListener(ee,Je=>{e.instances.forEach(_t=>{var jt;return it(jt=_t,be,we).call(jt,Je)})});let{SESSION_STATE_CHANGED:ke}=cast.framework.CastContextEventType;H(e,d,c).addEventListener(ke,Je=>{e.instances.forEach(_t=>{var jt;return it(jt=_t,Se,Z).call(jt,Je)})}),e.instances.forEach(Je=>{var _t;return it(_t=Je,ne,se).call(_t)})}}),e},Ef=globalThis.HTMLVideoElement?Ov(HTMLVideoElement):Ov(Object);globalThis.customElements&&!globalThis.customElements.get("castable-video")&&(customElements.define("castable-video",Ef,{extends:"video"}),globalThis.CastableVideoElement=Ef);Ef.initCast();var fd=["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","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],Pv,bf=(Pv=globalThis.document)==null?void 0:Pv.createElement("template");bf&&(bf.innerHTML=`
1079
+ `))}),xS=i=>{var e,t,r;let s=(t=((e=i.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),n=aE(s),a=oE(s),o;if(n===qe.LIVE){let l=i.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)o=+l.split(":")[1].split("=")[1]*2;else{let d=i.find(u=>u.startsWith("#EXT-X-TARGETDURATION")),c=(r=d==null?void 0:d.split(":"))==null?void 0:r[1];o=+(c!=null?c:6)*3}}return{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:o}},IS=async(i,e)=>{if(e===Er.MP4)return{streamType:qe.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===Er.M3U8){let t=await SS(i);return xS(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},eE=async(i,e,t=hd({src:i}))=>{var r,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await IS(i,t);((r=_t.get(e))!=null?r:{}).liveEdgeStartOffset=l,((s=_t.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=_t.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},LS=i=>{var e;let t=i.type,r=aE(t),s=oE(t),n,a=!!((e=i.partList)!=null&&e.length);return r===qe.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},RS=(i,e,t)=>{var r,s,n,a,o,l,d,c;let{streamType:u,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:g}=LS(i);if(u===qe.LIVE){g?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let E=Object.freeze({get length(){return e.seekable.length},start(T){return e.seekable.start(T)},end(T){var A;return T>this.length?e.seekable.end(T):(A=t.liveSyncPosition)!=null?A:e.seekable.end(T)}});((o=_t.get(e))!=null?o:{}).seekable=E}((l=_t.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=_t.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((c=_t.get(e))!=null?c:{}).streamType=u,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},tE,iE,kS=(iE=(tE=globalThis==null?void 0:globalThis.navigator)==null?void 0:tE.userAgent)!=null?iE:"",wS=kS.toLowerCase().indexOf("android")!==-1,_t=new WeakMap,fE="mux.com",rE,sE,mE=(sE=(rE=it).isSupported)==null?void 0:sE.call(rE),DS=wS,pE=()=>ud.default.utils.now(),CS=ud.default.utils.generateUUID,ga=({playbackId:i,customDomain:e=fE,maxResolution:t,minResolution:r,renditionOrder:s,tokens:{playback:n}={},extraSourceParams:a={}}={})=>{if(!i)return;let[o,l=""]=gS(i),d=new URL(`https://stream.${e}/${o}.m3u8${l}`);return n||d.searchParams.has("token")?(d.searchParams.forEach((c,u)=>{u!="token"&&d.searchParams.delete(u)}),n&&d.searchParams.set("token",n)):(t&&d.searchParams.set("max_resolution",t),r&&(d.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&d.searchParams.set("rendition_order",s),Object.entries(a).forEach(([c,u])=>{u!=null&&d.searchParams.set(c,u)})),d.toString()},MS=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},PS=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(".m3u8");return e||void 0},OS=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:AE(i)&&(r=(t=MS(i.playbackId))!=null?t:PS(i.src))!=null?r:i.src},gE=i=>{var e;return(e=_t.get(i))==null?void 0:e.error},vE=i=>{var e,t;return(t=(e=_t.get(i))==null?void 0:e.streamType)!=null?t:qe.UNKNOWN},EE=i=>{var e,t;return(t=(e=_t.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},Nf=i=>{var e,t;return(t=(e=_t.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},bE=i=>{var e;let t=(e=_t.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=Nf(i);return r.length?r.end(r.length-1)-t:Number.NaN},NS=(i,e,t=.001)=>Math.abs(i-e)<=t,yE=(i,e,t=.001)=>i>e||NS(i,e,t),US=i=>i.paused&&yE(i.currentTime,i.duration),Uf=(i,e)=>i.loop||e?i.ended:i.ended||US(i),TE=(i,e,t)=>{Ff(e,t);let{metadata:r={}}=i,{view_session_id:s=CS()}=r,n=OS(i);r.view_session_id=s,r.video_id=n,i.metadata=r,_t.set(e,{});let a=FS(i,e);$S(i,e,a),HS(i,e,a),AS(e);let o=bS(i,e,a),l=yS(i,e,a);return{engine:a,setAutoplay:o,setPreload:l}},Ff=(i,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),i!=null&&i.mux&&!i.mux.deleted&&(i.mux.destroy(),delete i.mux),i&&(i.removeAttribute("src"),i.load(),i.removeEventListener("error",xE),i.removeEventListener("error",Df),i.removeEventListener("durationchange",SE),_t.delete(i),i.dispatchEvent(new Event("teardown")))};function _E(i,e){var t;let r=hd(i);if(r!==Er.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===li.MSE,o=n===li.NATIVE;return s&&(o||!(mE&&(a||DS)))}var FS=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=hd(i)===Er.M3U8,d=_E(i,e);if(l&&!d&&mE){let c={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},u=BS(r),h=a!==cd.NONE?{useHeaders:a===cd.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new it({debug:t,startPosition:s,cmcd:h,xhrSetup:(f,g)=>{var E,T;if(a&&a!==cd.QUERY)return;let A=new URL(g);if(!A.searchParams.has("CMCD"))return;let R=((T=(E=A.searchParams.get("CMCD"))==null?void 0:E.split(","))!=null?T:[]).filter(L=>L.startsWith("sid")||L.startsWith("cid")).join(",");A.searchParams.set("CMCD",R),f.open("GET",A)},...c,...u,...o})}},BS=i=>i===qe.LIVE?{backBufferLength:8}:{},AE=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(fE)||!!t&&s.includes(t.toLocaleLowerCase())},$S=(i,e,t)=>{var r;let{envKey:s}=i,n=AE(i);if(s||n){let{playerInitTime:a,playerSoftwareName:o,playerSoftwareVersion:l,beaconCollectionDomain:d,debug:c,disableCookies:u}=i,h={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},f=g=>typeof g.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(g):g;ud.default.monitor(e,{debug:c,beaconCollectionDomain:d,hlsjs:t,Hls:t?it:void 0,automaticErrorTracking:!1,errorTranslator:f,disableCookies:u,data:{...s?{env_key:s}:{},player_software_name:o,player_software:o,player_software_version:l,player_init_time:a,...h}})}},HS=(i,e,t)=>{var r;let s=_E(i,e),{src:n}=i;if(e&&s){let a=hd(i);typeof n=="string"?(e.preload==="none"?_i(e,"loadstart",()=>eE(n,e,a)):eE(n,e,a),e.setAttribute("src",n),i.startTime&&(((r=_t.get(e))!=null?r:{}).startTime=i.startTime,e.addEventListener("durationchange",SE,{once:!0}))):e.removeAttribute("src"),e.addEventListener("error",xE),e.addEventListener("error",Df),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(l=>{l.remove()})},{once:!0});let o=()=>{e.ended||Uf(e)&&e.dispatchEvent(new Event("ended"))};_i(e,"pause",o),_i(e,"seeked",o),_i(e,"play",()=>{e.ended||yE(e.currentTime,e.duration)&&(e.currentTime=e.seekable.start(0))})}else t&&n?(t.once(it.Events.LEVEL_LOADED,(a,o)=>{RS(o.details,e,t)}),t.on(it.Events.ERROR,(a,o)=>{let l={[it.ErrorTypes.NETWORK_ERROR]:At.MEDIA_ERR_NETWORK,[it.ErrorTypes.MEDIA_ERROR]:At.MEDIA_ERR_DECODE},d=new At("",l[o.type]);d.fatal=o.fatal,d.data=o,e.dispatchEvent(new CustomEvent("error",{detail:d}))}),e.addEventListener("error",Df),TS(i,t),_S(e,t),t.attachMedia(e)):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 SE(i){var e;let t=i.target,r=(e=_t.get(t))==null?void 0:e.startTime;if(r&&pS(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function xE(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new At(t,r);if(e.src&&(r!==At.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:s}))}function Df(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof At))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=_t.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var GS=Object.defineProperty,VS=Object.getPrototypeOf,KS=Reflect.get,WS=(i,e,t)=>e in i?GS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,We=(i,e,t)=>(WS(i,typeof e!="symbol"?e+"":e,t),t),lm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},P=(i,e,t)=>(lm(i,e,"read from private field"),t?t.call(i):e.get(i)),ae=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ce=(i,e,t,r)=>(lm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),rt=(i,e,t)=>(lm(i,e,"access private method"),t),Bf=(i,e,t)=>KS(VS(i),t,e),Rd=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment=="undefined"){class i extends Rd{}globalThis.DocumentFragment=i}var dm=class extends Rd{},qS=class extends Rd{},YS={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(dm)}},md,jS=class{constructor(i,e={}){ae(this,md,void 0),ce(this,md,e==null?void 0:e.detail)}get detail(){return P(this,md)}initCustomEvent(){}};md=new WeakMap;function zS(i,e){return new dm}var ME={document:{createElement:zS},DocumentFragment,customElements:YS,CustomEvent:jS,EventTarget:Rd,HTMLElement:dm,HTMLVideoElement:qS},PE=typeof window=="undefined"||typeof globalThis.customElements=="undefined",$f=PE?ME:globalThis,vC=PE?ME.document:globalThis.document,XS=()=>{try{return"0.17.1"}catch{}return"UNKNOWN"},QS=XS(),ZS=()=>QS,kd=["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","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],IE,Kf=(IE=globalThis.document)==null?void 0:IE.createElement("template");Kf&&(Kf.innerHTML=`
1044
1080
  <style>
1045
1081
  :host {
1046
- display: inline-block;
1082
+ display: inline-flex;
1047
1083
  line-height: 0;
1084
+ flex-direction: column;
1085
+ justify-content: end;
1048
1086
  }
1049
1087
 
1050
1088
  audio {
1051
- max-width: 100%;
1052
- max-height: 100%;
1053
- min-width: 100%;
1054
- min-height: 100%;
1089
+ width: 100%;
1055
1090
  }
1056
1091
  </style>
1092
+ <slot name="media"></slot>
1057
1093
  <slot></slot>
1058
- `);var Nv,yf=(Nv=globalThis.document)==null?void 0:Nv.createElement("template");yf&&(yf.innerHTML=`
1094
+ `);var LE,Wf=(LE=globalThis.document)==null?void 0:LE.createElement("template");Wf&&(Wf.innerHTML=`
1059
1095
  <style>
1060
1096
  :host {
1061
1097
  display: inline-block;
@@ -1076,9 +1112,10 @@ svg, img, ::slotted(svg), ::slotted(img) {
1076
1112
  transition: var(--media-webkit-text-track-transition);
1077
1113
  }
1078
1114
  </style>
1115
+ <slot name="media"></slot>
1079
1116
  <slot></slot>
1080
- `);var Mf=(i,{tag:e,is:t})=>{var r,s,n,a,o,l,d,c,u,h,f,g,E;let T=(r=globalThis.document)==null?void 0:r.createElement(e,{is:t}),A=T?W1(T):[];return s=class extends i{constructor(){super(),le(this,c),le(this,h),le(this,g),le(this,l,void 0),le(this,d,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var k,L,N;return it(k=s,a,o).call(k),[...(N=(L=T==null?void 0:T.constructor)==null?void 0:L.observedAttributes)!=null?N:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var k,L;return(L=(k=H(this,d))!=null?k:this.shadowRoot.querySelector(e))!=null?L:this.querySelector(e)}set nativeEl(k){ue(this,d,k)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(k){this.toggleAttribute("muted",Boolean(k))}get src(){return this.getAttribute("src")}set src(k){this.setAttribute("src",`${k}`)}get preload(){var k,L;return(L=this.getAttribute("preload"))!=null?L:(k=this.nativeEl)==null?void 0:k.preload}set preload(k){this.setAttribute("preload",`${k}`)}attributeChangedCallback(k,L,N){it(this,c,u).call(this),it(this,g,E).call(this,k,L,N)}connectedCallback(){it(this,c,u).call(this)}},n=new WeakMap,a=new WeakSet,o=function(){if(H(this,n))return;ue(this,n,!0);let k=new Set(this.observedAttributes);k.delete("muted");for(let L of A)if(!(L in this.prototype))if(typeof T[L]=="function")this.prototype[L]=function(...N){return it(this,c,u).call(this),(()=>this.call?this.call(L,...N):this.nativeEl[L].apply(this.nativeEl,N))()};else{let N={get(){var D,$,O;it(this,c,u).call(this);let G=L.toLowerCase();if(k.has(G)){let Y=this.getAttribute(G);return Y===null?!1:Y===""?!0:Y}return(O=(D=this.get)==null?void 0:D.call(this,L))!=null?O:($=this.nativeEl)==null?void 0:$[L]}};L!==L.toUpperCase()&&(N.set=function(D){it(this,c,u).call(this);let $=L.toLowerCase();if(k.has($)){D===!0||D===!1||D==null?this.toggleAttribute($,Boolean(D)):this.setAttribute($,D);return}if(this.set){this.set(L,D);return}this.nativeEl[L]=D}),Object.defineProperty(this.prototype,L,N)}},l=new WeakMap,d=new WeakMap,c=new WeakSet,u=function(){var k,L;if(H(this,l))return;if(ue(this,l,!0),!this.nativeEl){let $=document.createElement(e,{is:t});$.part=e,this.shadowRoot.append($)}this.nativeEl.muted=this.hasAttribute("muted");for(let $ of A)it(this,h,f).call(this,$);let N=new Map,D=this.shadowRoot.querySelector("slot:not([name])");D==null||D.addEventListener("slotchange",()=>{let $=new Map(N);D.assignedElements().filter(O=>["track","source"].includes(O.localName)).forEach(O=>{var G,Y;$.delete(O);let P=N.get(O);P||(P=O.cloneNode(),N.set(O,P)),(Y=(G=this.nativeEl).append)==null||Y.call(G,P)}),$.forEach(O=>O.remove())});for(let $ of this.constructor.Events)(L=(k=this.shadowRoot).addEventListener)==null||L.call(k,$,O=>{O.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(O.type,{detail:O.detail}))},!0)},h=new WeakSet,f=function(k){if(Object.prototype.hasOwnProperty.call(this,k)){let L=this[k];delete this[k],this[k]=L}},g=new WeakSet,E=function(k,L,N){var D,$,O,G;["id","class"].includes(k)||(N===null?($=(D=this.nativeEl).removeAttribute)==null||$.call(D,k):(G=(O=this.nativeEl).setAttribute)==null||G.call(O,k,N))},le(s,a),Ge(s,"Events",fd),Ge(s,"template",e.endsWith("audio")?bf:yf),le(s,n,void 0),s};function W1(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}var Jw=globalThis.document?Mf(HTMLElement,{tag:"video"}):class{},eD=globalThis.document?Mf(HTMLElement,{tag:"audio"}):class{},md=class extends Event{constructor(i,e){super(i),Ge(this,"track"),this.track=e.track}},Tf=new WeakMap;function ie(i){var e;return(e=Tf.get(i))!=null?e:q1(i,{})}function q1(i,e){let t=Tf.get(i);return t||Tf.set(i,t={}),Object.assign(t,e)}function _f(i,e){let t=i.videoTracks;ie(e).media=i,ie(e).renditionSet||(ie(e).renditionSet=new Set);let r=ie(t).trackSet;r.add(e);let s=r.size-1;s in Sf.prototype||Object.defineProperty(Sf.prototype,s,{get(){return[...ie(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new md("addtrack",{track:e}))})}function Af(i){var e;let t=(e=ie(i).media)==null?void 0:e.videoTracks;!t||(ie(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new md("removetrack",{track:i}))}))}function Y1(i){var e;let t=(e=ie(i).media.videoTracks)!=null?e:[],r=!1;for(let s of t)s!==i&&(s.selected=!1,r=!0);if(r){if(ie(t).changeRequested)return;ie(t).changeRequested=!0,queueMicrotask(()=>{delete ie(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var es,ts,is,sn,da,Sf=class extends EventTarget{constructor(){super(),le(this,sn),le(this,es,void 0),le(this,ts,void 0),le(this,is,void 0),ie(this).trackSet=new Set}[Symbol.iterator](){return H(this,sn,da).values()}get length(){return H(this,sn,da).size}getTrackById(i){var e;return(e=[...H(this,sn,da)].find(t=>t.id===i))!=null?e:null}get selectedIndex(){return[...H(this,sn,da)].findIndex(i=>i.selected)}get onaddtrack(){return H(this,es)}set onaddtrack(i){H(this,es)&&(this.removeEventListener("addtrack",H(this,es)),ue(this,es,void 0)),typeof i=="function"&&(ue(this,es,i),this.addEventListener("addtrack",i))}get onremovetrack(){return H(this,ts)}set onremovetrack(i){H(this,ts)&&(this.removeEventListener("removetrack",H(this,ts)),ue(this,ts,void 0)),typeof i=="function"&&(ue(this,ts,i),this.addEventListener("removetrack",i))}get onchange(){return H(this,is)}set onchange(i){H(this,is)&&(this.removeEventListener("change",H(this,is)),ue(this,is,void 0)),typeof i=="function"&&(ue(this,is,i),this.addEventListener("change",i))}};es=new WeakMap,ts=new WeakMap,is=new WeakMap,sn=new WeakSet,da=function(){return ie(this).trackSet};var pd=class extends Event{constructor(i,e){super(i),Ge(this,"rendition"),this.rendition=e.rendition}};function j1(i,e){let t=ie(i).media.videoRenditions;ie(e).media=ie(i).media,ie(e).track=i;let r=ie(i).renditionSet;r.add(e);let s=r.size-1;s in xf.prototype||Object.defineProperty(xf.prototype,s,{get(){return nn(this)[s]}}),queueMicrotask(()=>{!i.selected||t.dispatchEvent(new pd("addrendition",{rendition:e}))})}function z1(i){let e=ie(i).media.videoRenditions,t=ie(i).track;ie(t).renditionSet.delete(i),queueMicrotask(()=>{!ie(i).track.selected||e.dispatchEvent(new pd("removerendition",{rendition:i}))})}function X1(i){let e=ie(i).media.videoRenditions;!e||ie(e).changeRequested||(ie(e).changeRequested=!0,queueMicrotask(()=>{delete ie(e).changeRequested,ie(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function nn(i){return[...ie(i).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...ie(e).renditionSet])}var rs,ss,ns,xf=class extends EventTarget{constructor(){super(...arguments),le(this,rs,void 0),le(this,ss,void 0),le(this,ns,void 0)}[Symbol.iterator](){return nn(this).values()}get length(){return nn(this).length}getRenditionById(i){var e;return(e=nn(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return nn(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of nn(this).entries())t.selected=e===i}get onaddrendition(){return H(this,rs)}set onaddrendition(i){H(this,rs)&&(this.removeEventListener("addrendition",H(this,rs)),ue(this,rs,void 0)),typeof i=="function"&&(ue(this,rs,i),this.addEventListener("addrendition",i))}get onremoverendition(){return H(this,ss)}set onremoverendition(i){H(this,ss)&&(this.removeEventListener("removerendition",H(this,ss)),ue(this,ss,void 0)),typeof i=="function"&&(ue(this,ss,i),this.addEventListener("removerendition",i))}get onchange(){return H(this,ns)}set onchange(i){H(this,ns)&&(this.removeEventListener("change",H(this,ns)),ue(this,ns,void 0)),typeof i=="function"&&(ue(this,ns,i),this.addEventListener("change",i))}};rs=new WeakMap,ss=new WeakMap,ns=new WeakMap;var ca,Q1=class{constructor(){Ge(this,"src"),Ge(this,"id"),Ge(this,"width"),Ge(this,"height"),Ge(this,"bitrate"),Ge(this,"frameRate"),Ge(this,"codec"),le(this,ca,!1)}get selected(){return H(this,ca)}set selected(i){H(this,ca)!==i&&(ue(this,ca,i),X1(this))}};ca=new WeakMap;var ua,Hv=class{constructor(){Ge(this,"id"),Ge(this,"kind"),Ge(this,"label",""),Ge(this,"language",""),Ge(this,"sourceBuffer"),le(this,ua,!1)}addRendition(i,e,t,r,s,n){let a=new Q1;return a.src=i,a.width=e,a.height=t,a.frameRate=n,a.bitrate=s,a.codec=r,j1(this,a),a}removeRendition(i){z1(i)}get selected(){return H(this,ua)}set selected(i){H(this,ua)!==i&&(ue(this,ua,i),i===!0&&Y1(this))}};ua=new WeakMap;function Z1(i,e){let t=ie(i).media.audioRenditions;ie(e).media=ie(i).media,ie(e).track=i;let r=ie(i).renditionSet;r.add(e);let s=r.size-1;s in If.prototype||Object.defineProperty(If.prototype,s,{get(){return an(this)[s]}}),queueMicrotask(()=>{!i.enabled||t.dispatchEvent(new pd("addrendition",{rendition:e}))})}function J1(i){let e=ie(i).media.audioRenditions,t=ie(i).track;ie(t).renditionSet.delete(i),queueMicrotask(()=>{!ie(i).track.enabled||e.dispatchEvent(new pd("removerendition",{rendition:i}))})}function eS(i){let e=ie(i).media.audioRenditions;!e||ie(e).changeRequested||(ie(e).changeRequested=!0,queueMicrotask(()=>{delete ie(e).changeRequested,ie(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function an(i){return[...ie(i).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...ie(e).renditionSet])}var as,os,ls,If=class extends EventTarget{constructor(){super(...arguments),le(this,as,void 0),le(this,os,void 0),le(this,ls,void 0)}[Symbol.iterator](){return an(this).values()}get length(){return an(this).length}getRenditionById(i){var e;return(e=an(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return an(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of an(this).entries())t.selected=e===i}get onaddrendition(){return H(this,as)}set onaddrendition(i){H(this,as)&&(this.removeEventListener("addrendition",H(this,as)),ue(this,as,void 0)),typeof i=="function"&&(ue(this,as,i),this.addEventListener("addrendition",i))}get onremoverendition(){return H(this,os)}set onremoverendition(i){H(this,os)&&(this.removeEventListener("removerendition",H(this,os)),ue(this,os,void 0)),typeof i=="function"&&(ue(this,os,i),this.addEventListener("removerendition",i))}get onchange(){return H(this,ls)}set onchange(i){H(this,ls)&&(this.removeEventListener("change",H(this,ls)),ue(this,ls,void 0)),typeof i=="function"&&(ue(this,ls,i),this.addEventListener("change",i))}};as=new WeakMap,os=new WeakMap,ls=new WeakMap;var ha,tS=class{constructor(){Ge(this,"src"),Ge(this,"id"),Ge(this,"bitrate"),Ge(this,"codec"),le(this,ha,!1)}get selected(){return H(this,ha)}set selected(i){H(this,ha)!==i&&(ue(this,ha,i),eS(this))}};ha=new WeakMap;function Lf(i,e){let t=i.audioTracks;ie(e).media=i,ie(e).renditionSet||(ie(e).renditionSet=new Set);let r=ie(t).trackSet;r.add(e);let s=r.size-1;s in Rf.prototype||Object.defineProperty(Rf.prototype,s,{get(){return[...ie(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new md("addtrack",{track:e}))})}function kf(i){var e;let t=(e=ie(i).media)==null?void 0:e.audioTracks;!t||(ie(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new md("removetrack",{track:i}))}))}function iS(i){let e=ie(i).media.audioTracks;!e||ie(e).changeRequested||(ie(e).changeRequested=!0,queueMicrotask(()=>{delete ie(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var ds,cs,us,fa,nd,Rf=class extends EventTarget{constructor(){super(),le(this,fa),le(this,ds,void 0),le(this,cs,void 0),le(this,us,void 0),ie(this).trackSet=new Set}[Symbol.iterator](){return H(this,fa,nd).values()}get length(){return H(this,fa,nd).size}getTrackById(i){var e;return(e=[...H(this,fa,nd)].find(t=>t.id===i))!=null?e:null}get onaddtrack(){return H(this,ds)}set onaddtrack(i){H(this,ds)&&(this.removeEventListener("addtrack",H(this,ds)),ue(this,ds,void 0)),typeof i=="function"&&(ue(this,ds,i),this.addEventListener("addtrack",i))}get onremovetrack(){return H(this,cs)}set onremovetrack(i){H(this,cs)&&(this.removeEventListener("removetrack",H(this,cs)),ue(this,cs,void 0)),typeof i=="function"&&(ue(this,cs,i),this.addEventListener("removetrack",i))}get onchange(){return H(this,us)}set onchange(i){H(this,us)&&(this.removeEventListener("change",H(this,us)),ue(this,us,void 0)),typeof i=="function"&&(ue(this,us,i),this.addEventListener("change",i))}};ds=new WeakMap,cs=new WeakMap,us=new WeakMap,fa=new WeakSet,nd=function(){return ie(this).trackSet};var ma,Gv=class{constructor(){Ge(this,"id"),Ge(this,"kind"),Ge(this,"label",""),Ge(this,"language",""),Ge(this,"sourceBuffer"),le(this,ma,!1)}addRendition(i,e,t){let r=new tS;return r.src=i,r.codec=e,r.bitrate=t,Z1(this,r),r}removeRendition(i){J1(i)}get enabled(){return H(this,ma)}set enabled(i){H(this,ma)!==i&&(ue(this,ma,i),iS(this))}};ma=new WeakMap;var Uv=ud(globalThis.HTMLMediaElement,"video"),Fv=ud(globalThis.HTMLMediaElement,"audio");function rS(i){if(!(i!=null&&i.prototype))return i;let e=ud(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return sS(this)}});let t=ud(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return nS(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new Hv;return l.kind=n,l.label=a,l.language=o,_f(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=Af),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new Gv;return l.kind=n,l.label=a,l.language=o,Lf(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=kf),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return r(this)}});let r=n=>{let a=ie(n).videoRenditions;return a||(a=new xf,ie(a).media=n,ie(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return s(this)}});let s=n=>{let a=ie(n).audioRenditions;return a||(a=new If,ie(a).media=n,ie(n).audioRenditions=a),a};return i}function ud(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function sS(i){var e;let t=ie(i).videoTracks;if(!t&&(t=new Sf,ie(i).videoTracks=t,Uv)){let r=Uv.call((e=i.nativeEl)!=null?e:i);for(let s of r)_f(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof Hv)){for(let n of r)Af(n);return}_f(i,s.track)}),r.addEventListener("removetrack",s=>{Af(s.track)})}return t}function nS(i){var e;let t=ie(i).audioTracks;if(!t&&(t=new Rf,ie(i).audioTracks=t,Fv)){let r=Fv.call((e=i.nativeEl)!=null?e:i);for(let s of r)Lf(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof Gv)){for(let n of r)kf(n);return}Lf(i,s.track)}),r.addEventListener("removetrack",s=>{kf(s.track)})}return t}fd.push("castchange","entercast","leavecast");var vf=rS(Mf(sd.HTMLElement,{tag:"video",is:"castable-video"})),q={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},aS=Object.values(q),oS=K1(),lS="mux-video",zi,pa,ad,ga,od,ld,dd,va,cd,wf=class extends vf{constructor(){super(),le(this,va),le(this,zi,void 0),le(this,pa,void 0),le(this,ad,void 0),le(this,ga,{}),le(this,od,void 0),le(this,ld,void 0),le(this,dd,void 0),ue(this,ad,Av())}static get observedAttributes(){var i;return[...aS,...(i=vf.observedAttributes)!=null?i:[]]}get preferCmcd(){var i;return(i=this.getAttribute(q.PREFER_CMCD))!=null?i:void 0}set preferCmcd(i){i!==this.preferCmcd&&(i?rn.includes(i)?this.setAttribute(q.PREFER_CMCD,i):console.warn(`Invalid value for preferCmcd. Must be one of ${rn.join()}`):this.removeAttribute(q.PREFER_CMCD))}get playerInitTime(){return H(this,ad)}get playerSoftwareName(){var i;return(i=H(this,ld))!=null?i:lS}set playerSoftwareName(i){ue(this,ld,i)}get playerSoftwareVersion(){var i;return(i=H(this,od))!=null?i:oS}set playerSoftwareVersion(i){ue(this,od,i)}get _hls(){var i;return(i=H(this,zi))==null?void 0:i.engine}get mux(){var i;return(i=this.nativeEl)==null?void 0:i.mux}get error(){var i;return(i=Sv(this.nativeEl))!=null?i:null}get errorTranslator(){return H(this,dd)}set errorTranslator(i){ue(this,dd,i)}get src(){return this.getAttribute("src")}set src(i){i!==this.src&&(i==null?this.removeAttribute("src"):this.setAttribute("src",i))}get type(){var i;return(i=this.getAttribute(q.TYPE))!=null?i:void 0}set type(i){i!==this.type&&(i?this.setAttribute(q.TYPE,i):this.removeAttribute(q.TYPE))}get autoplay(){let i=this.getAttribute("autoplay");return i===null?!1:i===""?!0:i}set autoplay(i){let e=this.autoplay;i!==e&&(i?this.setAttribute("autoplay",typeof i=="string"?i:""):this.removeAttribute("autoplay"))}get preload(){let i=this.getAttribute("preload");return i===""?"auto":["none","metadata","auto"].includes(i)?i:super.preload}set preload(i){i!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(i)?this.setAttribute("preload",i):this.removeAttribute("preload"))}get debug(){return this.getAttribute(q.DEBUG)!=null}set debug(i){i!==this.debug&&(i?this.setAttribute(q.DEBUG,""):this.removeAttribute(q.DEBUG))}get disableCookies(){return this.hasAttribute(q.DISABLE_COOKIES)}set disableCookies(i){i!==this.disableCookies&&(i?this.setAttribute(q.DISABLE_COOKIES,""):this.removeAttribute(q.DISABLE_COOKIES))}get startTime(){let i=this.getAttribute(q.START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set startTime(i){i!==this.startTime&&(i==null?this.removeAttribute(q.START_TIME):this.setAttribute(q.START_TIME,`${i}`))}get playbackId(){var i;return(i=this.getAttribute(q.PLAYBACK_ID))!=null?i:void 0}set playbackId(i){i!==this.playbackId&&(i?this.setAttribute(q.PLAYBACK_ID,i):this.removeAttribute(q.PLAYBACK_ID))}get maxResolution(){var i;return(i=this.getAttribute(q.MAX_RESOLUTION))!=null?i:void 0}set maxResolution(i){i!==this.maxResolution&&(i?this.setAttribute(q.MAX_RESOLUTION,i):this.removeAttribute(q.MAX_RESOLUTION))}get minResolution(){var i;return(i=this.getAttribute(q.MIN_RESOLUTION))!=null?i:void 0}set minResolution(i){i!==this.minResolution&&(i?this.setAttribute(q.MIN_RESOLUTION,i):this.removeAttribute(q.MIN_RESOLUTION))}get renditionOrder(){var i;return(i=this.getAttribute(q.RENDITION_ORDER))!=null?i:void 0}set renditionOrder(i){i!==this.renditionOrder&&(i?this.setAttribute(q.RENDITION_ORDER,i):this.removeAttribute(q.RENDITION_ORDER))}get customDomain(){var i;return(i=this.getAttribute(q.CUSTOM_DOMAIN))!=null?i:void 0}set customDomain(i){i!==this.customDomain&&(i?this.setAttribute(q.CUSTOM_DOMAIN,i):this.removeAttribute(q.CUSTOM_DOMAIN))}get ended(){return pf(this.nativeEl,this._hls)}get envKey(){var i;return(i=this.getAttribute(q.ENV_KEY))!=null?i:void 0}set envKey(i){i!==this.envKey&&(i?this.setAttribute(q.ENV_KEY,i):this.removeAttribute(q.ENV_KEY))}get beaconCollectionDomain(){var i;return(i=this.getAttribute(q.BEACON_COLLECTION_DOMAIN))!=null?i:void 0}set beaconCollectionDomain(i){i!==this.beaconCollectionDomain&&(i?this.setAttribute(q.BEACON_COLLECTION_DOMAIN,i):this.removeAttribute(q.BEACON_COLLECTION_DOMAIN))}get streamType(){var i;return(i=this.getAttribute(q.STREAM_TYPE))!=null?i:xv(this.nativeEl)}set streamType(i){i!==this.streamType&&(i?this.setAttribute(q.STREAM_TYPE,i):this.removeAttribute(q.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(q.TARGET_LIVE_WINDOW)?+this.getAttribute(q.TARGET_LIVE_WINDOW):Iv(this.nativeEl)}set targetLiveWindow(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(q.TARGET_LIVE_WINDOW):this.setAttribute(q.TARGET_LIVE_WINDOW,`${+i}`))}get liveEdgeStart(){var i,e;if(this.hasAttribute(q.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:t}=this,r=(i=this.nativeEl.seekable.end(0))!=null?i:0,s=(e=this.nativeEl.seekable.start(0))!=null?e:0;return Math.max(s,r-t)}return Lv(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(q.LIVE_EDGE_OFFSET))return+this.getAttribute(q.LIVE_EDGE_OFFSET)}set liveEdgeOffset(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(q.LIVE_EDGE_OFFSET):this.setAttribute(q.LIVE_EDGE_OFFSET,`${+i}`))}get seekable(){return mf(this.nativeEl)}async addCuePoints(i){return hf(this.nativeEl,i)}get activeCuePoint(){return ff(this.nativeEl)}get cuePoints(){return Ev(this.nativeEl)}getStartDate(){return bv(this.nativeEl,this._hls)}get currentPdt(){return yv(this.nativeEl,this._hls)}get preferPlayback(){let i=this.getAttribute(q.PREFER_PLAYBACK);if(i===ui.MSE||i===ui.NATIVE)return i}set preferPlayback(i){i!==this.preferPlayback&&(i===ui.MSE||i===ui.NATIVE?this.setAttribute(q.PREFER_PLAYBACK,i):this.removeAttribute(q.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(i=>i.startsWith("metadata-")&&![q.METADATA_URL].includes(i)).reduce((i,e)=>{let t=this.getAttribute(e);return t!=null&&(i[e.replace(/^metadata-/,"").replace(/-/g,"_")]=t),i},{}),...H(this,ga)}}set metadata(i){ue(this,ga,i!=null?i:{}),this.mux&&this.mux.emit("hb",H(this,ga))}load(){ue(this,zi,Rv(this,this.nativeEl,H(this,zi)))}unload(){gf(this.nativeEl,H(this,zi)),ue(this,zi,void 0)}attributeChangedCallback(i,e,t){var r,s;switch(vf.observedAttributes.includes(i)&&!["src","autoplay","preload"].includes(i)&&super.attributeChangedCallback(i,e,t),i){case q.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case q.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":{let n=!!e,a=!!t;!n&&a?it(this,va,cd).call(this):n&&!a?this.unload():n&&a&&(this.unload(),it(this,va,cd).call(this));break}case"autoplay":if(t===e)break;(r=H(this,zi))==null||r.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=H(this,zi))==null||s.setPreload(t);break;case q.PLAYBACK_ID:this.src=la(this);break;case q.DEBUG:{let n=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=n);break}case q.METADATA_URL:t&&fetch(t).then(n=>n.json()).then(n=>this.metadata=n).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${t}!`));break;case q.STREAM_TYPE:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case q.TARGET_LIVE_WINDOW:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}connectedCallback(){var i;(i=super.connectedCallback)==null||i.call(this),this.nativeEl&&this.src&&!H(this,zi)&&it(this,va,cd).call(this)}disconnectedCallback(){this.unload()}};zi=new WeakMap,pa=new WeakMap,ad=new WeakMap,ga=new WeakMap,od=new WeakMap,ld=new WeakMap,dd=new WeakMap,va=new WeakSet,cd=async function(){H(this,pa)||(await ue(this,pa,Promise.resolve()),ue(this,pa,null),this.load())};sd.customElements.get("mux-video")||(sd.customElements.define("mux-video",wf),sd.MuxVideoElement=wf);var Vv=wf;var dS="en",hs={code:dS};var Kv="en";function Re(i,e=!0){var s,n;let t=e&&(n=(s=hs)==null?void 0:s[i])!=null?n:i,r=e?hs.code:Kv;return new Of(t,r)}var Of=class{constructor(e,t=(r=>(r=hs.code)!=null?r:Kv)()){this.message=e,this.locale=t}format(e){return this.message.replace(/\{(\w+)\}/g,(t,r)=>{var s;return(s=e[r])!=null?s:""})}toString(){return this.message}};function Wv(i){let e="";return Object.entries(i).forEach(([t,r])=>{r!=null&&(e+=`${gd(t)}: ${r}; `)}),e?e.trim():void 0}function gd(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function vd(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function nr(i){if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}function Pf(i){let e=cS(i).toString();return e?"?"+e:""}function cS(i){let e={};for(let t in i)i[t]!=null&&(e[t]=i[t]);return new URLSearchParams(e)}function xr(i){let e=(i!=null?i:"").split(".")[1];if(!e)return{};let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)}var Nf=(i,e)=>!i||!e?!1:i.contains(e)?!0:Nf(i,e.getRootNode().host);var qv="mux.com",uS=()=>{try{return"2.2.0"}catch{}return"UNKNOWN"},hS=uS(),bd=()=>hS,Yv=(i,{token:e,customDomain:t=qv,thumbnailTime:r}={})=>{let s=e==null?r:void 0,{aud:n}=xr(e);if(!(e&&n!=="t"))return`https://image.${t}/${i}/thumbnail.webp${Pf({token:e,time:s})}`},jv=(i,{token:e,customDomain:t=qv}={})=>{let{aud:r}=xr(e);if(!(e&&r!=="s"))return`https://image.${t}/${i}/storyboard.vtt${Pf({token:e,format:"webp"})}`},Ea=i=>{if(!!i){if([Ze.LIVE,Ze.ON_DEMAND].includes(i))return i;if(i!=null&&i.includes("live"))return Ze.LIVE}};var fS={crossorigin:"crossOrigin",playsinline:"playsInline"};function zv(i){var e;return(e=fS[i])!=null?e:vd(i)}var fs,ms,Pt,Ed=class{constructor(e,t){ut(this,fs,void 0);ut(this,ms,void 0);ut(this,Pt,[]);si(this,fs,e),si(this,ms,t)}[Symbol.iterator](){return Ne(this,Pt).values()}get length(){return Ne(this,Pt).length}get value(){var e;return(e=Ne(this,Pt).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(si(this,Pt,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return Ne(this,Pt)[e]}values(){return Ne(this,Pt).values()}keys(){return Ne(this,Pt).keys()}forEach(e){Ne(this,Pt).forEach(e)}add(...e){var t,r;e.forEach(s=>{this.contains(s)||Ne(this,Pt).push(s)}),!(this.value===""&&!((t=Ne(this,fs))!=null&&t.hasAttribute(`${Ne(this,ms)}`)))&&((r=Ne(this,fs))==null||r.setAttribute(`${Ne(this,ms)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>{Ne(this,Pt).splice(Ne(this,Pt).indexOf(r),1)}),(t=Ne(this,fs))==null||t.setAttribute(`${Ne(this,ms)}`,`${this.value}`)}contains(e){return Ne(this,Pt).includes(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};fs=new WeakMap,ms=new WeakMap,Pt=new WeakMap;var Xv=`[mux-player ${bd()}]`;function Ir(...i){console.warn(Xv,...i)}function xi(...i){console.error(Xv,...i)}function Uf(i){var t;let e=(t=i.message)!=null?t:"";if(i.context&&(e+=` ${i.context}`),i.file){let r="https://github.com/muxinc/elements/blob/main/errors/";e+=` ${Re("Read more: ")}
1081
- ${r}${i.file}`}Ir(e)}var Mt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},ps={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},Zv=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),mS=fd.filter(i=>i!=="error"),pS=Object.values(Mt).filter(i=>![Mt.PLAYSINLINE].includes(i)),gS=Object.values(ps);function Jv(i){i.querySelectorAll(":scope > track").forEach(e=>{var t;(t=i.media)==null||t.append(e.cloneNode())}),mS.forEach(e=>{var t;(t=i.media)==null||t.addEventListener(e,r=>{i.dispatchEvent(new Event(r.type))})})}var Ff=class extends st.HTMLElement{static get observedAttributes(){return[...pS,...gS]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(r=>{var s;(s=this.media)==null||s.append(r.cloneNode())});let e=r=>{for(let s of r)s.type==="childList"&&(s.removedNodes.forEach(n=>{var o,l;let a=(o=this.media)==null?void 0:o.querySelector(`track[src="${n.src}"]`);a&&((l=this.media)==null||l.removeChild(a))}),s.addedNodes.forEach(n=>{var a;(a=this.media)==null||a.append(n.cloneNode())}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(e,t,r){var s,n;switch(e){case ps.MUTED:{this.media&&(this.media.muted=r!=null,this.media.defaultMuted=r!=null);return}case ps.VOLUME:{let a=(s=nr(r))!=null?s:1;this.media&&(this.media.volume=a);return}case ps.PLAYBACKRATE:{let a=(n=nr(r))!=null?n:1;this.media&&(this.media.playbackRate=a,this.media.defaultPlaybackRate=a);return}}}play(){var e,t;return(t=(e=this.media)==null?void 0:e.play())!=null?t:Promise.reject()}pause(){var e;(e=this.media)==null||e.pause()}requestCast(e){var t;return(t=this.media)==null?void 0:t.requestCast(e)}get media(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var e,t;return(t=(e=this.media)==null?void 0:e.paused)!=null?t:!0}get duration(){var e,t;return(t=(e=this.media)==null?void 0:e.duration)!=null?t:NaN}get ended(){var e,t;return(t=(e=this.media)==null?void 0:e.ended)!=null?t:!1}get buffered(){var e,t;return(t=(e=this.media)==null?void 0:e.buffered)!=null?t:Zv}get seekable(){var e,t;return(t=(e=this.media)==null?void 0:e.seekable)!=null?t:Zv}get readyState(){var e,t;return(t=(e=this.media)==null?void 0:e.readyState)!=null?t:0}get videoWidth(){var e,t;return(t=(e=this.media)==null?void 0:e.videoWidth)!=null?t:0}get videoHeight(){var e,t;return(t=(e=this.media)==null?void 0:e.videoHeight)!=null?t:0}get currentTime(){var e,t;return(t=(e=this.media)==null?void 0:e.currentTime)!=null?t:0}set currentTime(e){this.media&&(this.media.currentTime=Number(e))}get volume(){var e,t;return(t=(e=this.media)==null?void 0:e.volume)!=null?t:1}set volume(e){this.media&&(this.media.volume=Number(e))}get playbackRate(){var e,t;return(t=(e=this.media)==null?void 0:e.playbackRate)!=null?t:1}set playbackRate(e){this.media&&(this.media.playbackRate=Number(e))}get defaultPlaybackRate(){var e;return(e=nr(this.getAttribute(ps.PLAYBACKRATE)))!=null?e:1}set defaultPlaybackRate(e){e!=null?this.setAttribute(ps.PLAYBACKRATE,`${e}`):this.removeAttribute(ps.PLAYBACKRATE)}get crossOrigin(){return ba(this,Mt.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(Mt.CROSSORIGIN,`${e}`)}get autoplay(){return ba(this,Mt.AUTOPLAY)!=null}set autoplay(e){e?this.setAttribute(Mt.AUTOPLAY,typeof e=="string"?e:""):this.removeAttribute(Mt.AUTOPLAY)}get loop(){return ba(this,Mt.LOOP)!=null}set loop(e){e?this.setAttribute(Mt.LOOP,""):this.removeAttribute(Mt.LOOP)}get muted(){var e,t;return(t=(e=this.media)==null?void 0:e.muted)!=null?t:!1}set muted(e){this.media&&(this.media.muted=Boolean(e))}get defaultMuted(){return ba(this,Mt.MUTED)!=null}set defaultMuted(e){e?this.setAttribute(Mt.MUTED,""):this.removeAttribute(Mt.MUTED)}get playsInline(){return ba(this,Mt.PLAYSINLINE)!=null}set playsInline(e){xi("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(e){["","none","metadata","auto"].includes(e)?this.setAttribute(Mt.PRELOAD,e):this.removeAttribute(Mt.PRELOAD)}};function ba(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var Bf=Ff;var vS=Object.defineProperty,ES=(i,e,t)=>e in i?vS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,bS=(i,e,t)=>(ES(i,typeof e!="symbol"?e+"":e,t),t),sE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Le=(i,e,t)=>(sE(i,e,"read from private field"),t?t.call(i):e.get(i)),Xi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ar=(i,e,t,r)=>(sE(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),on,yd,gs,ya,Lr,kr,Rr,vs,ln,Td,Ii,eE=1,tE=0,yS=1,TS={processCallback(i,e,t){if(!!t){for(let[r,s]of e)if(r in t){let n=t[r];typeof n=="boolean"&&s instanceof Nt&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof Nt?s.element[s.attributeName]=n:s.value=n}}}},or=class extends w.DocumentFragment{constructor(e,t,r=TS){var s;super(),Xi(this,on,void 0),Xi(this,yd,void 0),this.append(e.content.cloneNode(!0)),ar(this,on,nE(this)),ar(this,yd,r),(s=r.createCallback)==null||s.call(r,this,Le(this,on),t),r.processCallback(this,Le(this,on),t)}update(e){Le(this,yd).processCallback(this,Le(this,on),e)}};on=new WeakMap;yd=new WeakMap;var nE=(i,e=[])=>{let t,r;for(let s of i.attributes||[])if(s.value.includes("{{")){let n=new $f;for([t,r]of rE(s.value))if(!t)n.append(r);else{let a=new Nt(i,s.name,s.namespaceURI);n.append(a),e.push([r,a])}s.value=n.toString()}for(let s of i.childNodes)if(s.nodeType===eE&&!(s instanceof HTMLTemplateElement))nE(s,e);else if(s.nodeType===eE||s.data.includes("{{")){let n=[];if(s.data)for([t,r]of rE(s.data))if(!t)n.push(new Text(r));else{let a=new lr(i);n.push(a),e.push([r,a])}else if(s instanceof HTMLTemplateElement){let a=new Ta(i,s);n.push(a),e.push([a.expression,a])}s.replaceWith(...n.flatMap(a=>a.replacementNodes||[a]))}return e},iE={},rE=i=>{let e="",t=0,r=iE[i],s=0,n;if(r)return r;for(r=[];n=i[s];s++)n==="{"&&i[s+1]==="{"&&i[s-1]!=="\\"&&i[s+2]&&++t==1?(e&&r.push([tE,e]),e="",s++):n==="}"&&i[s+1]==="}"&&i[s-1]!=="\\"&&!--t?(r.push([yS,e.trim()]),e="",s++):e+=n||"";return e&&r.push([tE,(t>0?"{{":"")+e]),iE[i]=r},_S=11,_d=class{get value(){return""}set value(e){}toString(){return this.value}},aE=new WeakMap,$f=class{constructor(){Xi(this,gs,[])}[Symbol.iterator](){return Le(this,gs).values()}get length(){return Le(this,gs).length}item(e){return Le(this,gs)[e]}append(...e){for(let t of e)t instanceof Nt&&aE.set(t,this),Le(this,gs).push(t)}toString(){return Le(this,gs).join("")}};gs=new WeakMap;var Nt=class extends _d{constructor(e,t,r){super(),Xi(this,vs),Xi(this,ya,""),Xi(this,Lr,void 0),Xi(this,kr,void 0),Xi(this,Rr,void 0),ar(this,Lr,e),ar(this,kr,t),ar(this,Rr,r)}get attributeName(){return Le(this,kr)}get attributeNamespace(){return Le(this,Rr)}get element(){return Le(this,Lr)}get value(){return Le(this,ya)}set value(e){Le(this,ya)!==e&&(ar(this,ya,e),!Le(this,vs,ln)||Le(this,vs,ln).length===1?e==null?Le(this,Lr).removeAttributeNS(Le(this,Rr),Le(this,kr)):Le(this,Lr).setAttributeNS(Le(this,Rr),Le(this,kr),e):Le(this,Lr).setAttributeNS(Le(this,Rr),Le(this,kr),Le(this,vs,ln)))}get booleanValue(){return Le(this,Lr).hasAttributeNS(Le(this,Rr),Le(this,kr))}set booleanValue(e){if(!Le(this,vs,ln)||Le(this,vs,ln).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};ya=new WeakMap;Lr=new WeakMap;kr=new WeakMap;Rr=new WeakMap;vs=new WeakSet;ln=function(){return aE.get(this)};var lr=class extends _d{constructor(e,t){super(),Xi(this,Td,void 0),Xi(this,Ii,void 0),ar(this,Td,e),ar(this,Ii,t?[...t]:[new Text])}get replacementNodes(){return Le(this,Ii)}get parentNode(){return Le(this,Td)}get nextSibling(){return Le(this,Ii)[Le(this,Ii).length-1].nextSibling}get previousSibling(){return Le(this,Ii)[0].previousSibling}get value(){return Le(this,Ii).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){let t=e.flat().flatMap(r=>r==null?[new Text]:r.forEach?[...r]:r.nodeType===_S?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),ar(this,Ii,AS(Le(this,Ii)[0].parentNode,Le(this,Ii),t,this.nextSibling))}};Td=new WeakMap;Ii=new WeakMap;var Ta=class extends lr{constructor(e,t){let r=t.getAttribute("directive")||t.getAttribute("type"),s=t.getAttribute("expression")||t.getAttribute(r)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),bS(this,"directive"),this.expression=s,this.template=t,this.directive=r}};function AS(i,e,t,r=null){let s=0,n,a,o,l=t.length,d=e.length;for(;s<l&&s<d&&e[s]==t[s];)s++;for(;s<l&&s<d&&t[l-1]==e[d-1];)r=t[--d,--l];if(s==d)for(;s<l;)i.insertBefore(t[s++],r);if(s==l)for(;s<d;)i.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:r,n==o?n=a:s<l&&t[s]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=r;)a=n.nextSibling,i.removeChild(n),n=a}return t}var oE={string:i=>String(i)},Sd=class{constructor(e){this.template=e,this.state=void 0}},Es=new WeakMap,bs=new WeakMap,Hf={partial:(i,e)=>{e[i.expression]=new Sd(i.template)},if:(i,e)=>{var t;if(dE(i.expression,e))if(Es.get(i)!==i.template){Es.set(i,i.template);let r=new or(i.template,e,xd);i.replace(r),bs.set(i,r)}else(t=bs.get(i))==null||t.update(e);else i.replace(""),Es.delete(i),bs.delete(i)}},SS=Object.keys(Hf),xd={processCallback(i,e,t){var r,s;if(!!t)for(let[n,a]of e){if(a instanceof Ta){if(!a.directive){let l=SS.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(r=Hf[a.directive])==null||r.call(Hf,a,t);continue}let o=dE(n,t);if(o instanceof Sd){Es.get(a)!==o.template?(Es.set(a,o.template),o=new or(o.template,o.state,xd),a.value=o,bs.set(a,o)):(s=bs.get(a))==null||s.update(o.state);continue}o?(a instanceof Nt&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof Nt?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,Es.delete(a),bs.delete(a))):a instanceof Nt?a.value=void 0:(a.value=void 0,Es.delete(a),bs.delete(a))}}},lE={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i!=null?i:e,"|":(i,e)=>{var t;return(t=oE[e])==null?void 0:t.call(oE,i)}};function xS(i){return IS(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function dE(i,e={}){var t,r,s,n,a,o,l;let d=xS(i);if(d.length===0||d.some(({type:c})=>!c))return _a(i);if(((t=d[0])==null?void 0:t.token)===">"){let c=e[(r=d[1])==null?void 0:r.token];if(!c)return _a(i);let u={...e};c.state=u;let h=d.slice(2);for(let f=0;f<h.length;f+=3){let g=(s=h[f])==null?void 0:s.token,E=(n=h[f+1])==null?void 0:n.token,T=(a=h[f+2])==null?void 0:a.token;g&&E==="="&&(u[g]=Aa(T,e))}return c}if(d.length===1)return Ad(d[0])?Aa(d[0].token,e):_a(i);if(d.length===2){let c=(o=d[0])==null?void 0:o.token,u=lE[c];if(!u||!Ad(d[1]))return _a(i);let h=Aa(d[1].token,e);return u(h)}if(d.length===3){let c=(l=d[1])==null?void 0:l.token,u=lE[c];if(!u||!Ad(d[0])||!Ad(d[2]))return _a(i);let h=Aa(d[0].token,e);if(c==="|")return u(h,d[2].token);let f=Aa(d[2].token,e);return u(h,f)}}function _a(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function Ad({type:i}){return["number","boolean","string","param"].includes(i)}function Aa(i,e){let t=i[0],r=i.slice(-1);return i==="true"||i==="false"?i==="true":t===r&&["'",'"'].includes(t)?i.slice(1,-1):$a(i)?parseFloat(i):e[i]}function IS(i,e){let t,r,s,n=[];for(;i;){s=null,t=i.length;for(let a in e)r=e[a].exec(i),r&&r.index<t&&(s={token:r[0],type:a,matches:r.slice(1)},t=r.index);t&&n.push({token:i.substr(0,t),type:void 0}),s&&n.push(s),i=i.substr(t+(s?s.token.length:0))}return n}var LS=Object.defineProperty,kS=(i,e,t)=>e in i?LS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,xa=(i,e,t)=>(kS(i,typeof e!="symbol"?e+"":e,t),t),Yf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Kf=(i,e,t)=>(Yf(i,e,"read from private field"),t?t.call(i):e.get(i)),Sa=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ys=(i,e,t,r)=>(Yf(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Gf=(i,e,t)=>(Yf(i,e,"access private method"),t),dn,Id,cn,Wf,cE,Ld,qf,Vf={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},uE=j.createElement("template");uE.innerHTML=`
1117
+ `);var OE=(i,{tag:e,is:t})=>{var r,s,n,a,o,l,d,c,u,h,f,g,E;let T=(r=globalThis.document)==null?void 0:r.createElement(e,{is:t}),A=T?JS(T):[];return s=class extends i{constructor(){super(),ae(this,c),ae(this,h),ae(this,g),ae(this,l,void 0),ae(this,d,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var R,L,N;return rt(R=s,a,o).call(R),[...(N=(L=T==null?void 0:T.constructor)==null?void 0:L.observedAttributes)!=null?N:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var R,L,N;return(N=(L=(R=P(this,d))!=null?R:this.shadowRoot.querySelector(e))!=null?L:this.querySelector(":scope > slot[slot=media]"))!=null?N:this.querySelector(e)}set nativeEl(R){ce(this,d,R)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(R){this.toggleAttribute("muted",!!R)}get src(){return this.getAttribute("src")}set src(R){this.setAttribute("src",`${R}`)}get preload(){var R,L;return(L=this.getAttribute("preload"))!=null?L:(R=this.nativeEl)==null?void 0:R.preload}set preload(R){this.setAttribute("preload",`${R}`)}handleEvent(R){R.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(R.type,{detail:R.detail}))}attributeChangedCallback(R,L,N){rt(this,c,u).call(this),rt(this,g,E).call(this,R,L,N)}connectedCallback(){rt(this,c,u).call(this)}},n=new WeakMap,a=new WeakSet,o=function(){if(P(this,n))return;ce(this,n,!0);let R=new Set(this.observedAttributes);R.delete("muted");for(let L of A)if(!(L in this.prototype))if(typeof T[L]=="function")this.prototype[L]=function(...N){return rt(this,c,u).call(this),this.call?this.call(L,...N):this.nativeEl[L].apply(this.nativeEl,N)};else{let N={get(){var M,$,U;rt(this,c,u).call(this);let H=L.toLowerCase();if(R.has(H)){let W=this.getAttribute(H);return W===null?!1:W===""?!0:W}return(U=(M=this.get)==null?void 0:M.call(this,L))!=null?U:($=this.nativeEl)==null?void 0:$[L]}};L!==L.toUpperCase()&&(N.set=function(M){rt(this,c,u).call(this);let $=L.toLowerCase();if(R.has($)){M===!0||M===!1||M==null?this.toggleAttribute($,!!M):this.setAttribute($,M);return}if(this.set){this.set(L,M);return}this.nativeEl[L]=M}),Object.defineProperty(this.prototype,L,N)}},l=new WeakMap,d=new WeakMap,c=new WeakSet,u=function(){var R,L;if(P(this,l))return;if(ce(this,l,!0),!this.nativeEl){let $=document.createElement(e,{is:t});$.part=e,this.shadowRoot.append($)}this.nativeEl.muted=this.hasAttribute("muted");for(let $ of A)rt(this,h,f).call(this,$);let N=new Map,M=this.shadowRoot.querySelector("slot:not([name])");M==null||M.addEventListener("slotchange",()=>{let $=new Map(N);M.assignedElements().filter(U=>["track","source"].includes(U.localName)).forEach(U=>{var H,W;$.delete(U);let O=N.get(U);O||(O=U.cloneNode(),N.set(U,O)),(W=(H=this.nativeEl).append)==null||W.call(H,O)}),$.forEach(U=>U.remove())});for(let $ of this.constructor.Events)(L=(R=this.shadowRoot).addEventListener)==null||L.call(R,$,this,!0)},h=new WeakSet,f=function(R){if(Object.prototype.hasOwnProperty.call(this,R)){let L=this[R];delete this[R],this[R]=L}},g=new WeakSet,E=function(R,L,N){var M,$,U,H,W,O;["id","class"].includes(R)||(N===null?($=(M=this.nativeEl).removeAttribute)==null||$.call(M,R):((H=(U=this.nativeEl).getAttribute)==null?void 0:H.call(U,R))!=N&&((O=(W=this.nativeEl).setAttribute)==null||O.call(W,R,N)))},ae(s,a),We(s,"Events",kd),We(s,"template",e.endsWith("audio")?Kf:Wf),ae(s,n,void 0),s};function JS(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}var Hf=globalThis.document?OE(HTMLElement,{tag:"video"}):class{},bC=globalThis.document?OE(HTMLElement,{tag:"audio"}):class{},cs=new WeakMap,Gf=class extends Error{},ex=class extends Error{},tx=globalThis.WeakRef?class extends Set{add(i){super.add(new WeakRef(i))}forEach(i){super.forEach(e=>{let t=e.deref();t&&i(t)})}}:Set;function ix(i){NE()?UE()?i(chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>i(chrome.cast.isAvailable)):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>i(chrome.cast.isAvailable))}}function rx(){return globalThis.chrome}function sx(){let i="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if(globalThis.chrome.cast||document.querySelector(`script[src="${i}"]`))return;let e=document.createElement("script");e.src=i,document.head.append(e)}function NE(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable}function UE(){return typeof cast!="undefined"&&cast.framework}function us(){if(UE())return cast.framework.CastContext.getInstance()}function cm(){var i;return(i=us())==null?void 0:i.getCurrentSession()}function um(){var i;return(i=cm())==null?void 0:i.getSessionObj().media[0]}function nx(i){return new Promise((e,t)=>{um().editTracksInfo(i,e,t)})}function ax(i){return new Promise((e,t)=>{um().getStatus(i,e,t)})}function FE(i){return us().setOptions({...BE(),...i})}function BE(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}var pd=new tx,Tr=new WeakSet,ct;ix(i=>{i&&!ct&&(ct=cast.framework,us().addEventListener(ct.CastContextEventType.CAST_STATE_CHANGED,e=>{pd.forEach(t=>{var r,s;return(s=(r=cs.get(t)).onCastStateChanged)==null?void 0:s.call(r,e)})}),us().addEventListener(ct.CastContextEventType.SESSION_STATE_CHANGED,e=>{pd.forEach(t=>{var r,s;return(s=(r=cs.get(t)).onSessionStateChanged)==null?void 0:s.call(r,e)})}),pd.forEach(e=>{var t,r;return(r=(t=cs.get(e)).init)==null?void 0:r.call(t)}))});var RE=0,Ne,gd,di,br,hn,ln,ds,qf,yr,Xr,Yf,kE,Id,jf,zf,$E,vd,Xf,Qf,wE,Ed,Vf,ox=class extends EventTarget{constructor(i){super(),ae(this,yr),ae(this,Yf),ae(this,Id),ae(this,zf),ae(this,vd),ae(this,Qf),ae(this,Ed),ae(this,Ne,void 0),ae(this,gd,void 0),ae(this,di,void 0),ae(this,br,void 0),ae(this,hn,"disconnected"),ae(this,ln,!1),ae(this,ds,new Set),ae(this,qf,new WeakMap),ce(this,Ne,i),pd.add(this),cs.set(this,{init:()=>rt(this,vd,Xf).call(this),onCastStateChanged:()=>rt(this,Id,jf).call(this),onSessionStateChanged:()=>rt(this,zf,$E).call(this),getCastPlayer:()=>P(this,yr,Xr)}),rt(this,vd,Xf).call(this)}get state(){return P(this,hn)}async watchAvailability(i){if(P(this,Ne).disableRemotePlayback)throw new Gf("disableRemotePlayback attribute is present.");return P(this,qf).set(i,++RE),P(this,ds).add(i),RE}async cancelWatchAvailability(i){if(P(this,Ne).disableRemotePlayback)throw new Gf("disableRemotePlayback attribute is present.");i?P(this,ds).delete(i):P(this,ds).clear()}async prompt(){var i,e;if(P(this,Ne).disableRemotePlayback)throw new Gf("disableRemotePlayback attribute is present.");if(!NE())throw new ex("The RemotePlayback API is disabled on this platform.");let t=Tr.has(P(this,Ne));Tr.add(P(this,Ne)),FE(P(this,Ne).castOptions),Object.entries(P(this,br)).forEach(([r,s])=>{P(this,di).controller.addEventListener(r,s)});try{await us().requestSession()}catch(r){if(r==="cancel"){t||Tr.delete(P(this,Ne));return}throw new Error(r)}(e=(i=cs.get(P(this,Ne)))==null?void 0:i.loadOnPrompt)==null||e.call(i)}};Ne=new WeakMap,gd=new WeakMap,di=new WeakMap,br=new WeakMap,hn=new WeakMap,ln=new WeakMap,ds=new WeakMap,qf=new WeakMap,yr=new WeakSet,Xr=function(){if(Tr.has(P(this,Ne)))return P(this,di)},Yf=new WeakSet,kE=function(){Tr.has(P(this,Ne))&&(Object.entries(P(this,br)).forEach(([i,e])=>{P(this,di).controller.removeEventListener(i,e)}),Tr.delete(P(this,Ne)),P(this,Ne).muted=P(this,di).isMuted,P(this,Ne).currentTime=P(this,di).savedPlayerState.currentTime,P(this,di).savedPlayerState.isPaused===!1&&P(this,Ne).play())},Id=new WeakSet,jf=function(){let i=us().getCastState();if(Tr.has(P(this,Ne))&&i==="CONNECTING"&&(ce(this,hn,"connecting"),this.dispatchEvent(new Event("connecting"))),!P(this,ln)&&i!=null&&i.includes("CONNECT")){ce(this,ln,!0);for(let e of P(this,ds))e(!0)}else if(P(this,ln)&&(!i||i==="NO_DEVICES_AVAILABLE")){ce(this,ln,!1);for(let e of P(this,ds))e(!1)}},zf=new WeakSet,$E=async function(){var i;let{SESSION_RESUMED:e}=ct.SessionState;if(us().getSessionState()===e&&P(this,Ne).castSrc===((i=um())==null?void 0:i.media.contentId)){Tr.add(P(this,Ne)),Object.entries(P(this,br)).forEach(([t,r])=>{P(this,di).controller.addEventListener(t,r)});try{await ax(new chrome.cast.media.GetStatusRequest)}catch(t){console.error(t)}P(this,br)[ct.RemotePlayerEventType.IS_PAUSED_CHANGED](),P(this,br)[ct.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},vd=new WeakSet,Xf=function(){!ct||P(this,gd)||(ce(this,gd,!0),FE(P(this,Ne).castOptions),P(this,Ne).textTracks.addEventListener("change",()=>rt(this,Ed,Vf).call(this)),rt(this,Id,jf).call(this),ce(this,di,new ct.RemotePlayer),new ct.RemotePlayerController(P(this,di)),ce(this,br,{[ct.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:i})=>{i===!0?(ce(this,hn,"connected"),this.dispatchEvent(new Event("connect"))):(rt(this,Yf,kE).call(this),ce(this,hn,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[ct.RemotePlayerEventType.DURATION_CHANGED]:()=>{P(this,Ne).dispatchEvent(new Event("durationchange"))},[ct.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{P(this,Ne).dispatchEvent(new Event("volumechange"))},[ct.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{P(this,Ne).dispatchEvent(new Event("volumechange"))},[ct.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var i;(i=P(this,yr,Xr))!=null&&i.isMediaLoaded&&P(this,Ne).dispatchEvent(new Event("timeupdate"))},[ct.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{P(this,Ne).dispatchEvent(new Event("resize"))},[ct.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{P(this,Ne).dispatchEvent(new Event(this.paused?"pause":"play"))},[ct.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var i,e;((i=P(this,yr,Xr))==null?void 0:i.playerState)!==chrome.cast.media.PlayerState.PAUSED&&P(this,Ne).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(e=P(this,yr,Xr))==null?void 0:e.playerState]))},[ct.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var i;(i=P(this,yr,Xr))!=null&&i.isMediaLoaded&&(await Promise.resolve(),rt(this,Qf,wE).call(this))}}))},Qf=new WeakSet,wE=function(){rt(this,Ed,Vf).call(this)},Ed=new WeakSet,Vf=async function(){var i,e,t,r,s;if(!P(this,yr,Xr))return;let n=((e=(i=P(this,di).mediaInfo)==null?void 0:i.tracks)!=null?e:[]).filter(({type:h})=>h===chrome.cast.media.TrackType.TEXT),a=[...P(this,Ne).textTracks].filter(({kind:h})=>h==="subtitles"||h==="captions"),o=n.map(({language:h,name:f,trackId:g})=>{var E;let{mode:T}=(E=a.find(A=>A.language===h&&A.label===f))!=null?E:{};return T?{mode:T,trackId:g}:!1}).filter(Boolean),l=o.filter(({mode:h})=>h!=="showing").map(({trackId:h})=>h),d=o.find(({mode:h})=>h==="showing"),c=(s=(r=(t=cm())==null?void 0:t.getSessionObj().media[0])==null?void 0:r.activeTrackIds)!=null?s:[],u=c;if(c.length&&(u=u.filter(h=>!l.includes(h))),d!=null&&d.trackId&&(u=[...u,d.trackId]),u=[...new Set(u)],!((h,f)=>h.length===f.length&&h.every(g=>f.includes(g)))(c,u))try{let h=new chrome.cast.media.EditTracksInfoRequest(u);await nx(h)}catch(h){console.error(h)}};var lx=i=>{var e,t,r,s,n,a,o,l,d;return t=class extends i{constructor(){super(...arguments),ae(this,a),ae(this,l),ae(this,r,{paused:!1}),ae(this,s,BE()),ae(this,n,void 0)}get remote(){return P(this,n)?P(this,n):rx()?(sx(),cs.set(this,{loadOnPrompt:()=>rt(this,l,d).call(this)}),ce(this,n,new ox(this))):super.remote}attributeChangedCallback(c,u,h){if(super.attributeChangedCallback(c,u,h),c==="cast-receiver"&&h){P(this,s).receiverApplicationId=h;return}if(P(this,a,o))switch(c){case"cast-stream-type":case"cast-src":this.load();break}}async load(){var c,u;if(!P(this,a,o))return super.load();let h=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),f=[...this.querySelectorAll("track")].filter(({kind:A,src:R})=>R&&(A==="subtitles"||A==="captions")),g=[],E=0;f.length&&(h.tracks=f.map(A=>{let R=++E;g.length===0&&A.track.mode==="showing"&&g.push(R);let L=new chrome.cast.media.Track(R,chrome.cast.media.TrackType.TEXT);return L.trackContentId=A.src,L.trackContentType="text/vtt",L.subtype=A.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,L.name=A.label,L.language=A.srclang,L})),this.castStreamType==="live"?h.streamType=chrome.cast.media.StreamType.LIVE:h.streamType=chrome.cast.media.StreamType.BUFFERED,h.metadata=new chrome.cast.media.GenericMediaMetadata,h.metadata.title=this.title,h.metadata.images=[{url:this.poster}];let T=new chrome.cast.media.LoadRequest(h);T.currentTime=(c=super.currentTime)!=null?c:0,T.autoplay=!P(this,r).paused,T.activeTrackIds=g,await((u=cm())==null?void 0:u.loadMedia(T)),this.dispatchEvent(new Event("volumechange"))}play(){var c;if(P(this,a,o)){P(this,a,o).isPaused&&((c=P(this,a,o).controller)==null||c.playOrPause());return}return super.play()}pause(){var c;if(P(this,a,o)){P(this,a,o).isPaused||(c=P(this,a,o).controller)==null||c.playOrPause();return}super.pause()}get castOptions(){return P(this,s)}get castReceiver(){var c;return(c=this.getAttribute("cast-receiver"))!=null?c:void 0}set castReceiver(c){this.castReceiver!=c&&this.setAttribute("cast-receiver",`${c}`)}get castSrc(){var c,u,h;return(h=(u=this.getAttribute("cast-src"))!=null?u:(c=this.querySelector("source"))==null?void 0:c.src)!=null?h:this.currentSrc}set castSrc(c){this.castSrc!=c&&this.setAttribute("cast-src",`${c}`)}get castContentType(){var c;return(c=this.getAttribute("cast-content-type"))!=null?c:void 0}set castContentType(c){this.setAttribute("cast-content-type",`${c}`)}get castStreamType(){var c,u;return(u=(c=this.getAttribute("cast-stream-type"))!=null?c:this.streamType)!=null?u:void 0}set castStreamType(c){this.setAttribute("cast-stream-type",`${c}`)}get readyState(){if(P(this,a,o))switch(P(this,a,o).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 P(this,a,o)?P(this,a,o).isPaused:super.paused}get muted(){var c;return P(this,a,o)?(c=P(this,a,o))==null?void 0:c.isMuted:super.muted}set muted(c){var u;if(P(this,a,o)){(c&&!P(this,a,o).isMuted||!c&&P(this,a,o).isMuted)&&((u=P(this,a,o).controller)==null||u.muteOrUnmute());return}super.muted=c}get volume(){var c,u;return P(this,a,o)?(u=(c=P(this,a,o))==null?void 0:c.volumeLevel)!=null?u:1:super.volume}set volume(c){var u;if(P(this,a,o)){P(this,a,o).volumeLevel=+c,(u=P(this,a,o).controller)==null||u.setVolumeLevel();return}super.volume=c}get duration(){var c,u,h;return P(this,a,o)&&(c=P(this,a,o))!=null&&c.isMediaLoaded?(h=(u=P(this,a,o))==null?void 0:u.duration)!=null?h:NaN:super.duration}get currentTime(){var c,u,h;return P(this,a,o)&&(c=P(this,a,o))!=null&&c.isMediaLoaded?(h=(u=P(this,a,o))==null?void 0:u.currentTime)!=null?h:0:super.currentTime}set currentTime(c){var u;if(P(this,a,o)){P(this,a,o).currentTime=c,(u=P(this,a,o).controller)==null||u.seek();return}super.currentTime=c}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakSet,o=function(){var c,u;return(u=(c=cs.get(this.remote))==null?void 0:c.getCastPlayer)==null?void 0:u.call(c)},l=new WeakSet,d=async function(){P(this,r).paused=Bf(t.prototype,this,"paused"),Bf(t.prototype,this,"pause").call(this),this.muted=Bf(t.prototype,this,"muted");try{await this.load()}catch(c){console.error(c)}},We(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t},wd=class extends Event{constructor(i,e){super(i),We(this,"track"),this.track=e.track}},Zf=new WeakMap;function J(i){var e;return(e=Zf.get(i))!=null?e:dx(i,{})}function dx(i,e){let t=Zf.get(i);return t||Zf.set(i,t={}),Object.assign(t,e)}function Jf(i,e){let t=i.videoTracks;J(e).media=i,J(e).renditionSet||(J(e).renditionSet=new Set);let r=J(t).trackSet;r.add(e);let s=r.size-1;s in tm.prototype||Object.defineProperty(tm.prototype,s,{get(){return[...J(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new wd("addtrack",{track:e}))})}function em(i){var e;let t=(e=J(i).media)==null?void 0:e.videoTracks;t&&(J(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new wd("removetrack",{track:i}))}))}function cx(i){var e;let t=(e=J(i).media.videoTracks)!=null?e:[],r=!1;for(let s of t)s!==i&&(s.selected=!1,r=!0);if(r){if(J(t).changeRequested)return;J(t).changeRequested=!0,queueMicrotask(()=>{delete J(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var Qr,Zr,Jr,dn,va,tm=class extends EventTarget{constructor(){super(),ae(this,dn),ae(this,Qr,void 0),ae(this,Zr,void 0),ae(this,Jr,void 0),J(this).trackSet=new Set}[Symbol.iterator](){return P(this,dn,va).values()}get length(){return P(this,dn,va).size}getTrackById(i){var e;return(e=[...P(this,dn,va)].find(t=>t.id===i))!=null?e:null}get selectedIndex(){return[...P(this,dn,va)].findIndex(i=>i.selected)}get onaddtrack(){return P(this,Qr)}set onaddtrack(i){P(this,Qr)&&(this.removeEventListener("addtrack",P(this,Qr)),ce(this,Qr,void 0)),typeof i=="function"&&(ce(this,Qr,i),this.addEventListener("addtrack",i))}get onremovetrack(){return P(this,Zr)}set onremovetrack(i){P(this,Zr)&&(this.removeEventListener("removetrack",P(this,Zr)),ce(this,Zr,void 0)),typeof i=="function"&&(ce(this,Zr,i),this.addEventListener("removetrack",i))}get onchange(){return P(this,Jr)}set onchange(i){P(this,Jr)&&(this.removeEventListener("change",P(this,Jr)),ce(this,Jr,void 0)),typeof i=="function"&&(ce(this,Jr,i),this.addEventListener("change",i))}};Qr=new WeakMap,Zr=new WeakMap,Jr=new WeakMap,dn=new WeakSet,va=function(){return J(this).trackSet};var Dd=class extends Event{constructor(i,e){super(i),We(this,"rendition"),this.rendition=e.rendition}};function ux(i,e){let t=J(i).media.videoRenditions;J(e).media=J(i).media,J(e).track=i;let r=J(i).renditionSet;r.add(e);let s=r.size-1;s in im.prototype||Object.defineProperty(im.prototype,s,{get(){return cn(this)[s]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new Dd("addrendition",{rendition:e}))})}function hx(i){let e=J(i).media.videoRenditions,t=J(i).track;J(t).renditionSet.delete(i),queueMicrotask(()=>{J(i).track.selected&&e.dispatchEvent(new Dd("removerendition",{rendition:i}))})}function fx(i){let e=J(i).media.videoRenditions;!e||J(e).changeRequested||(J(e).changeRequested=!0,queueMicrotask(()=>{delete J(e).changeRequested,J(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function cn(i){return[...J(i).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...J(e).renditionSet])}var es,ts,is,im=class extends EventTarget{constructor(){super(...arguments),ae(this,es,void 0),ae(this,ts,void 0),ae(this,is,void 0)}[Symbol.iterator](){return cn(this).values()}get length(){return cn(this).length}getRenditionById(i){var e;return(e=cn(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return cn(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of cn(this).entries())t.selected=e===i}get onaddrendition(){return P(this,es)}set onaddrendition(i){P(this,es)&&(this.removeEventListener("addrendition",P(this,es)),ce(this,es,void 0)),typeof i=="function"&&(ce(this,es,i),this.addEventListener("addrendition",i))}get onremoverendition(){return P(this,ts)}set onremoverendition(i){P(this,ts)&&(this.removeEventListener("removerendition",P(this,ts)),ce(this,ts,void 0)),typeof i=="function"&&(ce(this,ts,i),this.addEventListener("removerendition",i))}get onchange(){return P(this,is)}set onchange(i){P(this,is)&&(this.removeEventListener("change",P(this,is)),ce(this,is,void 0)),typeof i=="function"&&(ce(this,is,i),this.addEventListener("change",i))}};es=new WeakMap,ts=new WeakMap,is=new WeakMap;var Ea,mx=class{constructor(){We(this,"src"),We(this,"id"),We(this,"width"),We(this,"height"),We(this,"bitrate"),We(this,"frameRate"),We(this,"codec"),ae(this,Ea,!1)}get selected(){return P(this,Ea)}set selected(i){P(this,Ea)!==i&&(ce(this,Ea,i),fx(this))}};Ea=new WeakMap;var ba,HE=class{constructor(){We(this,"id"),We(this,"kind"),We(this,"label",""),We(this,"language",""),We(this,"sourceBuffer"),ae(this,ba,!1)}addRendition(i,e,t,r,s,n){let a=new mx;return a.src=i,a.width=e,a.height=t,a.frameRate=n,a.bitrate=s,a.codec=r,ux(this,a),a}removeRendition(i){hx(i)}get selected(){return P(this,ba)}set selected(i){P(this,ba)!==i&&(ce(this,ba,i),i===!0&&cx(this))}};ba=new WeakMap;function px(i,e){let t=J(i).media.audioRenditions;J(e).media=J(i).media,J(e).track=i;let r=J(i).renditionSet;r.add(e);let s=r.size-1;s in rm.prototype||Object.defineProperty(rm.prototype,s,{get(){return un(this)[s]}}),queueMicrotask(()=>{i.enabled&&t.dispatchEvent(new Dd("addrendition",{rendition:e}))})}function gx(i){let e=J(i).media.audioRenditions,t=J(i).track;J(t).renditionSet.delete(i),queueMicrotask(()=>{J(i).track.enabled&&e.dispatchEvent(new Dd("removerendition",{rendition:i}))})}function vx(i){let e=J(i).media.audioRenditions;!e||J(e).changeRequested||(J(e).changeRequested=!0,queueMicrotask(()=>{delete J(e).changeRequested,J(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function un(i){return[...J(i).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...J(e).renditionSet])}var rs,ss,ns,rm=class extends EventTarget{constructor(){super(...arguments),ae(this,rs,void 0),ae(this,ss,void 0),ae(this,ns,void 0)}[Symbol.iterator](){return un(this).values()}get length(){return un(this).length}getRenditionById(i){var e;return(e=un(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return un(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of un(this).entries())t.selected=e===i}get onaddrendition(){return P(this,rs)}set onaddrendition(i){P(this,rs)&&(this.removeEventListener("addrendition",P(this,rs)),ce(this,rs,void 0)),typeof i=="function"&&(ce(this,rs,i),this.addEventListener("addrendition",i))}get onremoverendition(){return P(this,ss)}set onremoverendition(i){P(this,ss)&&(this.removeEventListener("removerendition",P(this,ss)),ce(this,ss,void 0)),typeof i=="function"&&(ce(this,ss,i),this.addEventListener("removerendition",i))}get onchange(){return P(this,ns)}set onchange(i){P(this,ns)&&(this.removeEventListener("change",P(this,ns)),ce(this,ns,void 0)),typeof i=="function"&&(ce(this,ns,i),this.addEventListener("change",i))}};rs=new WeakMap,ss=new WeakMap,ns=new WeakMap;var ya,Ex=class{constructor(){We(this,"src"),We(this,"id"),We(this,"bitrate"),We(this,"codec"),ae(this,ya,!1)}get selected(){return P(this,ya)}set selected(i){P(this,ya)!==i&&(ce(this,ya,i),vx(this))}};ya=new WeakMap;function sm(i,e){let t=i.audioTracks;J(e).media=i,J(e).renditionSet||(J(e).renditionSet=new Set);let r=J(t).trackSet;r.add(e);let s=r.size-1;s in am.prototype||Object.defineProperty(am.prototype,s,{get(){return[...J(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new wd("addtrack",{track:e}))})}function nm(i){var e;let t=(e=J(i).media)==null?void 0:e.audioTracks;t&&(J(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new wd("removetrack",{track:i}))}))}function bx(i){let e=J(i).media.audioTracks;!e||J(e).changeRequested||(J(e).changeRequested=!0,queueMicrotask(()=>{delete J(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var as,os,ls,Ta,bd,am=class extends EventTarget{constructor(){super(),ae(this,Ta),ae(this,as,void 0),ae(this,os,void 0),ae(this,ls,void 0),J(this).trackSet=new Set}[Symbol.iterator](){return P(this,Ta,bd).values()}get length(){return P(this,Ta,bd).size}getTrackById(i){var e;return(e=[...P(this,Ta,bd)].find(t=>t.id===i))!=null?e:null}get onaddtrack(){return P(this,as)}set onaddtrack(i){P(this,as)&&(this.removeEventListener("addtrack",P(this,as)),ce(this,as,void 0)),typeof i=="function"&&(ce(this,as,i),this.addEventListener("addtrack",i))}get onremovetrack(){return P(this,os)}set onremovetrack(i){P(this,os)&&(this.removeEventListener("removetrack",P(this,os)),ce(this,os,void 0)),typeof i=="function"&&(ce(this,os,i),this.addEventListener("removetrack",i))}get onchange(){return P(this,ls)}set onchange(i){P(this,ls)&&(this.removeEventListener("change",P(this,ls)),ce(this,ls,void 0)),typeof i=="function"&&(ce(this,ls,i),this.addEventListener("change",i))}};as=new WeakMap,os=new WeakMap,ls=new WeakMap,Ta=new WeakSet,bd=function(){return J(this).trackSet};var _a,GE=class{constructor(){We(this,"id"),We(this,"kind"),We(this,"label",""),We(this,"language",""),We(this,"sourceBuffer"),ae(this,_a,!1)}addRendition(i,e,t){let r=new Ex;return r.src=i,r.codec=e,r.bitrate=t,px(this,r),r}removeRendition(i){gx(i)}get enabled(){return P(this,_a)}set enabled(i){P(this,_a)!==i&&(ce(this,_a,i),bx(this))}};_a=new WeakMap;var DE=Ld(globalThis.HTMLMediaElement,"video"),CE=Ld(globalThis.HTMLMediaElement,"audio");function yx(i){if(!(i!=null&&i.prototype))return i;let e=Ld(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return Tx(this)}});let t=Ld(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return _x(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new HE;return l.kind=n,l.label=a,l.language=o,Jf(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=em),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new GE;return l.kind=n,l.label=a,l.language=o,sm(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=nm),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return r(this)}});let r=n=>{let a=J(n).videoRenditions;return a||(a=new im,J(a).media=n,J(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return s(this)}});let s=n=>{let a=J(n).audioRenditions;return a||(a=new rm,J(a).media=n,J(n).audioRenditions=a),a};return i}function Ld(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function Tx(i){var e;let t=J(i).videoTracks;if(!t&&(t=new tm,J(i).videoTracks=t,DE)){let r=DE.call((e=i.nativeEl)!=null?e:i);for(let s of r)Jf(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof HE)){for(let n of r)em(n);return}Jf(i,s.track)}),r.addEventListener("removetrack",s=>{em(s.track)})}return t}function _x(i){var e;let t=J(i).audioTracks;if(!t&&(t=new am,J(i).audioTracks=t,CE)){let r=CE.call((e=i.nativeEl)!=null?e:i);for(let s of r)sm(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof GE)){for(let n of r)nm(n);return}sm(i,s.track)}),r.addEventListener("removetrack",s=>{nm(s.track)})}return t}kd.push("castchange","entercast","leavecast");var K={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},Ax=Object.values(K),Sx=ZS(),xx="mux-video",Gi,Aa,yd,Sa,Td,_d,Ad,Sd,xa,xd,Ix=class extends Hf{constructor(){super(),ae(this,xa),ae(this,Gi,void 0),ae(this,Aa,void 0),ae(this,yd,void 0),ae(this,Sa,{}),ae(this,Td,void 0),ae(this,_d,void 0),ae(this,Ad,void 0),ae(this,Sd,void 0),ce(this,yd,pE())}static get observedAttributes(){var i;return[...Ax,...(i=Hf.observedAttributes)!=null?i:[]]}get preferCmcd(){var i;return(i=this.getAttribute(K.PREFER_CMCD))!=null?i:void 0}set preferCmcd(i){i!==this.preferCmcd&&(i?on.includes(i)?this.setAttribute(K.PREFER_CMCD,i):console.warn(`Invalid value for preferCmcd. Must be one of ${on.join()}`):this.removeAttribute(K.PREFER_CMCD))}get playerInitTime(){return P(this,yd)}get playerSoftwareName(){var i;return(i=P(this,Ad))!=null?i:xx}set playerSoftwareName(i){ce(this,Ad,i)}get playerSoftwareVersion(){var i;return(i=P(this,_d))!=null?i:Sx}set playerSoftwareVersion(i){ce(this,_d,i)}get _hls(){var i;return(i=P(this,Gi))==null?void 0:i.engine}get mux(){var i;return(i=this.nativeEl)==null?void 0:i.mux}get error(){var i;return(i=gE(this.nativeEl))!=null?i:null}get errorTranslator(){return P(this,Sd)}set errorTranslator(i){ce(this,Sd,i)}get src(){return this.getAttribute("src")}set src(i){i!==this.src&&(i==null?this.removeAttribute("src"):this.setAttribute("src",i))}get type(){var i;return(i=this.getAttribute(K.TYPE))!=null?i:void 0}set type(i){i!==this.type&&(i?this.setAttribute(K.TYPE,i):this.removeAttribute(K.TYPE))}get autoplay(){let i=this.getAttribute("autoplay");return i===null?!1:i===""?!0:i}set autoplay(i){let e=this.autoplay;i!==e&&(i?this.setAttribute("autoplay",typeof i=="string"?i:""):this.removeAttribute("autoplay"))}get preload(){let i=this.getAttribute("preload");return i===""?"auto":["none","metadata","auto"].includes(i)?i:super.preload}set preload(i){i!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(i)?this.setAttribute("preload",i):this.removeAttribute("preload"))}get debug(){return this.getAttribute(K.DEBUG)!=null}set debug(i){i!==this.debug&&(i?this.setAttribute(K.DEBUG,""):this.removeAttribute(K.DEBUG))}get disableCookies(){return this.hasAttribute(K.DISABLE_COOKIES)}set disableCookies(i){i!==this.disableCookies&&(i?this.setAttribute(K.DISABLE_COOKIES,""):this.removeAttribute(K.DISABLE_COOKIES))}get startTime(){let i=this.getAttribute(K.START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set startTime(i){i!==this.startTime&&(i==null?this.removeAttribute(K.START_TIME):this.setAttribute(K.START_TIME,`${i}`))}get playbackId(){var i;return(i=this.getAttribute(K.PLAYBACK_ID))!=null?i:void 0}set playbackId(i){i!==this.playbackId&&(i?this.setAttribute(K.PLAYBACK_ID,i):this.removeAttribute(K.PLAYBACK_ID))}get maxResolution(){var i;return(i=this.getAttribute(K.MAX_RESOLUTION))!=null?i:void 0}set maxResolution(i){i!==this.maxResolution&&(i?this.setAttribute(K.MAX_RESOLUTION,i):this.removeAttribute(K.MAX_RESOLUTION))}get minResolution(){var i;return(i=this.getAttribute(K.MIN_RESOLUTION))!=null?i:void 0}set minResolution(i){i!==this.minResolution&&(i?this.setAttribute(K.MIN_RESOLUTION,i):this.removeAttribute(K.MIN_RESOLUTION))}get renditionOrder(){var i;return(i=this.getAttribute(K.RENDITION_ORDER))!=null?i:void 0}set renditionOrder(i){i!==this.renditionOrder&&(i?this.setAttribute(K.RENDITION_ORDER,i):this.removeAttribute(K.RENDITION_ORDER))}get customDomain(){var i;return(i=this.getAttribute(K.CUSTOM_DOMAIN))!=null?i:void 0}set customDomain(i){i!==this.customDomain&&(i?this.setAttribute(K.CUSTOM_DOMAIN,i):this.removeAttribute(K.CUSTOM_DOMAIN))}get ended(){return Uf(this.nativeEl,this._hls)}get envKey(){var i;return(i=this.getAttribute(K.ENV_KEY))!=null?i:void 0}set envKey(i){i!==this.envKey&&(i?this.setAttribute(K.ENV_KEY,i):this.removeAttribute(K.ENV_KEY))}get beaconCollectionDomain(){var i;return(i=this.getAttribute(K.BEACON_COLLECTION_DOMAIN))!=null?i:void 0}set beaconCollectionDomain(i){i!==this.beaconCollectionDomain&&(i?this.setAttribute(K.BEACON_COLLECTION_DOMAIN,i):this.removeAttribute(K.BEACON_COLLECTION_DOMAIN))}get streamType(){var i;return(i=this.getAttribute(K.STREAM_TYPE))!=null?i:vE(this.nativeEl)}set streamType(i){i!==this.streamType&&(i?this.setAttribute(K.STREAM_TYPE,i):this.removeAttribute(K.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(K.TARGET_LIVE_WINDOW)?+this.getAttribute(K.TARGET_LIVE_WINDOW):EE(this.nativeEl)}set targetLiveWindow(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(K.TARGET_LIVE_WINDOW):this.setAttribute(K.TARGET_LIVE_WINDOW,`${+i}`))}get liveEdgeStart(){var i,e;if(this.hasAttribute(K.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:t}=this,r=(i=this.nativeEl.seekable.end(0))!=null?i:0,s=(e=this.nativeEl.seekable.start(0))!=null?e:0;return Math.max(s,r-t)}return bE(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(K.LIVE_EDGE_OFFSET))return+this.getAttribute(K.LIVE_EDGE_OFFSET)}set liveEdgeOffset(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(K.LIVE_EDGE_OFFSET):this.setAttribute(K.LIVE_EDGE_OFFSET,`${+i}`))}get seekable(){return Nf(this.nativeEl)}async addCuePoints(i){return Pf(this.nativeEl,i)}get activeCuePoint(){return Of(this.nativeEl)}get cuePoints(){return cE(this.nativeEl)}getStartDate(){return uE(this.nativeEl,this._hls)}get currentPdt(){return hE(this.nativeEl,this._hls)}get preferPlayback(){let i=this.getAttribute(K.PREFER_PLAYBACK);if(i===li.MSE||i===li.NATIVE)return i}set preferPlayback(i){i!==this.preferPlayback&&(i===li.MSE||i===li.NATIVE?this.setAttribute(K.PREFER_PLAYBACK,i):this.removeAttribute(K.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(i=>i.startsWith("metadata-")&&![K.METADATA_URL].includes(i)).reduce((i,e)=>{let t=this.getAttribute(e);return t!=null&&(i[e.replace(/^metadata-/,"").replace(/-/g,"_")]=t),i},{}),...P(this,Sa)}}set metadata(i){ce(this,Sa,i!=null?i:{}),this.mux&&this.mux.emit("hb",P(this,Sa))}get _hlsConfig(){return P(this,Td)}set _hlsConfig(i){ce(this,Td,i)}load(){ce(this,Gi,TE(this,this.nativeEl,P(this,Gi)))}unload(){Ff(this.nativeEl,P(this,Gi)),ce(this,Gi,void 0)}attributeChangedCallback(i,e,t){var r,s;switch(Hf.observedAttributes.includes(i)&&!["src","autoplay","preload"].includes(i)&&super.attributeChangedCallback(i,e,t),i){case K.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case K.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":{let n=!!e,a=!!t;!n&&a?rt(this,xa,xd).call(this):n&&!a?this.unload():n&&a&&(this.unload(),rt(this,xa,xd).call(this));break}case"autoplay":if(t===e)break;(r=P(this,Gi))==null||r.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=P(this,Gi))==null||s.setPreload(t);break;case K.PLAYBACK_ID:this.src=ga(this);break;case K.DEBUG:{let n=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=n);break}case K.METADATA_URL:t&&fetch(t).then(n=>n.json()).then(n=>this.metadata=n).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${t}!`));break;case K.STREAM_TYPE:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case K.TARGET_LIVE_WINDOW:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}connectedCallback(){var i;(i=super.connectedCallback)==null||i.call(this),this.nativeEl&&this.src&&!P(this,Gi)&&rt(this,xa,xd).call(this)}disconnectedCallback(){this.unload()}};Gi=new WeakMap,Aa=new WeakMap,yd=new WeakMap,Sa=new WeakMap,Td=new WeakMap,_d=new WeakMap,Ad=new WeakMap,Sd=new WeakMap,xa=new WeakSet,xd=async function(){P(this,Aa)||(await ce(this,Aa,Promise.resolve()),ce(this,Aa,null),this.load())};var om=class extends lx(yx(Ix)){};$f.customElements.get("mux-video")||($f.customElements.define("mux-video",om),$f.MuxVideoElement=om);var VE=om;var Lx="en",hs={code:Lx};var KE="en";function _e(i,e=!0){var s,n;let t=e&&(n=(s=hs)==null?void 0:s[i])!=null?n:i,r=e?hs.code:KE;return new hm(t,r)}var hm=class{constructor(e,t=(r=>(r=hs.code)!=null?r:KE)()){this.message=e,this.locale=t}format(e){return this.message.replace(/\{(\w+)\}/g,(t,r)=>{var s;return(s=e[r])!=null?s:""})}toString(){return this.message}};function WE(i){let e="";return Object.entries(i).forEach(([t,r])=>{r!=null&&(e+=`${Cd(t)}: ${r}; `)}),e?e.trim():void 0}function Cd(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Md(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Vi(i){if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}function fm(i){let e=Rx(i).toString();return e?"?"+e:""}function Rx(i){let e={};for(let t in i)i[t]!=null&&(e[t]=i[t]);return new URLSearchParams(e)}function _r(i){let e=(i!=null?i:"").split(".")[1];if(!e)return{};let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)}var mm=(i,e)=>!i||!e?!1:i.contains(e)?!0:mm(i,e.getRootNode().host);var qE="mux.com",kx=()=>{try{return"2.3.0"}catch{}return"UNKNOWN"},wx=kx(),Od=()=>wx,YE=(i,{token:e,customDomain:t=qE,thumbnailTime:r}={})=>{let s=e==null?r:void 0,{aud:n}=_r(e);if(!(e&&n!=="t"))return`https://image.${t}/${i}/thumbnail.webp${fm({token:e,time:s})}`},jE=(i,{token:e,customDomain:t=qE}={})=>{let{aud:r}=_r(e);if(!(e&&r!=="s"))return`https://image.${t}/${i}/storyboard.vtt${fm({token:e,format:"webp"})}`},Ia=i=>{if(i){if([qe.LIVE,qe.ON_DEMAND].includes(i))return i;if(i!=null&&i.includes("live"))return qe.LIVE}};var Dx={crossorigin:"crossOrigin",playsinline:"playsInline"};function zE(i){var e;return(e=Dx[i])!=null?e:Md(i)}var fs,ms,Ct,Pd=class{constructor(e,t){nt(this,fs,void 0);nt(this,ms,void 0);nt(this,Ct,[]);ti(this,fs,e),ti(this,ms,t)}[Symbol.iterator](){return Pe(this,Ct).values()}get length(){return Pe(this,Ct).length}get value(){var e;return(e=Pe(this,Ct).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(ti(this,Ct,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return Pe(this,Ct)[e]}values(){return Pe(this,Ct).values()}keys(){return Pe(this,Ct).keys()}forEach(e){Pe(this,Ct).forEach(e)}add(...e){var t,r;e.forEach(s=>{this.contains(s)||Pe(this,Ct).push(s)}),!(this.value===""&&!((t=Pe(this,fs))!=null&&t.hasAttribute(`${Pe(this,ms)}`)))&&((r=Pe(this,fs))==null||r.setAttribute(`${Pe(this,ms)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>{Pe(this,Ct).splice(Pe(this,Ct).indexOf(r),1)}),(t=Pe(this,fs))==null||t.setAttribute(`${Pe(this,ms)}`,`${this.value}`)}contains(e){return Pe(this,Ct).includes(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};fs=new WeakMap,ms=new WeakMap,Ct=new WeakMap;var XE=`[mux-player ${Od()}]`;function Ar(...i){console.warn(XE,...i)}function ci(...i){console.error(XE,...i)}function pm(i){var t;let e=(t=i.message)!=null?t:"";if(i.context&&(e+=` ${i.context}`),i.file){let r="https://github.com/muxinc/elements/blob/main/errors/";e+=` ${_e("Read more: ")}
1118
+ ${r}${i.file}`}Ar(e)}var Rt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},ps={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},ZE=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),Cx=kd.filter(i=>i!=="error"),Mx=Object.values(Rt).filter(i=>![Rt.PLAYSINLINE].includes(i)),Px=Object.values(ps);function JE(i){i.querySelectorAll(":scope > track").forEach(e=>{var t;(t=i.media)==null||t.append(e.cloneNode())}),Cx.forEach(e=>{var t;(t=i.media)==null||t.addEventListener(e,r=>{i.dispatchEvent(new Event(r.type))})})}var gm=class extends Xe.HTMLElement{static get observedAttributes(){return[...Mx,...Px]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(r=>{var s;(s=this.media)==null||s.append(r.cloneNode())});let e=r=>{for(let s of r)s.type==="childList"&&(s.removedNodes.forEach(n=>{var o,l;let a=(o=this.media)==null?void 0:o.querySelector(`track[src="${n.src}"]`);a&&((l=this.media)==null||l.removeChild(a))}),s.addedNodes.forEach(n=>{var a;(a=this.media)==null||a.append(n.cloneNode())}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(e,t,r){var s,n;switch(e){case ps.MUTED:{this.media&&(this.media.muted=r!=null,this.media.defaultMuted=r!=null);return}case ps.VOLUME:{let a=(s=Vi(r))!=null?s:1;this.media&&(this.media.volume=a);return}case ps.PLAYBACKRATE:{let a=(n=Vi(r))!=null?n:1;this.media&&(this.media.playbackRate=a,this.media.defaultPlaybackRate=a);return}}}play(){var e,t;return(t=(e=this.media)==null?void 0:e.play())!=null?t:Promise.reject()}pause(){var e;(e=this.media)==null||e.pause()}requestCast(e){var t;return(t=this.media)==null?void 0:t.requestCast(e)}get media(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var e,t;return(t=(e=this.media)==null?void 0:e.paused)!=null?t:!0}get duration(){var e,t;return(t=(e=this.media)==null?void 0:e.duration)!=null?t:NaN}get ended(){var e,t;return(t=(e=this.media)==null?void 0:e.ended)!=null?t:!1}get buffered(){var e,t;return(t=(e=this.media)==null?void 0:e.buffered)!=null?t:ZE}get seekable(){var e,t;return(t=(e=this.media)==null?void 0:e.seekable)!=null?t:ZE}get readyState(){var e,t;return(t=(e=this.media)==null?void 0:e.readyState)!=null?t:0}get videoWidth(){var e,t;return(t=(e=this.media)==null?void 0:e.videoWidth)!=null?t:0}get videoHeight(){var e,t;return(t=(e=this.media)==null?void 0:e.videoHeight)!=null?t:0}get currentTime(){var e,t;return(t=(e=this.media)==null?void 0:e.currentTime)!=null?t:0}set currentTime(e){this.media&&(this.media.currentTime=Number(e))}get volume(){var e,t;return(t=(e=this.media)==null?void 0:e.volume)!=null?t:1}set volume(e){this.media&&(this.media.volume=Number(e))}get playbackRate(){var e,t;return(t=(e=this.media)==null?void 0:e.playbackRate)!=null?t:1}set playbackRate(e){this.media&&(this.media.playbackRate=Number(e))}get defaultPlaybackRate(){var e;return(e=Vi(this.getAttribute(ps.PLAYBACKRATE)))!=null?e:1}set defaultPlaybackRate(e){e!=null?this.setAttribute(ps.PLAYBACKRATE,`${e}`):this.removeAttribute(ps.PLAYBACKRATE)}get crossOrigin(){return La(this,Rt.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(Rt.CROSSORIGIN,`${e}`)}get autoplay(){return La(this,Rt.AUTOPLAY)!=null}set autoplay(e){e?this.setAttribute(Rt.AUTOPLAY,typeof e=="string"?e:""):this.removeAttribute(Rt.AUTOPLAY)}get loop(){return La(this,Rt.LOOP)!=null}set loop(e){e?this.setAttribute(Rt.LOOP,""):this.removeAttribute(Rt.LOOP)}get muted(){var e,t;return(t=(e=this.media)==null?void 0:e.muted)!=null?t:!1}set muted(e){this.media&&(this.media.muted=!!e)}get defaultMuted(){return La(this,Rt.MUTED)!=null}set defaultMuted(e){e?this.setAttribute(Rt.MUTED,""):this.removeAttribute(Rt.MUTED)}get playsInline(){return La(this,Rt.PLAYSINLINE)!=null}set playsInline(e){ci("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(e){["","none","metadata","auto"].includes(e)?this.setAttribute(Rt.PRELOAD,e):this.removeAttribute(Rt.PRELOAD)}};function La(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var vm=gm;var Ox=Object.defineProperty,Nx=(i,e,t)=>e in i?Ox(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ux=(i,e,t)=>(Nx(i,typeof e!="symbol"?e+"":e,t),t),sb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Te=(i,e,t)=>(sb(i,e,"read from private field"),t?t.call(i):e.get(i)),Ki=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Zi=(i,e,t,r)=>(sb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),fn,Nd,gs,Ra,Sr,xr,Ir,vs,mn,Ud,Ai,eb=1,tb=0,Fx=1,Bx={processCallback(i,e,t){if(t){for(let[r,s]of e)if(r in t){let n=t[r];typeof n=="boolean"&&s instanceof Mt&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof Mt?s.element[s.attributeName]=n:s.value=n}}}},Ji=class extends w.DocumentFragment{constructor(e,t,r=Bx){var s;super(),Ki(this,fn,void 0),Ki(this,Nd,void 0),this.append(e.content.cloneNode(!0)),Zi(this,fn,nb(this)),Zi(this,Nd,r),(s=r.createCallback)==null||s.call(r,this,Te(this,fn),t),r.processCallback(this,Te(this,fn),t)}update(e){Te(this,Nd).processCallback(this,Te(this,fn),e)}};fn=new WeakMap;Nd=new WeakMap;var nb=(i,e=[])=>{let t,r;for(let s of i.attributes||[])if(s.value.includes("{{")){let n=new Em;for([t,r]of rb(s.value))if(!t)n.append(r);else{let a=new Mt(i,s.name,s.namespaceURI);n.append(a),e.push([r,a])}s.value=n.toString()}for(let s of i.childNodes)if(s.nodeType===eb&&!(s instanceof HTMLTemplateElement))nb(s,e);else if(s.nodeType===eb||s.data.includes("{{")){let n=[];if(s.data)for([t,r]of rb(s.data))if(!t)n.push(new Text(r));else{let a=new er(i);n.push(a),e.push([r,a])}else if(s instanceof HTMLTemplateElement){let a=new ka(i,s);n.push(a),e.push([a.expression,a])}s.replaceWith(...n.flatMap(a=>a.replacementNodes||[a]))}return e},ib={},rb=i=>{let e="",t=0,r=ib[i],s=0,n;if(r)return r;for(r=[];n=i[s];s++)n==="{"&&i[s+1]==="{"&&i[s-1]!=="\\"&&i[s+2]&&++t==1?(e&&r.push([tb,e]),e="",s++):n==="}"&&i[s+1]==="}"&&i[s-1]!=="\\"&&!--t?(r.push([Fx,e.trim()]),e="",s++):e+=n||"";return e&&r.push([tb,(t>0?"{{":"")+e]),ib[i]=r},$x=11,Fd=class{get value(){return""}set value(e){}toString(){return this.value}},ab=new WeakMap,Em=class{constructor(){Ki(this,gs,[])}[Symbol.iterator](){return Te(this,gs).values()}get length(){return Te(this,gs).length}item(e){return Te(this,gs)[e]}append(...e){for(let t of e)t instanceof Mt&&ab.set(t,this),Te(this,gs).push(t)}toString(){return Te(this,gs).join("")}};gs=new WeakMap;var Mt=class extends Fd{constructor(e,t,r){super(),Ki(this,vs),Ki(this,Ra,""),Ki(this,Sr,void 0),Ki(this,xr,void 0),Ki(this,Ir,void 0),Zi(this,Sr,e),Zi(this,xr,t),Zi(this,Ir,r)}get attributeName(){return Te(this,xr)}get attributeNamespace(){return Te(this,Ir)}get element(){return Te(this,Sr)}get value(){return Te(this,Ra)}set value(e){Te(this,Ra)!==e&&(Zi(this,Ra,e),!Te(this,vs,mn)||Te(this,vs,mn).length===1?e==null?Te(this,Sr).removeAttributeNS(Te(this,Ir),Te(this,xr)):Te(this,Sr).setAttributeNS(Te(this,Ir),Te(this,xr),e):Te(this,Sr).setAttributeNS(Te(this,Ir),Te(this,xr),Te(this,vs,mn)))}get booleanValue(){return Te(this,Sr).hasAttributeNS(Te(this,Ir),Te(this,xr))}set booleanValue(e){if(!Te(this,vs,mn)||Te(this,vs,mn).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};Ra=new WeakMap;Sr=new WeakMap;xr=new WeakMap;Ir=new WeakMap;vs=new WeakSet;mn=function(){return ab.get(this)};var er=class extends Fd{constructor(e,t){super(),Ki(this,Ud,void 0),Ki(this,Ai,void 0),Zi(this,Ud,e),Zi(this,Ai,t?[...t]:[new Text])}get replacementNodes(){return Te(this,Ai)}get parentNode(){return Te(this,Ud)}get nextSibling(){return Te(this,Ai)[Te(this,Ai).length-1].nextSibling}get previousSibling(){return Te(this,Ai)[0].previousSibling}get value(){return Te(this,Ai).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){let t=e.flat().flatMap(r=>r==null?[new Text]:r.forEach?[...r]:r.nodeType===$x?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),Zi(this,Ai,Hx(Te(this,Ai)[0].parentNode,Te(this,Ai),t,this.nextSibling))}};Ud=new WeakMap;Ai=new WeakMap;var ka=class extends er{constructor(e,t){let r=t.getAttribute("directive")||t.getAttribute("type"),s=t.getAttribute("expression")||t.getAttribute(r)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),Ux(this,"directive"),this.expression=s,this.template=t,this.directive=r}};function Hx(i,e,t,r=null){let s=0,n,a,o,l=t.length,d=e.length;for(;s<l&&s<d&&e[s]==t[s];)s++;for(;s<l&&s<d&&t[l-1]==e[d-1];)r=t[--d,--l];if(s==d)for(;s<l;)i.insertBefore(t[s++],r);if(s==l)for(;s<d;)i.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:r,n==o?n=a:s<l&&t[s]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=r;)a=n.nextSibling,i.removeChild(n),n=a}return t}var ob={string:i=>String(i)},$d=class{constructor(e){this.template=e,this.state=void 0}},Es=new WeakMap,bs=new WeakMap,bm={partial:(i,e)=>{e[i.expression]=new $d(i.template)},if:(i,e)=>{var t;if(db(i.expression,e))if(Es.get(i)!==i.template){Es.set(i,i.template);let r=new Ji(i.template,e,Hd);i.replace(r),bs.set(i,r)}else(t=bs.get(i))==null||t.update(e);else i.replace(""),Es.delete(i),bs.delete(i)}},Gx=Object.keys(bm),Hd={processCallback(i,e,t){var r,s;if(t)for(let[n,a]of e){if(a instanceof ka){if(!a.directive){let l=Gx.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(r=bm[a.directive])==null||r.call(bm,a,t);continue}let o=db(n,t);if(o instanceof $d){Es.get(a)!==o.template?(Es.set(a,o.template),o=new Ji(o.template,o.state,Hd),a.value=o,bs.set(a,o)):(s=bs.get(a))==null||s.update(o.state);continue}o?(a instanceof Mt&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof Mt?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,Es.delete(a),bs.delete(a))):a instanceof Mt?a.value=void 0:(a.value=void 0,Es.delete(a),bs.delete(a))}}},lb={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i!=null?i:e,"|":(i,e)=>{var t;return(t=ob[e])==null?void 0:t.call(ob,i)}};function Vx(i){return Kx(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function db(i,e={}){var t,r,s,n,a,o,l;let d=Vx(i);if(d.length===0||d.some(({type:c})=>!c))return wa(i);if(((t=d[0])==null?void 0:t.token)===">"){let c=e[(r=d[1])==null?void 0:r.token];if(!c)return wa(i);let u={...e};c.state=u;let h=d.slice(2);for(let f=0;f<h.length;f+=3){let g=(s=h[f])==null?void 0:s.token,E=(n=h[f+1])==null?void 0:n.token,T=(a=h[f+2])==null?void 0:a.token;g&&E==="="&&(u[g]=Da(T,e))}return c}if(d.length===1)return Bd(d[0])?Da(d[0].token,e):wa(i);if(d.length===2){let c=(o=d[0])==null?void 0:o.token,u=lb[c];if(!u||!Bd(d[1]))return wa(i);let h=Da(d[1].token,e);return u(h)}if(d.length===3){let c=(l=d[1])==null?void 0:l.token,u=lb[c];if(!u||!Bd(d[0])||!Bd(d[2]))return wa(i);let h=Da(d[0].token,e);if(c==="|")return u(h,d[2].token);let f=Da(d[2].token,e);return u(h,f)}}function wa(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function Bd({type:i}){return["number","boolean","string","param"].includes(i)}function Da(i,e){let t=i[0],r=i.slice(-1);return i==="true"||i==="false"?i==="true":t===r&&["'",'"'].includes(t)?i.slice(1,-1):Wa(i)?parseFloat(i):e[i]}function Kx(i,e){let t,r,s,n=[];for(;i;){s=null,t=i.length;for(let a in e)r=e[a].exec(i),r&&r.index<t&&(s={token:r[0],type:a,matches:r.slice(1)},t=r.index);t&&n.push({token:i.substr(0,t),type:void 0}),s&&n.push(s),i=i.substr(t+(s?s.token.length:0))}return n}var Wx=Object.defineProperty,qx=(i,e,t)=>e in i?Wx(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ma=(i,e,t)=>(qx(i,typeof e!="symbol"?e+"":e,t),t),xm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},_m=(i,e,t)=>(xm(i,e,"read from private field"),t?t.call(i):e.get(i)),Ca=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ys=(i,e,t,r)=>(xm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ym=(i,e,t)=>(xm(i,e,"access private method"),t),pn,Gd,gn,Am,cb,Vd,Sm,Tm={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},ub=q.createElement("template");ub.innerHTML=`
1082
1119
  <style>
1083
1120
  :host {
1084
1121
  display: inline-block;
@@ -1102,7 +1139,7 @@ ${r}${i.file}`}Ir(e)}var Mt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:
1102
1139
  display: none;
1103
1140
  }
1104
1141
  </style>
1105
- `;var wr=class extends w.HTMLElement{constructor(){super(),Sa(this,Wf),Sa(this,Ld),xa(this,"renderRoot"),xa(this,"renderer"),Sa(this,dn,void 0),Sa(this,Id,void 0),Sa(this,cn,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());let e=new MutationObserver(t=>{var r;this.mediaController&&!((r=this.mediaController)!=null&&r.breakpointsComputed)||t.some(s=>{let n=s.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(Vf[s.attributeName]||s.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),this.addEventListener(Zi.BREAKPOINTS_COMPUTED,this.render),Gf(this,Wf,cE).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=Kf(this,dn))!=null?e:this.constructor.template}set template(e){ys(this,cn,null),ys(this,dn,e),this.createRenderer()}get props(){var e,t,r;let s=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>Vf[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(let a of s){let o=(r=Vf[a.name])!=null?r:Fm(a.name),{value:l}=a;l!=null?($a(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,r){e==="template"&&t!=r&&Gf(this,Ld,qf).call(this)}connectedCallback(){Gf(this,Ld,qf).call(this)}createRenderer(){this.template&&this.template!==Kf(this,Id)&&(ys(this,Id,this.template),this.renderer=new or(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(uE.content.cloneNode(!0),this.renderer))}render(){var e;(e=this.renderer)==null||e.update(this.props)}};dn=new WeakMap;Id=new WeakMap;cn=new WeakMap;Wf=new WeakSet;cE=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){let e=this[i];delete this[i],this[i]=e}};Ld=new WeakSet;qf=function(){var i;let e=this.getAttribute("template");if(!e||e===Kf(this,cn))return;let t=this.getRootNode(),r=(i=t==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(r){ys(this,cn,e),ys(this,dn,r),this.createRenderer();return}RS(e)&&(ys(this,cn,e),wS(e).then(s=>{let n=j.createElement("template");n.innerHTML=s,ys(this,dn,n),this.createRenderer()}).catch(console.error))};xa(wr,"template");xa(wr,"observedAttributes",["template"]);xa(wr,"processor",xd);function RS(i){if(!/^(\/|\.\/|https?:\/\/)/.test(i))return!1;let e=/^https?:\/\//.test(i)?void 0:location.origin;try{new URL(i,e)}catch{return!1}return!0}async function wS(i){let e=await fetch(i);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}w.customElements.get("media-theme")||w.customElements.define("media-theme",wr);var hE=`:host {
1142
+ `;var Lr=class extends w.HTMLElement{constructor(){super(),Ca(this,Am),Ca(this,Vd),Ma(this,"renderRoot"),Ma(this,"renderer"),Ca(this,pn,void 0),Ca(this,Gd,void 0),Ca(this,gn,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());let e=new MutationObserver(t=>{var r;this.mediaController&&!((r=this.mediaController)!=null&&r.breakpointsComputed)||t.some(s=>{let n=s.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(Tm[s.attributeName]||s.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),this.addEventListener(Yi.BREAKPOINTS_COMPUTED,this.render),ym(this,Am,cb).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=_m(this,pn))!=null?e:this.constructor.template}set template(e){ys(this,gn,null),ys(this,pn,e),this.createRenderer()}get props(){var e,t,r;let s=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>Tm[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(let a of s){let o=(r=Tm[a.name])!=null?r:Sp(a.name),{value:l}=a;l!=null?(Wa(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,r){e==="template"&&t!=r&&ym(this,Vd,Sm).call(this)}connectedCallback(){ym(this,Vd,Sm).call(this)}createRenderer(){this.template&&this.template!==_m(this,Gd)&&(ys(this,Gd,this.template),this.renderer=new Ji(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(ub.content.cloneNode(!0),this.renderer))}render(){var e;(e=this.renderer)==null||e.update(this.props)}};pn=new WeakMap;Gd=new WeakMap;gn=new WeakMap;Am=new WeakSet;cb=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){let e=this[i];delete this[i],this[i]=e}};Vd=new WeakSet;Sm=function(){var i;let e=this.getAttribute("template");if(!e||e===_m(this,gn))return;let t=this.getRootNode(),r=(i=t==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(r){ys(this,gn,e),ys(this,pn,r),this.createRenderer();return}Yx(e)&&(ys(this,gn,e),jx(e).then(s=>{let n=q.createElement("template");n.innerHTML=s,ys(this,pn,n),this.createRenderer()}).catch(console.error))};Ma(Lr,"template");Ma(Lr,"observedAttributes",["template"]);Ma(Lr,"processor",Hd);function Yx(i){if(!/^(\/|\.\/|https?:\/\/)/.test(i))return!1;let e=/^https?:\/\//.test(i)?void 0:location.origin;try{new URL(i,e)}catch{return!1}return!0}async function jx(i){let e=await fetch(i);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}w.customElements.get("media-theme")||w.customElements.define("media-theme",Lr);var hb=`:host {
1106
1143
  --media-control-display: var(--controls);
1107
1144
  --media-loading-indicator-display: var(--loading-indicator);
1108
1145
  --media-dialog-display: var(--dialog);
@@ -1120,6 +1157,7 @@ ${r}${i.file}`}Ir(e)}var Mt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:
1120
1157
  --media-fullscreen-button-display: var(--fullscreen-button);
1121
1158
  --media-cast-button-display: var(--cast-button);
1122
1159
  --media-playback-rate-button-display: var(--playback-rate-button);
1160
+ --media-playback-rate-selectmenu-display: var(--playback-rate-selectmenu);
1123
1161
  --media-volume-range-display: var(--volume-range);
1124
1162
  --media-time-range-display: var(--time-range);
1125
1163
  --media-time-display-display: var(--time-display);
@@ -1177,6 +1215,10 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1177
1215
  --media-fullscreen-button-display: var(--fullscreen-button, var(--top-fullscreen-button));
1178
1216
  --media-cast-button-display: var(--cast-button, var(--top-cast-button));
1179
1217
  --media-playback-rate-button-display: var(--playback-rate-button, var(--top-playback-rate-button));
1218
+ --media-playback-rate-selectmenu-display: var(
1219
+ --captions-selectmenu,
1220
+ var(--media-playback-rate-button-display, var(--top-playback-rate-selectmenu))
1221
+ );
1180
1222
  --media-volume-range-display: var(--volume-range, var(--top-volume-range));
1181
1223
  --media-time-range-display: var(--time-range, var(--top-time-range));
1182
1224
  --media-time-display-display: var(--time-display, var(--top-time-display));
@@ -1204,6 +1246,10 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1204
1246
  --media-fullscreen-button-display: var(--fullscreen-button, var(--center-fullscreen-button));
1205
1247
  --media-cast-button-display: var(--cast-button, var(--center-cast-button));
1206
1248
  --media-playback-rate-button-display: var(--playback-rate-button, var(--center-playback-rate-button));
1249
+ --media-playback-rate-selectmenu-display: var(
1250
+ --playback-rate-selectmenu,
1251
+ var(--media-playback-rate-button-display, var(--center-playback-rate-selectmenu))
1252
+ );
1207
1253
  --media-volume-range-display: var(--volume-range, var(--center-volume-range));
1208
1254
  --media-time-range-display: var(--time-range, var(--center-time-range));
1209
1255
  --media-time-display-display: var(--time-display, var(--center-time-display));
@@ -1230,13 +1276,17 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1230
1276
  --media-fullscreen-button-display: var(--fullscreen-button, var(--bottom-fullscreen-button));
1231
1277
  --media-cast-button-display: var(--cast-button, var(--bottom-cast-button));
1232
1278
  --media-playback-rate-button-display: var(--playback-rate-button, var(--bottom-playback-rate-button));
1279
+ --media-playback-rate-selectmenu-display: var(
1280
+ --playback-rate-selectmenu,
1281
+ var(--media-playback-rate-button-display, var(--bottom-playback-rate-selectmenu))
1282
+ );
1233
1283
  --media-volume-range-display: var(--volume-range, var(--bottom-volume-range));
1234
1284
  --media-time-range-display: var(--time-range, var(--bottom-time-range));
1235
1285
  --media-time-display-display: var(--time-display, var(--bottom-time-display));
1236
1286
  --media-duration-display-display: var(--duration-display, var(--bottom-duration-display));
1237
1287
  --media-title-display-display: var(--title-display, var(--bottom-title-display));
1238
1288
  }
1239
- `;var mE=`
1289
+ `;var mb=`
1240
1290
  :host {
1241
1291
  z-index: 100;
1242
1292
  display: var(--media-dialog-display, flex);
@@ -1288,17 +1338,17 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1288
1338
  text-align: center;
1289
1339
  line-height: 1.4;
1290
1340
  }
1291
- `,pE=zt.createElement("template");pE.innerHTML=`
1341
+ `,pb=Yt.createElement("template");pb.innerHTML=`
1292
1342
  <style>
1293
- ${mE}
1343
+ ${mb}
1294
1344
  </style>
1295
1345
 
1296
1346
  <div class="dialog">
1297
1347
  <slot></slot>
1298
1348
  </div>
1299
- `;var Dr=class extends st.HTMLElement{constructor(){var t;super();this.attachShadow({mode:"open"}),(t=this.shadowRoot)==null||t.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),fE(this)}close(){!this.hasAttribute("open")||(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),CS(this))}attributeChangedCallback(t,r,s){t==="open"&&r!==s&&(s!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&fE(this)}};Dr.styles=mE,Dr.template=pE,Dr.observedAttributes=["open"];function fE(i){let e=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(i.dispatchEvent(e),e.defaultPrevented)return;let t=i.querySelector("[autofocus]:not([disabled])");!t&&i.tabIndex>=0&&(t=i),t||(t=gE(i.shadowRoot)),i._previouslyFocusedElement=zt.activeElement,zt.activeElement instanceof HTMLElement&&zt.activeElement.blur(),i.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function gE(i){let t=["button","input","keygen","select","textarea"].map(function(s){return s+":not([disabled])"});t.push('[tabindex]:not([disabled]):not([tabindex=""])');let r=i==null?void 0:i.querySelector(t.join(", "));if(!r&&"attachShadow"in Element.prototype){let s=(i==null?void 0:i.querySelectorAll("*"))||[];for(let n=0;n<s.length&&!(s[n].tagName&&s[n].shadowRoot&&(r=gE(s[n].shadowRoot),r));n++);}return r}function CS(i){i._previouslyFocusedElement instanceof HTMLElement&&i._previouslyFocusedElement.focus()}st.customElements.get("media-dialog")||(st.customElements.define("media-dialog",Dr),st.MediaDialog=Dr);var jf=Dr;var vE=zt.createElement("template");vE.innerHTML=`
1349
+ `;var Rr=class extends Xe.HTMLElement{constructor(){var t;super();this.attachShadow({mode:"open"}),(t=this.shadowRoot)==null||t.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),fb(this)}close(){this.hasAttribute("open")&&(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),Xx(this))}attributeChangedCallback(t,r,s){t==="open"&&r!==s&&(s!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&fb(this)}};Rr.styles=mb,Rr.template=pb,Rr.observedAttributes=["open"];function fb(i){let e=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(i.dispatchEvent(e),e.defaultPrevented)return;let t=i.querySelector("[autofocus]:not([disabled])");!t&&i.tabIndex>=0&&(t=i),t||(t=gb(i.shadowRoot)),i._previouslyFocusedElement=Yt.activeElement,Yt.activeElement instanceof HTMLElement&&Yt.activeElement.blur(),i.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function gb(i){let t=["button","input","keygen","select","textarea"].map(function(s){return s+":not([disabled])"});t.push('[tabindex]:not([disabled]):not([tabindex=""])');let r=i==null?void 0:i.querySelector(t.join(", "));if(!r&&"attachShadow"in Element.prototype){let s=(i==null?void 0:i.querySelectorAll("*"))||[];for(let n=0;n<s.length&&!(s[n].tagName&&s[n].shadowRoot&&(r=gb(s[n].shadowRoot),r));n++);}return r}function Xx(i){i._previouslyFocusedElement instanceof HTMLElement&&i._previouslyFocusedElement.focus()}Xe.customElements.get("media-dialog")||(Xe.customElements.define("media-dialog",Rr),Xe.MediaDialog=Rr);var Im=Rr;var vb=Yt.createElement("template");vb.innerHTML=`
1300
1350
  <style>
1301
- ${jf.styles}
1351
+ ${Im.styles}
1302
1352
 
1303
1353
  .close {
1304
1354
  background: none;
@@ -1327,85 +1377,86 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1327
1377
  </svg>
1328
1378
  </button>
1329
1379
  </slot>
1330
- `;var Ia=class extends jf{constructor(){var e,t;super(),(t=(e=this.shadowRoot)==null?void 0:e.querySelector(".close"))==null||t.addEventListener("click",()=>{this.close()})}};Ia.template=vE;st.customElements.get("mxp-dialog")||(st.customElements.define("mxp-dialog",Ia),st.MxpDialog=Ia);var La=new WeakMap,ka=class{constructor(e,t){this.element=e;this.type=t;this.element.addEventListener(this.type,this);let r=La.get(this.element);r&&r.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=La.get(this.element);t&&t.delete(this.type)}}static for(e){La.has(e.element)||La.set(e.element,new Map);let t=e.attributeName.slice(2),r=La.get(e.element);return r&&r.has(t)?r.get(t):new ka(e.element,t)}};function MS(i,e){return i instanceof Nt&&i.attributeName.startsWith("on")?(ka.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function OS(i,e){return e instanceof kd&&i instanceof lr?(e.renderInto(i),!0):!1}function PS(i,e){return e instanceof DocumentFragment&&i instanceof lr?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function NS(i,e){if(i instanceof Nt){let t=i.attributeNamespace,r=i.element.getAttributeNS(t,i.attributeName);return String(e)!==r&&(i.value=String(e)),!0}return i.value=String(e),!0}function US(i,e){if(i instanceof Nt&&e instanceof Element){let t=i.element;return t[i.attributeName]!==e&&(i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),t[i.attributeName]=e),!0}return!1}function FS(i,e){if(typeof e=="boolean"&&i instanceof Nt){let t=i.attributeNamespace,r=i.element.hasAttributeNS(t,i.attributeName);return e!==r&&(i.booleanValue=e),!0}return!1}function BS(i,e){return e===!1&&i instanceof lr?(i.replace(""),!0):!1}function $S(i,e){US(i,e)||FS(i,e)||MS(i,e)||BS(i,e)||OS(i,e)||PS(i,e)||NS(i,e)}var zf=new Map,EE=new WeakMap,bE=new WeakMap,kd=class{constructor(e,t,r){this.strings=e;this.values=t;this.processor=r;this.stringsKey=this.strings.join("")}get template(){if(zf.has(this.stringsKey))return zf.get(this.stringsKey);{let e=zt.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((r,s,n)=>r+s+(n<t?`{{ ${n} }}`:""),""),zf.set(this.stringsKey,e),e}}renderInto(e){var s;let t=this.template;if(EE.get(e)!==t){EE.set(e,t);let n=new or(t,this.values,this.processor);bE.set(e,n),e instanceof lr?e.replace(...n.children):e.appendChild(n);return}let r=bE.get(e);(s=r==null?void 0:r.update)==null||s.call(r,this.values)}},HS={processCallback(i,e,t){var r;if(!!t){for(let[s,n]of e)if(s in t){let a=(r=t[s])!=null?r:"";$S(n,a)}}}};function dr(i,...e){return new kd(i,e,HS)}function yE(i,e){i.renderInto(e)}var TE=i=>dr`
1380
+ `;var Pa=class extends Im{constructor(){var e,t;super(),(t=(e=this.shadowRoot)==null?void 0:e.querySelector(".close"))==null||t.addEventListener("click",()=>{this.close()})}};Pa.template=vb;Xe.customElements.get("mxp-dialog")||(Xe.customElements.define("mxp-dialog",Pa),Xe.MxpDialog=Pa);var Oa=new WeakMap,Rm=class i{constructor(e,t){this.element=e;this.type=t;this.element.addEventListener(this.type,this);let r=Oa.get(this.element);r&&r.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=Oa.get(this.element);t&&t.delete(this.type)}}static for(e){Oa.has(e.element)||Oa.set(e.element,new Map);let t=e.attributeName.slice(2),r=Oa.get(e.element);return r&&r.has(t)?r.get(t):new i(e.element,t)}};function Qx(i,e){return i instanceof Mt&&i.attributeName.startsWith("on")?(Rm.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function Zx(i,e){return e instanceof Kd&&i instanceof er?(e.renderInto(i),!0):!1}function Jx(i,e){return e instanceof DocumentFragment&&i instanceof er?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function eI(i,e){if(i instanceof Mt){let t=i.attributeNamespace,r=i.element.getAttributeNS(t,i.attributeName);return String(e)!==r&&(i.value=String(e)),!0}return i.value=String(e),!0}function tI(i,e){if(i instanceof Mt&&e instanceof Element){let t=i.element;return t[i.attributeName]!==e&&(i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),t[i.attributeName]=e),!0}return!1}function iI(i,e){if(typeof e=="boolean"&&i instanceof Mt){let t=i.attributeNamespace,r=i.element.hasAttributeNS(t,i.attributeName);return e!==r&&(i.booleanValue=e),!0}return!1}function rI(i,e){return e===!1&&i instanceof er?(i.replace(""),!0):!1}function sI(i,e){tI(i,e)||iI(i,e)||Qx(i,e)||rI(i,e)||Zx(i,e)||Jx(i,e)||eI(i,e)}var Lm=new Map,Eb=new WeakMap,bb=new WeakMap,Kd=class{constructor(e,t,r){this.strings=e;this.values=t;this.processor=r;this.stringsKey=this.strings.join("")}get template(){if(Lm.has(this.stringsKey))return Lm.get(this.stringsKey);{let e=Yt.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((r,s,n)=>r+s+(n<t?`{{ ${n} }}`:""),""),Lm.set(this.stringsKey,e),e}}renderInto(e){var s;let t=this.template;if(Eb.get(e)!==t){Eb.set(e,t);let n=new Ji(t,this.values,this.processor);bb.set(e,n),e instanceof er?e.replace(...n.children):e.appendChild(n);return}let r=bb.get(e);(s=r==null?void 0:r.update)==null||s.call(r,this.values)}},nI={processCallback(i,e,t){var r;if(t){for(let[s,n]of e)if(s in t){let a=(r=t[s])!=null?r:"";sI(n,a)}}}};function tr(i,...e){return new Kd(i,e,nI)}function yb(i,e){i.renderInto(e)}var Tb=i=>tr`
1331
1381
  <style>
1332
- ${hE}
1382
+ ${hb}
1333
1383
  </style>
1334
- ${VS(i)}
1335
- `,GS=i=>{let e=i.hotKeys?`${i.hotKeys}`:"";return Ea(i.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},VS=i=>{var e,t,r,s,n,a,o,l,d,c,u,h,f,g,E,T,A,k,L,N,D,$,O,G,Y,P,X,z,Ae,Ee,be,we,Se,Z;return dr`
1384
+ ${dI(i)}
1385
+ `,aI=i=>{let e=i.hotKeys?`${i.hotKeys}`:"";return Ia(i.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},oI={TOP:"top",CENTER:"center",BOTTOM:"bottom",LAYER:"layer",MEDIA_LAYER:"media-layer",POSTER_LAYER:"poster-layer",VERTICAL_LAYER:"vertical-layer",CENTERED_LAYER:"centered-layer",GESTURE_LAYER:"gesture-layer",CONTROLLER_LAYER:"controller",BUTTON:"button",RANGE:"range",DISPLAY:"display",CONTROL_BAR:"control-bar",SELECTMENU:"selectmenu",LISTBOX:"listbox",OPTION:"option",POSTER:"poster",LIVE:"live",PLAY:"play",PRE_PLAY:"pre-play",SEEK_BACKWARD:"seek-backward",SEEK_FORWARD:"seek-forward",MUTE:"mute",CAPTIONS:"captions",AIRPLAY:"airplay",PIP:"pip",FULLSCREEN:"fullscreen",CAST:"cast",PLAYBACK_RATE:"playback-rate",VOLUME:"volume",TIME:"time",TITLE:"title",AUDIO_TRACK:"audio-track",RENDITION:"rendition"},lI=Object.values(oI).join(", "),dI=i=>{var e,t,r,s,n,a,o,l,d,c,u,h,f,g,E,T,A,R,L,N,M,$,U,H,W,O,z,Y,ye,Ee,be,ke,Se,Z,te;return tr`
1336
1386
  <media-theme
1337
1387
  template="${i.themeTemplate||!1}"
1338
1388
  defaultstreamtype="${(e=i.defaultStreamType)!=null?e:!1}"
1339
- hotkeys="${GS(i)||!1}"
1389
+ hotkeys="${aI(i)||!1}"
1340
1390
  nohotkeys="${i.noHotKeys||!i.hasSrc||i.isDialogOpen||!1}"
1341
- noautoseektolive="${!!((t=i.streamType)!=null&&t.includes(Ze.LIVE))&&i.targetLiveWindow!==0}"
1391
+ noautoseektolive="${!!((t=i.streamType)!=null&&t.includes(qe.LIVE))&&i.targetLiveWindow!==0}"
1342
1392
  novolumepref="${i.novolumepref||!1}"
1343
1393
  disabled="${!i.hasSrc||i.isDialogOpen}"
1344
1394
  audio="${(r=i.audio)!=null?r:!1}"
1345
- style="${(s=Wv({"--media-primary-color":i.primaryColor,"--media-secondary-color":i.secondaryColor,"--media-accent-color":i.accentColor}))!=null?s:!1}"
1395
+ style="${(s=WE({"--media-primary-color":i.primaryColor,"--media-secondary-color":i.secondaryColor,"--media-accent-color":i.accentColor}))!=null?s:!1}"
1346
1396
  defaultsubtitles="${!i.defaultHiddenCaptions}"
1347
1397
  forwardseekoffset="${(n=i.forwardSeekOffset)!=null?n:!1}"
1348
1398
  backwardseekoffset="${(a=i.backwardSeekOffset)!=null?a:!1}"
1349
1399
  playbackrates="${(o=i.playbackRates)!=null?o:!1}"
1350
1400
  defaultshowremainingtime="${(l=i.defaultShowRemainingTime)!=null?l:!1}"
1351
- hideduration="${(d=i.hideDuration)!=null?d:!1}"
1352
- title="${(c=i.title)!=null?c:!1}"
1353
- exportparts="top, center, bottom, layer, media-layer, poster-layer, vertical-layer, centered-layer, gesture-layer, controller, poster, live, play, button, seek-backward, seek-forward, mute, captions, airplay, pip, fullscreen, cast, playback-rate, volume, range, time, display, control-bar"
1401
+ defaultduration="${(d=i.defaultDuration)!=null?d:!1}"
1402
+ hideduration="${(c=i.hideDuration)!=null?c:!1}"
1403
+ title="${(u=i.title)!=null?u:!1}"
1404
+ exportparts="${lI}"
1354
1405
  >
1355
1406
  <mux-video
1356
1407
  slot="media"
1357
- target-live-window="${(u=i.targetLiveWindow)!=null?u:!1}"
1358
- stream-type="${(h=Ea(i.streamType))!=null?h:!1}"
1359
- crossorigin="${(f=i.crossOrigin)!=null?f:""}"
1408
+ target-live-window="${(h=i.targetLiveWindow)!=null?h:!1}"
1409
+ stream-type="${(f=Ia(i.streamType))!=null?f:!1}"
1410
+ crossorigin="${(g=i.crossOrigin)!=null?g:""}"
1360
1411
  playsinline
1361
- autoplay="${(g=i.autoplay)!=null?g:!1}"
1362
- muted="${(E=i.muted)!=null?E:!1}"
1363
- loop="${(T=i.loop)!=null?T:!1}"
1364
- preload="${(A=i.preload)!=null?A:!1}"
1365
- debug="${(k=i.debug)!=null?k:!1}"
1366
- prefer-cmcd="${(L=i.preferCmcd)!=null?L:!1}"
1367
- disable-cookies="${(N=i.disableCookies)!=null?N:!1}"
1368
- prefer-playback="${(D=i.preferPlayback)!=null?D:!1}"
1412
+ autoplay="${(E=i.autoplay)!=null?E:!1}"
1413
+ muted="${(T=i.muted)!=null?T:!1}"
1414
+ loop="${(A=i.loop)!=null?A:!1}"
1415
+ preload="${(R=i.preload)!=null?R:!1}"
1416
+ debug="${(L=i.debug)!=null?L:!1}"
1417
+ prefer-cmcd="${(N=i.preferCmcd)!=null?N:!1}"
1418
+ disable-cookies="${(M=i.disableCookies)!=null?M:!1}"
1419
+ prefer-playback="${($=i.preferPlayback)!=null?$:!1}"
1369
1420
  start-time="${i.startTime!=null?i.startTime:!1}"
1370
- beacon-collection-domain="${($=i.beaconCollectionDomain)!=null?$:!1}"
1371
- player-software-name="${(O=i.playerSoftwareName)!=null?O:!1}"
1372
- player-software-version="${(G=i.playerSoftwareVersion)!=null?G:!1}"
1373
- env-key="${(Y=i.envKey)!=null?Y:!1}"
1374
- custom-domain="${(P=i.customDomain)!=null?P:!1}"
1375
- src="${i.src?i.src:i.playbackId?la(i):!1}"
1376
- cast-src="${i.src?i.src:i.playbackId?la(i):!1}"
1421
+ beacon-collection-domain="${(U=i.beaconCollectionDomain)!=null?U:!1}"
1422
+ player-software-name="${(H=i.playerSoftwareName)!=null?H:!1}"
1423
+ player-software-version="${(W=i.playerSoftwareVersion)!=null?W:!1}"
1424
+ env-key="${(O=i.envKey)!=null?O:!1}"
1425
+ custom-domain="${(z=i.customDomain)!=null?z:!1}"
1426
+ src="${i.src?i.src:i.playbackId?ga(i):!1}"
1427
+ cast-src="${i.src?i.src:i.playbackId?ga(i):!1}"
1377
1428
  exportparts="video"
1378
1429
  >
1379
- ${i.storyboard?dr`<track label="thumbnails" default kind="metadata" src="${i.storyboard}" />`:dr``}
1430
+ ${i.storyboard?tr`<track label="thumbnails" default kind="metadata" src="${i.storyboard}" />`:tr``}
1380
1431
  </mux-video>
1381
1432
  <slot name="poster" slot="poster">
1382
1433
  <media-poster-image
1383
1434
  part="poster"
1384
1435
  exportparts="poster, img"
1385
- src="${i.poster===""?!1:(X=i.poster)!=null?X:!1}"
1386
- placeholdersrc="${(z=i.placeholder)!=null?z:!1}"
1436
+ src="${i.poster===""?!1:(Y=i.poster)!=null?Y:!1}"
1437
+ placeholdersrc="${(ye=i.placeholder)!=null?ye:!1}"
1387
1438
  ></media-poster-image>
1388
1439
  </slot>
1389
1440
  <mxp-dialog
1390
1441
  no-auto-hide
1391
- open="${(Ae=i.isDialogOpen)!=null?Ae:!1}"
1442
+ open="${(Ee=i.isDialogOpen)!=null?Ee:!1}"
1392
1443
  onclose="${i.onCloseErrorDialog}"
1393
1444
  oninitfocus="${i.onInitFocusDialog}"
1394
1445
  >
1395
- ${(Ee=i.dialog)!=null&&Ee.title?dr`<h3>${i.dialog.title}</h3>`:dr``}
1446
+ ${(be=i.dialog)!=null&&be.title?tr`<h3>${i.dialog.title}</h3>`:tr``}
1396
1447
  <p>
1397
- ${(be=i.dialog)==null?void 0:be.message}
1398
- ${(we=i.dialog)!=null&&we.linkUrl?dr`<a
1448
+ ${(ke=i.dialog)==null?void 0:ke.message}
1449
+ ${(Se=i.dialog)!=null&&Se.linkUrl?tr`<a
1399
1450
  href="${i.dialog.linkUrl}"
1400
1451
  target="_blank"
1401
1452
  rel="external noopener"
1402
- aria-label="${(Se=i.dialog.linkText)!=null?Se:""} ${Re("(opens in a new window)")}"
1403
- >${(Z=i.dialog.linkText)!=null?Z:i.dialog.linkUrl}</a
1404
- >`:dr``}
1453
+ aria-label="${(Z=i.dialog.linkText)!=null?Z:""} ${_e("(opens in a new window)")}"
1454
+ >${(te=i.dialog.linkText)!=null?te:i.dialog.linkUrl}</a
1455
+ >`:tr``}
1405
1456
  </p>
1406
1457
  </mxp-dialog>
1407
1458
  </media-theme>
1408
- `};function Rd(i,e,t,r,s){var o,l,d;let n={},a={};switch(i.code){case tt.MEDIA_ERR_NETWORK:{switch(n.title=Re("Network Error",s),n.message=i.message,(o=i.data)==null?void 0:o.response.code){case 412:{n.title=Re("Video is not currently available",s),n.message=Re("The live stream or video file are not yet ready.",s),a.message=Re("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",s),a.file="412-not-playable.md";break}case 404:{n.title=Re("Video does not exist",s),n.message="",a.message=Re("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",s),a.file="404-not-found.md";break}case 403:{if(n.title=Re("Invalid playback URL",s),n.message=Re("The video URL or playback-token are formatted with incorrect or incomplete information.",s),a.message=Re("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",s),a.file="missing-signed-tokens.md",!r)break;let{exp:c,aud:u,sub:h}=xr(r),f=Date.now()>c*1e3,g=h!==t,E=u!=="v",T={timeStyle:"medium",dateStyle:"medium"};if(f){n.title=Re("Video URL has expired",s),n.message=Re("The video\u2019s secured playback-token has expired.",s),a.message=Re("The video\u2019s secured playback-token has expired.",s),a.context=Re("Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat(hs.code,T).format(c*1e3),currentDate:new Intl.DateTimeFormat(hs.code,T).format(Date.now())}),a.file="403-expired-token.md";break}if(g){n.title=Re("Video URL is formatted incorrectly",s),n.message=Re("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.message=Re("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.context=Re("Specified playback ID: {playbackId} and the playback ID encoded in the playback-token: {tokenPlaybackId}",s).format({playbackId:t,tokenPlaybackId:h}),a.file="403-playback-id-mismatch.md";break}if(E){n.title=Re("Video URL is formatted incorrectly",s),n.message=Re("The playback-token is formatted with incorrect information.",s),a.message=Re("The playback-token is formatted with incorrect information.",s),a.context=Re("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",s).format({tokenType:u}),a.file="403-incorrect-aud-value.md";break}a.message=Re("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",s),a.file="403-malformatted-token.md";break}}break}case tt.MEDIA_ERR_DECODE:{let{message:c}=i;n={title:Re("Media Error",s),message:c},a.file="media-decode-error.md";break}case tt.MEDIA_ERR_SRC_NOT_SUPPORTED:{let c=(d=(l=i.data)==null?void 0:l.response)==null?void 0:d.code;if(c>=400&&c<500){i.code=tt.MEDIA_ERR_NETWORK,i.data={response:{code:c}},{dialog:n,devlog:a}=Rd(i,e,t,r);break}n={title:Re("Source Not Supported",s),message:i.message},a.file="media-src-not-supported.md";break}default:n={title:Re("Error",s),message:i.message};break}return e&&(n={title:Re("Your device appears to be offline",s),message:Re("Check your internet connection and try reloading this video.",s)}),{dialog:n,devlog:a}}var _E=`<template id="media-theme-gerwig">
1459
+ `};function Wd(i,e,t,r,s){var o,l,d;let n={},a={};switch(i.code){case At.MEDIA_ERR_NETWORK:{switch(n.title=_e("Network Error",s),n.message=i.message,(o=i.data)==null?void 0:o.response.code){case 412:{n.title=_e("Video is not currently available",s),n.message=_e("The live stream or video file are not yet ready.",s),a.message=_e("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",s),a.file="412-not-playable.md";break}case 404:{n.title=_e("Video does not exist",s),n.message="",a.message=_e("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",s),a.file="404-not-found.md";break}case 403:{if(n.title=_e("Invalid playback URL",s),n.message=_e("The video URL or playback-token are formatted with incorrect or incomplete information.",s),a.message=_e("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",s),a.file="missing-signed-tokens.md",!r)break;let{exp:c,aud:u,sub:h}=_r(r),f=Date.now()>c*1e3,g=h!==t,E=u!=="v",T={timeStyle:"medium",dateStyle:"medium"};if(f){n.title=_e("Video URL has expired",s),n.message=_e("The video\u2019s secured playback-token has expired.",s),a.message=_e("The video\u2019s secured playback-token has expired.",s),a.context=_e("Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat(hs.code,T).format(c*1e3),currentDate:new Intl.DateTimeFormat(hs.code,T).format(Date.now())}),a.file="403-expired-token.md";break}if(g){n.title=_e("Video URL is formatted incorrectly",s),n.message=_e("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.message=_e("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.context=_e("Specified playback ID: {playbackId} and the playback ID encoded in the playback-token: {tokenPlaybackId}",s).format({playbackId:t,tokenPlaybackId:h}),a.file="403-playback-id-mismatch.md";break}if(E){n.title=_e("Video URL is formatted incorrectly",s),n.message=_e("The playback-token is formatted with incorrect information.",s),a.message=_e("The playback-token is formatted with incorrect information.",s),a.context=_e("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",s).format({tokenType:u}),a.file="403-incorrect-aud-value.md";break}a.message=_e("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",s),a.file="403-malformatted-token.md";break}}break}case At.MEDIA_ERR_DECODE:{let{message:c}=i;n={title:_e("Media Error",s),message:c},a.file="media-decode-error.md";break}case At.MEDIA_ERR_SRC_NOT_SUPPORTED:{let c=(d=(l=i.data)==null?void 0:l.response)==null?void 0:d.code;if(c>=400&&c<500){i.code=At.MEDIA_ERR_NETWORK,i.data={response:{code:c}},{dialog:n,devlog:a}=Wd(i,e,t,r);break}n={title:_e("Source Not Supported",s),message:i.message},a.file="media-src-not-supported.md";break}default:n={title:_e("Error",s),message:i.message};break}return e&&(n={title:_e("Your device appears to be offline",s),message:_e("Check your internet connection and try reloading this video.",s)}),{dialog:n,devlog:a}}var _b=`<template id="media-theme-gerwig">
1409
1460
  <style>
1410
1461
  @keyframes pre-play-hide {
1411
1462
  0% {
@@ -1448,6 +1499,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1448
1499
  }
1449
1500
 
1450
1501
  :host([audio]) {
1502
+ --_secondary-color: var(--media-secondary-color, black);
1451
1503
  --media-preview-time-border-radius: 3px;
1452
1504
  --media-preview-time-margin: 0 0 5px;
1453
1505
  --media-preview-time-text-shadow: none;
@@ -1471,6 +1523,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1471
1523
 
1472
1524
  :host([audio]) media-control-bar {
1473
1525
  width: 100%;
1526
+ background-color: var(--media-control-background);
1474
1527
  }
1475
1528
 
1476
1529
  /*
@@ -1478,10 +1531,11 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1478
1531
  * Borrowed here, so the captions don't move too fast.
1479
1532
  */
1480
1533
  media-controller ::slotted([slot='media']) {
1534
+ --media-webkit-text-track-transform: translateY(0) scale(0.98);
1481
1535
  --media-webkit-text-track-transition: transform 0.433s ease-out 0.3s;
1482
1536
  }
1483
1537
  media-controller:is([mediapaused], :not([userinactive])) ::slotted([slot='media']) {
1484
- --media-webkit-text-track-transform: translateY(-50px);
1538
+ --media-webkit-text-track-transform: translateY(-50px) scale(0.98);
1485
1539
  --media-webkit-text-track-transition: transform 0.15s ease;
1486
1540
  }
1487
1541
 
@@ -1800,7 +1854,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1800
1854
  opacity: 1;
1801
1855
  }
1802
1856
 
1803
- media-loading-indicator[media-loading]:not([media-paused]) ~ div > * {
1857
+ media-loading-indicator[medialoading]:not([mediapaused]) ~ div > * {
1804
1858
  opacity: 0;
1805
1859
  transition-delay: 400ms;
1806
1860
  }
@@ -1888,6 +1942,19 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1888
1942
  media-mute-button[mediavolumelevel='off'] .muted {
1889
1943
  opacity: 1;
1890
1944
  }
1945
+
1946
+ /**
1947
+ * Our defaults for these buttons are to hide them at small sizes
1948
+ * users can override this with CSS
1949
+ */
1950
+ media-controller:not([breakpointsm]):not([audio]) {
1951
+ --bottom-play-button: none;
1952
+ --bottom-seek-backward-button: none;
1953
+ --bottom-seek-forward-button: none;
1954
+ --bottom-time-display: none;
1955
+ --bottom-playback-rate-selectmenu: none;
1956
+ --bottom-pip-button: none;
1957
+ }
1891
1958
  </style>
1892
1959
 
1893
1960
  <template partial="TitleDisplay">
@@ -2049,7 +2116,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2049
2116
  />
2050
2117
  </svg>
2051
2118
  </media-captions-button>
2052
- <media-captions-listbox slot="listbox" part="bottom captions listbox">
2119
+ <media-captions-listbox slot="listbox" exportparts="option" part="bottom captions listbox">
2053
2120
  <div slot="select-indicator">
2054
2121
  <style>
2055
2122
  .listbox-indicator {
@@ -2128,7 +2195,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2128
2195
  d="M16.0072 0H2.0291C0.9185 0 0.0181 0.9003 0.0181 2.011V5.5009C0.357 5.5016 0.6895 5.5275 1.0181 5.5669V2.011C1.0181 1.4536 1.4716 1 2.029 1H16.0072C16.5646 1 17.0181 1.4536 17.0181 2.011V11.9891C17.0181 12.5465 16.5646 13 16.0072 13H8.4358C8.4746 13.3286 8.4999 13.6611 8.4999 13.9999H16.0071C17.1177 13.9999 18.018 13.0996 18.018 11.989V2.011C18.0181 0.9003 17.1178 0 16.0072 0ZM0 6.4999V7.4999C3.584 7.4999 6.5 10.4159 6.5 13.9999H7.5C7.5 9.8642 4.1357 6.4999 0 6.4999ZM0 8.7499V9.7499C2.3433 9.7499 4.25 11.6566 4.25 13.9999H5.25C5.25 11.1049 2.895 8.7499 0 8.7499ZM0.0181 11V14H3.0181C3.0181 12.3431 1.675 11 0.0181 11Z"
2129
2196
  />
2130
2197
  </svg>
2131
- <svg viewBox="0 0 18 14" aria-hidden="true" slot="exist">
2198
+ <svg viewBox="0 0 18 14" aria-hidden="true" slot="exit">
2132
2199
  <path
2133
2200
  d="M15.9891 0H2.01103C0.900434 0 3.35947e-05 0.9003 3.35947e-05 2.011V5.5009C0.338934 5.5016 0.671434 5.5275 1.00003 5.5669V2.011C1.00003 1.4536 1.45353 1 2.01093 1H15.9891C16.5465 1 17 1.4536 17 2.011V11.9891C17 12.5465 16.5465 13 15.9891 13H8.41773C8.45653 13.3286 8.48183 13.6611 8.48183 13.9999H15.989C17.0996 13.9999 17.9999 13.0996 17.9999 11.989V2.011C18 0.9003 17.0997 0 15.9891 0ZM-0.0180664 6.4999V7.4999C3.56593 7.4999 6.48193 10.4159 6.48193 13.9999H7.48193C7.48193 9.8642 4.11763 6.4999 -0.0180664 6.4999ZM-0.0180664 8.7499V9.7499C2.32523 9.7499 4.23193 11.6566 4.23193 13.9999H5.23193C5.23193 11.1049 2.87693 8.7499 -0.0180664 8.7499ZM3.35947e-05 11V14H3.00003C3.00003 12.3431 1.65693 11 3.35947e-05 11Z"
2134
2201
  />
@@ -2145,13 +2212,17 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2145
2212
 
2146
2213
  <template partial="PlaybackRateSelect">
2147
2214
  <media-playback-rate-selectmenu
2148
- rates="{{playbackrates}}"
2149
2215
  part="bottom playback-rate selectmenu"
2150
2216
  disabled="{{disabled}}"
2151
2217
  aria-disabled="{{disabled}}"
2152
2218
  >
2153
2219
  <media-playback-rate-button slot="button" part="bottom playback-rate button"></media-playback-rate-button>
2154
- <media-playback-rate-listbox slot="listbox" part="bottom playback-rate listbox"></media-playback-rate-listbox>
2220
+ <media-playback-rate-listbox
2221
+ slot="listbox"
2222
+ rates="{{playbackrates}}"
2223
+ exportparts="option"
2224
+ part="bottom playback-rate listbox"
2225
+ ></media-playback-rate-listbox>
2155
2226
  </media-playback-rate-selectmenu>
2156
2227
  </template>
2157
2228
 
@@ -2191,7 +2262,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2191
2262
  />
2192
2263
  </svg>
2193
2264
  </media-audio-track-button>
2194
- <media-audio-track-listbox slot="listbox" part="bottom audio-track listbox">
2265
+ <media-audio-track-listbox slot="listbox" exportparts="option" part="bottom audio-track listbox">
2195
2266
  <div slot="select-indicator">
2196
2267
  <style>
2197
2268
  .listbox-indicator {
@@ -2226,7 +2297,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2226
2297
  />
2227
2298
  </svg>
2228
2299
  </media-rendition-button>
2229
- <media-rendition-listbox slot="listbox" part="bottom rendition listbox">
2300
+ <media-rendition-listbox slot="listbox" exportparts="option" part="bottom rendition listbox">
2230
2301
  <div slot="select-indicator">
2231
2302
  <style>
2232
2303
  .listbox-indicator {
@@ -2253,6 +2324,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2253
2324
  </template>
2254
2325
 
2255
2326
  <media-controller
2327
+ part="controller"
2256
2328
  defaultstreamtype="{{defaultstreamtype ?? 'on-demand'}}"
2257
2329
  breakpoints="sm:470"
2258
2330
  gesturesdisabled="{{disabled}}"
@@ -2262,13 +2334,14 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2262
2334
  audio="{{audio}}"
2263
2335
  noautoseektolive="{{noautoseektolive}}"
2264
2336
  defaultsubtitles="{{defaultsubtitles}}"
2337
+ defaultduration="{{defaultduration ?? false}}"
2265
2338
  exportparts="layer, media-layer, poster-layer, vertical-layer, centered-layer, gesture-layer"
2266
2339
  style="--_pre-playback-place:{{preplaybackplace ?? 'center'}}"
2267
2340
  >
2268
2341
  <slot name="media" slot="media"></slot>
2269
2342
  <slot name="poster" slot="poster"></slot>
2270
2343
 
2271
- <media-loading-indicator slot="centered-chrome" no-auto-hide></media-loading-indicator>
2344
+ <media-loading-indicator slot="centered-chrome" noautohide></media-loading-indicator>
2272
2345
 
2273
2346
  <template if="!audio">
2274
2347
  <!-- Pre-playback UI -->
@@ -2317,16 +2390,11 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2317
2390
  </template>
2318
2391
  {{>TimeRange}}
2319
2392
  <media-control-bar part="control-bar bottom">
2320
- <template if="breakpointsm">
2321
- {{>PlayButton}} {{>SeekBackwardButton}} {{>SeekForwardButton}} {{>TimeDisplay}}
2322
- </template>
2323
- {{>MuteButton}} {{>VolumeRange}}
2393
+ {{>PlayButton}} {{>SeekBackwardButton}} {{>SeekForwardButton}} {{>TimeDisplay}} {{>MuteButton}}
2394
+ {{>VolumeRange}}
2324
2395
  <div class="spacer"></div>
2325
- {{>RenditionSelect}}
2326
- <template if="breakpointsm"> {{>PlaybackRateSelect}} </template>
2327
- {{>AudioTrackSelect}} {{>CaptionsMenuButton}} {{>AirplayButton}} {{>CastButton}}
2328
- <template if="breakpointsm"> {{>PipButton}} </template>
2329
- {{>FullscreenButton}}
2396
+ {{>RenditionSelect}} {{>PlaybackRateSelect}} {{>AudioTrackSelect}} {{>CaptionsMenuButton}} {{>AirplayButton}}
2397
+ {{>CastButton}} {{>PipButton}} {{>FullscreenButton}}
2330
2398
  </media-control-bar>
2331
2399
  </template>
2332
2400
 
@@ -2337,15 +2405,12 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2337
2405
  </media-control-bar>
2338
2406
  <template if="targetlivewindow > 0">{{>TimeRange}}</template>
2339
2407
  <media-control-bar part="control-bar bottom">
2340
- <template if="breakpointsm">
2341
- {{>PlayButton}}
2342
- <template if="targetlivewindow > 0"> {{>SeekBackwardButton}} {{>SeekForwardButton}} </template>
2343
- </template>
2408
+ {{>PlayButton}}
2409
+ <template if="targetlivewindow > 0">{{>SeekBackwardButton}} {{>SeekForwardButton}}</template>
2344
2410
  {{>MuteButton}} {{>VolumeRange}}
2345
2411
  <div class="spacer"></div>
2346
2412
  {{>RenditionSelect}} {{>AudioTrackSelect}} {{>CaptionsMenuButton}} {{>AirplayButton}} {{>CastButton}}
2347
- <template if="breakpointsm">{{>PipButton}}</template>
2348
- {{>FullscreenButton}}
2413
+ {{>PipButton}} {{>FullscreenButton}}
2349
2414
  </media-control-bar>
2350
2415
  </template>
2351
2416
  </template>
@@ -2361,7 +2426,6 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2361
2426
  {{>MuteButton}}
2362
2427
  <template if="breakpointsm">{{>VolumeRange}}</template>
2363
2428
  {{>TimeDisplay}} {{>TimeRange}}
2364
- <div class="spacer"></div>
2365
2429
  <template if="breakpointsm">{{>PlaybackRateSelect}}</template>
2366
2430
  {{>AirplayButton}} {{>CastButton}}
2367
2431
  </media-control-bar>
@@ -2377,7 +2441,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2377
2441
  <template if="targetlivewindow > 0"> {{>SeekBackwardButton}} {{>SeekForwardButton}} </template>
2378
2442
  </template>
2379
2443
  <template if="targetlivewindow > 0"> {{>TimeDisplay}} {{>TimeRange}} </template>
2380
- <div class="spacer"></div>
2444
+ <template if="!targetlivewindow"><div class="spacer"></div></template>
2381
2445
  {{>AirplayButton}} {{>CastButton}}
2382
2446
  </media-control-bar>
2383
2447
  </template>
@@ -2386,17 +2450,21 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2386
2450
  <slot></slot>
2387
2451
  </media-controller>
2388
2452
  </template>
2389
- `;var Xf=zt.createElement("template");"innerHTML"in Xf&&(Xf.innerHTML=_E);var AE,SE,wd=class extends wr{};wd.template=(SE=(AE=Xf.content)==null?void 0:AE.children)==null?void 0:SE[0];st.customElements.get("media-theme-gerwig")||st.customElements.define("media-theme-gerwig",wd);var WS="gerwig";var cr={SRC:"src",POSTER:"poster"},J={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-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",STORYBOARD_SRC:"storyboard-src",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",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",NO_VOLUME_PREF:"no-volume-pref"},Qf=["audio","backwardseekoffset","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function qS(i,e){var r;return{src:!i.playbackId&&i.src,playbackId:i.playbackId,hasSrc:!!i.playbackId||!!i.src,poster:i.poster,storyboard:i.storyboard,storyboardSrc:i.getAttribute(J.STORYBOARD_SRC),placeholder:i.getAttribute("placeholder"),themeTemplate:YS(i),thumbnailTime:!i.tokens.thumbnail&&i.thumbnailTime,autoplay:i.autoplay,crossOrigin:i.crossOrigin,loop:i.loop,noHotKeys:i.hasAttribute(J.NOHOTKEYS),hotKeys:i.getAttribute(J.HOTKEYS),muted:i.muted,paused:i.paused,preload:i.preload,envKey:i.envKey,preferCmcd:i.preferCmcd,debug:i.debug,disableCookies:i.disableCookies,tokens:i.tokens,beaconCollectionDomain:i.beaconCollectionDomain,maxResolution:i.maxResolution,minResolution:i.minResolution,renditionOrder:i.renditionOrder,metadata:i.metadata,playerSoftwareName:i.playerSoftwareName,playerSoftwareVersion:i.playerSoftwareVersion,startTime:i.startTime,preferPlayback:i.preferPlayback,audio:i.audio,defaultStreamType:i.defaultStreamType,targetLiveWindow:i.getAttribute(q.TARGET_LIVE_WINDOW),streamType:Ea(i.getAttribute(q.STREAM_TYPE)),primaryColor:i.primaryColor,secondaryColor:i.secondaryColor,accentColor:i.accentColor,forwardSeekOffset:i.forwardSeekOffset,backwardSeekOffset:i.backwardSeekOffset,defaultHiddenCaptions:i.defaultHiddenCaptions,defaultShowRemainingTime:i.defaultShowRemainingTime,hideDuration:jS(i),playbackRates:i.getAttribute(J.PLAYBACK_RATES),customDomain:(r=i.getAttribute(q.CUSTOM_DOMAIN))!=null?r:void 0,title:i.getAttribute(J.TITLE),novolumepref:i.hasAttribute(J.NO_VOLUME_PREF),extraPlaylistParams:{redundant_streams:!0},...e}}function YS(i){var t,r;let e=i.theme;if(e){let s=(r=(t=i.getRootNode())==null?void 0:t.getElementById)==null?void 0:r.call(t,e);if(s&&s instanceof HTMLTemplateElement)return s;e.startsWith("media-theme-")||(e=`media-theme-${e}`);let n=st.customElements.get(e);if(n!=null&&n.template)return n.template}}function jS(i){var t;let e=(t=i.mediaController)==null?void 0:t.querySelector("media-time-display");return e&&getComputedStyle(e).getPropertyValue("--media-duration-display-display").trim()==="none"}function xE(i){let e=i.hasAttribute(J.TITLE)?{video_title:i.getAttribute(J.TITLE)}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,r)=>{let s=i.getAttribute(r);return s!==null&&(t[r.replace(/^metadata-/,"").replace(/-/g,"_")]=s),t},e)}var zS=Object.values(q),XS=Object.values(cr),QS=Object.values(J),ZS=bd(),JS="mux-player",IE={dialog:void 0,isDialogOpen:!1},wa,Da,ur,Ca,Ts,Cr,hn,Dd,LE,Ma,Zf,Mr,fn,Cd,kE,Md,RE,Od,wE,Pd,DE,Ra=class extends Bf{constructor(){super();ut(this,Cr);ut(this,Dd);ut(this,Ma);ut(this,Mr);ut(this,Cd);ut(this,Md);ut(this,Od);ut(this,Pd);ut(this,wa,!1);ut(this,Da,{});ut(this,ur,!0);ut(this,Ca,new Ed(this,"hotkeys"));ut(this,Ts,{...IE,onCloseErrorDialog:()=>Et(this,Ma,Zf).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:t=>{Nf(this,zt.activeElement)||t.preventDefault()}});this.attachShadow({mode:"open"}),Et(this,Dd,LE).call(this),this.isConnected&&Et(this,Cr,hn).call(this)}static get observedAttributes(){var t;return[...(t=Bf.observedAttributes)!=null?t:[],...XS,...zS,...QS]}get mediaTheme(){var t;return(t=this.shadowRoot)==null?void 0:t.querySelector("media-theme")}get mediaController(){var t,r;return(r=(t=this.mediaTheme)==null?void 0:t.shadowRoot)==null?void 0:r.querySelector("media-controller")}connectedCallback(){var r;let t=(r=this.shadowRoot)==null?void 0:r.querySelector("mux-video");t&&(t.metadata=xE(this))}attributeChangedCallback(t,r,s){switch(Et(this,Cr,hn).call(this),super.attributeChangedCallback(t,r,s),t){case J.HOTKEYS:Ne(this,Ca).value=s;break;case J.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&Ir(Re("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case J.THUMBNAIL_TOKEN:{let{aud:a}=xr(s);s&&a!=="t"&&Ir(Re("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:a}));break}case J.STORYBOARD_TOKEN:{let{aud:a}=xr(s);s&&a!=="s"&&Ir(Re("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:a}));break}case q.PLAYBACK_ID:{s!=null&&s.includes("?token")&&xi(Re("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:s}));break}case q.STREAM_TYPE:s&&![Ze.LIVE,Ze.ON_DEMAND,Ze.UNKNOWN].includes(s)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=s.includes("dvr")?Number.POSITIVE_INFINITY:0:Uf({file:"invalid-stream-type.md",message:Re("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):this.targetLiveWindow=s===Ze.LIVE?0:Number.NaN}[q.PLAYBACK_ID,cr.SRC,J.PLAYBACK_TOKEN].includes(t)&&r!==s&&si(this,Ts,{...Ne(this,Ts),...IE}),Et(this,Mr,fn).call(this,{[zv(t)]:s})}get preferCmcd(){var t;return(t=this.getAttribute(q.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?rn.includes(t)?this.setAttribute(q.PREFER_CMCD,t):Ir(`Invalid value for preferCmcd. Must be one of ${rn.join()}`):this.removeAttribute(q.PREFER_CMCD))}get hasPlayed(){var t,r;return(r=(t=this.mediaController)==null?void 0:t.hasAttribute("media-has-played"))!=null?r:!1}get inLiveWindow(){var t;return(t=this.mediaController)==null?void 0:t.hasAttribute("media-time-is-live")}get _hls(){var t;return(t=this.media)==null?void 0:t._hls}get mux(){var t;return(t=this.media)==null?void 0:t.mux}get theme(){var t;return(t=this.getAttribute(J.THEME))!=null?t:WS}set theme(t){this.setAttribute(J.THEME,`${t}`)}get themeProps(){let t=this.mediaTheme;if(!t)return;let r={};for(let s of t.getAttributeNames()){if(Qf.includes(s))continue;let n=t.getAttribute(s);r[vd(s)]=n===""?!0:n}return r}set themeProps(t){var s,n;Et(this,Cr,hn).call(this);let r={...this.themeProps,...t};for(let a in r){if(Qf.includes(a))continue;let o=t==null?void 0:t[a];typeof o=="boolean"||o==null?(s=this.mediaTheme)==null||s.toggleAttribute(gd(a),Boolean(o)):(n=this.mediaTheme)==null||n.setAttribute(gd(a),o)}}get playbackId(){var t;return(t=this.getAttribute(q.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t?this.setAttribute(q.PLAYBACK_ID,t):this.removeAttribute(q.PLAYBACK_ID)}get src(){var t,r;return this.playbackId?(t=un(this,cr.SRC))!=null?t:void 0:(r=this.getAttribute(cr.SRC))!=null?r:void 0}set src(t){t?this.setAttribute(cr.SRC,t):this.removeAttribute(cr.SRC)}get poster(){var r;let t=this.getAttribute(cr.POSTER);if(t!=null)return t;if(this.playbackId&&!this.audio)return Yv(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(r=this.thumbnailTime)!=null?r:this.startTime,token:this.tokens.thumbnail})}set poster(t){t||t===""?this.setAttribute(cr.POSTER,t):this.removeAttribute(cr.POSTER)}get storyboardSrc(){var t;return(t=this.getAttribute(J.STORYBOARD_SRC))!=null?t:void 0}set storyboardSrc(t){t?this.setAttribute(J.STORYBOARD_SRC,t):this.removeAttribute(J.STORYBOARD_SRC)}get storyboard(){if(this.storyboardSrc&&!this.tokens.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[Ze.LIVE,Ze.UNKNOWN].includes(this.streamType)))return jv(this.playbackId,{customDomain:this.customDomain,token:this.tokens.storyboard})}get audio(){return this.hasAttribute(J.AUDIO)}set audio(t){if(!t){this.removeAttribute(J.AUDIO);return}this.setAttribute(J.AUDIO,"")}get hotkeys(){return Ne(this,Ca)}get nohotkeys(){return this.hasAttribute(J.NOHOTKEYS)}set nohotkeys(t){if(!t){this.removeAttribute(J.NOHOTKEYS);return}this.setAttribute(J.NOHOTKEYS,"")}get thumbnailTime(){return nr(this.getAttribute(J.THUMBNAIL_TIME))}set thumbnailTime(t){this.setAttribute(J.THUMBNAIL_TIME,`${t}`)}get title(){var t;return(t=this.getAttribute(J.TITLE))!=null?t:""}set title(t){t!==this.title&&(t?this.setAttribute(J.TITLE,t):this.removeAttribute("title"),super.title=t)}get placeholder(){var t;return(t=un(this,J.PLACEHOLDER))!=null?t:""}set placeholder(t){this.setAttribute(J.PLACEHOLDER,`${t}`)}get primaryColor(){var r,s;let t=this.getAttribute(J.PRIMARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=st.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_primary-color"))==null?void 0:s.trim(),t))return t}set primaryColor(t){this.setAttribute(J.PRIMARY_COLOR,`${t}`)}get secondaryColor(){var r,s;let t=this.getAttribute(J.SECONDARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=st.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_secondary-color"))==null?void 0:s.trim(),t))return t}set secondaryColor(t){this.setAttribute(J.SECONDARY_COLOR,`${t}`)}get accentColor(){var r,s;let t=this.getAttribute(J.ACCENT_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=st.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_accent-color"))==null?void 0:s.trim(),t))return t}set accentColor(t){this.setAttribute(J.ACCENT_COLOR,`${t}`)}get defaultShowRemainingTime(){return this.hasAttribute(J.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(t){t?this.setAttribute(J.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(J.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(!!this.hasAttribute(J.PLAYBACK_RATES))return this.getAttribute(J.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(t=>Number(t)).filter(t=>!Number.isNaN(t)).sort((t,r)=>t-r)}set playbackRates(t){if(!t){this.removeAttribute(J.PLAYBACK_RATES);return}this.setAttribute(J.PLAYBACK_RATES,t.join(" "))}get forwardSeekOffset(){var t;return(t=nr(this.getAttribute(J.FORWARD_SEEK_OFFSET)))!=null?t:10}set forwardSeekOffset(t){this.setAttribute(J.FORWARD_SEEK_OFFSET,`${t}`)}get backwardSeekOffset(){var t;return(t=nr(this.getAttribute(J.BACKWARD_SEEK_OFFSET)))!=null?t:10}set backwardSeekOffset(t){this.setAttribute(J.BACKWARD_SEEK_OFFSET,`${t}`)}get defaultHiddenCaptions(){return this.hasAttribute(J.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(t){t?this.setAttribute(J.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(J.DEFAULT_HIDDEN_CAPTIONS)}get playerSoftwareName(){var t;return(t=this.getAttribute(q.PLAYER_SOFTWARE_NAME))!=null?t:JS}get playerSoftwareVersion(){var t;return(t=this.getAttribute(q.PLAYER_SOFTWARE_VERSION))!=null?t:ZS}get beaconCollectionDomain(){var t;return(t=this.getAttribute(q.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(q.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(q.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var t;return(t=this.getAttribute(q.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(q.MAX_RESOLUTION,t):this.removeAttribute(q.MAX_RESOLUTION))}get minResolution(){var t;return(t=this.getAttribute(q.MIN_RESOLUTION))!=null?t:void 0}set minResolution(t){t!==this.minResolution&&(t?this.setAttribute(q.MIN_RESOLUTION,t):this.removeAttribute(q.MIN_RESOLUTION))}get renditionOrder(){var t;return(t=this.getAttribute(q.RENDITION_ORDER))!=null?t:void 0}set renditionOrder(t){t!==this.renditionOrder&&(t?this.setAttribute(q.RENDITION_ORDER,t):this.removeAttribute(q.RENDITION_ORDER))}get customDomain(){var t;return(t=this.getAttribute(q.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(q.CUSTOM_DOMAIN,t):this.removeAttribute(q.CUSTOM_DOMAIN))}get envKey(){var t;return(t=un(this,q.ENV_KEY))!=null?t:void 0}set envKey(t){this.setAttribute(q.ENV_KEY,`${t}`)}get noVolumePref(){return this.hasAttribute(J.NO_VOLUME_PREF)}set noVolumePref(t){t?this.setAttribute(J.NO_VOLUME_PREF,""):this.removeAttribute(J.NO_VOLUME_PREF)}get debug(){return un(this,q.DEBUG)!=null}set debug(t){t?this.setAttribute(q.DEBUG,""):this.removeAttribute(q.DEBUG)}get disableCookies(){return un(this,q.DISABLE_COOKIES)!=null}set disableCookies(t){t?this.setAttribute(q.DISABLE_COOKIES,""):this.removeAttribute(q.DISABLE_COOKIES)}get streamType(){var t,r,s;return(s=(r=this.getAttribute(q.STREAM_TYPE))!=null?r:(t=this.media)==null?void 0:t.streamType)!=null?s:Ze.UNKNOWN}set streamType(t){this.setAttribute(q.STREAM_TYPE,`${t}`)}get defaultStreamType(){var t,r,s;return(s=(r=this.getAttribute(J.DEFAULT_STREAM_TYPE))!=null?r:(t=this.mediaController)==null?void 0:t.getAttribute(J.DEFAULT_STREAM_TYPE))!=null?s:Ze.ON_DEMAND}set defaultStreamType(t){t?this.setAttribute(J.DEFAULT_STREAM_TYPE,t):this.removeAttribute(J.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var t,r;return this.hasAttribute(J.TARGET_LIVE_WINDOW)?+this.getAttribute(J.TARGET_LIVE_WINDOW):(r=(t=this.media)==null?void 0:t.targetLiveWindow)!=null?r:Number.NaN}set targetLiveWindow(t){t!=this.targetLiveWindow&&(t==null?this.removeAttribute(J.TARGET_LIVE_WINDOW):this.setAttribute(J.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t;return(t=this.media)==null?void 0:t.liveEdgeStart}get startTime(){return nr(un(this,q.START_TIME))}set startTime(t){this.setAttribute(q.START_TIME,`${t}`)}get preferPlayback(){let t=this.getAttribute(q.PREFER_PLAYBACK);if(t===ui.MSE||t===ui.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===ui.MSE||t===ui.NATIVE?this.setAttribute(q.PREFER_PLAYBACK,t):this.removeAttribute(q.PREFER_PLAYBACK))}get metadata(){var t;return(t=this.media)==null?void 0:t.metadata}set metadata(t){if(Et(this,Cr,hn).call(this),!this.media){xi("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...xE(this),...t}}async addCuePoints(t){var r;if(Et(this,Cr,hn).call(this),!this.media){xi("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(r=this.media)==null?void 0:r.addCuePoints(t)}get activeCuePoint(){var t;return(t=this.media)==null?void 0:t.activeCuePoint}get cuePoints(){var t,r;return(r=(t=this.media)==null?void 0:t.cuePoints)!=null?r:[]}getStartDate(){var t;return(t=this.media)==null?void 0:t.getStartDate()}get currentPdt(){var t;return(t=this.media)==null?void 0:t.currentPdt}get tokens(){let t=this.getAttribute(J.PLAYBACK_TOKEN),r=this.getAttribute(J.THUMBNAIL_TOKEN),s=this.getAttribute(J.STORYBOARD_TOKEN);return{...Ne(this,Da),...t!=null?{playback:t}:{},...r!=null?{thumbnail:r}:{},...s!=null?{storyboard:s}:{}}}set tokens(t){si(this,Da,t!=null?t:{})}get playbackToken(){var t;return(t=this.getAttribute(J.PLAYBACK_TOKEN))!=null?t:void 0}set playbackToken(t){this.setAttribute(J.PLAYBACK_TOKEN,`${t}`)}get thumbnailToken(){var t;return(t=this.getAttribute(J.THUMBNAIL_TOKEN))!=null?t:void 0}set thumbnailToken(t){this.setAttribute(J.THUMBNAIL_TOKEN,`${t}`)}get storyboardToken(){var t;return(t=this.getAttribute(J.STORYBOARD_TOKEN))!=null?t:void 0}set storyboardToken(t){this.setAttribute(J.STORYBOARD_TOKEN,`${t}`)}addTextTrack(t,r,s,n){var o;let a=(o=this.media)==null?void 0:o.nativeEl;if(!!a)return id(a,t,r,s,n)}removeTextTrack(t){var s;let r=(s=this.media)==null?void 0:s.nativeEl;if(!!r)return gv(r,t)}get textTracks(){var t;return(t=this.media)==null?void 0:t.textTracks}};wa=new WeakMap,Da=new WeakMap,ur=new WeakMap,Ca=new WeakMap,Ts=new WeakMap,Cr=new WeakSet,hn=function(){var t,r,s;if(!Ne(this,wa)){si(this,wa,!0),Et(this,Mr,fn).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof st.HTMLElement))throw""}catch{xi("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof Vv))throw""}catch{xi("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof oc))throw""}catch{xi("<media-controller> failed to upgrade!")}Jv(this),Et(this,Cd,kE).call(this),Et(this,Md,RE).call(this),Et(this,Od,wE).call(this),si(this,ur,(r=(t=this.mediaController)==null?void 0:t.hasAttribute("userinactive"))!=null?r:!0),Et(this,Pd,DE).call(this),(s=this.media)==null||s.addEventListener("streamtypechange",()=>{Et(this,Mr,fn).call(this)})}},Dd=new WeakSet,LE=function(){var t,r;try{(t=window==null?void 0:window.CSS)==null||t.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(r=window==null?void 0:window.CSS)==null||r.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},Ma=new WeakSet,Zf=function(t){Object.assign(Ne(this,Ts),t),Et(this,Mr,fn).call(this)},Mr=new WeakSet,fn=function(t={}){yE(TE(qS(this,{...Ne(this,Ts),...t})),this.shadowRoot)},Cd=new WeakSet,kE=function(){let t=s=>{var o,l;if(!(s!=null&&s.startsWith("theme-")))return;let n=s.replace(/^theme-/,"");if(Qf.includes(n))return;let a=this.getAttribute(s);a!=null?(o=this.mediaTheme)==null||o.setAttribute(n,a):(l=this.mediaTheme)==null||l.removeAttribute(n)};new MutationObserver(s=>{for(let{attributeName:n}of s)t(n)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(t)},Md=new WeakSet,RE=function(){var r;let t=s=>{let{detail:n}=s;if(n instanceof tt||(n=new tt(n.message,n.code,n.fatal)),!(n!=null&&n.fatal)){Ir(n),n.data&&Ir(`${n.name} data:`,n.data);return}let{dialog:a,devlog:o}=Rd(n,!window.navigator.onLine,this.playbackId,this.playbackToken);o.message&&Uf(o),xi(n),n.data&&xi(`${n.name} data:`,n.data),Et(this,Ma,Zf).call(this,{isDialogOpen:!0,dialog:a})};this.addEventListener("error",t),this.media&&(this.media.errorTranslator=(s={})=>{var a,o,l;if(!(((a=this.media)==null?void 0:a.error)instanceof tt))return s;let{devlog:n}=Rd((o=this.media)==null?void 0:o.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(l=this.media)==null?void 0:l.error.code,player_error_message:n.message?String(n.message):s.player_error_message,player_error_context:n.context?String(n.context):s.player_error_context}}),(r=this.media)==null||r.addEventListener("error",s=>{var a,o;let{detail:n}=s;if(!n){let{message:l,code:d}=(o=(a=this.media)==null?void 0:a.error)!=null?o:{};n=new tt(l,d)}!(n!=null&&n.fatal)||this.dispatchEvent(new CustomEvent("error",{detail:n}))})},Od=new WeakSet,wE=function(){var r,s,n,a;let t=()=>Et(this,Mr,fn).call(this);(s=(r=this.media)==null?void 0:r.textTracks)==null||s.addEventListener("addtrack",t),(a=(n=this.media)==null?void 0:n.textTracks)==null||a.addEventListener("removetrack",t)},Pd=new WeakSet,DE=function(){var c,u;let t=/.*Version\/.*Safari\/.*/.test(navigator.userAgent);if(!/Firefox/i.test(navigator.userAgent))return;let s,n=new WeakMap,a=()=>this.streamType===Ze.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,o=(h,f,g=!1)=>{if(a())return;Array.from(h&&h.activeCues||[]).forEach(T=>{if(!(!T.snapToLines||T.line<-5||T.line>=0&&T.line<10))if(!f||this.paused){let A=T.text.split(`
2390
- `).length,k=t?-2:-3;this.streamType===Ze.LIVE&&(k=t?-1:-2);let L=k-A;if(T.line===L&&!g)return;n.has(T)||n.set(T,T.line),T.line=L-1,T.line=L}else setTimeout(()=>{T.line=n.get(T)||"auto"},500)})},l=()=>{var h,f;o(s,(f=(h=this.mediaController)==null?void 0:h.hasAttribute("userinactive"))!=null?f:!1)},d=()=>{var g,E;let f=Array.from(((E=(g=this.mediaController)==null?void 0:g.media)==null?void 0:E.textTracks)||[]).filter(T=>["subtitles","captions"].includes(T.kind)&&T.mode==="showing")[0];f!==s&&(s==null||s.removeEventListener("cuechange",l)),s=f,s==null||s.addEventListener("cuechange",l),o(s,Ne(this,ur))};if(d(),(c=this.textTracks)==null||c.addEventListener("change",d),(u=this.textTracks)==null||u.addEventListener("addtrack",d),navigator.userAgent.includes("Chrome/")){let h=()=>{o(s,Ne(this,ur),!0),this.paused||window.requestAnimationFrame(h)};this.addEventListener("playing",()=>{h()})}this.addEventListener("userinactivechange",()=>{var f,g;let h=(g=(f=this.mediaController)==null?void 0:f.hasAttribute("userinactive"))!=null?g:!0;Ne(this,ur)!==h&&(si(this,ur,h),o(s,Ne(this,ur)))})};function un(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}st.customElements.get("mux-player")||(st.customElements.define("mux-player",Ra),st.MuxPlayerElement=Ra);var MC=Ra;export{tt as MediaError,MC as default,un as getVideoAttribute};
2391
- /*!
2392
- * JavaScript Cookie v2.1.3
2393
- * https://github.com/js-cookie/js-cookie
2394
- *
2395
- * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
2396
- * Released under the MIT license
2397
- */
2398
- /*!
2399
- * mux-embed
2400
- * @version 4.27.0
2401
- * @copyright 2023 Mux, Inc
2402
- */
2453
+ `;var km=Yt.createElement("template");"innerHTML"in km&&(km.innerHTML=_b);var Ab,Sb,qd=class extends Lr{};qd.template=(Sb=(Ab=km.content)==null?void 0:Ab.children)==null?void 0:Sb[0];Xe.customElements.get("media-theme-gerwig")||Xe.customElements.define("media-theme-gerwig",qd);var uI="gerwig";var ir={SRC:"src",POSTER:"poster"},j={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-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",STORYBOARD_SRC:"storyboard-src",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",DEFAULT_DURATION:"default-duration",TITLE:"title",PLACEHOLDER:"placeholder",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",EXTRA_SOURCE_PARAMS:"extra-source-params",NO_VOLUME_PREF:"no-volume-pref"},wm=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function hI(i,e){var r;return{src:!i.playbackId&&i.src,playbackId:i.playbackId,hasSrc:!!i.playbackId||!!i.src,poster:i.poster,storyboard:i.storyboard,storyboardSrc:i.getAttribute(j.STORYBOARD_SRC),placeholder:i.getAttribute("placeholder"),themeTemplate:fI(i),thumbnailTime:!i.tokens.thumbnail&&i.thumbnailTime,autoplay:i.autoplay,crossOrigin:i.crossOrigin,loop:i.loop,noHotKeys:i.hasAttribute(j.NOHOTKEYS),hotKeys:i.getAttribute(j.HOTKEYS),muted:i.muted,paused:i.paused,preload:i.preload,envKey:i.envKey,preferCmcd:i.preferCmcd,debug:i.debug,disableCookies:i.disableCookies,tokens:i.tokens,beaconCollectionDomain:i.beaconCollectionDomain,maxResolution:i.maxResolution,minResolution:i.minResolution,renditionOrder:i.renditionOrder,metadata:i.metadata,playerSoftwareName:i.playerSoftwareName,playerSoftwareVersion:i.playerSoftwareVersion,startTime:i.startTime,preferPlayback:i.preferPlayback,audio:i.audio,defaultStreamType:i.defaultStreamType,targetLiveWindow:i.getAttribute(K.TARGET_LIVE_WINDOW),streamType:Ia(i.getAttribute(K.STREAM_TYPE)),primaryColor:i.getAttribute(j.PRIMARY_COLOR),secondaryColor:i.getAttribute(j.SECONDARY_COLOR),accentColor:i.getAttribute(j.ACCENT_COLOR),forwardSeekOffset:i.forwardSeekOffset,backwardSeekOffset:i.backwardSeekOffset,defaultHiddenCaptions:i.defaultHiddenCaptions,defaultDuration:i.defaultDuration,defaultShowRemainingTime:i.defaultShowRemainingTime,hideDuration:mI(i),playbackRates:i.getAttribute(j.PLAYBACK_RATES),customDomain:(r=i.getAttribute(K.CUSTOM_DOMAIN))!=null?r:void 0,title:i.getAttribute(j.TITLE),novolumepref:i.hasAttribute(j.NO_VOLUME_PREF),...e,extraSourceParams:i.extraSourceParams}}function fI(i){var t,r;let e=i.theme;if(e){let s=(r=(t=i.getRootNode())==null?void 0:t.getElementById)==null?void 0:r.call(t,e);if(s&&s instanceof HTMLTemplateElement)return s;e.startsWith("media-theme-")||(e=`media-theme-${e}`);let n=Xe.customElements.get(e);if(n!=null&&n.template)return n.template}}function mI(i){var t;let e=(t=i.mediaController)==null?void 0:t.querySelector("media-time-display");return e&&getComputedStyle(e).getPropertyValue("--media-duration-display-display").trim()==="none"}function xb(i){let e=i.hasAttribute(j.TITLE)?{video_title:i.getAttribute(j.TITLE)}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,r)=>{let s=i.getAttribute(r);return s!==null&&(t[r.replace(/^metadata-/,"").replace(/-/g,"_")]=s),t},e)}var pI=Object.values(K),gI=Object.values(ir),vI=Object.values(j),EI=Od(),bI="mux-player",Ib={dialog:void 0,isDialogOpen:!1},yI={redundant_streams:!0},Ua,Fa,kr,Ba,_s,rr,Ts,Yd,Lb,$a,Dm,wr,En,jd,Rb,zd,kb,Xd,wb,Qd,Db,Na=class extends vm{constructor(){super();nt(this,rr);nt(this,Yd);nt(this,$a);nt(this,wr);nt(this,jd);nt(this,zd);nt(this,Xd);nt(this,Qd);nt(this,Ua,!1);nt(this,Fa,{});nt(this,kr,!0);nt(this,Ba,new Pd(this,"hotkeys"));nt(this,_s,{...Ib,onCloseErrorDialog:()=>ot(this,$a,Dm).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:t=>{mm(this,Yt.activeElement)||t.preventDefault()}});this.attachShadow({mode:"open"}),ot(this,Yd,Lb).call(this),this.isConnected&&ot(this,rr,Ts).call(this)}static get observedAttributes(){var t;return[...(t=vm.observedAttributes)!=null?t:[],...gI,...pI,...vI]}get mediaTheme(){var t;return(t=this.shadowRoot)==null?void 0:t.querySelector("media-theme")}get mediaController(){var t,r;return(r=(t=this.mediaTheme)==null?void 0:t.shadowRoot)==null?void 0:r.querySelector("media-controller")}connectedCallback(){var r;let t=(r=this.shadowRoot)==null?void 0:r.querySelector("mux-video");t&&(t.metadata=xb(this))}attributeChangedCallback(t,r,s){switch(ot(this,rr,Ts).call(this),super.attributeChangedCallback(t,r,s),t){case j.HOTKEYS:Pe(this,Ba).value=s;break;case j.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&Ar(_e("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case j.THUMBNAIL_TOKEN:{let{aud:a}=_r(s);s&&a!=="t"&&Ar(_e("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:a}));break}case j.STORYBOARD_TOKEN:{let{aud:a}=_r(s);s&&a!=="s"&&Ar(_e("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:a}));break}case K.PLAYBACK_ID:{s!=null&&s.includes("?token")&&ci(_e("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:s}));break}case K.STREAM_TYPE:s&&![qe.LIVE,qe.ON_DEMAND,qe.UNKNOWN].includes(s)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=s.includes("dvr")?Number.POSITIVE_INFINITY:0:pm({file:"invalid-stream-type.md",message:_e("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):this.targetLiveWindow=s===qe.LIVE?0:Number.NaN}[K.PLAYBACK_ID,ir.SRC,j.PLAYBACK_TOKEN].includes(t)&&r!==s&&ti(this,_s,{...Pe(this,_s),...Ib}),ot(this,wr,En).call(this,{[zE(t)]:s})}get preferCmcd(){var t;return(t=this.getAttribute(K.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?on.includes(t)?this.setAttribute(K.PREFER_CMCD,t):Ar(`Invalid value for preferCmcd. Must be one of ${on.join()}`):this.removeAttribute(K.PREFER_CMCD))}get hasPlayed(){var t,r;return(r=(t=this.mediaController)==null?void 0:t.hasAttribute(S.MEDIA_HAS_PLAYED))!=null?r:!1}get inLiveWindow(){var t;return(t=this.mediaController)==null?void 0:t.hasAttribute(S.MEDIA_TIME_IS_LIVE)}get _hls(){var t;return(t=this.media)==null?void 0:t._hls}get mux(){var t;return(t=this.media)==null?void 0:t.mux}get theme(){var t;return(t=this.getAttribute(j.THEME))!=null?t:uI}set theme(t){this.setAttribute(j.THEME,`${t}`)}get themeProps(){let t=this.mediaTheme;if(!t)return;let r={};for(let s of t.getAttributeNames()){if(wm.includes(s))continue;let n=t.getAttribute(s);r[Md(s)]=n===""?!0:n}return r}set themeProps(t){var s,n;ot(this,rr,Ts).call(this);let r={...this.themeProps,...t};for(let a in r){if(wm.includes(a))continue;let o=t==null?void 0:t[a];typeof o=="boolean"||o==null?(s=this.mediaTheme)==null||s.toggleAttribute(Cd(a),!!o):(n=this.mediaTheme)==null||n.setAttribute(Cd(a),o)}}get playbackId(){var t;return(t=this.getAttribute(K.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t?this.setAttribute(K.PLAYBACK_ID,t):this.removeAttribute(K.PLAYBACK_ID)}get src(){var t,r;return this.playbackId?(t=vn(this,ir.SRC))!=null?t:void 0:(r=this.getAttribute(ir.SRC))!=null?r:void 0}set src(t){t?this.setAttribute(ir.SRC,t):this.removeAttribute(ir.SRC)}get poster(){var r;let t=this.getAttribute(ir.POSTER);if(t!=null)return t;if(this.playbackId&&!this.audio)return YE(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(r=this.thumbnailTime)!=null?r:this.startTime,token:this.tokens.thumbnail})}set poster(t){t||t===""?this.setAttribute(ir.POSTER,t):this.removeAttribute(ir.POSTER)}get storyboardSrc(){var t;return(t=this.getAttribute(j.STORYBOARD_SRC))!=null?t:void 0}set storyboardSrc(t){t?this.setAttribute(j.STORYBOARD_SRC,t):this.removeAttribute(j.STORYBOARD_SRC)}get storyboard(){if(this.storyboardSrc&&!this.tokens.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[qe.LIVE,qe.UNKNOWN].includes(this.streamType)))return jE(this.playbackId,{customDomain:this.customDomain,token:this.tokens.storyboard})}get audio(){return this.hasAttribute(j.AUDIO)}set audio(t){if(!t){this.removeAttribute(j.AUDIO);return}this.setAttribute(j.AUDIO,"")}get hotkeys(){return Pe(this,Ba)}get nohotkeys(){return this.hasAttribute(j.NOHOTKEYS)}set nohotkeys(t){if(!t){this.removeAttribute(j.NOHOTKEYS);return}this.setAttribute(j.NOHOTKEYS,"")}get thumbnailTime(){return Vi(this.getAttribute(j.THUMBNAIL_TIME))}set thumbnailTime(t){this.setAttribute(j.THUMBNAIL_TIME,`${t}`)}get title(){var t;return(t=this.getAttribute(j.TITLE))!=null?t:""}set title(t){t!==this.title&&(t?this.setAttribute(j.TITLE,t):this.removeAttribute("title"),super.title=t)}get placeholder(){var t;return(t=vn(this,j.PLACEHOLDER))!=null?t:""}set placeholder(t){this.setAttribute(j.PLACEHOLDER,`${t}`)}get primaryColor(){var r,s;let t=this.getAttribute(j.PRIMARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Xe.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_primary-color"))==null?void 0:s.trim(),t))return t}set primaryColor(t){this.setAttribute(j.PRIMARY_COLOR,`${t}`)}get secondaryColor(){var r,s;let t=this.getAttribute(j.SECONDARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Xe.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_secondary-color"))==null?void 0:s.trim(),t))return t}set secondaryColor(t){this.setAttribute(j.SECONDARY_COLOR,`${t}`)}get accentColor(){var r,s;let t=this.getAttribute(j.ACCENT_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=Xe.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_accent-color"))==null?void 0:s.trim(),t))return t}set accentColor(t){this.setAttribute(j.ACCENT_COLOR,`${t}`)}get defaultShowRemainingTime(){return this.hasAttribute(j.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(t){t?this.setAttribute(j.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(j.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute(j.PLAYBACK_RATES))return this.getAttribute(j.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(t=>Number(t)).filter(t=>!Number.isNaN(t)).sort((t,r)=>t-r)}set playbackRates(t){if(!t){this.removeAttribute(j.PLAYBACK_RATES);return}this.setAttribute(j.PLAYBACK_RATES,t.join(" "))}get forwardSeekOffset(){var t;return(t=Vi(this.getAttribute(j.FORWARD_SEEK_OFFSET)))!=null?t:10}set forwardSeekOffset(t){this.setAttribute(j.FORWARD_SEEK_OFFSET,`${t}`)}get backwardSeekOffset(){var t;return(t=Vi(this.getAttribute(j.BACKWARD_SEEK_OFFSET)))!=null?t:10}set backwardSeekOffset(t){this.setAttribute(j.BACKWARD_SEEK_OFFSET,`${t}`)}get defaultHiddenCaptions(){return this.hasAttribute(j.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(t){t?this.setAttribute(j.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(j.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return Vi(this.getAttribute(j.DEFAULT_DURATION))}set defaultDuration(t){t==null?this.removeAttribute(j.DEFAULT_DURATION):this.setAttribute(j.DEFAULT_DURATION,`${t}`)}get playerSoftwareName(){var t;return(t=this.getAttribute(K.PLAYER_SOFTWARE_NAME))!=null?t:bI}get playerSoftwareVersion(){var t;return(t=this.getAttribute(K.PLAYER_SOFTWARE_VERSION))!=null?t:EI}get beaconCollectionDomain(){var t;return(t=this.getAttribute(K.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(K.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(K.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var t;return(t=this.getAttribute(K.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(K.MAX_RESOLUTION,t):this.removeAttribute(K.MAX_RESOLUTION))}get minResolution(){var t;return(t=this.getAttribute(K.MIN_RESOLUTION))!=null?t:void 0}set minResolution(t){t!==this.minResolution&&(t?this.setAttribute(K.MIN_RESOLUTION,t):this.removeAttribute(K.MIN_RESOLUTION))}get renditionOrder(){var t;return(t=this.getAttribute(K.RENDITION_ORDER))!=null?t:void 0}set renditionOrder(t){t!==this.renditionOrder&&(t?this.setAttribute(K.RENDITION_ORDER,t):this.removeAttribute(K.RENDITION_ORDER))}get extraSourceParams(){return this.hasAttribute(j.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute(j.EXTRA_SOURCE_PARAMS)).entries()].reduce((t,[r,s])=>(t[r]=s,t),{}):yI}set extraSourceParams(t){t==null?this.removeAttribute(j.EXTRA_SOURCE_PARAMS):this.setAttribute(j.EXTRA_SOURCE_PARAMS,new URLSearchParams(t).toString())}get customDomain(){var t;return(t=this.getAttribute(K.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(K.CUSTOM_DOMAIN,t):this.removeAttribute(K.CUSTOM_DOMAIN))}get envKey(){var t;return(t=vn(this,K.ENV_KEY))!=null?t:void 0}set envKey(t){this.setAttribute(K.ENV_KEY,`${t}`)}get noVolumePref(){return this.hasAttribute(j.NO_VOLUME_PREF)}set noVolumePref(t){t?this.setAttribute(j.NO_VOLUME_PREF,""):this.removeAttribute(j.NO_VOLUME_PREF)}get debug(){return vn(this,K.DEBUG)!=null}set debug(t){t?this.setAttribute(K.DEBUG,""):this.removeAttribute(K.DEBUG)}get disableCookies(){return vn(this,K.DISABLE_COOKIES)!=null}set disableCookies(t){t?this.setAttribute(K.DISABLE_COOKIES,""):this.removeAttribute(K.DISABLE_COOKIES)}get streamType(){var t,r,s;return(s=(r=this.getAttribute(K.STREAM_TYPE))!=null?r:(t=this.media)==null?void 0:t.streamType)!=null?s:qe.UNKNOWN}set streamType(t){this.setAttribute(K.STREAM_TYPE,`${t}`)}get defaultStreamType(){var t,r,s;return(s=(r=this.getAttribute(j.DEFAULT_STREAM_TYPE))!=null?r:(t=this.mediaController)==null?void 0:t.getAttribute(j.DEFAULT_STREAM_TYPE))!=null?s:qe.ON_DEMAND}set defaultStreamType(t){t?this.setAttribute(j.DEFAULT_STREAM_TYPE,t):this.removeAttribute(j.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var t,r;return this.hasAttribute(j.TARGET_LIVE_WINDOW)?+this.getAttribute(j.TARGET_LIVE_WINDOW):(r=(t=this.media)==null?void 0:t.targetLiveWindow)!=null?r:Number.NaN}set targetLiveWindow(t){t!=this.targetLiveWindow&&(t==null?this.removeAttribute(j.TARGET_LIVE_WINDOW):this.setAttribute(j.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t;return(t=this.media)==null?void 0:t.liveEdgeStart}get startTime(){return Vi(vn(this,K.START_TIME))}set startTime(t){this.setAttribute(K.START_TIME,`${t}`)}get preferPlayback(){let t=this.getAttribute(K.PREFER_PLAYBACK);if(t===li.MSE||t===li.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===li.MSE||t===li.NATIVE?this.setAttribute(K.PREFER_PLAYBACK,t):this.removeAttribute(K.PREFER_PLAYBACK))}get metadata(){var t;return(t=this.media)==null?void 0:t.metadata}set metadata(t){if(ot(this,rr,Ts).call(this),!this.media){ci("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...xb(this),...t}}get _hlsConfig(){var t;return(t=this.media)==null?void 0:t._hlsConfig}set _hlsConfig(t){if(ot(this,rr,Ts).call(this),!this.media){ci("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.");return}this.media._hlsConfig=t}async addCuePoints(t){var r;if(ot(this,rr,Ts).call(this),!this.media){ci("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(r=this.media)==null?void 0:r.addCuePoints(t)}get activeCuePoint(){var t;return(t=this.media)==null?void 0:t.activeCuePoint}get cuePoints(){var t,r;return(r=(t=this.media)==null?void 0:t.cuePoints)!=null?r:[]}getStartDate(){var t;return(t=this.media)==null?void 0:t.getStartDate()}get currentPdt(){var t;return(t=this.media)==null?void 0:t.currentPdt}get tokens(){let t=this.getAttribute(j.PLAYBACK_TOKEN),r=this.getAttribute(j.THUMBNAIL_TOKEN),s=this.getAttribute(j.STORYBOARD_TOKEN);return{...Pe(this,Fa),...t!=null?{playback:t}:{},...r!=null?{thumbnail:r}:{},...s!=null?{storyboard:s}:{}}}set tokens(t){ti(this,Fa,t!=null?t:{})}get playbackToken(){var t;return(t=this.getAttribute(j.PLAYBACK_TOKEN))!=null?t:void 0}set playbackToken(t){this.setAttribute(j.PLAYBACK_TOKEN,`${t}`)}get thumbnailToken(){var t;return(t=this.getAttribute(j.THUMBNAIL_TOKEN))!=null?t:void 0}set thumbnailToken(t){this.setAttribute(j.THUMBNAIL_TOKEN,`${t}`)}get storyboardToken(){var t;return(t=this.getAttribute(j.STORYBOARD_TOKEN))!=null?t:void 0}set storyboardToken(t){this.setAttribute(j.STORYBOARD_TOKEN,`${t}`)}addTextTrack(t,r,s,n){var o;let a=(o=this.media)==null?void 0:o.nativeEl;if(a)return fd(a,t,r,s,n)}removeTextTrack(t){var s;let r=(s=this.media)==null?void 0:s.nativeEl;if(r)return lE(r,t)}get textTracks(){var t;return(t=this.media)==null?void 0:t.textTracks}};Ua=new WeakMap,Fa=new WeakMap,kr=new WeakMap,Ba=new WeakMap,_s=new WeakMap,rr=new WeakSet,Ts=function(){var t,r,s;if(!Pe(this,Ua)){ti(this,Ua,!0),ot(this,wr,En).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof Xe.HTMLElement))throw""}catch{ci("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof VE))throw""}catch{ci("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof wc))throw""}catch{ci("<media-controller> failed to upgrade!")}JE(this),ot(this,jd,Rb).call(this),ot(this,zd,kb).call(this),ot(this,Xd,wb).call(this),ti(this,kr,(r=(t=this.mediaController)==null?void 0:t.hasAttribute(Le.USER_INACTIVE))!=null?r:!0),ot(this,Qd,Db).call(this),(s=this.media)==null||s.addEventListener("streamtypechange",()=>{ot(this,wr,En).call(this)})}},Yd=new WeakSet,Lb=function(){var t,r;try{(t=window==null?void 0:window.CSS)==null||t.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(r=window==null?void 0:window.CSS)==null||r.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},$a=new WeakSet,Dm=function(t){Object.assign(Pe(this,_s),t),ot(this,wr,En).call(this)},wr=new WeakSet,En=function(t={}){yb(Tb(hI(this,{...Pe(this,_s),...t})),this.shadowRoot)},jd=new WeakSet,Rb=function(){let t=s=>{var o,l;if(!(s!=null&&s.startsWith("theme-")))return;let n=s.replace(/^theme-/,"");if(wm.includes(n))return;let a=this.getAttribute(s);a!=null?(o=this.mediaTheme)==null||o.setAttribute(n,a):(l=this.mediaTheme)==null||l.removeAttribute(n)};new MutationObserver(s=>{for(let{attributeName:n}of s)t(n)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(t)},zd=new WeakSet,kb=function(){var r;let t=s=>{let{detail:n}=s;if(n instanceof At||(n=new At(n.message,n.code,n.fatal)),!(n!=null&&n.fatal)){Ar(n),n.data&&Ar(`${n.name} data:`,n.data);return}let{dialog:a,devlog:o}=Wd(n,!window.navigator.onLine,this.playbackId,this.playbackToken);o.message&&pm(o),ci(n),n.data&&ci(`${n.name} data:`,n.data),ot(this,$a,Dm).call(this,{isDialogOpen:!0,dialog:a})};this.addEventListener("error",t),this.media&&(this.media.errorTranslator=(s={})=>{var a,o,l;if(!(((a=this.media)==null?void 0:a.error)instanceof At))return s;let{devlog:n}=Wd((o=this.media)==null?void 0:o.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(l=this.media)==null?void 0:l.error.code,player_error_message:n.message?String(n.message):s.player_error_message,player_error_context:n.context?String(n.context):s.player_error_context}}),(r=this.media)==null||r.addEventListener("error",s=>{var a,o;let{detail:n}=s;if(!n){let{message:l,code:d}=(o=(a=this.media)==null?void 0:a.error)!=null?o:{};n=new At(l,d)}n!=null&&n.fatal&&this.dispatchEvent(new CustomEvent("error",{detail:n}))})},Xd=new WeakSet,wb=function(){var r,s,n,a;let t=()=>ot(this,wr,En).call(this);(s=(r=this.media)==null?void 0:r.textTracks)==null||s.addEventListener("addtrack",t),(a=(n=this.media)==null?void 0:n.textTracks)==null||a.addEventListener("removetrack",t)},Qd=new WeakSet,Db=function(){var d,c;if(!/Firefox/i.test(navigator.userAgent))return;let r,s=new WeakMap,n=()=>this.streamType===qe.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,a=(u,h,f=!1)=>{if(n())return;Array.from(u&&u.activeCues||[]).forEach(E=>{if(!(!E.snapToLines||E.line<-5||E.line>=0&&E.line<10))if(!h||this.paused){let T=E.text.split(`
2454
+ `).length,A=-3;this.streamType===qe.LIVE&&(A=-2);let R=A-T;if(E.line===R&&!f)return;s.has(E)||s.set(E,E.line),E.line=R}else setTimeout(()=>{E.line=s.get(E)||"auto"},500)})},o=()=>{var u,h;a(r,(h=(u=this.mediaController)==null?void 0:u.hasAttribute(Le.USER_INACTIVE))!=null?h:!1)},l=()=>{var f,g;let h=Array.from(((g=(f=this.mediaController)==null?void 0:f.media)==null?void 0:g.textTracks)||[]).filter(E=>["subtitles","captions"].includes(E.kind)&&E.mode==="showing")[0];h!==r&&(r==null||r.removeEventListener("cuechange",o)),r=h,r==null||r.addEventListener("cuechange",o),a(r,Pe(this,kr))};l(),(d=this.textTracks)==null||d.addEventListener("change",l),(c=this.textTracks)==null||c.addEventListener("addtrack",l),this.addEventListener("userinactivechange",()=>{var h,f;let u=(f=(h=this.mediaController)==null?void 0:h.hasAttribute(Le.USER_INACTIVE))!=null?f:!0;Pe(this,kr)!==u&&(ti(this,kr,u),a(r,Pe(this,kr)))})};function vn(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}Xe.customElements.get("mux-player")||(Xe.customElements.define("mux-player",Na),Xe.MuxPlayerElement=Na);var nP=Na;export{At as MediaError,nP as default,vn as getVideoAttribute};
2455
+ /*! Bundled license information:
2456
+
2457
+ mux-embed/dist/mux.js:
2458
+ (*!
2459
+ * mux-embed
2460
+ * @version 4.27.0
2461
+ * @copyright 2023 Mux, Inc
2462
+ *)
2463
+ (*!
2464
+ * JavaScript Cookie v2.1.3
2465
+ * https://github.com/js-cookie/js-cookie
2466
+ *
2467
+ * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
2468
+ * Released under the MIT license
2469
+ *)
2470
+ */