@mux/mux-player 1.12.0 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +49 -49
- package/dist/index.mjs +1 -1
- package/dist/mux-player.js +114 -114
- package/dist/mux-player.mjs +114 -114
- package/dist/themes/2023/index.cjs.js +3 -0
- package/dist/themes/2023/index.js +3 -0
- package/dist/themes/2023/index.mjs +3 -0
- package/dist/themes/classic/index.cjs.js +3 -0
- package/dist/themes/classic/index.js +3 -0
- package/dist/themes/classic/index.mjs +3 -0
- package/dist/themes/microvideo/index.cjs.js +3 -0
- package/dist/themes/microvideo/index.js +3 -0
- package/dist/themes/microvideo/index.mjs +3 -0
- package/dist/themes/minimal/index.cjs.js +3 -0
- package/dist/themes/minimal/index.js +3 -0
- package/dist/themes/minimal/index.mjs +3 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -6
package/dist/mux-player.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var VE=Object.create;var Hf=Object.defineProperty;var KE=Object.getOwnPropertyDescriptor;var WE=Object.getOwnPropertyNames;var qE=Object.getPrototypeOf,YE=Object.prototype.hasOwnProperty;var jE=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var zE=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of WE(e))!YE.call(r,s)&&s!==t&&Hf(r,s,{get:()=>e[s],enumerable:!(i=KE(e,s))||i.enumerable});return r};var XE=(r,e,t)=>(t=r!=null?VE(qE(r)):{},zE(e||!r||!r.__esModule?Hf(t,"default",{value:r,enumerable:!0}):t,r));var hd=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var Ne=(r,e,t)=>(hd(r,e,"read from private field"),t?t.call(r):e.get(r)),ut=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},ii=(r,e,t,i)=>(hd(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var yt=(r,e,t)=>(hd(r,e,"access private method"),t);var Dp=jE((Ko,Bc)=>{(function(){var r,e;r=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 BE}});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 b=T(v,m,p);return function(){for(var _=["[mux]"],L=0;L<arguments.length;L++)_.push(arguments[L]);b.apply(void 0,_)}},E().setLevel(E().getLevel());var A=E();function R(){return(d().doNotTrack||d().navigator&&d().navigator.doNotTrack)==="1"}var x={now:function(){var v=d().performance,m=v&&v.timing,p=m&&m.navigationStart,b=typeof p=="number"&&typeof v.now=="function"?p+v.now():Date.now();return Math.round(b)}},N=function(v){return w(v)[0]},w=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 H=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],q=["x-cdn","content-type"].concat(H);function P(v){var m={};return(v=v||"").trim().split(/[\r\n]+/).forEach(function(p){if(p){var b=p.split(": "),_=b.shift();_&&(q.indexOf(_.toLowerCase())>=0||_.toLowerCase().indexOf("x-litix-")===0)&&(m[_]=b.join(": "))}}),m}function X(v){if(v){var m=H.find(function(p){return v[p]!==void 0});return m?v[m]:void 0}}var j=function(v){var m={};for(var p in v){var b=v[p];b["DATA-ID"].search("io.litix.data.")!==-1&&(m[b["DATA-ID"].replace("io.litix.data.","")]=b.VALUE)}return m};function Ae(v,m){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(v);m&&(b=b.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,b)}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(b){ye(v,b,p[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Ae(Object(p)).forEach(function(b){Object.defineProperty(v,b,Object.getOwnPropertyDescriptor(p,b))})}return v}function ye(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,b=p?p.start:v.trequest,_=p?p.first:v.tfirst,L=p?p.end:v.tload;return{bytesLoaded:v.total,requestStart:Math.round(m+b),responseStart:Math.round(m+_),responseEnd:Math.round(m+L)}},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 b=Object.getOwnPropertySymbols(v);m&&(b=b.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,b)}return p}function ae(v){for(var m=1;m<arguments.length;m++){var p=arguments[m]!=null?arguments[m]:{};m%2?Z(Object(p),!0).forEach(function(b){se(v,b,p[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Z(Object(p)).forEach(function(b){Object.defineProperty(v,b,Object.getOwnPropertyDescriptor(p,b))})}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 b,_=p[p.length-1],L=N(_.url),I=_.url,k=_.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&&(b=P(de[de.length-1]._responseHeaders||"")),{requestStart:U,requestResponseStart:C,requestResponseEnd:K,requestBytesLoaded:k,requestResponseHeaders:b,requestMediaDuration:ve,requestHostname:L,requestUrl:I,requestId:b?X(b):void 0}},Ie=function(v,m){var p=m.getQualityFor(v),b=m.getCurrentTrackFor(v).bitrateList;return b?{currentLevel:p,renditionWidth:b[p].width||null,renditionHeight:b[p].height||null,renditionBitrate:b[p].bandwidth}:{}},$e=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 b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var V=0,J=function(){function v(){(function(_,L){if(!(_ instanceof L))throw new TypeError("Cannot call a class as a function")})(this,v)}var m,p,b;return m=v,p=[{key:"on",value:function(_,L,I){return L._eventEmitterGuid=L._eventEmitterGuid||++V,this._listeners=this._listeners||{},this._listeners[_]=this._listeners[_]||[],I&&(L=L.bind(I)),this._listeners[_].push(L),L}},{key:"off",value:function(_,L){var I=this._listeners&&this._listeners[_];I&&I.forEach(function(k,U){k._eventEmitterGuid===L._eventEmitterGuid&&I.splice(U,1)})}},{key:"one",value:function(_,L,I){var k=this;L._eventEmitterGuid=L._eventEmitterGuid||++V;var U=function C(){k.off(_,C),L.apply(I||this,arguments)};U._eventEmitterGuid=L._eventEmitterGuid,this.on(_,U)}},{key:"emit",value:function(_,L){var I=this;if(this._listeners){L=L||{};var k=this._listeners["before*"]||[],U=this._listeners[_]||[],C=this._listeners["after"+_]||[],K=function(ve,de){(ve=ve.slice()).forEach(function(he){he.call(I,{type:_},de)})};K(k,L),K(U,L),K(C,L)}}}],p&&ht(m.prototype,p),b&&ht(m,b),Object.defineProperty(m,"prototype",{writable:!1}),v}(),Re=J;function Je(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var _t=function(){function v(_){var L=this;(function(I,k){if(!(I 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(){L._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?L._stopPlaybackHeartbeatInterval():L._startPlaybackHeartbeatInterval()}),_.on("timeupdate",function(){L._playbackHeartbeatInterval!==null&&_.emit("playbackheartbeat")}),_.on("devicesleep",function(I,k){L._playbackHeartbeatInterval!==null&&(d().clearInterval(L._playbackHeartbeatInterval),_.emit("playbackheartbeatend",{viewer_time:k.viewer_time}),L._playbackHeartbeatInterval=null)})}var m,p,b;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),b&&Je(m,b),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Xt(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function sr(v,m,p){return m&&Xt(v.prototype,m),p&&Xt(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Jt=sr(function v(m){var p=this;(function(b,_){if(!(b instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),m.on("viewinit",function(){p.viewErrored=!1}),m.on("error",function(b,_){try{var L=m.errorTranslator({player_error_code:_.player_error_code,player_error_message:_.player_error_message,player_error_context:_.player_error_context});L?(m.data.player_error_code=L.player_error_code||_.player_error_code,m.data.player_error_message=L.player_error_message||_.player_error_message,m.data.player_error_context=L.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(I){m.mux.log.warn("Exception in error translator callback.",I),p.viewErrored=!0}})});function yi(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var bi=function(){function v(_){(function(L,I){if(!(L instanceof I))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,b;return m=v,(p=[{key:"_updateWatchTime",value:function(_,L){var I=L.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=I),O(this.pm.data,"view_watch_time",I-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=I}},{key:"_clearWatchTimeState",value:function(_,L){this._updateWatchTime(_,L),this._watchTimeTrackerLastCheckedTime=null}}])&&yi(m.prototype,p),b&&yi(m,b),Object.defineProperty(m,"prototype",{writable:!1}),v}();function fs(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var sn=function(){function v(_){(function(L,I){if(!(L instanceof I))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._playbackTimeTrackerLastPlayheadPosition=-1,_.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),_.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),_.on("seeking",this._clearPlaybackTimeState.bind(this))}var m,p,b;return m=v,(p=[{key:"_updatePlaybackTime",value:function(){var _=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&_>this._playbackTimeTrackerLastPlayheadPosition){var L=_-this._playbackTimeTrackerLastPlayheadPosition;L<=1e3&&O(this.pm.data,"view_content_playback_time",L)}this._playbackTimeTrackerLastPlayheadPosition=_}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&fs(m.prototype,p),b&&fs(m,b),Object.defineProperty(m,"prototype",{writable:!1}),v}();function li(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var rt=function(){function v(_){(function(I,k){if(!(I instanceof k))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_;var L=this._updatePlayheadTime.bind(this);_.on("playbackheartbeat",L),_.on("playbackheartbeatend",L),_.on("timeupdate",L),_.on("destroy",function(){_.off("timeupdate",L)})}var m,p,b;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(_,L){var I=this,k=function(){I.pm.currentFragmentPDT&&I.pm.currentFragmentStart&&(I.pm.data.player_program_time=I.pm.currentFragmentPDT+I.pm.data.player_playhead_time-I.pm.currentFragmentStart)};if(L&&L.player_playhead_time)this.pm.data.player_playhead_time=L.player_playhead_time,k(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var U=this.pm.getPlayheadTime();U!==void 0&&(this.pm.data.player_playhead_time=U,k(),this._updateMaxPlayheadPosition())}}}])&&li(m.prototype,p),b&&li(m,b),Object.defineProperty(m,"prototype",{writable:!1}),v}();function Rr(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function nn(v,m,p){return m&&Rr(v.prototype,m),p&&Rr(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var an=3e5,Ta=nn(function v(m){if(function(L,I){if(!(L instanceof I))throw new TypeError("Cannot call a class as a function")}(this,v),!m.disableRebufferTracking){var p,b=function(L,I){_(I),p=void 0},_=function(L){if(p){var I=L.viewer_time-p;O(m.data,"view_rebuffer_duration",I),p=L.viewer_time,m.data.view_rebuffer_duration>an&&(m.emit("viewend"),m.send("viewend"),m.mux.log.warn("Ending view after rebuffering for longer than ".concat(an,"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(L,I){return _(I)}),m.on("rebufferstart",function(L,I){p||(O(m.data,"view_rebuffer_count",1),p=I.viewer_time,m.one("rebufferend",b))}),m.on("viewinit",function(){p=void 0,m.off("rebufferend",b)})}});function on(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var Ov=function(){function v(_){var L=this;(function(I,k){if(!(I 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(){L._cleanupRebufferTracker(null,{viewer_time:x.now()})}))}var m,p,b;return m=v,p=[{key:"_checkIfRebuffering",value:function(_,L){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(_,L);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var I=L.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&I>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=L.viewer_time}else this._cleanupRebufferTracker(_,L,!0);else this._prepareRebufferTrackerState(L.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(_,L){var I=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:L.viewer_time});else{if(this._lastCheckedTime===null)return;var k=this.pm.data.player_playhead_time-this._lastPlayheadTime,U=L.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&k>0&&U-k>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+U-k}))}I?this._prepareRebufferTrackerState(L.viewer_time):this._clearRebufferTrackerState()}}],p&&on(m.prototype,p),b&&on(m,b),Object.defineProperty(m,"prototype",{writable:!1}),v}(),Pv=Ov;function hf(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var Nv=function(){function v(_){var L=this;(function(I,k){if(!(I instanceof k))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){var I=_.data,k=I.view_id;if(!I.view_program_changed){var U=function(C,K){var ve=K.viewer_time;C.type==="playing"&&_.data.view_time_to_first_frame===void 0?L.calculateTimeToFirstFrame(ve||x.now(),k):C.type!=="adplaying"||_.data.view_time_to_first_frame!==void 0&&!L._inPrerollPosition()||L.calculateTimeToFirstFrame(ve||x.now(),k)};_.one("playing",U),_.one("adplaying",U),_.one("viewend",function(){_.off("playing",U),_.off("adplaying",U)})}})}var m,p,b;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(_,L){L===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))}}])&&hf(m.prototype,p),b&&hf(m,b),Object.defineProperty(m,"prototype",{writable:!1}),v}();function ff(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function Fv(v,m,p){return m&&ff(v.prototype,m),p&&ff(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Uv=Fv(function v(m){var p=this;(function(b,_){if(!(b 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(b){m.on(b,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 L=Math.min(p._lastPlayerWidth/p._lastSourceWidth,p._lastPlayerHeight/p._lastSourceHeight),I=Math.max(0,L-1),k=Math.max(0,1-L);m.data.view_max_upscale_percentage=Math.max(m.data.view_max_upscale_percentage||0,I),m.data.view_max_downscale_percentage=Math.max(m.data.view_max_downscale_percentage||0,k),O(m.data,"view_total_content_playback_time",_),O(m.data,"view_total_upscaling",I*_),O(m.data,"view_total_downscaling",k*_)}p._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(b){m.on(b,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 mf(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function Bv(v,m,p){return m&&mf(v.prototype,m),p&&mf(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var $v=Bv(function v(m){var p=this;(function(b,_){if(!(b instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),this.isSeeking=!1,m.on("seeking",function(b,_){Object.assign(m.data,_),p._lastSeekingTime=x.now(),p.isSeeking===!1&&(p.isSeeking=!0,m.send("seeking"))}),m.on("seeked",function(){p.isSeeking=!1;var b=p._lastSeekingTime||x.now(),_=x.now()-b;O(m.data,"view_seek_count",1),O(m.data,"view_seek_duration",_);var L=m.data.view_max_seek_time||0;m.data.view_max_seek_time=Math.max(L,_)}),m.on("viewend",function(){p.isSeeking=!1})});function pf(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,b){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var L,I,k=[],U=!0,C=!1;try{for(_=_.call(p);!(U=(L=_.next()).done)&&(k.push(L.value),!b||k.length!==b);U=!0);}catch(K){C=!0,I=K}finally{try{U||_.return==null||_.return()}finally{if(C)throw I}}return k}}(v,m)||function(p,b){if(p){if(typeof p=="string")return gf(p,b);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(_)?gf(p,b):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 gf(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,b=new Array(m);p<m;p++)b[p]=v[p];return b}function vf(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var Ef=function(v,m){v.push(m),v.sort(function(p,b){return p.viewer_time-b.viewer_time})},Gv=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Hv=function(){function v(_){var L=this;(function(k,U){if(!(k instanceof U))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){L.isAdBreak=!1,L._currentAdRequestNumber=0,L._currentAdResponseNumber=0,L._adRequests=[],L._adResponses=[],L._adHasPlayed=!1,L._wouldBeNewAdPlay=!0,L._prerollPlayTime=void 0}),Gv.forEach(function(k){return _.on(k,L._updateAdData.bind(L))});var I=function(){L.isAdBreak=!1};_.on("adbreakstart",function(){L.isAdBreak=!0}),_.on("play",I),_.on("playing",I),_.on("viewend",I),_.on("adrequest",function(k,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+L._currentAdRequestNumber++},U),Ef(L._adRequests,U),O(_.data,"view_ad_request_count"),L.inPrerollPosition()&&(_.data.view_preroll_requested=!0,L._adHasPlayed||O(_.data,"view_preroll_request_count"))}),_.on("adresponse",function(k,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+L._currentAdResponseNumber++},U),Ef(L._adResponses,U);var C=L.findAdRequest(U.ad_request_id);C&&O(_.data,"view_ad_request_time",Math.max(0,U.viewer_time-C.viewer_time))}),_.on("adplay",function(k,U){L._adHasPlayed=!0,L._wouldBeNewAdPlay&&(L._wouldBeNewAdPlay=!1,O(_.data,"view_ad_played_count")),L.inPrerollPosition()&&!_.data.view_preroll_played&&(_.data.view_preroll_played=!0,L._adRequests.length>0&&(_.data.view_preroll_request_time=Math.max(0,U.viewer_time-L._adRequests[0].viewer_time)),_.data.view_start&&(_.data.view_startup_preroll_request_time=Math.max(0,U.viewer_time-_.data.view_start)),L._prerollPlayTime=U.viewer_time)}),_.on("adplaying",function(k,U){L.inPrerollPosition()&&_.data.view_preroll_load_time===void 0&&L._prerollPlayTime!==void 0&&(_.data.view_preroll_load_time=U.viewer_time-L._prerollPlayTime,_.data.view_startup_preroll_load_time=U.viewer_time-L._prerollPlayTime)}),_.on("adended",function(){L._wouldBeNewAdPlay=!0}),_.on("aderror",function(){L._wouldBeNewAdPlay=!0})}var m,p,b;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 L=0;L<this._adRequests.length;L++)if(this._adRequests[L].ad_request_id===_)return this._adRequests[L]}},{key:"_updateAdData",value:function(_,L){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&L.ad_tag_url){var I=pf(w(L.ad_tag_url),2),k=I[0],U=I[1];this.pm.data.view_preroll_ad_tag_domain=U,this.pm.data.view_preroll_ad_tag_hostname=k}if(!this.pm.data.view_preroll_ad_asset_hostname&&L.ad_asset_url){var C=pf(w(L.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=L==null?void 0:L.ad_asset_url,this.pm.data.ad_tag_url=L==null?void 0:L.ad_tag_url,this.pm.data.ad_creative_id=L==null?void 0:L.ad_creative_id,this.pm.data.ad_id=L==null?void 0:L.ad_id,this.pm.data.ad_universal_id=L==null?void 0:L.ad_universal_id}}])&&vf(m.prototype,p),b&&vf(m,b),Object.defineProperty(m,"prototype",{writable:!1}),v}();function yf(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function Vv(v,m,p){return m&&yf(v.prototype,m),p&&yf(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Kv=Vv(function v(m){var p,b;(function(k,U){if(!(k 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",x.now()-p),p=!1,d().clearInterval(b))},L=!1,I=function(){L=!1,_()};m.on("waiting",function(){L&&(m.disableRebufferTracking||(O(m.data,"view_waiting_rebuffer_count",1),p=x.now(),b=d().setInterval(function(){if(p){var k=x.now();O(m.data,"view_waiting_rebuffer_duration",k-p),p=k}},250)))}),m.on("playing",function(){_(),L=!0}),m.on("pause",I),m.on("seeking",I)});function bf(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function Wv(v,m,p){return m&&bf(v.prototype,m),p&&bf(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var qv=Wv(function v(m){var p=this;(function(L,I){if(!(L instanceof I))throw new TypeError("Cannot call a class as a function")})(this,v);var b=function(){p.lastWallClockTime=x.now(),m.on("before*",_)},_=function(L){var I=x.now(),k=p.lastWallClockTime;p.lastWallClockTime=I,I-k>3e4&&(m.emit("devicesleep",{viewer_time:k}),Object.assign(m.data,{viewer_time:k}),m.send("devicesleep"),m.emit("devicewake",{viewer_time:I}),Object.assign(m.data,{viewer_time:I}),m.send("devicewake"))};m.one("playbackheartbeat",b),m.on("playbackheartbeatend",function(){m.off("before*",_),m.one("playbackheartbeat",b)})}),Tf=o(375),Yv=o(655),_f=o.n(Yv),Af="muxData",Sf=function(){var v;try{v=Tf.parse(_f().get(Af)||"")}catch{v={}}return v},xf=function(v){try{_f().set(Af,Tf.stringify(v),{expires:7300})}catch{}},jv=function(){var v=Sf();return v.mux_viewer_id=v.mux_viewer_id||c(),v.msn=v.msn||Math.random(),xf(v),{mux_viewer_id:v.mux_viewer_id,mux_sample_number:v.msn}};function zv(v,m){var p=m.beaconCollectionDomain,b=m.beaconDomain;if(p)return"https://"+p;var _=b||"litix.io";return(v=v||"inferred").match(/^[a-z0-9]+$/)?"https://"+v+"."+_:"https://img.litix.io/a.gif"}var If=function(){var v;switch(Lf()){case"cellular":v="cellular";break;case"ethernet":v="wired";break;case"wifi":v="wifi";break;case void 0:break;default:v="other"}return v},Lf=function(){var v=d().navigator,m=v&&(v.connection||v.mozConnection||v.webkitConnection);return m&&m.type};If.getConnectionFromAPI=Lf;var Xv=If,Qv=kf({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"}),Rf=kf({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",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",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 kf(v){var m={};for(var p in v)v.hasOwnProperty(p)&&(m[v[p]]=p);return m}function ad(v){var m={},p={};return Object.keys(v).forEach(function(b){var _=!1;if(v.hasOwnProperty(b)&&v[b]!==void 0){var L=b.split("_"),I=L[0],k=Qv[I];k||(A.info("Data key word `"+L[0]+"` not expected in "+b),k=I+"_"),L.splice(1).forEach(function(U){U==="url"&&(_=!0),Rf[U]?k+=Rf[U]:Number(U)&&Math.floor(Number(U))===Number(U)?k+=U:(A.info("Data key word `"+U+"` not expected in "+b),k+="_"+U+"_")}),_?p[k]=v[b]:m[k]=v[b]}}),Object.assign(m,p)}var Zv={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Jv=["hb","requestcompleted","requestfailed","requestcanceled"],eE="https://img.litix.io",Gi=function(v){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=v||eE,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},Zv,m)};Gi.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)},Gi.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())},Gi.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)},Gi.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],ad({mux_view_message:"event queue truncated"}));var p=this._createPayload(m);wf(this._beaconUrl,p,!0,function(){})},Gi.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),b=x.now();wf(this._beaconUrl,p,!1,function(_,L){L?(v._eventQueue=m.concat(v._eventQueue),v._failureCount+=1,A.info("Error sending beacon: "+L)):v._failureCount=0,v._roundTripTime=x.now()-b,v._postInFlight=!1})}},Gi.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},Gi.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()))},Gi.prototype._createPayload=function(v){var m,p,b,_=this,L={transmission_timestamp:Math.round(x.now())};this._roundTripTime&&(L.rtt_ms=Math.round(this._roundTripTime));var I=function(){m=JSON.stringify({metadata:L,events:p||v}),b=m.length/1024},k=function(){return b<=_._options.maxPayloadKBSize};return I(),k()||(A.info("Payload size is too big ("+b+" kb). Removing unnecessary events."),p=v.filter(function(U){return Jv.indexOf(U.e)===-1}),I()),k()||(A.info("Payload size still too big ("+b+" 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))}}),I()),m};var tE=function(v){return v.length<=57344},wf=function(v,m,p,b){if(p&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(v,m))b();else if(d().fetch)d().fetch(v,{method:"POST",body:m,headers:{"Content-Type":"text/plain"},keepalive:tE(m)}).then(function(L){return b(null,L.ok?null:"Error")}).catch(function(L){return b(null,L)});else{if(d().XMLHttpRequest){var _=new(d()).XMLHttpRequest;return _.onreadystatechange=function(){if(_.readyState===4)return b(null,_.status!==200?"error":void 0)},_.open("POST",v),_.setRequestHeader("Content-Type","text/plain"),void _.send(m)}b()}},iE=Gi;function rE(v,m){return function(p){if(Array.isArray(p))return p}(v)||function(p,b){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var L,I,k=[],U=!0,C=!1;try{for(_=_.call(p);!(U=(L=_.next()).done)&&(k.push(L.value),!b||k.length!==b);U=!0);}catch(K){C=!0,I=K}finally{try{U||_.return==null||_.return()}finally{if(C)throw I}}return k}}(v,m)||function(p,b){if(p){if(typeof p=="string")return Df(p,b);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(_)?Df(p,b):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
|
|
4
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Nf(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,b=new Array(m);p<m;p++)b[p]=v[p];return b}function Ff(v,m){for(var p=0;p<m.length;p++){var b=m[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function ld(v,m){return ld=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,b){return p.__proto__=b,p},ld(v,m)}function mE(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,b=Aa(v);if(m){var _=Aa(this).constructor;p=Reflect.construct(b,arguments,_)}else p=b.apply(this,arguments);return pE(this,p)}}function pE(v,m){if(m&&(od(m)==="object"||typeof m=="function"))return m;if(m!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return gt(v)}function gt(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function Aa(v){return Aa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(m){return m.__proto__||Object.getPrototypeOf(m)},Aa(v)}var gE=["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"],vE=function(v){(function(I,k){if(typeof k!="function"&&k!==null)throw new TypeError("Super expression must either be null or a function");I.prototype=Object.create(k&&k.prototype,{constructor:{value:I,writable:!0,configurable:!0}}),Object.defineProperty(I,"prototype",{writable:!1}),k&&ld(I,k)})(L,v);var m,p,b,_=mE(L);function L(I,k,U){var C;(function(oe,me){if(!(oe instanceof me))throw new TypeError("Cannot call a class as a function")})(this,L),(C=_.call(this)).DOM_CONTENT_LOADED_EVENT_END=$.domContentLoadedEventEnd(),C.NAVIGATION_START=$.navigationStart(),C.mux=I,C.id=k,(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 lE(I,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(gt(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(gt(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)}),gE.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 hE(gt(C)),C.errorTracker=new Jt(gt(C)),new qv(gt(C)),C.seekingTracker=new $v(gt(C)),C.playheadTime=new rt(gt(C)),C.playbackHeartbeat=new _t(gt(C)),new Uv(gt(C)),C.watchTimeTracker=new bi(gt(C)),new sn(gt(C)),C.adTracker=new Hv(gt(C)),new Pv(gt(C)),new Ta(gt(C)),new Nv(gt(C)),new Kv(gt(C)),new cE(gt(C)),U.hlsjs&&C.addHLSJS(U),U.dashjs&&C.addDashJS(U),C.emit("viewinit",U.data),C}return m=L,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(I){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(ve){k[ve]=void 0}),k.video_source_url=k.video_source_url||k.player_source_url,k.video_source_url){var U=fE(w(k.video_source_url),2),C=U[0],K=U[1];k.video_source_domain=K,k.video_source_hostname=C}delete k.ad_request_id,this.playbackEventDispatcher.send(I,k),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),I==="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 I=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(k){var U=parseInt(I.data[k],10);I.data[k]=isNaN(U)?void 0:U}),["player_source_url","video_source_url"].forEach(function(k){if(I.data[k]){var U=I.data[k].toLowerCase();U.indexOf("data:")!==0&&U.indexOf("blob:")!==0||(I.data[k]="MSE style URL")}})}},{key:"_resetVideoData",value:function(I,k){var U=this;Object.keys(this.data).forEach(function(C){C.indexOf("video_")===0&&delete U.data[C]})}},{key:"_resetViewData",value:function(){var I=this;Object.keys(this.data).forEach(function(k){k.indexOf("view_")===0&&delete I.data[k]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(I,k){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var I=this,k=this.data.view_id=c(),U=function(){k===I.data.view_id&&O(I.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",U):U()}},{key:"_restartHeartBeat",value:function(){var I=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){I.data.player_is_paused||I.emit("hb")},1e4))}},{key:"addHLSJS",value:function(I){I.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=I.hlsjs,function(k,U,C){var K=arguments.length>4?arguments[4]:void 0,ve=k.log,de=k.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 k.emit(U,Oe,Q)},me=function(Oe,Q){var fe=Q.levels,ee=Q.audioTracks,Te=Q.url,De=Q.stats,ct=Q.networkDetails,Gt=Q.sessionData,xt={},Nt={};fe.forEach(function(ft,hn){xt[hn]={width:ft.width,height:ft.height,bitrate:ft.bitrate,attrs:ft.attrs}}),ee.forEach(function(ft,hn){Nt[hn]={name:ft.name,language:ft.lang,bitrate:ft.bitrate}});var vt=we(De),Et=vt.bytesLoaded,nr=vt.requestStart,un=vt.responseStart,kr=vt.responseEnd;oe("requestcompleted",Ee(Ee({},j(Gt)),{},{request_event_type:Oe,request_bytes_loaded:Et,request_start:nr,request_response_start:un,request_response_end:kr,request_type:"manifest",request_hostname:N(Te),request_response_headers:Se(ct),request_rendition_lists:{media:xt,audio:Nt,video:{}}}))};C.on(K.Events.MANIFEST_LOADED,me);var Me=function(Oe,Q){var fe=Q.details,ee=Q.level,Te=Q.networkDetails,De=Q.stats,ct=we(De),Gt=ct.bytesLoaded,xt=ct.requestStart,Nt=ct.responseStart,vt=ct.responseEnd,Et=fe.fragments[fe.fragments.length-1],nr=he(Et)+de(Et.duration);oe("requestcompleted",{request_event_type:Oe,request_bytes_loaded:Gt,request_start:xt,request_response_start:Nt,request_response_end:vt,request_current_level:ee,request_type:"manifest",request_hostname:N(fe.url),request_response_headers:Se(Te),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(nr)?void 0:nr})};C.on(K.Events.LEVEL_LOADED,Me);var At=function(Oe,Q){var fe=Q.details,ee=Q.networkDetails,Te=Q.stats,De=we(Te),ct=De.bytesLoaded,Gt=De.requestStart,xt=De.responseStart,Nt=De.responseEnd;oe("requestcompleted",{request_event_type:Oe,request_bytes_loaded:ct,request_start:Gt,request_response_start:xt,request_response_end:Nt,request_type:"manifest",request_hostname:N(fe.url),request_response_headers:Se(ee)})};C.on(K.Events.AUDIO_TRACK_LOADED,At);var St=function(Oe,Q){var fe=Q.stats,ee=Q.networkDetails,Te=Q.frag;fe=fe||Te.stats;var De=we(fe),ct=De.bytesLoaded,Gt=De.requestStart,xt=De.responseStart,Nt=De.responseEnd,vt=ee?Se(ee):void 0,Et={request_event_type:Oe,request_bytes_loaded:ct,request_start:Gt,request_response_start:xt,request_response_end:Nt,request_hostname:ee?N(ee.responseURL):void 0,request_id:vt?X(vt):void 0,request_response_headers:vt,request_media_duration:Te.duration,request_url:ee==null?void 0:ee.responseURL};Te.type==="main"?(Et.request_type="media",Et.request_current_level=Te.level,Et.request_video_width=(C.levels[Te.level]||{}).width,Et.request_video_height=(C.levels[Te.level]||{}).height,Et.request_labeled_bitrate=(C.levels[Te.level]||{}).bitrate):Et.request_type=Te.type,oe("requestcompleted",Et)};C.on(K.Events.FRAG_LOADED,St);var $t=function(Oe,Q){var fe=Q.frag,ee=fe.start,Te={currentFragmentPDT:he(fe),currentFragmentStart:de(ee)};oe("fragmentchange",Te)};C.on(K.Events.FRAG_CHANGED,$t);var ti=function(Oe,Q){var fe=Q.type,ee=Q.details,Te=Q.response,De=Q.fatal,ct=Q.frag,Gt=Q.networkDetails,xt=(ct==null?void 0:ct.url)||Q.url||"",Nt=Gt?Se(Gt):void 0;if(ee!==K.ErrorDetails.MANIFEST_LOAD_ERROR&&ee!==K.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&ee!==K.ErrorDetails.FRAG_LOAD_ERROR&&ee!==K.ErrorDetails.FRAG_LOAD_TIMEOUT&&ee!==K.ErrorDetails.LEVEL_LOAD_ERROR&&ee!==K.ErrorDetails.LEVEL_LOAD_TIMEOUT&&ee!==K.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&ee!==K.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&ee!==K.ErrorDetails.SUBTITLE_LOAD_ERROR&&ee!==K.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&ee!==K.ErrorDetails.KEY_LOAD_ERROR&&ee!==K.ErrorDetails.KEY_LOAD_TIMEOUT||oe("requestfailed",{request_error:ee,request_url:xt,request_hostname:N(xt),request_id:Nt?X(Nt):void 0,request_type:ee===K.ErrorDetails.FRAG_LOAD_ERROR||ee===K.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":ee===K.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||ee===K.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":ee===K.ErrorDetails.SUBTITLE_LOAD_ERROR||ee===K.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":ee===K.ErrorDetails.KEY_LOAD_ERROR||ee===K.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:Te==null?void 0:Te.code,request_error_text:Te==null?void 0:Te.text}),De){var vt,Et="".concat(xt?"url: ".concat(xt,`
|
|
1
|
+
var qE=Object.create;var Wf=Object.defineProperty;var YE=Object.getOwnPropertyDescriptor;var jE=Object.getOwnPropertyNames;var zE=Object.getPrototypeOf,XE=Object.prototype.hasOwnProperty;var QE=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var ZE=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of jE(e))!XE.call(r,s)&&s!==t&&Wf(r,s,{get:()=>e[s],enumerable:!(i=YE(e,s))||i.enumerable});return r};var JE=(r,e,t)=>(t=r!=null?qE(zE(r)):{},ZE(e||!r||!r.__esModule?Wf(t,"default",{value:r,enumerable:!0}):t,r));var fd=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var Ne=(r,e,t)=>(fd(r,e,"read from private field"),t?t.call(r):e.get(r)),ut=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},ii=(r,e,t,i)=>(fd(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var yt=(r,e,t)=>(fd(r,e,"access private method"),t);var Op=QE((Ko,$c)=>{(function(){var r,e;r=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 HE}});var l=o(48),d=o.n(l),c=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(v){var f=16*Math.random()|0;return(v==="x"?f:3&f|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},m=function(v){var f;v&&v.nodeName!==void 0?v=h(f=v):f=document.querySelector(v);var p=f&&f.nodeName?f.nodeName.toLowerCase():"";return[f,v,p]},g=o(640),E=o.n(g),T=E().methodFactory;E().methodFactory=function(v,f,p){var b=T(v,f,p);return function(){for(var _=["[mux]"],L=0;L<arguments.length;L++)_.push(arguments[L]);b.apply(void 0,_)}},E().setLevel(E().getLevel());var A=E();function R(){return(d().doNotTrack||d().navigator&&d().navigator.doNotTrack)==="1"}var x={now:function(){var v=d().performance,f=v&&v.timing,p=f&&f.navigationStart,b=typeof p=="number"&&typeof v.now=="function"?p+v.now():Date.now();return Math.round(b)}},N=function(v){return w(v)[0]},w=function(v){if(typeof v!="string"||v==="")return["localhost"];var f,p=(v.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return p&&(f=(p.match(/[^\.]+\.[^\.]+$/)||[])[0]),[p,f]},$={exists:function(){var v=d().performance;return(v&&v.timing)!==void 0},domContentLoadedEventEnd:function(){var v=d().performance,f=v&&v.timing;return f&&f.domContentLoadedEventEnd},navigationStart:function(){var v=d().performance,f=v&&v.timing;return f&&f.navigationStart}};function O(v,f,p){p=p===void 0?1:p,v[f]=v[f]||0,v[f]+=p}var H=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],q=["x-cdn","content-type"].concat(H);function P(v){var f={};return(v=v||"").trim().split(/[\r\n]+/).forEach(function(p){if(p){var b=p.split(": "),_=b.shift();_&&(q.indexOf(_.toLowerCase())>=0||_.toLowerCase().indexOf("x-litix-")===0)&&(f[_]=b.join(": "))}}),f}function X(v){if(v){var f=H.find(function(p){return v[p]!==void 0});return f?v[f]:void 0}}var j=function(v){var f={};for(var p in v){var b=v[p];b["DATA-ID"].search("io.litix.data.")!==-1&&(f[b["DATA-ID"].replace("io.litix.data.","")]=b.VALUE)}return f};function Ae(v,f){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(v);f&&(b=b.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,b)}return p}function Ee(v){for(var f=1;f<arguments.length;f++){var p=arguments[f]!=null?arguments[f]:{};f%2?Ae(Object(p),!0).forEach(function(b){ye(v,b,p[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Ae(Object(p)).forEach(function(b){Object.defineProperty(v,b,Object.getOwnPropertyDescriptor(p,b))})}return v}function ye(v,f,p){return f in v?Object.defineProperty(v,f,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[f]=p,v}var we=function(v){if(!v)return{};var f=$.navigationStart(),p=v.loading,b=p?p.start:v.trequest,_=p?p.first:v.tfirst,L=p?p.end:v.tload;return{bytesLoaded:v.total,requestStart:Math.round(f+b),responseStart:Math.round(f+_),responseEnd:Math.round(f+L)}},Se=function(v){if(v&&typeof v.getAllResponseHeaders=="function")return P(v.getAllResponseHeaders())};function Z(v,f){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(v);f&&(b=b.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,b)}return p}function ae(v){for(var f=1;f<arguments.length;f++){var p=arguments[f]!=null?arguments[f]:{};f%2?Z(Object(p),!0).forEach(function(b){se(v,b,p[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Z(Object(p)).forEach(function(b){Object.defineProperty(v,b,Object.getOwnPropertyDescriptor(p,b))})}return v}function se(v,f,p){return f in v?Object.defineProperty(v,f,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[f]=p,v}var xe=function(v,f){if(!v||typeof v.getRequests!="function")return{};var p=v.getRequests({state:"executed"});if(p.length===0)return{};var b,_=p[p.length-1],L=N(_.url),I=_.url,k=_.bytesLoaded,U=new Date(_.requestStartDate).getTime(),C=new Date(_.firstByteDate).getTime(),K=new Date(_.requestEndDate).getTime(),ve=isNaN(_.duration)?0:_.duration,de=typeof f.getMetricsFor=="function"?f.getMetricsFor(_.mediaType).HttpList:f.getDashMetrics().getHttpRequests(_.mediaType);return de.length>0&&(b=P(de[de.length-1]._responseHeaders||"")),{requestStart:U,requestResponseStart:C,requestResponseEnd:K,requestBytesLoaded:k,requestResponseHeaders:b,requestMediaDuration:ve,requestHostname:L,requestUrl:I,requestId:b?X(b):void 0}},Ie=function(v,f){var p=f.getQualityFor(v),b=f.getCurrentTrackFor(v).bitrateList;return b?{currentLevel:p,renditionWidth:b[p].width||null,renditionHeight:b[p].height||null,renditionBitrate:b[p].bandwidth}:{}},$e=function(v){var f;return(f=v.match(/.*codecs\*?="(.*)"/))===null||f===void 0?void 0:f[1]};function ht(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var V=0,J=function(){function v(){(function(_,L){if(!(_ instanceof L))throw new TypeError("Cannot call a class as a function")})(this,v)}var f,p,b;return f=v,p=[{key:"on",value:function(_,L,I){return L._eventEmitterGuid=L._eventEmitterGuid||++V,this._listeners=this._listeners||{},this._listeners[_]=this._listeners[_]||[],I&&(L=L.bind(I)),this._listeners[_].push(L),L}},{key:"off",value:function(_,L){var I=this._listeners&&this._listeners[_];I&&I.forEach(function(k,U){k._eventEmitterGuid===L._eventEmitterGuid&&I.splice(U,1)})}},{key:"one",value:function(_,L,I){var k=this;L._eventEmitterGuid=L._eventEmitterGuid||++V;var U=function C(){k.off(_,C),L.apply(I||this,arguments)};U._eventEmitterGuid=L._eventEmitterGuid,this.on(_,U)}},{key:"emit",value:function(_,L){var I=this;if(this._listeners){L=L||{};var k=this._listeners["before*"]||[],U=this._listeners[_]||[],C=this._listeners["after"+_]||[],K=function(ve,de){(ve=ve.slice()).forEach(function(he){he.call(I,{type:_},de)})};K(k,L),K(U,L),K(C,L)}}}],p&&ht(f.prototype,p),b&&ht(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}(),Re=J;function Je(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var _t=function(){function v(_){var L=this;(function(I,k){if(!(I 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(){L._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?L._stopPlaybackHeartbeatInterval():L._startPlaybackHeartbeatInterval()}),_.on("timeupdate",function(){L._playbackHeartbeatInterval!==null&&_.emit("playbackheartbeat")}),_.on("devicesleep",function(I,k){L._playbackHeartbeatInterval!==null&&(d().clearInterval(L._playbackHeartbeatInterval),_.emit("playbackheartbeatend",{viewer_time:k.viewer_time}),L._playbackHeartbeatInterval=null)})}var f,p,b;return f=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(f.prototype,p),b&&Je(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}();function Xt(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function sr(v,f,p){return f&&Xt(v.prototype,f),p&&Xt(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Jt=sr(function v(f){var p=this;(function(b,_){if(!(b instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),f.on("viewinit",function(){p.viewErrored=!1}),f.on("error",function(b,_){try{var L=f.errorTranslator({player_error_code:_.player_error_code,player_error_message:_.player_error_message,player_error_context:_.player_error_context});L?(f.data.player_error_code=L.player_error_code||_.player_error_code,f.data.player_error_message=L.player_error_message||_.player_error_message,f.data.player_error_context=L.player_error_context||_.player_error_context,p.viewErrored=!0):(delete f.data.player_error_code,delete f.data.player_error_message,delete f.data.player_error_context)}catch(I){f.mux.log.warn("Exception in error translator callback.",I),p.viewErrored=!0}})});function yi(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var bi=function(){function v(_){(function(L,I){if(!(L instanceof I))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 f,p,b;return f=v,(p=[{key:"_updateWatchTime",value:function(_,L){var I=L.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=I),O(this.pm.data,"view_watch_time",I-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=I}},{key:"_clearWatchTimeState",value:function(_,L){this._updateWatchTime(_,L),this._watchTimeTrackerLastCheckedTime=null}}])&&yi(f.prototype,p),b&&yi(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}();function fs(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var sn=function(){function v(_){(function(L,I){if(!(L instanceof I))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._playbackTimeTrackerLastPlayheadPosition=-1,_.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),_.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),_.on("seeking",this._clearPlaybackTimeState.bind(this))}var f,p,b;return f=v,(p=[{key:"_updatePlaybackTime",value:function(){var _=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&_>this._playbackTimeTrackerLastPlayheadPosition){var L=_-this._playbackTimeTrackerLastPlayheadPosition;L<=1e3&&O(this.pm.data,"view_content_playback_time",L)}this._playbackTimeTrackerLastPlayheadPosition=_}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&fs(f.prototype,p),b&&fs(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}();function li(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var rt=function(){function v(_){(function(I,k){if(!(I instanceof k))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_;var L=this._updatePlayheadTime.bind(this);_.on("playbackheartbeat",L),_.on("playbackheartbeatend",L),_.on("timeupdate",L),_.on("destroy",function(){_.off("timeupdate",L)})}var f,p,b;return f=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(_,L){var I=this,k=function(){I.pm.currentFragmentPDT&&I.pm.currentFragmentStart&&(I.pm.data.player_program_time=I.pm.currentFragmentPDT+I.pm.data.player_playhead_time-I.pm.currentFragmentStart)};if(L&&L.player_playhead_time)this.pm.data.player_playhead_time=L.player_playhead_time,k(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var U=this.pm.getPlayheadTime();U!==void 0&&(this.pm.data.player_playhead_time=U,k(),this._updateMaxPlayheadPosition())}}}])&&li(f.prototype,p),b&&li(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}();function Rr(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function nn(v,f,p){return f&&Rr(v.prototype,f),p&&Rr(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var an=3e5,Ta=nn(function v(f){if(function(L,I){if(!(L instanceof I))throw new TypeError("Cannot call a class as a function")}(this,v),!f.disableRebufferTracking){var p,b=function(L,I){_(I),p=void 0},_=function(L){if(p){var I=L.viewer_time-p;O(f.data,"view_rebuffer_duration",I),p=L.viewer_time,f.data.view_rebuffer_duration>an&&(f.emit("viewend"),f.send("viewend"),f.mux.log.warn("Ending view after rebuffering for longer than ".concat(an,"ms, future events will be ignored unless a programchange or videochange occurs.")))}f.data.view_watch_time>=0&&f.data.view_rebuffer_count>0&&(f.data.view_rebuffer_frequency=f.data.view_rebuffer_count/f.data.view_watch_time,f.data.view_rebuffer_percentage=f.data.view_rebuffer_duration/f.data.view_watch_time)};f.on("playbackheartbeat",function(L,I){return _(I)}),f.on("rebufferstart",function(L,I){p||(O(f.data,"view_rebuffer_count",1),p=I.viewer_time,f.one("rebufferend",b))}),f.on("viewinit",function(){p=void 0,f.off("rebufferend",b)})}});function on(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var Fv=function(){function v(_){var L=this;(function(I,k){if(!(I 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(){L._cleanupRebufferTracker(null,{viewer_time:x.now()})}))}var f,p,b;return f=v,p=[{key:"_checkIfRebuffering",value:function(_,L){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(_,L);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var I=L.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&I>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=L.viewer_time}else this._cleanupRebufferTracker(_,L,!0);else this._prepareRebufferTrackerState(L.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(_,L){var I=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:L.viewer_time});else{if(this._lastCheckedTime===null)return;var k=this.pm.data.player_playhead_time-this._lastPlayheadTime,U=L.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&k>0&&U-k>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+U-k}))}I?this._prepareRebufferTrackerState(L.viewer_time):this._clearRebufferTrackerState()}}],p&&on(f.prototype,p),b&&on(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}(),Uv=Fv;function pf(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var Bv=function(){function v(_){var L=this;(function(I,k){if(!(I instanceof k))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){var I=_.data,k=I.view_id;if(!I.view_program_changed){var U=function(C,K){var ve=K.viewer_time;C.type==="playing"&&_.data.view_time_to_first_frame===void 0?L.calculateTimeToFirstFrame(ve||x.now(),k):C.type!=="adplaying"||_.data.view_time_to_first_frame!==void 0&&!L._inPrerollPosition()||L.calculateTimeToFirstFrame(ve||x.now(),k)};_.one("playing",U),_.one("adplaying",U),_.one("viewend",function(){_.off("playing",U),_.off("adplaying",U)})}})}var f,p,b;return f=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(_,L){L===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))}}])&&pf(f.prototype,p),b&&pf(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}();function gf(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function $v(v,f,p){return f&&gf(v.prototype,f),p&&gf(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Gv=$v(function v(f){var p=this;(function(b,_){if(!(b instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),f.on("viewinit",function(){p._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(b){f.on(b,function(){if(p._lastPlayheadPosition>=0&&f.data.player_playhead_time>=0&&p._lastPlayerWidth>=0&&p._lastSourceWidth>0&&p._lastPlayerHeight>=0&&p._lastSourceHeight>0){var _=f.data.player_playhead_time-p._lastPlayheadPosition;if(_<0)return void(p._lastPlayheadPosition=-1);var L=Math.min(p._lastPlayerWidth/p._lastSourceWidth,p._lastPlayerHeight/p._lastSourceHeight),I=Math.max(0,L-1),k=Math.max(0,1-L);f.data.view_max_upscale_percentage=Math.max(f.data.view_max_upscale_percentage||0,I),f.data.view_max_downscale_percentage=Math.max(f.data.view_max_downscale_percentage||0,k),O(f.data,"view_total_content_playback_time",_),O(f.data,"view_total_upscaling",I*_),O(f.data,"view_total_downscaling",k*_)}p._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(b){f.on(b,function(){p._lastPlayheadPosition=f.data.player_playhead_time,p._lastPlayerWidth=f.data.player_width,p._lastPlayerHeight=f.data.player_height,p._lastSourceWidth=f.data.video_source_width,p._lastSourceHeight=f.data.video_source_height})})});function vf(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function Hv(v,f,p){return f&&vf(v.prototype,f),p&&vf(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Vv=Hv(function v(f){var p=this;(function(b,_){if(!(b instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),this.isSeeking=!1,f.on("seeking",function(b,_){Object.assign(f.data,_),p._lastSeekingTime=x.now(),p.isSeeking===!1&&(p.isSeeking=!0,f.send("seeking"))}),f.on("seeked",function(){p.isSeeking=!1;var b=p._lastSeekingTime||x.now(),_=x.now()-b;O(f.data,"view_seek_count",1),O(f.data,"view_seek_duration",_);var L=f.data.view_max_seek_time||0;f.data.view_max_seek_time=Math.max(L,_)}),f.on("viewend",function(){p.isSeeking=!1})});function Ef(v,f){return function(p){if(Array.isArray(p))return p}(v)||function(p,b){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var L,I,k=[],U=!0,C=!1;try{for(_=_.call(p);!(U=(L=_.next()).done)&&(k.push(L.value),!b||k.length!==b);U=!0);}catch(K){C=!0,I=K}finally{try{U||_.return==null||_.return()}finally{if(C)throw I}}return k}}(v,f)||function(p,b){if(p){if(typeof p=="string")return yf(p,b);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(_)?yf(p,b):void 0}}(v,f)||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 yf(v,f){(f==null||f>v.length)&&(f=v.length);for(var p=0,b=new Array(f);p<f;p++)b[p]=v[p];return b}function bf(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}var Tf=function(v,f){v.push(f),v.sort(function(p,b){return p.viewer_time-b.viewer_time})},Kv=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Wv=function(){function v(_){var L=this;(function(k,U){if(!(k instanceof U))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){L.isAdBreak=!1,L._currentAdRequestNumber=0,L._currentAdResponseNumber=0,L._adRequests=[],L._adResponses=[],L._adHasPlayed=!1,L._wouldBeNewAdPlay=!0,L._prerollPlayTime=void 0}),Kv.forEach(function(k){return _.on(k,L._updateAdData.bind(L))});var I=function(){L.isAdBreak=!1};_.on("adbreakstart",function(){L.isAdBreak=!0}),_.on("play",I),_.on("playing",I),_.on("viewend",I),_.on("adrequest",function(k,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+L._currentAdRequestNumber++},U),Tf(L._adRequests,U),O(_.data,"view_ad_request_count"),L.inPrerollPosition()&&(_.data.view_preroll_requested=!0,L._adHasPlayed||O(_.data,"view_preroll_request_count"))}),_.on("adresponse",function(k,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+L._currentAdResponseNumber++},U),Tf(L._adResponses,U);var C=L.findAdRequest(U.ad_request_id);C&&O(_.data,"view_ad_request_time",Math.max(0,U.viewer_time-C.viewer_time))}),_.on("adplay",function(k,U){L._adHasPlayed=!0,L._wouldBeNewAdPlay&&(L._wouldBeNewAdPlay=!1,O(_.data,"view_ad_played_count")),L.inPrerollPosition()&&!_.data.view_preroll_played&&(_.data.view_preroll_played=!0,L._adRequests.length>0&&(_.data.view_preroll_request_time=Math.max(0,U.viewer_time-L._adRequests[0].viewer_time)),_.data.view_start&&(_.data.view_startup_preroll_request_time=Math.max(0,U.viewer_time-_.data.view_start)),L._prerollPlayTime=U.viewer_time)}),_.on("adplaying",function(k,U){L.inPrerollPosition()&&_.data.view_preroll_load_time===void 0&&L._prerollPlayTime!==void 0&&(_.data.view_preroll_load_time=U.viewer_time-L._prerollPlayTime,_.data.view_startup_preroll_load_time=U.viewer_time-L._prerollPlayTime)}),_.on("adended",function(){L._wouldBeNewAdPlay=!0}),_.on("aderror",function(){L._wouldBeNewAdPlay=!0})}var f,p,b;return f=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 L=0;L<this._adRequests.length;L++)if(this._adRequests[L].ad_request_id===_)return this._adRequests[L]}},{key:"_updateAdData",value:function(_,L){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&L.ad_tag_url){var I=Ef(w(L.ad_tag_url),2),k=I[0],U=I[1];this.pm.data.view_preroll_ad_tag_domain=U,this.pm.data.view_preroll_ad_tag_hostname=k}if(!this.pm.data.view_preroll_ad_asset_hostname&&L.ad_asset_url){var C=Ef(w(L.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=L==null?void 0:L.ad_asset_url,this.pm.data.ad_tag_url=L==null?void 0:L.ad_tag_url,this.pm.data.ad_creative_id=L==null?void 0:L.ad_creative_id,this.pm.data.ad_id=L==null?void 0:L.ad_id,this.pm.data.ad_universal_id=L==null?void 0:L.ad_universal_id}}])&&bf(f.prototype,p),b&&bf(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}();function _f(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function qv(v,f,p){return f&&_f(v.prototype,f),p&&_f(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Yv=qv(function v(f){var p,b;(function(k,U){if(!(k instanceof U))throw new TypeError("Cannot call a class as a function")})(this,v);var _=function(){f.disableRebufferTracking||p&&(O(f.data,"view_waiting_rebuffer_duration",x.now()-p),p=!1,d().clearInterval(b))},L=!1,I=function(){L=!1,_()};f.on("waiting",function(){L&&(f.disableRebufferTracking||(O(f.data,"view_waiting_rebuffer_count",1),p=x.now(),b=d().setInterval(function(){if(p){var k=x.now();O(f.data,"view_waiting_rebuffer_duration",k-p),p=k}},250)))}),f.on("playing",function(){_(),L=!0}),f.on("pause",I),f.on("seeking",I)});function Af(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function jv(v,f,p){return f&&Af(v.prototype,f),p&&Af(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var zv=jv(function v(f){var p=this;(function(L,I){if(!(L instanceof I))throw new TypeError("Cannot call a class as a function")})(this,v);var b=function(){p.lastWallClockTime=x.now(),f.on("before*",_)},_=function(L){var I=x.now(),k=p.lastWallClockTime;p.lastWallClockTime=I,I-k>3e4&&(f.emit("devicesleep",{viewer_time:k}),Object.assign(f.data,{viewer_time:k}),f.send("devicesleep"),f.emit("devicewake",{viewer_time:I}),Object.assign(f.data,{viewer_time:I}),f.send("devicewake"))};f.one("playbackheartbeat",b),f.on("playbackheartbeatend",function(){f.off("before*",_),f.one("playbackheartbeat",b)})}),Sf=o(375),Xv=o(655),xf=o.n(Xv),If="muxData",Lf=function(){var v;try{v=Sf.parse(xf().get(If)||"")}catch{v={}}return v},Rf=function(v){try{xf().set(If,Sf.stringify(v),{expires:7300})}catch{}},Qv=function(){var v=Lf();return v.mux_viewer_id=v.mux_viewer_id||c(),v.msn=v.msn||Math.random(),Rf(v),{mux_viewer_id:v.mux_viewer_id,mux_sample_number:v.msn}};function Zv(v,f){var p=f.beaconCollectionDomain,b=f.beaconDomain;if(p)return"https://"+p;var _=b||"litix.io";return(v=v||"inferred").match(/^[a-z0-9]+$/)?"https://"+v+"."+_:"https://img.litix.io/a.gif"}var kf=function(){var v;switch(wf()){case"cellular":v="cellular";break;case"ethernet":v="wired";break;case"wifi":v="wifi";break;case void 0:break;default:v="other"}return v},wf=function(){var v=d().navigator,f=v&&(v.connection||v.mozConnection||v.webkitConnection);return f&&f.type};kf.getConnectionFromAPI=wf;var Jv=kf,eE=Cf({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"}),Df=Cf({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",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",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 Cf(v){var f={};for(var p in v)v.hasOwnProperty(p)&&(f[v[p]]=p);return f}function od(v){var f={},p={};return Object.keys(v).forEach(function(b){var _=!1;if(v.hasOwnProperty(b)&&v[b]!==void 0){var L=b.split("_"),I=L[0],k=eE[I];k||(A.info("Data key word `"+L[0]+"` not expected in "+b),k=I+"_"),L.splice(1).forEach(function(U){U==="url"&&(_=!0),Df[U]?k+=Df[U]:Number(U)&&Math.floor(Number(U))===Number(U)?k+=U:(A.info("Data key word `"+U+"` not expected in "+b),k+="_"+U+"_")}),_?p[k]=v[b]:f[k]=v[b]}}),Object.assign(f,p)}var tE={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},iE=["hb","requestcompleted","requestfailed","requestcanceled"],rE="https://img.litix.io",Gi=function(v){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=v||rE,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},tE,f)};Gi.prototype.queueEvent=function(v,f){var p=Object.assign({},f);return(this._eventQueue.length<=this._options.maxQueueLength||v==="eventrateexceeded")&&(this._eventQueue.push(p),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},Gi.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())},Gi.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)},Gi.prototype._clearBeaconQueue=function(){var v=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,f=this._eventQueue.slice(v);v>0&&Object.assign(f[f.length-1],od({mux_view_message:"event queue truncated"}));var p=this._createPayload(f);Mf(this._beaconUrl,p,!0,function(){})},Gi.prototype._sendBeaconQueue=function(){var v=this;if(!this._postInFlight){var f=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var p=this._createPayload(f),b=x.now();Mf(this._beaconUrl,p,!1,function(_,L){L?(v._eventQueue=f.concat(v._eventQueue),v._failureCount+=1,A.info("Error sending beacon: "+L)):v._failureCount=0,v._roundTripTime=x.now()-b,v._postInFlight=!1})}},Gi.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},Gi.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()))},Gi.prototype._createPayload=function(v){var f,p,b,_=this,L={transmission_timestamp:Math.round(x.now())};this._roundTripTime&&(L.rtt_ms=Math.round(this._roundTripTime));var I=function(){f=JSON.stringify({metadata:L,events:p||v}),b=f.length/1024},k=function(){return b<=_._options.maxPayloadKBSize};return I(),k()||(A.info("Payload size is too big ("+b+" kb). Removing unnecessary events."),p=v.filter(function(U){return iE.indexOf(U.e)===-1}),I()),k()||(A.info("Payload size still too big ("+b+" 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))}}),I()),f};var sE=function(v){return v.length<=57344},Mf=function(v,f,p,b){if(p&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(v,f))b();else if(d().fetch)d().fetch(v,{method:"POST",body:f,headers:{"Content-Type":"text/plain"},keepalive:sE(f)}).then(function(L){return b(null,L.ok?null:"Error")}).catch(function(L){return b(null,L)});else{if(d().XMLHttpRequest){var _=new(d()).XMLHttpRequest;return _.onreadystatechange=function(){if(_.readyState===4)return b(null,_.status!==200?"error":void 0)},_.open("POST",v),_.setRequestHeader("Content-Type","text/plain"),void _.send(f)}b()}},nE=Gi;function aE(v,f){return function(p){if(Array.isArray(p))return p}(v)||function(p,b){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var L,I,k=[],U=!0,C=!1;try{for(_=_.call(p);!(U=(L=_.next()).done)&&(k.push(L.value),!b||k.length!==b);U=!0);}catch(K){C=!0,I=K}finally{try{U||_.return==null||_.return()}finally{if(C)throw I}}return k}}(v,f)||function(p,b){if(p){if(typeof p=="string")return Of(p,b);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(_)?Of(p,b):void 0}}(v,f)||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 Of(v,f){(f==null||f>v.length)&&(f=v.length);for(var p=0,b=new Array(f);p<f;p++)b[p]=v[p];return b}function Pf(v,f){var p=Object.keys(v);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(v);f&&(b=b.filter(function(_){return Object.getOwnPropertyDescriptor(v,_).enumerable})),p.push.apply(p,b)}return p}function ms(v){for(var f=1;f<arguments.length;f++){var p=arguments[f]!=null?arguments[f]:{};f%2?Pf(Object(p),!0).forEach(function(b){_a(v,b,p[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Pf(Object(p)).forEach(function(b){Object.defineProperty(v,b,Object.getOwnPropertyDescriptor(p,b))})}return v}function ln(v){return ln=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f},ln(v)}function oE(v,f){if(!(v instanceof f))throw new TypeError("Cannot call a class as a function")}function Nf(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function _a(v,f,p){return f in v?Object.defineProperty(v,f,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[f]=p,v}var lE=["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"],dE=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse"],cE=["viewstart","error","ended","viewend"],uE=function(){function v(_,L){var I,k,U,C,K,ve,de,he,oe,me,Me,At,St,$t,ti,Ce=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};oE(this,v),_a(this,"previousBeaconData",null),_a(this,"lastEventTime",0),_a(this,"rateLimited",!1),this.mux=_,this.envKey=L,this.options=Ce,this.eventQueue=new nE(Zv(this.envKey,this.options)),this.sampleRate=(I=this.options.sampleRate)!==null&&I!==void 0?I:1,this.disableCookies=(k=this.options.disableCookies)!==null&&k!==void 0&&k,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||($t=St.os)===null||$t===void 0?void 0:$t.version,viewer_connection_type:Jv(),page_url:d()===null||d()===void 0||(ti=d().location)===null||ti===void 0?void 0:ti.href},this.viewerData=this.disableCookies?{}:Qv()}var f,p,b;return f=v,(p=[{key:"send",value:function(_,L){var I;if(_&&L!=null&&L.view_id){if(this.respectDoNotTrack&&R())return A.info("Not sending `"+_+"` because Do Not Track is enabled");if(!L||ln(L)!=="object")return A.error("A data object was expected in send() but was not provided");var k,U,C=this.disableCookies?{}:(k=Lf(),U=x.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<U)&&(k.sid=c(),k.sst=U),k.sex=U+15e5,Rf(k),{session_id:k.sid,session_start:k.sst,session_expires:k.sex}),K=ms(ms(ms(ms(ms({},this.pageLevelData),L),C),this.viewerData),{},{event:_,env_key:this.envKey});K.user_id&&(K.viewer_user_id=K.user_id,delete K.user_id);var ve=((I=K.mux_sample_number)!==null&&I!==void 0?I:0)>=this.sampleRate,de=od(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):cE.indexOf(_)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return K.event="eventrateexceeded",de=od(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(_,L){var I=this,k={},U=L.view_id;if(U==="-1"||_==="viewstart"||_==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)k=ms({},L),U&&(this.previousBeaconData=k),U&&_==="viewend"&&(this.previousBeaconData=null);else{var C=_.indexOf("request")===0;Object.entries(L).forEach(function(K){var ve=aE(K,2),de=ve[0],he=ve[1];I.previousBeaconData&&(he!==I.previousBeaconData[de]||lE.indexOf(de)>-1||I.objectHasChanged(C,de,he,I.previousBeaconData[de])||I.eventRequiresKey(_,de))&&(k[de]=he,I.previousBeaconData[de]=he)})}return k}},{key:"objectHasChanged",value:function(_,L,I,k){return!(!_||L.indexOf("request_")!==0||L!=="request_response_headers"&&ln(I)==="object"&&ln(k)==="object"&&Object.keys(I||{}).length===Object.keys(k||{}).length)}},{key:"eventRequiresKey",value:function(_,L){return _==="renditionchange"&&L.indexOf("video_source_")===0||!(L.indexOf("ad_id")!==0||!dE.includes(_))}}])&&Nf(f.prototype,p),b&&Nf(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}();function Ff(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function hE(v,f,p){return f&&Ff(v.prototype,f),p&&Ff(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var fE=hE(function v(f){(function(C,K){if(!(C instanceof K))throw new TypeError("Cannot call a class as a function")})(this,v);var p=0,b=0,_=0,L=0,I=0,k=0,U=0;f.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(L++,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;I++,b+=Me,_+=de,f.data.view_min_request_throughput=Math.min(f.data.view_min_request_throughput||1/0,At),f.data.view_average_request_throughput=b/_*8e3,f.data.view_request_count=L,ve>0&&(p+=ve,f.data.view_max_request_latency=Math.max(f.data.view_max_request_latency||0,ve),f.data.view_average_request_latency=p/I)}}),f.on("requestfailed",function(C,K){L++,k++,f.data.view_request_count=L,f.data.view_request_failed_count=k}),f.on("requestcanceled",function(C,K){L++,U++,f.data.view_request_count=L,f.data.view_request_canceled_count=U})});function Uf(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function mE(v,f,p){return f&&Uf(v.prototype,f),p&&Uf(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var pE=mE(function v(f){var p=this;(function(b,_){if(!(b instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),f.on("before*",function(b,_){var L=_.viewer_time,I=x.now(),k=p._lastEventTime;if(p._lastEventTime=I,k&&I-k>36e5){var U=Object.keys(f.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,f.data[K])):C},{});f.mux.log.info("Received event after at least an hour inactivity, creating a new view"),f.emit("viewinit",Object.assign({viewer_time:L},U)),f.playbackHeartbeat._playheadShouldBeProgressing&&b.type!=="play"&&b.type!=="adbreakstart"&&(f.emit("play",{viewer_time:L}),b.type!=="playing"&&f.emit("playing",{viewer_time:L}))}})});function ld(v){return ld=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f},ld(v)}function gE(v,f){return function(p){if(Array.isArray(p))return p}(v)||function(p,b){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var L,I,k=[],U=!0,C=!1;try{for(_=_.call(p);!(U=(L=_.next()).done)&&(k.push(L.value),!b||k.length!==b);U=!0);}catch(K){C=!0,I=K}finally{try{U||_.return==null||_.return()}finally{if(C)throw I}}return k}}(v,f)||function(p,b){if(p){if(typeof p=="string")return Bf(p,b);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(_)?Bf(p,b):void 0}}(v,f)||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 Bf(v,f){(f==null||f>v.length)&&(f=v.length);for(var p=0,b=new Array(f);p<f;p++)b[p]=v[p];return b}function $f(v,f){for(var p=0;p<f.length;p++){var b=f[p];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function dd(v,f){return dd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,b){return p.__proto__=b,p},dd(v,f)}function vE(v){var f=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,b=Aa(v);if(f){var _=Aa(this).constructor;p=Reflect.construct(b,arguments,_)}else p=b.apply(this,arguments);return EE(this,p)}}function EE(v,f){if(f&&(ld(f)==="object"||typeof f=="function"))return f;if(f!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return gt(v)}function gt(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function Aa(v){return Aa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(f){return f.__proto__||Object.getPrototypeOf(f)},Aa(v)}var yE=["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"],bE=function(v){(function(I,k){if(typeof k!="function"&&k!==null)throw new TypeError("Super expression must either be null or a function");I.prototype=Object.create(k&&k.prototype,{constructor:{value:I,writable:!0,configurable:!0}}),Object.defineProperty(I,"prototype",{writable:!1}),k&&dd(I,k)})(L,v);var f,p,b,_=vE(L);function L(I,k,U){var C;(function(oe,me){if(!(oe instanceof me))throw new TypeError("Cannot call a class as a function")})(this,L),(C=_.call(this)).DOM_CONTENT_LOADED_EVENT_END=$.domContentLoadedEventEnd(),C.NAVIGATION_START=$.navigationStart(),C.mux=I,C.id=k,(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 uE(I,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(gt(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(gt(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)}),yE.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 pE(gt(C)),C.errorTracker=new Jt(gt(C)),new zv(gt(C)),C.seekingTracker=new Vv(gt(C)),C.playheadTime=new rt(gt(C)),C.playbackHeartbeat=new _t(gt(C)),new Gv(gt(C)),C.watchTimeTracker=new bi(gt(C)),new sn(gt(C)),C.adTracker=new Wv(gt(C)),new Uv(gt(C)),new Ta(gt(C)),new Bv(gt(C)),new Yv(gt(C)),new fE(gt(C)),U.hlsjs&&C.addHLSJS(U),U.dashjs&&C.addDashJS(U),C.emit("viewinit",U.data),C}return f=L,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(I){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(ve){k[ve]=void 0}),k.video_source_url=k.video_source_url||k.player_source_url,k.video_source_url){var U=gE(w(k.video_source_url),2),C=U[0],K=U[1];k.video_source_domain=K,k.video_source_hostname=C}delete k.ad_request_id,this.playbackEventDispatcher.send(I,k),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),I==="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 I=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(k){var U=parseInt(I.data[k],10);I.data[k]=isNaN(U)?void 0:U}),["player_source_url","video_source_url"].forEach(function(k){if(I.data[k]){var U=I.data[k].toLowerCase();U.indexOf("data:")!==0&&U.indexOf("blob:")!==0||(I.data[k]="MSE style URL")}})}},{key:"_resetVideoData",value:function(I,k){var U=this;Object.keys(this.data).forEach(function(C){C.indexOf("video_")===0&&delete U.data[C]})}},{key:"_resetViewData",value:function(){var I=this;Object.keys(this.data).forEach(function(k){k.indexOf("view_")===0&&delete I.data[k]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(I,k){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var I=this,k=this.data.view_id=c(),U=function(){k===I.data.view_id&&O(I.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",U):U()}},{key:"_restartHeartBeat",value:function(){var I=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){I.data.player_is_paused||I.emit("hb")},1e4))}},{key:"addHLSJS",value:function(I){I.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=I.hlsjs,function(k,U,C){var K=arguments.length>4?arguments[4]:void 0,ve=k.log,de=k.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 k.emit(U,Oe,Q)},me=function(Oe,Q){var fe=Q.levels,ee=Q.audioTracks,Te=Q.url,De=Q.stats,ct=Q.networkDetails,Gt=Q.sessionData,xt={},Nt={};fe.forEach(function(ft,hn){xt[hn]={width:ft.width,height:ft.height,bitrate:ft.bitrate,attrs:ft.attrs}}),ee.forEach(function(ft,hn){Nt[hn]={name:ft.name,language:ft.lang,bitrate:ft.bitrate}});var vt=we(De),Et=vt.bytesLoaded,nr=vt.requestStart,un=vt.responseStart,kr=vt.responseEnd;oe("requestcompleted",Ee(Ee({},j(Gt)),{},{request_event_type:Oe,request_bytes_loaded:Et,request_start:nr,request_response_start:un,request_response_end:kr,request_type:"manifest",request_hostname:N(Te),request_response_headers:Se(ct),request_rendition_lists:{media:xt,audio:Nt,video:{}}}))};C.on(K.Events.MANIFEST_LOADED,me);var Me=function(Oe,Q){var fe=Q.details,ee=Q.level,Te=Q.networkDetails,De=Q.stats,ct=we(De),Gt=ct.bytesLoaded,xt=ct.requestStart,Nt=ct.responseStart,vt=ct.responseEnd,Et=fe.fragments[fe.fragments.length-1],nr=he(Et)+de(Et.duration);oe("requestcompleted",{request_event_type:Oe,request_bytes_loaded:Gt,request_start:xt,request_response_start:Nt,request_response_end:vt,request_current_level:ee,request_type:"manifest",request_hostname:N(fe.url),request_response_headers:Se(Te),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(nr)?void 0:nr})};C.on(K.Events.LEVEL_LOADED,Me);var At=function(Oe,Q){var fe=Q.details,ee=Q.networkDetails,Te=Q.stats,De=we(Te),ct=De.bytesLoaded,Gt=De.requestStart,xt=De.responseStart,Nt=De.responseEnd;oe("requestcompleted",{request_event_type:Oe,request_bytes_loaded:ct,request_start:Gt,request_response_start:xt,request_response_end:Nt,request_type:"manifest",request_hostname:N(fe.url),request_response_headers:Se(ee)})};C.on(K.Events.AUDIO_TRACK_LOADED,At);var St=function(Oe,Q){var fe=Q.stats,ee=Q.networkDetails,Te=Q.frag;fe=fe||Te.stats;var De=we(fe),ct=De.bytesLoaded,Gt=De.requestStart,xt=De.responseStart,Nt=De.responseEnd,vt=ee?Se(ee):void 0,Et={request_event_type:Oe,request_bytes_loaded:ct,request_start:Gt,request_response_start:xt,request_response_end:Nt,request_hostname:ee?N(ee.responseURL):void 0,request_id:vt?X(vt):void 0,request_response_headers:vt,request_media_duration:Te.duration,request_url:ee==null?void 0:ee.responseURL};Te.type==="main"?(Et.request_type="media",Et.request_current_level=Te.level,Et.request_video_width=(C.levels[Te.level]||{}).width,Et.request_video_height=(C.levels[Te.level]||{}).height,Et.request_labeled_bitrate=(C.levels[Te.level]||{}).bitrate):Et.request_type=Te.type,oe("requestcompleted",Et)};C.on(K.Events.FRAG_LOADED,St);var $t=function(Oe,Q){var fe=Q.frag,ee=fe.start,Te={currentFragmentPDT:he(fe),currentFragmentStart:de(ee)};oe("fragmentchange",Te)};C.on(K.Events.FRAG_CHANGED,$t);var ti=function(Oe,Q){var fe=Q.type,ee=Q.details,Te=Q.response,De=Q.fatal,ct=Q.frag,Gt=Q.networkDetails,xt=(ct==null?void 0:ct.url)||Q.url||"",Nt=Gt?Se(Gt):void 0;if(ee!==K.ErrorDetails.MANIFEST_LOAD_ERROR&&ee!==K.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&ee!==K.ErrorDetails.FRAG_LOAD_ERROR&&ee!==K.ErrorDetails.FRAG_LOAD_TIMEOUT&&ee!==K.ErrorDetails.LEVEL_LOAD_ERROR&&ee!==K.ErrorDetails.LEVEL_LOAD_TIMEOUT&&ee!==K.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&ee!==K.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&ee!==K.ErrorDetails.SUBTITLE_LOAD_ERROR&&ee!==K.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&ee!==K.ErrorDetails.KEY_LOAD_ERROR&&ee!==K.ErrorDetails.KEY_LOAD_TIMEOUT||oe("requestfailed",{request_error:ee,request_url:xt,request_hostname:N(xt),request_id:Nt?X(Nt):void 0,request_type:ee===K.ErrorDetails.FRAG_LOAD_ERROR||ee===K.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":ee===K.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||ee===K.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":ee===K.ErrorDetails.SUBTITLE_LOAD_ERROR||ee===K.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":ee===K.ErrorDetails.KEY_LOAD_ERROR||ee===K.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:Te==null?void 0:Te.code,request_error_text:Te==null?void 0:Te.text}),De){var vt,Et="".concat(xt?"url: ".concat(xt,`
|
|
5
5
|
`):"")+"".concat(Te&&(Te.code||Te.text)?"response: ".concat(Te.code,", ").concat(Te.text,`
|
|
6
6
|
`):"")+"".concat(Q.reason?"failure reason: ".concat(Q.reason,`
|
|
7
7
|
`):"")+"".concat(Q.level?"level: ".concat(Q.level,`
|
|
@@ -10,13 +10,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
10
10
|
`):"")+"".concat(Q.error?"error: ".concat(Q.error,`
|
|
11
11
|
`):"")+"".concat(Q.event?"event: ".concat(Q.event,`
|
|
12
12
|
`):"")+"".concat(Q.err?"error message: ".concat((vt=Q.err)===null||vt===void 0?void 0:vt.message,`
|
|
13
|
-
`):"");oe("error",{player_error_code:fe,player_error_message:ee,player_error_context:Et})}};C.on(K.Events.ERROR,ti);var Ce=function(Oe,Q){var fe=Q.frag,ee=fe&&fe._url||"";oe("requestcanceled",{request_event_type:Oe,request_url:ee,request_type:"media",request_hostname:N(ee)})};C.on(K.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ce);var lt=function(Oe,Q){var fe=Q.level,ee=C.levels[fe];if(ee&&ee.attrs&&ee.attrs.BANDWIDTH){var Te,De=ee.attrs.BANDWIDTH,ct=parseFloat(ee.attrs["FRAME-RATE"]);isNaN(ct)||(Te=ct),De?oe("renditionchange",{video_source_fps:Te,video_source_bitrate:De,video_source_width:ee.width,video_source_height:ee.height,video_source_rendition_name:ee.name,video_source_codec:ee==null?void 0:ee.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,$t),C.off(K.Events.ERROR,ti),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,I.hlsjs,{},I.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var I;this.hlsjs&&((I=this.hlsjs)&&typeof I._stopMuxMonitor=="function"&&I._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(I){I.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=I.dashjs,function(k,U,C){var K=k.log;if(C&&C.on){var ve=function(Ce,lt){return k.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,ee=Q.bitrateList,Te={};(ee=ee||[]).forEach(function(kr,ft){Te[ft]={},Te[ft].width=kr.width,Te[ft].height=kr.height,Te[ft].bitrate=kr.bandwidth,Te[ft].attrs={}}),fe==="video"?he.video=Te:fe==="audio"?he.audio=Te:he.media=Te;var De=xe(Oe,C),ct=De.requestStart,Gt=De.requestResponseStart,xt=De.requestResponseEnd,Nt=De.requestResponseHeaders,vt=De.requestMediaDuration,Et=De.requestHostname,nr=De.requestUrl,un=De.requestId;ve("requestcompleted",{request_event_type:lt,request_start:ct,request_response_start:Gt,request_response_end:xt,request_bytes_loaded:-1,request_type:fe+"_init",request_response_headers:Nt,request_hostname:Et,request_id:un,request_url:nr,request_media_duration:vt,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,ee=Q.start,Te=(fe||{}).type,De=xe(Oe,C),ct=De.requestStart,Gt=De.requestResponseStart,xt=De.requestResponseEnd,Nt=De.requestBytesLoaded,vt=De.requestResponseHeaders,Et=De.requestMediaDuration,nr=De.requestHostname,un=De.requestUrl,kr=De.requestId,ft=Ie(Te,C),hn=ft.currentLevel
|
|
13
|
+
`):"");oe("error",{player_error_code:fe,player_error_message:ee,player_error_context:Et})}};C.on(K.Events.ERROR,ti);var Ce=function(Oe,Q){var fe=Q.frag,ee=fe&&fe._url||"";oe("requestcanceled",{request_event_type:Oe,request_url:ee,request_type:"media",request_hostname:N(ee)})};C.on(K.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ce);var lt=function(Oe,Q){var fe=Q.level,ee=C.levels[fe];if(ee&&ee.attrs&&ee.attrs.BANDWIDTH){var Te,De=ee.attrs.BANDWIDTH,ct=parseFloat(ee.attrs["FRAME-RATE"]);isNaN(ct)||(Te=ct),De?oe("renditionchange",{video_source_fps:Te,video_source_bitrate:De,video_source_width:ee.width,video_source_height:ee.height,video_source_rendition_name:ee.name,video_source_codec:ee==null?void 0:ee.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,$t),C.off(K.Events.ERROR,ti),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,I.hlsjs,{},I.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var I;this.hlsjs&&((I=this.hlsjs)&&typeof I._stopMuxMonitor=="function"&&I._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(I){I.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=I.dashjs,function(k,U,C){var K=k.log;if(C&&C.on){var ve=function(Ce,lt){return k.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,ee=Q.bitrateList,Te={};(ee=ee||[]).forEach(function(kr,ft){Te[ft]={},Te[ft].width=kr.width,Te[ft].height=kr.height,Te[ft].bitrate=kr.bandwidth,Te[ft].attrs={}}),fe==="video"?he.video=Te:fe==="audio"?he.audio=Te:he.media=Te;var De=xe(Oe,C),ct=De.requestStart,Gt=De.requestResponseStart,xt=De.requestResponseEnd,Nt=De.requestResponseHeaders,vt=De.requestMediaDuration,Et=De.requestHostname,nr=De.requestUrl,un=De.requestId;ve("requestcompleted",{request_event_type:lt,request_start:ct,request_response_start:Gt,request_response_end:xt,request_bytes_loaded:-1,request_type:fe+"_init",request_response_headers:Nt,request_hostname:Et,request_id:un,request_url:nr,request_media_duration:vt,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,ee=Q.start,Te=(fe||{}).type,De=xe(Oe,C),ct=De.requestStart,Gt=De.requestResponseStart,xt=De.requestResponseEnd,Nt=De.requestBytesLoaded,vt=De.requestResponseHeaders,Et=De.requestMediaDuration,nr=De.requestHostname,un=De.requestUrl,kr=De.requestId,ft=Ie(Te,C),hn=ft.currentLevel,VE=ft.renditionWidth,KE=ft.renditionHeight,WE=ft.renditionBitrate;ve("requestcompleted",{request_event_type:lt,request_start:ct,request_response_start:Gt,request_response_end:xt,request_bytes_loaded:Nt,request_type:Te,request_response_headers:vt,request_hostname:nr,request_id:kr,request_url:un,request_media_start_time:ee,request_media_duration:Et,request_current_level:hn,request_labeled_bitrate:WE,request_video_width:VE,request_video_height:KE})};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:$e(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(Te){return Te.qualityIndex===Ce.newQuality});if(fe&&typeof fe.bitrate=="number"){Me[Q]=ae(ae({},fe),{},{codec:C.getCurrentTrackFor(Q).codec});var ee=At();ee&&ve("renditionchange",ee)}else K.warn("missing bitrate info for ".concat(Q))}}else K.warn("missing evt.newQuality in qualityChangeRendered event",Ce)};C.on("qualityChangeRendered",St);var $t=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",$t);var ti=function(Ce){var lt,Oe,Q=Ce.error,fe=(Q==null||(lt=Q.data)===null||lt===void 0?void 0:lt.request)||{},ee=(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:ee.status,request_error_text:ee.statusText});var Te="".concat(fe!=null&&fe.url?"url: ".concat(fe.url,`
|
|
14
14
|
`):"")+"".concat(ee!=null&&ee.status||ee!=null&&ee.statusText?"response: ".concat(ee==null?void 0:ee.status,", ").concat(ee==null?void 0:ee.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:Te})};C.on("error",ti),C._stopMuxMonitor=function(){C.off("manifestLoaded",de),C.off("initFragmentLoaded",oe),C.off("mediaFragmentLoaded",me),C.off("qualityChangeRendered",St),C.off("error",ti),C.off("fragmentLoadingAbandoned",$t),delete C._stopMuxMonitor}}else K.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,I.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var I;this.dashjs&&((I=this.dashjs)&&typeof I._stopMuxMonitor=="function"&&I._stopMuxMonitor(),this.dashjs=void 0)}}],p
|
|
16
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function
|
|
17
|
-
`);
|
|
18
|
-
`))this.processLine(this.buffer.substring(0,
|
|
19
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Gf(v,m){(m==null||m>v.length)&&(m=v.length);for(var p=0,b=new Array(m);p<m;p++)b[p]=v[p];return b}var ei={},cn=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.")},UE={loaded:x.now(),NAME:"mux-embed",VERSION:"4.24.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(v,m){return function(p,b,_){var L=Uf(f(b),3),I=L[0],k=L[1],U=L[2],C=p.log,K=p.utils.getComputedStyle,ve=p.utils.secondsToMs;if(!I)return C.error("No element was found with the `"+k+"` query selector.");if(U!=="video"&&U!=="audio")return C.error("The element of `"+k+"` was not a media element.");I.mux&&(I.mux.destroy(),delete I.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(I.currentTime)},_.getStateData=function(){var he,oe,me=this.hlsjs&&this.hlsjs.url,Me=this.dashjs&&dd(this.dashjs.getSource==="function")&&this.dashjs.getSource(),At={player_is_paused:I.paused,player_playhead_time:ve(I.currentTime),player_width:parseInt(K(I,"width")),player_height:parseInt(K(I,"height")),player_autoplay_on:I.autoplay,player_preload_on:I.preload,player_language_code:I.lang,player_is_fullscreen:dn()&&!!(dn().fullscreenElement||dn().webkitFullscreenElement||dn().mozFullScreenElement||dn().msFullscreenElement),video_poster_url:I.poster,video_source_url:me||Me||I.currentSrc,video_source_duration:ve(I.duration),video_source_height:I.videoHeight,video_source_width:I.videoWidth,view_dropped_frame_count:(he=I)===null||he===void 0||(oe=he.getVideoPlaybackQuality)===null||oe===void 0?void 0:oe.call(he).droppedVideoFrames},St=_.getPlayheadTime();if(I.getStartDate&&St>0){var $t=I.getStartDate();if($t&&typeof $t.getTime=="function"&&$t.getTime()){var ti=$t.getTime();if(At.player_program_time=ti+St,I.seekable.length>0){var Ce=ti+I.seekable.end(I.seekable.length-1);At.player_live_edge_program_time=Ce}}}return At},I.mux=I.mux||{},I.mux.deleted=!1,I.mux.emit=function(he,oe){p.emit(k,he,oe)};var de=function(){C.error("The monitor for this video element has already been destroyed.")};I.mux.destroy=function(){Object.keys(I.mux.listeners).forEach(function(he){I.removeEventListener(he,I.mux.listeners[he],!1)}),delete I.mux.listeners,I.mux.destroy=de,I.mux.swapElement=de,I.mux.emit=de,I.mux.addHLSJS=de,I.mux.addDashJS=de,I.mux.removeHLSJS=de,I.mux.removeDashJS=de,I.mux.deleted=!0,p.emit(k,"destroy")},I.mux.swapElement=function(he){var oe=Uf(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=I.muxId,delete I.muxId,me.mux=me.mux||{},me.mux.listeners=Object.assign({},I.mux.listeners),delete I.mux.listeners,Object.keys(me.mux.listeners).forEach(function(St){I.removeEventListener(St,me.mux.listeners[St],!1),me.addEventListener(St,me.mux.listeners[St],!1)}),me.mux.swapElement=I.mux.swapElement,me.mux.destroy=I.mux.destroy,delete I.mux,void(I=me)):p.log.error("No element was found with the `"+Me+"` query selector.")},I.mux.addHLSJS=function(he){p.addHLSJS(k,he)},I.mux.addDashJS=function(he){p.addDashJS(k,he)},I.mux.removeHLSJS=function(){p.removeHLSJS(k)},I.mux.removeDashJS=function(){p.removeDashJS(k)},p.init(k,_),p.emit(k,"playerready"),I.paused||(p.emit(k,"play"),I.readyState>2&&p.emit(k,"playing")),I.mux.listeners={},bE.forEach(function(he){(he!=="error"||_.automaticErrorTracking)&&(I.mux.listeners[he]=function(){var oe={};if(he==="error"){if(!I.error||I.error.code===1)return;oe.player_error_code=I.error.code,oe.player_error_message=TE[I.error.code]||I.error.message}p.emit(k,he,oe)},I.addEventListener(he,I.mux.listeners[he],!1))})}(cn,v,m)},destroyMonitor:function(v){var m=FE(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);ei[p]?ei[p].addHLSJS(m):A.error("A monitor for `"+p+"` has not been initialized.")},addDashJS:function(v,m){var p=h(v);ei[p]?ei[p].addDashJS(m):A.error("A monitor for `"+p+"` has not been initialized.")},removeHLSJS:function(v){var m=h(v);ei[m]?ei[m].removeHLSJS():A.error("A monitor for `"+m+"` has not been initialized.")},removeDashJS:function(v){var m=h(v);ei[m]?ei[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);ei[p]=new EE(cn,p,m)},emit:function(v,m,p){var b=h(v);ei[b]?(ei[b].emit(m,p),m==="destroy"&&delete ei[b]):A.error("A monitor for `"+b+"` has not been initialized.")},checkDoNotTrack:R,log:A,utils:PE,events:NE,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(cn,UE),d()!==void 0&&typeof d().addEventListener=="function"&&d().addEventListener("pagehide",function(v){v.persisted||(cn.WINDOW_UNLOADING=!0)},!1);var BE=cn},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 x=new Date;x.setMilliseconds(x.getMilliseconds()+864e5*A.expires),A.expires=x}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("; "):[],w=/(%[0-9A-Z]{2})+/g,$=0;$<N.length;$++){var O=N[$].split("="),H=O.slice(1).join("=");H.charAt(0)==='"'&&(H=H.slice(1,-1));try{var q=O[0].replace(w,decodeURIComponent);if(H=f.read?f.read(H,q):f(H,q)||H.replace(w,decodeURIComponent),this.json)try{H=JSON.parse(H)}catch{}if(E===q){R=H;break}E||(R[q]=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(P,X){var j=P[X];if(typeof j.bind=="function")return j.bind(P);try{return Function.prototype.bind.call(j,P)}catch{return function(){return Function.prototype.apply.apply(j,[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 R(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 x(P,X){for(var j=0;j<E.length;j++){var Ae=E[j];this[Ae]=j<P?h:this.methodFactory(Ae,P,X)}this.log=this.debug}function N(P,X,j){return function(){typeof console!==f&&(x.call(this,X,j),this[P].apply(this,arguments))}}function w(P,X,j){return R(P)||N.apply(this,arguments)}function $(P,X,j){var Ae,Ee=this;X=X==null?"WARN":X;var ye="loglevel";function we(se){var xe=(E[se]||"silent").toUpperCase();if(typeof window!==f&&ye){try{return void(window.localStorage[ye]=xe)}catch{}try{window.document.cookie=encodeURIComponent(ye)+"="+xe+";"}catch{}}}function Se(){var se;if(typeof window!==f&&ye){try{se=window.localStorage[ye]}catch{}if(typeof se===f)try{var xe=window.document.cookie,Ie=xe.indexOf(encodeURIComponent(ye)+"=");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&&ye){try{return void window.localStorage.removeItem(ye)}catch{}try{window.document.cookie=encodeURIComponent(ye)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof P=="string"?ye+=":"+P:typeof P=="symbol"&&(ye=void 0),Ee.name=P,Ee.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Ee.methodFactory=j||w,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),x.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 ae=Se();ae==null&&(ae=X),Ee.setLevel(ae,!1)}var O=new $,H={};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=H[P];return X||(X=H[P]=new $(P,O.getLevel(),O.methodFactory)),X};var q=typeof window!==f?window.log:void 0;return O.noConflict=function(){return typeof window!==f&&window.log===O&&(window.log=q),O},O.getLoggers=function(){return H},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(){}},i={};function s(n){var a=i[n];if(a!==void 0)return a.exports;var o=i[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 Ko=="object"&&typeof Bc=="object"?Bc.exports=e():typeof Ko=="object"?Ko.mux=e():r.mux=e()})()});var gs=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class r extends gs{}globalThis.DocumentFragment=r}var fn=class extends gs{},fd=class extends gs{},QE={get(r){},define(r,e,t){},upgrade(r){},whenDefined(r){return Promise.resolve(fn)}},mn,md=class{constructor(e,t={}){ut(this,mn,void 0);ii(this,mn,t==null?void 0:t.detail)}get detail(){return Ne(this,mn)}initCustomEvent(){}};mn=new WeakMap;function ZE(r,e){return new fn}var Vf={document:{createElement:ZE},DocumentFragment,customElements:QE,CustomEvent:md,EventTarget:gs,HTMLElement:fn,HTMLVideoElement:fd},Kf=typeof window=="undefined"||typeof globalThis.customElements=="undefined",at=Kf?Vf:globalThis,Qt=Kf?Vf.document:globalThis.document;var ne={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_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},_e={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},wr={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",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"},Wf=Object.entries(wr),S=Wf.reduce((r,[e,t])=>(r[e]=`${t.toLowerCase()}`,r),{}),vs=Wf.reduce((r,[e,t])=>(r[e]=`${t.toLowerCase()}`,r),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange"}),QS=Object.entries(vs).reduce((r,[e,t])=>{let i=S[e];return i&&(r[t]=i),r},{userinactivechange:"userinactive"}),qf=Object.entries(S).reduce((r,[e,t])=>{let i=vs[e];return i&&(r[t]=i),r},{userinactive:"userinactivechange"}),Es={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},xa={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var pd={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},ri={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},di={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var Dt={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:r=1}={})=>`current playback rate ${r}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading"},je={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",AIRPLAY:()=>"air play",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:r=30}={})=>`seek forward ${r} seconds`,SEEK_BACK_N_SECS:({seekOffset:r=30}={})=>`seek back ${r} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"},ey={...Dt,...je};function Yf(r){return r==null?void 0:r.map(ty).join(" ")}function jf(r){return r==null?void 0:r.split(/\s+/).map(iy)}function ty(r){if(r){let{id:e,width:t,height:i}=r;return[e,t,i].filter(s=>s!=null).join(":")}}function iy(r){if(r){let[e,t,i]=r.split(":");return{id:e,width:t,height:i}}}function Ia(r,e=!1){return r.split("_").map(function(t,i){return(i||e?t[0].toUpperCase():t[0].toLowerCase())+t.slice(1).toLowerCase()}).join("")}function zf(r){return r.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Xf(r){return typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r)}function La(r){return typeof r!="string"?!1:!isNaN(r)&&!isNaN(parseFloat(r))}var Ra=r=>new Promise(e=>setTimeout(e,r));var Qf=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],ry=(r,e)=>{let t=r===1?Qf[e].singular:Qf[e].plural;return`${r} ${t}`},Dr=r=>{if(!Xf(r))return"";let e=Math.abs(r),t=e!==r,i=new Date(0,0,0,0,0,e,0);return`${[i.getHours(),i.getMinutes(),i.getSeconds()].map((o,l)=>o&&ry(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function Ti(r,e){let t=!1;r<0&&(t=!0,r=0-r),r=r<0?0:r;let i=Math.floor(r%60),s=Math.floor(r/60%60),n=Math.floor(r/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(r)||r===1/0)&&(n=s=i="0"),n=n>0||o>0?n+":":"",s=((n||a>=10)&&s<10?"0"+s:s)+":",i=i<10?"0"+i:i,(t?"-":"")+n+s+i}var tx=Object.freeze({length:0,start(r){let e=r>>>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(r){let e=r>>>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 ka=(r,e,t=".value")=>{let i=r.querySelector(t);!i||(i.textContent=e)},ny=(r,e)=>{let t=`slot[name="${e}"]`,i=r.shadowRoot.querySelector(t);return i?i.children:[]},wa=(r,e)=>ny(r,e)[0],pn=(r,e)=>!r||!e?!1:r.contains(e)?!0:pn(r,e.getRootNode().host),Cr=(r,e)=>{if(!r)return null;let t=r.closest(e);return t||Cr(r.getRootNode().host,e)};function ze(r,e){var t;let i;for(i of r.querySelectorAll("style")){let s;try{s=(t=i.sheet)==null?void 0:t.cssRules}catch{continue}for(let n of s!=null?s:[])if(n.selectorText===e)return n}return i!=null&&i.sheet?(i.sheet.insertRule(`${e}{}`,i.sheet.cssRules.length),i.sheet.cssRules[i.sheet.cssRules.length-1]):{style:{setProperty:()=>{},removeProperty:()=>{}}}}function Ue(r,e,t=Number.NaN){let i=r.getAttribute(e);return i!=null?+i:t}function Ye(r,e,t){let i=+t;if(t==null||Number.isNaN(i)){r.hasAttribute(e)&&r.removeAttribute(e);return}Ue(r,e,void 0)!==i&&r.setAttribute(e,`${i}`)}function Ke(r,e){return r.hasAttribute(e)}function Ge(r,e,t){if(t==null){r.hasAttribute(e)&&r.removeAttribute(e);return}Ke(r,e)!=t&&r.toggleAttribute(e,t)}function et(r,e,t=null){var i;return(i=r.getAttribute(e))!=null?i:t}function Xe(r,e,t){if(t==null){r.hasAttribute(e)&&r.removeAttribute(e);return}let i=`${t}`;et(r,e,void 0)!==i&&r.setAttribute(e,i)}var Da=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},gd=class{observe(){}},Zf={createElement:function(){return new vd.HTMLElement},addEventListener(){},removeEventListener(){}},vd={ResizeObserver:gd,document:Zf,HTMLElement:class extends Da{},DocumentFragment:class extends Da{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},CustomEvent:function(){},getComputedStyle:function(){}},Jf=typeof window=="undefined"||typeof window.customElements=="undefined",em=Object.keys(vd).every(r=>r in globalThis),D=Jf&&!em?vd:globalThis,z=Jf&&!em?Zf:globalThis.document;var ay=Object.defineProperty,oy=(r,e,t)=>e in r?ay(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ly=(r,e,t)=>(oy(r,typeof e!="symbol"?e+"":e,t),t),tm=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},si=(r,e,t)=>(tm(r,e,"read from private field"),t?t.call(r):e.get(r)),Ca=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Ma=(r,e,t,i)=>(tm(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),_i,Oa,ys,Pa,im=z.createElement("template");im.innerHTML=`
|
|
15
|
+
`):"");ve("error",{player_error_code:Q==null?void 0:Q.code,player_error_message:Q==null?void 0:Q.message,player_error_context:Te})};C.on("error",ti),C._stopMuxMonitor=function(){C.off("manifestLoaded",de),C.off("initFragmentLoaded",oe),C.off("mediaFragmentLoaded",me),C.off("qualityChangeRendered",St),C.off("error",ti),C.off("fragmentLoadingAbandoned",$t),delete C._stopMuxMonitor}}else K.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,I.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var I;this.dashjs&&((I=this.dashjs)&&typeof I._stopMuxMonitor=="function"&&I._stopMuxMonitor(),this.dashjs=void 0)}}],p&&$f(f.prototype,p),b&&$f(f,b),Object.defineProperty(f,"prototype",{writable:!1}),L}(Re),TE=bE,_E=o(153),dn=o.n(_E);function cd(v){return cd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f},cd(v)}function Gf(v,f){return function(p){if(Array.isArray(p))return p}(v)||function(p,b){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var L,I,k=[],U=!0,C=!1;try{for(_=_.call(p);!(U=(L=_.next()).done)&&(k.push(L.value),!b||k.length!==b);U=!0);}catch(K){C=!0,I=K}finally{try{U||_.return==null||_.return()}finally{if(C)throw I}}return k}}(v,f)||function(p,b){if(p){if(typeof p=="string")return Hf(p,b);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(_)?Hf(p,b):void 0}}(v,f)||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 Hf(v,f){(f==null||f>v.length)&&(f=v.length);for(var p=0,b=new Array(f);p<f;p++)b[p]=v[p];return b}var ps,AE=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],SE={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};d()&&d().WeakMap&&(ps=new WeakMap);var xE="#EXT-X-TARGETDURATION",IE="#EXT-X-PART-INF",LE="#EXT-X-SERVER-CONTROL",RE="#EXTINF",kE="#EXT-X-PROGRAM-DATE-TIME",wE="#EXT-X-VERSION",DE="#EXT-X-SESSION-DATA",Sa=function(v){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(v),this.manifest};Sa.prototype.process=function(v){var f;for(this.buffer+=v,f=this.buffer.indexOf(`
|
|
17
|
+
`);f>-1;f=this.buffer.indexOf(`
|
|
18
|
+
`))this.processLine(this.buffer.substring(0,f)),this.buffer=this.buffer.substring(f+1)},Sa.prototype.processLine=function(v){var f=v.indexOf(":"),p=PE(v,f),b=p[0],_=p.length===2?hd(p[1]):void 0;if(b[0]!=="#")this.currentUri.uri=b,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(b){case xE:if(!isFinite(_)||_<0)return;this.manifest.targetDuration=_,this.setHoldBack();break;case IE:ud(this.manifest,p),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case LE:ud(this.manifest,p),this.setHoldBack();break;case RE:_===0?this.currentUri.duration=.01:_>0&&(this.currentUri.duration=_);break;case kE:var L=_,I=new Date(L);this.manifest.dateTimeString||(this.manifest.dateTimeString=L,this.manifest.dateTimeObject=I),this.currentUri.dateTimeString=L,this.currentUri.dateTimeObject=I;break;case wE:ud(this.manifest,p);break;case DE:var k=NE(p[1]),U=j(k);Object.assign(this.manifest.sessionData,U)}},Sa.prototype.setHoldBack=function(){var v=this.manifest,f=v.serverControl,p=v.targetDuration,b=v.partTargetDuration;if(f){var _="holdBack",L="partHoldBack",I=p&&3*p,k=b&&2*b;p&&!f.hasOwnProperty(_)&&(f[_]=I),I&&f[_]<I&&(f[_]=I),b&&!f.hasOwnProperty(L)&&(f[L]=3*b),b&&f[L]<k&&(f[L]=k)}};var ud=function(v,f){var p,b=Vf(f[0].replace("#EXT-X-",""));OE(f[1])?(p={},p=Object.assign(ME(f[1]),p)):p=hd(f[1]),v[b]=p},Vf=function(v){return v.toLowerCase().replace(/-(\w)/g,function(f){return f[1].toUpperCase()})},hd=function(v){if(v.toLowerCase()==="yes"||v.toLowerCase()==="no")return v.toLowerCase()==="yes";var f=v.indexOf(":")!==-1?v:parseFloat(v);return isNaN(f)?v:f},CE=function(v){var f={},p=v.split("=");return p.length>1&&(f[Vf(p[0])]=hd(p[1])),f},ME=function(v){for(var f=v.split(","),p={},b=0;f.length>b;b++){var _=f[b],L=CE(_);p=Object.assign(L,p)}return p},OE=function(v){return v.indexOf("=")>-1},PE=function(v,f){return f===-1?[v]:[v.substring(0,f),v.substring(f+1)]},NE=function(v){var f={};if(v){var p=v.search(",");return[v.slice(0,p),v.slice(p+1)].forEach(function(b,_){for(var L=b.replace(/['"]+/g,"").split("="),I=0;I<L.length;I++)L[I]==="DATA-ID"&&(f["DATA-ID"]=L[1-I]),L[I]==="VALUE"&&(f.VALUE=L[1-I])}),{data:f}}},FE=Sa,UE={safeCall:function(v,f,p,b){var _=b;if(v&&typeof v[f]=="function")try{_=v[f].apply(v,p)}catch(L){A.info("safeCall error",L)}return _},safeIncrement:O,getComputedStyle:function(v,f){var p;if(v&&f&&d()&&typeof d().getComputedStyle=="function")return ps&&ps.has(v)&&(p=ps.get(v)),p||(p=d().getComputedStyle(v,null),ps&&ps.set(v,p)),p.getPropertyValue(f)},secondsToMs:function(v){return Math.floor(1e3*v)},assign:Object.assign,headersStringToObject:P,cdnHeadersToRequestId:X,extractHostnameAndDomain:w,extractHostname:N,manifestParser:FE,generateShortID:u,generateUUID:c,now:x.now},BE={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 $E(v,f){return function(p){if(Array.isArray(p))return p}(v)||function(p,b){var _=p==null?null:typeof Symbol!="undefined"&&p[Symbol.iterator]||p["@@iterator"];if(_!=null){var L,I,k=[],U=!0,C=!1;try{for(_=_.call(p);!(U=(L=_.next()).done)&&(k.push(L.value),!b||k.length!==b);U=!0);}catch(K){C=!0,I=K}finally{try{U||_.return==null||_.return()}finally{if(C)throw I}}return k}}(v,f)||function(p,b){if(p){if(typeof p=="string")return Kf(p,b);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(_)?Kf(p,b):void 0}}(v,f)||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 Kf(v,f){(f==null||f>v.length)&&(f=v.length);for(var p=0,b=new Array(f);p<f;p++)b[p]=v[p];return b}var ei={},cn=function v(f){var p=arguments;typeof f=="string"?v.hasOwnProperty(f)?d().setTimeout(function(){p=Array.prototype.splice.call(p,1),v[f].apply(null,p)},0):A.warn("`"+f+"` is an unknown task"):typeof f=="function"?d().setTimeout(function(){f(v)},0):A.warn("`"+f+"` is invalid.")},GE={loaded:x.now(),NAME:"mux-embed",VERSION:"4.24.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(v,f){return function(p,b,_){var L=Gf(m(b),3),I=L[0],k=L[1],U=L[2],C=p.log,K=p.utils.getComputedStyle,ve=p.utils.secondsToMs;if(!I)return C.error("No element was found with the `"+k+"` query selector.");if(U!=="video"&&U!=="audio")return C.error("The element of `"+k+"` was not a media element.");I.mux&&(I.mux.destroy(),delete I.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(I.currentTime)},_.getStateData=function(){var he,oe,me=this.hlsjs&&this.hlsjs.url,Me=this.dashjs&&cd(this.dashjs.getSource==="function")&&this.dashjs.getSource(),At={player_is_paused:I.paused,player_playhead_time:ve(I.currentTime),player_width:parseInt(K(I,"width")),player_height:parseInt(K(I,"height")),player_autoplay_on:I.autoplay,player_preload_on:I.preload,player_language_code:I.lang,player_is_fullscreen:dn()&&!!(dn().fullscreenElement||dn().webkitFullscreenElement||dn().mozFullScreenElement||dn().msFullscreenElement),video_poster_url:I.poster,video_source_url:me||Me||I.currentSrc,video_source_duration:ve(I.duration),video_source_height:I.videoHeight,video_source_width:I.videoWidth,view_dropped_frame_count:(he=I)===null||he===void 0||(oe=he.getVideoPlaybackQuality)===null||oe===void 0?void 0:oe.call(he).droppedVideoFrames},St=_.getPlayheadTime();if(I.getStartDate&&St>0){var $t=I.getStartDate();if($t&&typeof $t.getTime=="function"&&$t.getTime()){var ti=$t.getTime();if(At.player_program_time=ti+St,I.seekable.length>0){var Ce=ti+I.seekable.end(I.seekable.length-1);At.player_live_edge_program_time=Ce}}}return At},I.mux=I.mux||{},I.mux.deleted=!1,I.mux.emit=function(he,oe){p.emit(k,he,oe)};var de=function(){C.error("The monitor for this video element has already been destroyed.")};I.mux.destroy=function(){Object.keys(I.mux.listeners).forEach(function(he){I.removeEventListener(he,I.mux.listeners[he],!1)}),delete I.mux.listeners,I.mux.destroy=de,I.mux.swapElement=de,I.mux.emit=de,I.mux.addHLSJS=de,I.mux.addDashJS=de,I.mux.removeHLSJS=de,I.mux.removeDashJS=de,I.mux.deleted=!0,p.emit(k,"destroy")},I.mux.swapElement=function(he){var oe=Gf(m(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=I.muxId,delete I.muxId,me.mux=me.mux||{},me.mux.listeners=Object.assign({},I.mux.listeners),delete I.mux.listeners,Object.keys(me.mux.listeners).forEach(function(St){I.removeEventListener(St,me.mux.listeners[St],!1),me.addEventListener(St,me.mux.listeners[St],!1)}),me.mux.swapElement=I.mux.swapElement,me.mux.destroy=I.mux.destroy,delete I.mux,void(I=me)):p.log.error("No element was found with the `"+Me+"` query selector.")},I.mux.addHLSJS=function(he){p.addHLSJS(k,he)},I.mux.addDashJS=function(he){p.addDashJS(k,he)},I.mux.removeHLSJS=function(){p.removeHLSJS(k)},I.mux.removeDashJS=function(){p.removeDashJS(k)},p.init(k,_),p.emit(k,"playerready"),I.paused||(p.emit(k,"play"),I.readyState>2&&p.emit(k,"playing")),I.mux.listeners={},AE.forEach(function(he){(he!=="error"||_.automaticErrorTracking)&&(I.mux.listeners[he]=function(){var oe={};if(he==="error"){if(!I.error||I.error.code===1)return;oe.player_error_code=I.error.code,oe.player_error_message=SE[I.error.code]||I.error.message}p.emit(k,he,oe)},I.addEventListener(he,I.mux.listeners[he],!1))})}(cn,v,f)},destroyMonitor:function(v){var f=$E(m(v),1)[0];f&&f.mux&&typeof f.mux.destroy=="function"?f.mux.destroy():A.error("A video element monitor for `"+v+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(v,f){var p=h(v);ei[p]?ei[p].addHLSJS(f):A.error("A monitor for `"+p+"` has not been initialized.")},addDashJS:function(v,f){var p=h(v);ei[p]?ei[p].addDashJS(f):A.error("A monitor for `"+p+"` has not been initialized.")},removeHLSJS:function(v){var f=h(v);ei[f]?ei[f].removeHLSJS():A.error("A monitor for `"+f+"` has not been initialized.")},removeDashJS:function(v){var f=h(v);ei[f]?ei[f].removeDashJS():A.error("A monitor for `"+f+"` has not been initialized.")},init:function(v,f){R()&&f&&f.respectDoNotTrack&&A.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var p=h(v);ei[p]=new TE(cn,p,f)},emit:function(v,f,p){var b=h(v);ei[b]?(ei[b].emit(f,p),f==="destroy"&&delete ei[b]):A.error("A monitor for `"+b+"` has not been initialized.")},checkDoNotTrack:R,log:A,utils:UE,events:BE,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(cn,GE),d()!==void 0&&typeof d().addEventListener=="function"&&d().addEventListener("pagehide",function(v){v.persisted||(cn.WINDOW_UNLOADING=!0)},!1);var HE=cn},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 m=window.Cookies,g=window.Cookies=u();g.noConflict=function(){return window.Cookies=m,g}}})(function(){var u=function(){for(var h=0,m={};h<arguments.length;h++){var g=arguments[h];for(var E in g)m[E]=g[E]}return m};return function h(m){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 x=new Date;x.setMilliseconds(x.getMilliseconds()+864e5*A.expires),A.expires=x}try{R=JSON.stringify(T),/^[\{\[]/.test(R)&&(T=R)}catch{}return T=m.write?m.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("; "):[],w=/(%[0-9A-Z]{2})+/g,$=0;$<N.length;$++){var O=N[$].split("="),H=O.slice(1).join("=");H.charAt(0)==='"'&&(H=H.slice(1,-1));try{var q=O[0].replace(w,decodeURIComponent);if(H=m.read?m.read(H,q):m(H,q)||H.replace(w,decodeURIComponent),this.json)try{H=JSON.parse(H)}catch{}if(E===q){R=H;break}E||(R[q]=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(){},m="undefined",g=typeof window!==m&&typeof window.navigator!==m&&/Trident\/|MSIE /.test(window.navigator.userAgent),E=["trace","debug","info","warn","error"];function T(P,X){var j=P[X];if(typeof j.bind=="function")return j.bind(P);try{return Function.prototype.bind.call(j,P)}catch{return function(){return Function.prototype.apply.apply(j,[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 R(P){return P==="debug"&&(P="log"),typeof console!==m&&(P==="trace"&&g?A:console[P]!==void 0?T(console,P):console.log!==void 0?T(console,"log"):h)}function x(P,X){for(var j=0;j<E.length;j++){var Ae=E[j];this[Ae]=j<P?h:this.methodFactory(Ae,P,X)}this.log=this.debug}function N(P,X,j){return function(){typeof console!==m&&(x.call(this,X,j),this[P].apply(this,arguments))}}function w(P,X,j){return R(P)||N.apply(this,arguments)}function $(P,X,j){var Ae,Ee=this;X=X==null?"WARN":X;var ye="loglevel";function we(se){var xe=(E[se]||"silent").toUpperCase();if(typeof window!==m&&ye){try{return void(window.localStorage[ye]=xe)}catch{}try{window.document.cookie=encodeURIComponent(ye)+"="+xe+";"}catch{}}}function Se(){var se;if(typeof window!==m&&ye){try{se=window.localStorage[ye]}catch{}if(typeof se===m)try{var xe=window.document.cookie,Ie=xe.indexOf(encodeURIComponent(ye)+"=");Ie!==-1&&(se=/^([^;]+)/.exec(xe.slice(Ie))[1])}catch{}return Ee.levels[se]===void 0&&(se=void 0),se}}function Z(){if(typeof window!==m&&ye){try{return void window.localStorage.removeItem(ye)}catch{}try{window.document.cookie=encodeURIComponent(ye)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof P=="string"?ye+=":"+P:typeof P=="symbol"&&(ye=void 0),Ee.name=P,Ee.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Ee.methodFactory=j||w,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),x.call(Ee,se,P),typeof console===m&&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 ae=Se();ae==null&&(ae=X),Ee.setLevel(ae,!1)}var O=new $,H={};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=H[P];return X||(X=H[P]=new $(P,O.getLevel(),O.methodFactory)),X};var q=typeof window!==m?window.log:void 0;return O.noConflict=function(){return typeof window!==m&&window.log===O&&(window.log=q),O},O.getLoggers=function(){return H},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,m,g=[];for(m in typeof u!="string"&&(u="?"),c)if(o.call(c,m)){if((h=c[m])||h!=null&&!isNaN(h)||(h=""),m=d(m),h=d(h),m===null||h===null)continue;g.push(m+"="+h)}return g.length?u+g.join("&"):""},a.parse=function(c){for(var u,h=/([^=?#&]+)=?([^&]*)/g,m={};u=h.exec(c);){var g=l(u[1]),E=l(u[2]);g===null||E===null||g in m||(m[g]=E)}return m}},558:function(){}},i={};function s(n){var a=i[n];if(a!==void 0)return a.exports;var o=i[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 Ko=="object"&&typeof $c=="object"?$c.exports=e():typeof Ko=="object"?Ko.mux=e():r.mux=e()})()});var gs=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class r extends gs{}globalThis.DocumentFragment=r}var fn=class extends gs{},md=class extends gs{},ey={get(r){},define(r,e,t){},upgrade(r){},whenDefined(r){return Promise.resolve(fn)}},mn,pd=class{constructor(e,t={}){ut(this,mn,void 0);ii(this,mn,t==null?void 0:t.detail)}get detail(){return Ne(this,mn)}initCustomEvent(){}};mn=new WeakMap;function ty(r,e){return new fn}var qf={document:{createElement:ty},DocumentFragment,customElements:ey,CustomEvent:pd,EventTarget:gs,HTMLElement:fn,HTMLVideoElement:md},Yf=typeof window=="undefined"||typeof globalThis.customElements=="undefined",at=Yf?qf:globalThis,Qt=Yf?qf.document:globalThis.document;var ne={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_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},_e={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},wr={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",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"},jf=Object.entries(wr),S=jf.reduce((r,[e,t])=>(r[e]=`${t.toLowerCase()}`,r),{}),vs=jf.reduce((r,[e,t])=>(r[e]=`${t.toLowerCase()}`,r),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange"}),nx=Object.entries(vs).reduce((r,[e,t])=>{let i=S[e];return i&&(r[t]=i),r},{userinactivechange:"userinactive"}),zf=Object.entries(S).reduce((r,[e,t])=>{let i=vs[e];return i&&(r[t]=i),r},{userinactive:"userinactivechange"}),Es={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},xa={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var gd={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},ri={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},di={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var Dt={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:r=1}={})=>`current playback rate ${r}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading"},je={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",AIRPLAY:()=>"air play",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:r=30}={})=>`seek forward ${r} seconds`,SEEK_BACK_N_SECS:({seekOffset:r=30}={})=>`seek back ${r} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"},ry={...Dt,...je};function Xf(r){return r==null?void 0:r.map(sy).join(" ")}function Qf(r){return r==null?void 0:r.split(/\s+/).map(ny)}function sy(r){if(r){let{id:e,width:t,height:i}=r;return[e,t,i].filter(s=>s!=null).join(":")}}function ny(r){if(r){let[e,t,i]=r.split(":");return{id:e,width:t,height:i}}}function Ia(r,e=!1){return r.split("_").map(function(t,i){return(i||e?t[0].toUpperCase():t[0].toLowerCase())+t.slice(1).toLowerCase()}).join("")}function Zf(r){return r.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Jf(r){return typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r)}function La(r){return typeof r!="string"?!1:!isNaN(r)&&!isNaN(parseFloat(r))}var Ra=r=>new Promise(e=>setTimeout(e,r));var em=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],ay=(r,e)=>{let t=r===1?em[e].singular:em[e].plural;return`${r} ${t}`},Dr=r=>{if(!Jf(r))return"";let e=Math.abs(r),t=e!==r,i=new Date(0,0,0,0,0,e,0);return`${[i.getHours(),i.getMinutes(),i.getSeconds()].map((o,l)=>o&&ay(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function Ti(r,e){let t=!1;r<0&&(t=!0,r=0-r),r=r<0?0:r;let i=Math.floor(r%60),s=Math.floor(r/60%60),n=Math.floor(r/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(r)||r===1/0)&&(n=s=i="0"),n=n>0||o>0?n+":":"",s=((n||a>=10)&&s<10?"0"+s:s)+":",i=i<10?"0"+i:i,(t?"-":"")+n+s+i}var dx=Object.freeze({length:0,start(r){let e=r>>>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(r){let e=r>>>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 ka=(r,e,t=".value")=>{let i=r.querySelector(t);!i||(i.textContent=e)},ly=(r,e)=>{let t=`slot[name="${e}"]`,i=r.shadowRoot.querySelector(t);return i?i.children:[]},wa=(r,e)=>ly(r,e)[0],pn=(r,e)=>!r||!e?!1:r.contains(e)?!0:pn(r,e.getRootNode().host),Cr=(r,e)=>{if(!r)return null;let t=r.closest(e);return t||Cr(r.getRootNode().host,e)};function ze(r,e){var t;let i;for(i of r.querySelectorAll("style")){let s;try{s=(t=i.sheet)==null?void 0:t.cssRules}catch{continue}for(let n of s!=null?s:[])if(n.selectorText===e)return n}return i!=null&&i.sheet?(i.sheet.insertRule(`${e}{}`,i.sheet.cssRules.length),i.sheet.cssRules[i.sheet.cssRules.length-1]):{style:{setProperty:()=>{},removeProperty:()=>{}}}}function Ue(r,e,t=Number.NaN){let i=r.getAttribute(e);return i!=null?+i:t}function Ye(r,e,t){let i=+t;if(t==null||Number.isNaN(i)){r.hasAttribute(e)&&r.removeAttribute(e);return}Ue(r,e,void 0)!==i&&r.setAttribute(e,`${i}`)}function Ke(r,e){return r.hasAttribute(e)}function Ge(r,e,t){if(t==null){r.hasAttribute(e)&&r.removeAttribute(e);return}Ke(r,e)!=t&&r.toggleAttribute(e,t)}function et(r,e,t=null){var i;return(i=r.getAttribute(e))!=null?i:t}function Xe(r,e,t){if(t==null){r.hasAttribute(e)&&r.removeAttribute(e);return}let i=`${t}`;et(r,e,void 0)!==i&&r.setAttribute(e,i)}var Da=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},vd=class{observe(){}},tm={createElement:function(){return new Ed.HTMLElement},addEventListener(){},removeEventListener(){}},Ed={ResizeObserver:vd,document:tm,HTMLElement:class extends Da{},DocumentFragment:class extends Da{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},CustomEvent:function(){},getComputedStyle:function(){}},im=typeof window=="undefined"||typeof window.customElements=="undefined",rm=Object.keys(Ed).every(r=>r in globalThis),D=im&&!rm?Ed:globalThis,z=im&&!rm?tm:globalThis.document;var dy=Object.defineProperty,cy=(r,e,t)=>e in r?dy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,uy=(r,e,t)=>(cy(r,typeof e!="symbol"?e+"":e,t),t),sm=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},si=(r,e,t)=>(sm(r,e,"read from private field"),t?t.call(r):e.get(r)),Ca=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Ma=(r,e,t,i)=>(sm(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),_i,Oa,ys,Pa,nm=z.createElement("template");nm.innerHTML=`
|
|
20
20
|
<style>
|
|
21
21
|
:host {
|
|
22
22
|
font: var(--media-font,
|
|
@@ -64,12 +64,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
64
64
|
min-width: 100%;
|
|
65
65
|
}
|
|
66
66
|
</style>
|
|
67
|
-
`;var We=class extends D.HTMLElement{constructor(e={}){if(super(),Ca(this,_i,void 0),
|
|
67
|
+
`;var We=class extends D.HTMLElement{constructor(e={}){if(super(),Ca(this,_i,void 0),uy(this,"preventClick",!1),Ca(this,Oa,i=>{this.preventClick||this.handleClick(i)}),Ca(this,ys,i=>{let{key:s}=i;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",si(this,ys));return}this.preventClick||this.handleClick(i)}),Ca(this,Pa,i=>{let{metaKey:s,altKey:n,key:a}=i;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",si(this,ys));return}this.addEventListener("keyup",si(this,ys),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});let i=nm.content.cloneNode(!0);this.nativeEl=i;let s=e.slotTemplate;s||(s=z.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),this.shadowRoot.appendChild(i)}let{style:t}=ze(this.shadowRoot,":host");t.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`)}static get observedAttributes(){return["disabled",_e.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",si(this,Oa)),this.addEventListener("keydown",si(this,Pa)),this.tabIndex=0}disable(){this.removeEventListener("click",si(this,Oa)),this.removeEventListener("keydown",si(this,Pa)),this.removeEventListener("keyup",si(this,ys)),this.tabIndex=-1}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===_e.MEDIA_CONTROLLER?(t&&((n=(s=si(this,_i))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ma(this,_i,null)),i&&(Ma(this,_i,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=si(this,_i))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&i!==t&&(i==null?this.enable():this.disable())}connectedCallback(){var e,t,i;this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");let s=this.getAttribute(_e.MEDIA_CONTROLLER);s&&(Ma(this,_i,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=si(this,_i))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=si(this,_i))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ma(this,_i,null)}get keysUsed(){return["Enter"," "]}handleClick(e){}};_i=new WeakMap;Oa=new WeakMap;ys=new WeakMap;Pa=new WeakMap;D.customElements.get("media-chrome-button")||D.customElements.define("media-chrome-button",We);var hy=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
68
68
|
<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"/>
|
|
69
69
|
</svg>
|
|
70
|
-
`,
|
|
71
|
-
<slot name="icon">${
|
|
72
|
-
`;var
|
|
70
|
+
`,am=z.createElement("template");am.innerHTML=`
|
|
71
|
+
<slot name="icon">${hy}</slot>
|
|
72
|
+
`;var yd=class extends We{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:am,...e})}connectedCallback(){this.setAttribute("aria-label",je.AIRPLAY()),super.connectedCallback()}get mediaAirplayUnavailable(){return et(this,S.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){Xe(this,S.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new D.CustomEvent(ne.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};D.customElements.get("media-airplay-button")||D.customElements.define("media-airplay-button",yd);var fy='<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>',my='<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>',lm=z.createElement("template");lm.innerHTML=`
|
|
73
73
|
<style>
|
|
74
74
|
:host([${S.MEDIA_IS_CASTING}]) slot:not([name=exit]):not([name=icon]) {
|
|
75
75
|
display: none !important;
|
|
@@ -82,17 +82,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
82
82
|
</style>
|
|
83
83
|
|
|
84
84
|
<slot name="icon">
|
|
85
|
-
<slot name="enter">${
|
|
86
|
-
<slot name="exit">${
|
|
85
|
+
<slot name="enter">${fy}</slot>
|
|
86
|
+
<slot name="exit">${my}</slot>
|
|
87
87
|
</slot>
|
|
88
|
-
`;var
|
|
88
|
+
`;var om=r=>{let t=r.getAttribute(S.MEDIA_IS_CASTING)!=null?je.EXIT_CAST():je.ENTER_CAST();r.setAttribute("aria-label",t)},bd=class extends We{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_CASTING,S.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:lm,...e})}connectedCallback(){om(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===S.MEDIA_IS_CASTING&&om(this),super.attributeChangedCallback(e,t,i)}get mediaIsCasting(){return Ke(this,S.MEDIA_IS_CASTING)}set mediaIsCasting(e){Ge(this,S.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return et(this,S.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){Xe(this,S.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?ne.MEDIA_EXIT_CAST_REQUEST:ne.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new D.CustomEvent(e,{composed:!0,bubbles:!0}))}};D.customElements.get("media-cast-button")||D.customElements.define("media-cast-button",bd);var dm=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},ar=(r,e,t)=>(dm(r,e,"read from private field"),t?t.call(r):e.get(r)),py=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Na=(r,e,t,i)=>(dm(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Ht,cm=z.createElement("template");cm.innerHTML=`
|
|
89
89
|
<style>
|
|
90
90
|
:host {
|
|
91
91
|
display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
|
|
92
92
|
box-sizing: border-box;
|
|
93
93
|
}
|
|
94
94
|
</style>
|
|
95
|
-
`;var
|
|
95
|
+
`;var Td=class extends D.HTMLElement{constructor(e={}){if(super(),py(this,Ht,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),i=cm.content.cloneNode(!0);this.nativeEl=i;let s=e.slotTemplate;s||(s=z.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),t.appendChild(i)}}static get observedAttributes(){return[_e.MEDIA_CONTROLLER,S.MEDIA_PAUSED]}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===_e.MEDIA_CONTROLLER&&(t&&((n=(s=ar(this,Ht))==null?void 0:s.unassociateElement)==null||n.call(s,this),Na(this,Ht,null)),i&&(Na(this,Ht,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=ar(this,Ht))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,i,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),Na(this,Ht,gy(this)),this.getAttribute(_e.MEDIA_CONTROLLER)&&((t=(e=ar(this,Ht))==null?void 0:e.associateElement)==null||t.call(e,this)),(i=ar(this,Ht))==null||i.addEventListener("pointerdown",this),(s=ar(this,Ht))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,i,s;this.getAttribute(_e.MEDIA_CONTROLLER)&&((t=(e=ar(this,Ht))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(i=ar(this,Ht))==null||i.removeEventListener("pointerdown",this),(s=ar(this,Ht))==null||s.removeEventListener("click",this),Na(this,Ht,null)}handleEvent(e){var t;let i=(t=e.composedPath())==null?void 0:t[0];if(!!["video","media-controller"].includes(i==null?void 0:i.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:m=this._pointerType}=e;if(this._pointerType=void 0,m===gd.TOUCH){this.handleTap(e);return}else if(m===gd.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return Ke(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ge(this,S.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?ne.MEDIA_PLAY_REQUEST:ne.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new D.CustomEvent(t,{composed:!0,bubbles:!0}))}};Ht=new WeakMap;function gy(r){var e;let t=r.getAttribute(_e.MEDIA_CONTROLLER);return t?(e=r.getRootNode())==null?void 0:e.getElementById(t):Cr(r,"media-controller")}D.customElements.get("media-gesture-receiver")||D.customElements.define("media-gesture-receiver",Td);var vy=Object.defineProperty,Ey=(r,e,t)=>e in r?vy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yy=(r,e,t)=>(Ey(r,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"},um=z.createElement("template");um.innerHTML=`
|
|
96
96
|
<style>
|
|
97
97
|
|
|
98
98
|
:host([${S.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
|
|
@@ -216,7 +216,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
216
216
|
|
|
217
217
|
<slot part="bottom chrome"></slot>
|
|
218
218
|
</span>
|
|
219
|
-
`;var my=Object.values(S),py="sm:384 md:576 lg:768 xl:960";function gy(r){for(let e of r)vy(e.target,e.contentRect.width)}function vy(r,e){var t;if(!r.isConnected)return;let i=(t=r.getAttribute(He.BREAKPOINTS))!=null?t:py,s=Ey(i),n=yy(s,e),a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){r.hasAttribute(`breakpoint${o}`)||(r.setAttribute(`breakpoint${o}`,""),a=!0);return}r.hasAttribute(`breakpoint${o}`)&&(r.removeAttribute(`breakpoint${o}`),a=!0)}),a){let o=new CustomEvent(vs.BREAKPOINTS_CHANGE,{detail:n});r.dispatchEvent(o)}}function Ey(r){let e=r.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function yy(r,e){return Object.keys(r).filter(t=>e>=r[t])}var Fa=class extends D.HTMLElement{static get observedAttributes(){return[He.AUTOHIDE,He.GESTURES_DISABLED].concat(my).filter(e=>![S.MEDIA_RENDITION_LIST].includes(e))}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(lm.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 i=!1,s=l=>{i||(setTimeout(()=>{gy(l),i=!1},0),i=!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)))})}attributeChangedCallback(e,t,i){e.toLowerCase()==He.AUTOHIDE&&(this.autohide=i)}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?ne.MEDIA_PLAY_REQUEST:ne.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new D.CustomEvent(t,{composed:!0,bubbles:!0}))}}handleMediaUpdated(e){let t=n=>Promise.resolve(n),i=n=>(console.error('<media-chrome>: Media element set with slot="media" does not appear to be compatible.',n),Promise.reject(n));if(!e)return i(e);let s=e.nodeName.toLowerCase();return s.includes("-")?D.customElements.whenDefined(s).then(()=>t(e)):t(e)}mediaUnsetCallback(e){}connectedCallback(){var e;let i=this.getAttribute(He.AUDIO)!=null?Dt.AUDIO_PLAYER():Dt.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",i),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 D.CustomEvent(vs.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 D.CustomEvent(vs.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=>{o.pointerType==="mouse"&&(n(),clearTimeout(this._inactiveTimeout),[this,this.media].includes(o.target)&&a())}),this.addEventListener("mouseleave",()=>{s()}),this.addEventListener("keyup",()=>{this.setAttribute(He.KEYBOARD_CONTROL,"")}),(e=D.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 dm=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},bt=(r,e,t)=>(dm(r,e,"read from private field"),t?t.call(r):e.get(r)),gn=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Ua=(r,e,t,i)=>(dm(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),bs,Ts,Ba,Mr,Hi,or,lr=class{constructor(e,t,{defaultValue:i}={defaultValue:void 0}){gn(this,Hi),gn(this,bs,void 0),gn(this,Ts,void 0),gn(this,Ba,void 0),gn(this,Mr,new Set),Ua(this,bs,e),Ua(this,Ts,t),Ua(this,Ba,new Set(i))}[Symbol.iterator](){return bt(this,Hi,or).values()}get length(){return bt(this,Hi,or).size}get value(){var e;return(e=[...bt(this,Hi,or)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Ua(this,Mr,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...bt(this,Hi,or)][e]}values(){return bt(this,Hi,or).values()}forEach(e){bt(this,Hi,or).forEach(e)}add(...e){var t,i;e.forEach(s=>bt(this,Mr).add(s)),!(this.value===""&&!((t=bt(this,bs))!=null&&t.hasAttribute(`${bt(this,Ts)}`)))&&((i=bt(this,bs))==null||i.setAttribute(`${bt(this,Ts)}`,`${this.value}`))}remove(...e){var t;e.forEach(i=>bt(this,Mr).delete(i)),(t=bt(this,bs))==null||t.setAttribute(`${bt(this,Ts)}`,`${this.value}`)}contains(e){return bt(this,Hi,or).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}};bs=new WeakMap;Ts=new WeakMap;Ba=new WeakMap;Mr=new WeakMap;Hi=new WeakSet;or=function(){return bt(this,Mr).size?bt(this,Mr):bt(this,Ba)};var cm=(r="")=>r.split(/\s+/),um=(r="")=>{let[e,t,i]=r.split(":"),s=i?decodeURIComponent(i):void 0;return e=e==="cc"?"captions":"subtitles",{kind:e,language:t,label:s}},vn=(r="",e={})=>cm(r).map(t=>{let i=um(t);return{...e,...i}}),by=r=>Array.isArray(r)?r.map(e=>typeof e=="string"?um(e):e):typeof r=="string"?vn(r):[r],$a=({kind:r,label:e,language:t}={kind:"subtitles"})=>e?`${r==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,Or=(r=[])=>Array.prototype.map.call(r,$a).join(" "),Ty=(r,e)=>t=>t[r]===e,hm=r=>{let e=Object.entries(r).map(([t,i])=>Ty(t,i));return t=>e.every(i=>i(t))},Td=(r,e=[],t=[])=>{let i=by(t).map(hm),s=n=>i.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=r})},Ga=(r,e=()=>!0)=>{if(!(r!=null&&r.textTracks))return[];let t=typeof e=="function"?e:hm(e);return Array.from(r.textTracks).filter(t)},_d=r=>!!r.getAttribute(S.MEDIA_SUBTITLES_SHOWING),Vi=(r,e)=>{var t,i;let s=_d(r);if(s||e===!1){let n=r.getAttribute(S.MEDIA_SUBTITLES_SHOWING);if(n){let a=new D.CustomEvent(ne.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:n});r.dispatchEvent(a)}}else if(!s||e===!0){let[n]=(i=cm((t=r.getAttribute(S.MEDIA_SUBTITLES_LIST))!=null?t:""))!=null?i:[];if(n){let a=new D.CustomEvent(ne.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:n});r.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 ot={enter:"requestFullscreen",exit:"exitFullscreen",rootEvents:["fullscreenchange"],mediaEvents:[],element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};z.fullscreenElement===void 0&&(ot.enter="webkitRequestFullScreen",ot.exit=z.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",ot.rootEvents=["webkitfullscreenchange"],ot.mediaEvents=["webkitbeginfullscreen","webkitendfullscreen"],ot.element="webkitFullscreenElement",ot.error="webkitfullscreenerror",ot.enabled="webkitFullscreenEnabled");var Ha,Ad=()=>{var r,e;return Ha||(Ha=(e=(r=z)==null?void 0:r.createElement)==null?void 0:e.call(r,"video"),Ha)},fm=async(r=Ad())=>{if(!r)return!1;let e=r.volume;return r.volume=e/2+.1,await Ra(0),r.volume!==e},_y=(r=Ad())=>typeof(r==null?void 0:r.requestPictureInPicture)=="function",Ay=(r=Ad())=>{let e=z[ot.enabled];return!e&&r&&(e="webkitSupportsFullscreen"in r),e},Sd=Ay(),mm=_y(),pm=!!D.WebKitPlaybackTargetAvailabilityEvent,gm=!!D.chrome;var Va,vm=fm().then(r=>(Va=r,Va)),Sy=Object.values(di),xd=r=>Ga(r.media,e=>[Es.SUBTITLES,Es.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),xy=r=>Ga(r.media,e=>e.mode===xa.SHOWING&&[Es.SUBTITLES,Es.CAPTIONS].includes(e.kind)),Vt={MEDIA_PAUSED:{get:function(r){let{media:e}=r;return e?e.paused:!0},mediaEvents:["play","playing","pause","emptied"]},MEDIA_HAS_PLAYED:{get:function(r){let{media:e}=r;return e?!e.paused:!1},mediaEvents:["playing","emptied"]},MEDIA_ENDED:{get:function(r){let{media:e}=r;return e?e.ended:!1},mediaEvents:["seeked","ended","emptied"]},MEDIA_PLAYBACK_RATE:{get:function(r){let{media:e}=r;return!e||typeof e.playbackRate=="undefined"?1:e.playbackRate},mediaEvents:["ratechange","loadstart"]},MEDIA_MUTED:{get:function(r){let{media:e}=r;return!e||typeof e.muted=="undefined"?!1:e.muted},mediaEvents:["volumechange"]},MEDIA_VOLUME:{get:function(r){let{media:e}=r;return!e||typeof e.volume=="undefined"?1:Number(e.volume)},mediaEvents:["volumechange"]},MEDIA_VOLUME_LEVEL:{get:function(r){let{media:e}=r,t="high";if(!e||typeof e.volume=="undefined")return t;let{muted:i,volume:s}=e;return s===0||i?t="off":s<.5?t="low":s<.75&&(t="medium"),t},mediaEvents:["volumechange"]},MEDIA_CURRENT_TIME:{get:function(r){let{media:e}=r;return!e||typeof e.currentTime=="undefined"?0:e.currentTime},mediaEvents:["timeupdate","loadedmetadata"]},MEDIA_DURATION:{get:function(r){let{media:e}=r;return!e||!Number.isFinite(e.duration)?NaN:e.duration},mediaEvents:["durationchange","loadedmetadata","emptied"]},MEDIA_SEEKABLE:{get:function(r){var e;let{media:t}=r;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;let i=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!i&&!s))return[Number(i.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress"]},MEDIA_LOADING:{get:function(r){var e;return((e=r.media)==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},MEDIA_BUFFERED:{get:function(r){var e,t,i;let s=(e=r.media)==null?void 0:e.buffered;return Array.from((i=(t=r.media)==null?void 0:t.buffered)!=null?i:[]).map((n,a)=>[Number(s.start(a)).toFixed(3),Number(s.end(a)).toFixed(3)])},mediaEvents:["progress","emptied"]},MEDIA_STREAM_TYPE:{get:function(r){let{media:e}=r;if(!e)return;let{streamType:t}=e;if(Sy.includes(t)){if(t===di.UNKNOWN){let s=r.getAttribute("defaultstreamtype");return[di.LIVE,di.ON_DEMAND].includes(s)?s:void 0}return t}let i=e.duration;if(i===1/0)return di.LIVE;if(Number.isFinite(i))return di.ON_DEMAND;{let s=r.getAttribute("defaultstreamtype");if([di.LIVE,di.ON_DEMAND].includes(s))return s}},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},MEDIA_TARGET_LIVE_WINDOW:{get:function(r){let{media:e}=r;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,i=Vt.MEDIA_STREAM_TYPE.get(r);return(t==null||Number.isNaN(t))&&i===di.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},MEDIA_TIME_IS_LIVE:{get:function(r){let{media:e}=r;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(Vt.MEDIA_STREAM_TYPE.get(r)==="live"))return!1;let i=e.seekable;if(!i)return!0;if(!i.length)return!1;let s=r.hasAttribute("liveedgeoffset")?Number(r.getAttribute("liveedgeoffset")):10,n=i.end(i.length-1)-s;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},MEDIA_IS_FULLSCREEN:{get:function(r,e){var t;let i=r.media;if(i&&z[ot.element]===void 0&&"webkitDisplayingFullscreen"in i)return i.webkitDisplayingFullscreen&&i.webkitPresentationMode==="fullscreen";let s;return e?s=z[ot.element]?e.target:null:s=(t=r.getRootNode().fullscreenElement)!=null?t:z[ot.element],pn(r.fullscreenElement,s)},rootEvents:ot.rootEvents,mediaEvents:ot.mediaEvents},MEDIA_IS_PIP:{get:function(r,e){var t;let i=r.media;if(!i)return!1;if(e)return e.type=="enterpictureinpicture";{let s=(t=r.getRootNode().pictureInPictureElement)!=null?t:z.pictureInPictureElement;return pn(i,s)}},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},MEDIA_IS_CASTING:{get:function(r,e){var t;let{media:i}=r;if(!i)return!1;let s=(t=D.CastableVideoElement)==null?void 0:t.castElement,n=pn(i,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(r,e){if(!pm)return ri.UNSUPPORTED;if(!!e&&e.availability!=="available"&&e.availability==="not-available")return ri.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"]},MEDIA_CAST_UNAVAILABLE:{get:function(){var r;let e=(r=D.CastableVideoElement)==null?void 0:r.castState;if(!gm||!e)return ri.UNSUPPORTED;if(!e.includes("CONNECT"))return ri.UNAVAILABLE},mediaEvents:["castchange"]},MEDIA_FULLSCREEN_UNAVAILABLE:{get:function(){return Sd?void 0:ri.UNAVAILABLE}},MEDIA_PIP_UNAVAILABLE:{get:function(){return mm?void 0:ri.UNSUPPORTED}},MEDIA_RENDITION_UNAVAILABLE:{get:function(r){var e;let{media:t}=r;if(!t)return ri.UNSUPPORTED;if(!t.videoRenditions)return ri.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return ri.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_VOLUME_UNAVAILABLE:{get:function(r){if(Va!==void 0&&!Va)return ri.UNSUPPORTED;let{media:e}=r;if(e&&typeof e.volume=="undefined")return ri.UNAVAILABLE},mediaEvents:["loadstart"]},MEDIA_SUBTITLES_LIST:{get:function(r){return xd(r).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},MEDIA_SUBTITLES_SHOWING:{get:function(r){return r.hasAttribute("defaultsubtitles")&&!r.hasAttribute(S.MEDIA_HAS_PLAYED)&&!r.hasAttribute(S.MEDIA_SUBTITLES_SHOWING)&&Vi(r,!0),xy(r).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"]},MEDIA_RENDITION_LIST:{get:function(r){var e;let{media:t}=r;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]]},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_RENDITION_SELECTED:{get:function(r){var e,t,i;let{media:s}=r;return(i=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:i.id},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]}},Ka={MEDIA_PLAY_REQUEST:(r,e,t)=>{var i;let s=Vt.MEDIA_STREAM_TYPE.get(t),n=t.getAttribute("noautoseektolive")===null;s==di.LIVE&&n&&Ka.MEDIA_SEEK_TO_LIVE_REQUEST(r),(i=r.play())==null||i.catch(()=>{})},MEDIA_PAUSE_REQUEST:r=>r.pause(),MEDIA_MUTE_REQUEST:r=>r.muted=!0,MEDIA_UNMUTE_REQUEST:r=>{r.muted=!1,r.volume===0&&(r.volume=.25)},MEDIA_VOLUME_REQUEST:(r,e,t)=>{let i=e.detail;if(r.volume=i,i>0&&r.muted&&(r.muted=!1),!t.hasAttribute("novolumepref"))try{D.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch{}},MEDIA_ENTER_FULLSCREEN_REQUEST:(r,e,t)=>{if(!Sd){console.warn("Fullscreen support is unavailable; not entering fullscreen");return}z.pictureInPictureElement&&z.exitPictureInPicture(),t[ot.enter]?t.fullscreenElement[ot.enter]():r.webkitEnterFullscreen?r.webkitEnterFullscreen():r.requestFullscreen?r.requestFullscreen():console.warn("MediaChrome: Fullscreen not supported")},MEDIA_EXIT_FULLSCREEN_REQUEST:()=>{z[ot.exit]()},MEDIA_ENTER_PIP_REQUEST:r=>{if(!z.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!r.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}z[ot.element]&&z[ot.exit]();let e=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};r.requestPictureInPicture().catch(t=>{if(t.code===11)if(r.readyState===0&&r.preload==="none"){let i=()=>{r.removeEventListener("loadedmetadata",s),r.preload="none"},s=()=>{r.requestPictureInPicture().catch(e),i()};r.addEventListener("loadedmetadata",s),r.preload="metadata",setTimeout(()=>{r.readyState===0&&e(),i()},1e3)}else throw t;else throw t})},MEDIA_EXIT_PIP_REQUEST:()=>{z.pictureInPictureElement&&z.exitPictureInPicture()},MEDIA_ENTER_CAST_REQUEST:r=>{var e;!((e=D.CastableVideoElement)!=null&&e.castEnabled)||(z[ot.element]&&z[ot.exit](),r.requestCast())},MEDIA_EXIT_CAST_REQUEST:async()=>{var r;(r=D.CastableVideoElement)!=null&&r.castElement&&D.CastableVideoElement.exitCast()},MEDIA_SEEK_REQUEST:(r,e)=>{let t=e.detail;(r.readyState>0||r.readyState===void 0)&&(r.currentTime=t)},MEDIA_PLAYBACK_RATE_REQUEST:(r,e)=>{r.playbackRate=e.detail},MEDIA_PREVIEW_REQUEST:(r,e,t)=>{var i;if(!r)return;let s=e.detail;s===null&&t.propagateMediaState(S.MEDIA_PREVIEW_TIME,void 0),t.propagateMediaState(S.MEDIA_PREVIEW_TIME,s);let[n]=Ga(r,{kind:Es.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)||(i=r.querySelector('track[label="thumbnails"]'))==null?void 0:i.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:(r,e,t)=>{let i=xd(t),{detail:s=[]}=e;Td(xa.SHOWING,i,s)},MEDIA_DISABLE_SUBTITLES_REQUEST:(r,e,t)=>{let i=xd(t),{detail:s=[]}=e;Td(xa.DISABLED,i,s)},MEDIA_AIRPLAY_REQUEST:r=>{if(!!r){if(!(r.webkitShowPlaybackTargetPicker&&D.WebKitPlaybackTargetAvailabilityEvent)){console.warn("received a request to select AirPlay but AirPlay is not supported in this environment");return}r.webkitShowPlaybackTargetPicker()}},MEDIA_SEEK_TO_LIVE_REQUEST:r=>{let e=r.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}r.currentTime=e.end(e.length-1)},MEDIA_RENDITION_REQUEST:(r,e)=>{if(!(r!=null&&r.videoRenditions)){console.warn("MediaController: Rendition selection not supported by this media.");return}let t=e.detail,i=[...r.videoRenditions].findIndex(s=>s.id==t);r.videoRenditions.selectedIndex!=i&&(r.videoRenditions.selectedIndex=i)}};var Rd=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Nr=(r,e,t)=>(Rd(r,e,"read from private field"),t?t.call(r):e.get(r)),Wa=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Em=(r,e,t,i)=>(Rd(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),_s=(r,e,t)=>(Rd(r,e,"access private method"),t),dr,En,As,yn,qa,Id,Sm=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],Iy=10,ym=0,Kt={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"},Ya=class extends Fa{constructor(){super(),Wa(this,As),Wa(this,qa),Wa(this,dr,new lr(this,Kt.HOTKEYS)),Wa(this,En,void 0),Vt.MEDIA_VOLUME_UNAVAILABLE.get(this)===void 0&&vm.then(()=>{this.propagateMediaState(S.MEDIA_VOLUME_UNAVAILABLE,Vt.MEDIA_VOLUME_UNAVAILABLE.get(this))}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this),Object.keys(Ka).forEach(e=>{let t=`_handle${Ia(e,!0)}`;this[t]=i=>{if(i.stopPropagation(),!this.media){console.warn("MediaController: No media available.");return}Ka[e](this.media,i,this)},this.addEventListener(ne[e],this[t])}),this._mediaStatePropagators={},Object.keys(Vt).forEach(e=>{this._mediaStatePropagators[e]=t=>{this.propagateMediaState(wr[e],Vt[e].get(this,t))}}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(Kt.NO_HOTKEYS,Kt.HOTKEYS,Kt.DEFAULT_STREAM_TYPE,Kt.DEFAULT_SUBTITLES)}get fullscreenElement(){var e;return(e=Nr(this,En))!=null?e:this}set fullscreenElement(e){this.hasAttribute(Kt.FULLSCREEN_ELEMENT)&&this.removeAttribute(Kt.FULLSCREEN_ELEMENT),Em(this,En,e)}attributeChangedCallback(e,t,i){var s;if(e===Kt.NO_HOTKEYS)i!==t&&i===""?(this.hasAttribute(Kt.HOTKEYS)&&console.warn("Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):i!==t&&i===null&&this.enableHotkeys();else if(e===Kt.HOTKEYS)Nr(this,dr).value=i;else if(e===Kt.DEFAULT_SUBTITLES&&i!==t&&i==="")Vi(this,!0);else if(e===Kt.DEFAULT_STREAM_TYPE)this.propagateMediaState(wr.MEDIA_STREAM_TYPE);else if(e===Kt.FULLSCREEN_ELEMENT){let n=i?(s=this.getRootNode())==null?void 0:s.getElementById(i):void 0;Em(this,En,n)}super.attributeChangedCallback(e,t,i)}mediaSetCallback(e){if(super.mediaSetCallback(e),e.hasAttribute("tabindex")||(e.tabIndex=-1),Object.keys(Vt).forEach(t=>{let{mediaEvents:i,rootEvents:s,textTracksEvents:n,videoRenditionsEvents:a}=Vt[t],o=this._mediaStatePropagators[t];i==null||i.forEach(l=>{e.addEventListener(l,o),o()}),s==null||s.forEach(l=>{this.getRootNode().addEventListener(l,o),o()}),n==null||n.forEach(l=>{var d;(d=e.textTracks)==null||d.addEventListener(l,o),o()}),a==null||a.forEach(l=>{var d;(d=e.videoRenditions)==null||d.addEventListener(l,o),o()})}),!this.hasAttribute("novolumepref"))try{let t=D.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(Vt).forEach(t=>{let{mediaEvents:i,rootEvents:s,textTracksEvents:n,videoRenditionsEvents:a}=Vt[t],o=this._mediaStatePropagators[t];i==null||i.forEach(l=>{e.removeEventListener(l,o)}),s==null||s.forEach(l=>{this.getRootNode().removeEventListener(l,o)}),n==null||n.forEach(l=>{var d;(d=e.textTracks)==null||d.removeEventListener(l,o)}),a==null||a.forEach(l=>{var d;(d=e.videoRenditions)==null||d.removeEventListener(l,o),o()})}),this.propagateMediaState(wr.MEDIA_PAUSED,!0)}propagateMediaState(e,t){let i=Am(this.mediaStateReceivers,e);if(_m(this.mediaStateReceivers,e,t),i===Am(this.mediaStateReceivers,e))return;let s=e.toLowerCase(),n=new D.CustomEvent(qf[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 i=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=Cy(e,i,s);Object.keys(ne).forEach(a=>{e.addEventListener(ne[a],this[`_handle${Ia(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(ne).forEach(s=>{e.removeEventListener(ne[s],this[`_handle${Ia(s,!0)}`])})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),Object.keys(Vt).forEach(s=>{let n=Vt[s];_m([e],wr[s],n.get(this))}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,i=t.indexOf(e);i<0||t.splice(i,1)}enableHotkeys(){this.addEventListener("keydown",_s(this,qa,Id))}disableHotkeys(){this.removeEventListener("keydown",_s(this,qa,Id)),this.removeEventListener("keyup",_s(this,As,yn))}get hotkeys(){return Nr(this,dr)}keyboardShortcutHandler(e){var t,i,s,n;if(((n=(s=(t=e.target.getAttribute(Kt.KEYS_USED))==null?void 0:t.split(" "))!=null?s:(i=e.target)==null?void 0:i.keysUsed)!=null?n:[]).map(f=>f==="Space"?" ":f).filter(Boolean).includes(e.key))return;let o,l,d,c,u,h=Iy;if(!Nr(this,dr).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&Nr(this,dr).contains("nospace")))switch(e.key){case" ":case"k":o=this.getAttribute(S.MEDIA_PAUSED)!=null?ne.MEDIA_PLAY_REQUEST:ne.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new D.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"m":o=this.getAttribute(S.MEDIA_VOLUME_LEVEL)==="off"?ne.MEDIA_UNMUTE_REQUEST:ne.MEDIA_MUTE_REQUEST,this.dispatchEvent(new D.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"f":o=this.getAttribute(S.MEDIA_IS_FULLSCREEN)!=null?ne.MEDIA_EXIT_FULLSCREEN_REQUEST:ne.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new D.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"c":Vi(this);break;case"ArrowLeft":l=this.getAttribute(S.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:ym,c=Math.max(d-h,0),u=new D.CustomEvent(ne.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:ym,c=Math.max(d+h,0),u=new D.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break;default:break}}};dr=new WeakMap;En=new WeakMap;As=new WeakSet;yn=function(r){let{key:e}=r;if(!Sm.includes(e)){this.removeEventListener("keyup",_s(this,As,yn));return}this.keyboardShortcutHandler(r)};qa=new WeakSet;Id=function(r){let{metaKey:e,altKey:t,key:i}=r;if(e||t||!Sm.includes(i)){this.removeEventListener("keyup",_s(this,As,yn));return}[" ","ArrowLeft","ArrowRight"].includes(i)&&!(Nr(this,dr).contains(`no${i.toLowerCase()}`)||i===" "&&Nr(this,dr).contains("nospace"))&&r.preventDefault(),this.addEventListener("keyup",_s(this,As,yn),{once:!0})};var Ly=Object.values(S),Ry=Object.values(wr),kd=r=>{var e,t,i,s;let{observedAttributes:n}=r.constructor;!n&&((e=r.nodeName)==null?void 0:e.includes("-"))&&(D.customElements.upgrade(r),{observedAttributes:n}=r.constructor);let a=(s=(i=(t=r==null?void 0:r.getAttribute)==null?void 0:t.call(r,_e.MEDIA_CHROME_ATTRIBUTES))==null?void 0:i.split)==null?void 0:s.call(i,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>Ly.includes(o)):[]},ky=r=>{var e,t;return((e=r.nodeName)==null?void 0:e.includes("-"))&&!!D.customElements.get((t=r.nodeName)==null?void 0:t.toLowerCase())&&!(r instanceof D.customElements.get(r.nodeName.toLowerCase()))&&D.customElements.upgrade(r),Ry.some(i=>i in r)},Ld=r=>ky(r)||!!kd(r).length,bm=r=>{var e;return(e=r==null?void 0:r.join)==null?void 0:e.call(r,":")},Tm={[S.MEDIA_SUBTITLES_LIST]:Or,[S.MEDIA_SUBTITLES_SHOWING]:Or,[S.MEDIA_SEEKABLE]:bm,[S.MEDIA_BUFFERED]:r=>r==null?void 0:r.map(bm).join(" "),[S.MEDIA_PREVIEW_COORDS]:r=>r==null?void 0:r.join(" "),[S.MEDIA_RENDITION_LIST]:Yf},wy=async(r,e,t)=>{var i,s;if(r.isConnected||await Ra(0),typeof t=="boolean"||t==null)return Ge(r,e,t);if(typeof t=="number")return Ye(r,e,t);if(typeof t=="string")return Xe(r,e,t);if(Array.isArray(t)&&!t.length)return r.removeAttribute(e);let n=(s=(i=Tm[e])==null?void 0:i.call(Tm,t))!=null?s:t;return r.setAttribute(e,n)},Dy=r=>{var e;return!!((e=r.closest)!=null&&e.call(r,'*[slot="media"]'))},Pr=(r,e)=>{if(Dy(r))return;let t=(s,n)=>{var a,o;Ld(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=>Pr(u,n))},i=r==null?void 0:r.nodeName.toLowerCase();if(i.includes("-")&&!Ld(r)){D.customElements.whenDefined(i).then(()=>{t(r,e)});return}t(r,e)},_m=(r,e,t)=>{r.forEach(i=>{if(e in i){i[e]=t;return}let s=kd(i),n=e.toLowerCase();!s.includes(n)||wy(i,n,t)})},Am=(r,e)=>{for(let t of r){if(e in t)return t[e];let i=kd(t),s=e.toLowerCase();if(!!i.includes(s))return t.getAttribute(s)}},Cy=(r,e,t)=>{Pr(r,e);let i=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)};r.addEventListener(ne.REGISTER_MEDIA_STATE_RECEIVER,i),r.addEventListener(ne.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=>Pr(A,e)),Array.prototype.forEach.call(f,A=>Pr(A,t))):g==="attributes"&&T===_e.MEDIA_CHROME_ATTRIBUTES&&(Ld(E)?e(E):t(E))})},a=[],o=c=>{let u=c.target;u.name!=="media"&&(a.forEach(h=>Pr(h,t)),a=[...u.assignedElements({flatten:!0})],a.forEach(h=>Pr(h,e)))};r.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(r,{childList:!0,attributes:!0,subtree:!0}),()=>{Pr(r,t),r.removeEventListener("slotchange",o),l.disconnect(),r.removeEventListener(ne.REGISTER_MEDIA_STATE_RECEIVER,i),r.removeEventListener(ne.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};D.customElements.get("media-controller")||D.customElements.define("media-controller",Ya);var wd=Ya;var My=Object.defineProperty,Oy=(r,e,t)=>e in r?My(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Py=(r,e,t)=>(Oy(r,typeof e!="symbol"?e+"":e,t),t),Im=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},cr=(r,e,t)=>(Im(r,e,"read from private field"),t?t.call(r):e.get(r)),Dd=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},ja=(r,e,t,i)=>(Im(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Ai,za,Xa,Lm=z.createElement("template"),xm=`
|
|
219
|
+
`;var by=Object.values(S),Ty="sm:384 md:576 lg:768 xl:960";function _y(r){for(let e of r)Ay(e.target,e.contentRect.width)}function Ay(r,e){var t;if(!r.isConnected)return;let i=(t=r.getAttribute(He.BREAKPOINTS))!=null?t:Ty,s=Sy(i),n=xy(s,e),a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){r.hasAttribute(`breakpoint${o}`)||(r.setAttribute(`breakpoint${o}`,""),a=!0);return}r.hasAttribute(`breakpoint${o}`)&&(r.removeAttribute(`breakpoint${o}`),a=!0)}),a){let o=new CustomEvent(vs.BREAKPOINTS_CHANGE,{detail:n});r.dispatchEvent(o)}}function Sy(r){let e=r.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function xy(r,e){return Object.keys(r).filter(t=>e>=r[t])}var Fa=class extends D.HTMLElement{constructor(){super(),yy(this,"breakpointsUncomputed",!0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(um.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 m=h.slot!=="media";for(;(h=h.previousSibling)!==null;)h.slot=="media"&&(m=!1);m&&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 i=!1,s=l=>{i||(setTimeout(()=>{_y(l),i=!1,this.breakpointsUncomputed=!1},0),i=!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(by).filter(e=>![S.MEDIA_RENDITION_LIST].includes(e))}attributeChangedCallback(e,t,i){e.toLowerCase()==He.AUTOHIDE&&(this.autohide=i)}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?ne.MEDIA_PLAY_REQUEST:ne.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new D.CustomEvent(t,{composed:!0,bubbles:!0}))}}handleMediaUpdated(e){let t=n=>Promise.resolve(n),i=n=>(console.error('<media-chrome>: Media element set with slot="media" does not appear to be compatible.',n),Promise.reject(n));if(!e)return i(e);let s=e.nodeName.toLowerCase();return s.includes("-")?D.customElements.whenDefined(s).then(()=>t(e)):t(e)}mediaUnsetCallback(e){}connectedCallback(){var e;let i=this.getAttribute(He.AUDIO)!=null?Dt.AUDIO_PLAYER():Dt.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",i),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 D.CustomEvent(vs.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 D.CustomEvent(vs.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=>{o.pointerType==="mouse"&&(n(),clearTimeout(this._inactiveTimeout),[this,this.media].includes(o.target)&&a())}),this.addEventListener("mouseleave",()=>{s()}),this.addEventListener("keyup",()=>{this.setAttribute(He.KEYBOARD_CONTROL,"")}),(e=D.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 hm=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},bt=(r,e,t)=>(hm(r,e,"read from private field"),t?t.call(r):e.get(r)),gn=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Ua=(r,e,t,i)=>(hm(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),bs,Ts,Ba,Mr,Hi,or,lr=class{constructor(e,t,{defaultValue:i}={defaultValue:void 0}){gn(this,Hi),gn(this,bs,void 0),gn(this,Ts,void 0),gn(this,Ba,void 0),gn(this,Mr,new Set),Ua(this,bs,e),Ua(this,Ts,t),Ua(this,Ba,new Set(i))}[Symbol.iterator](){return bt(this,Hi,or).values()}get length(){return bt(this,Hi,or).size}get value(){var e;return(e=[...bt(this,Hi,or)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Ua(this,Mr,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...bt(this,Hi,or)][e]}values(){return bt(this,Hi,or).values()}forEach(e){bt(this,Hi,or).forEach(e)}add(...e){var t,i;e.forEach(s=>bt(this,Mr).add(s)),!(this.value===""&&!((t=bt(this,bs))!=null&&t.hasAttribute(`${bt(this,Ts)}`)))&&((i=bt(this,bs))==null||i.setAttribute(`${bt(this,Ts)}`,`${this.value}`))}remove(...e){var t;e.forEach(i=>bt(this,Mr).delete(i)),(t=bt(this,bs))==null||t.setAttribute(`${bt(this,Ts)}`,`${this.value}`)}contains(e){return bt(this,Hi,or).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}};bs=new WeakMap;Ts=new WeakMap;Ba=new WeakMap;Mr=new WeakMap;Hi=new WeakSet;or=function(){return bt(this,Mr).size?bt(this,Mr):bt(this,Ba)};var fm=(r="")=>r.split(/\s+/),mm=(r="")=>{let[e,t,i]=r.split(":"),s=i?decodeURIComponent(i):void 0;return e=e==="cc"?"captions":"subtitles",{kind:e,language:t,label:s}},vn=(r="",e={})=>fm(r).map(t=>{let i=mm(t);return{...e,...i}}),Iy=r=>Array.isArray(r)?r.map(e=>typeof e=="string"?mm(e):e):typeof r=="string"?vn(r):[r],$a=({kind:r,label:e,language:t}={kind:"subtitles"})=>e?`${r==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,Or=(r=[])=>Array.prototype.map.call(r,$a).join(" "),Ly=(r,e)=>t=>t[r]===e,pm=r=>{let e=Object.entries(r).map(([t,i])=>Ly(t,i));return t=>e.every(i=>i(t))},_d=(r,e=[],t=[])=>{let i=Iy(t).map(pm),s=n=>i.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=r})},Ga=(r,e=()=>!0)=>{if(!(r!=null&&r.textTracks))return[];let t=typeof e=="function"?e:pm(e);return Array.from(r.textTracks).filter(t)},Ad=r=>!!r.getAttribute(S.MEDIA_SUBTITLES_SHOWING),Vi=(r,e)=>{var t,i;let s=Ad(r);if(s||e===!1){let n=r.getAttribute(S.MEDIA_SUBTITLES_SHOWING);if(n){let a=new D.CustomEvent(ne.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:n});r.dispatchEvent(a)}}else if(!s||e===!0){let[n]=(i=fm((t=r.getAttribute(S.MEDIA_SUBTITLES_LIST))!=null?t:""))!=null?i:[];if(n){let a=new D.CustomEvent(ne.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:n});r.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 ot={enter:"requestFullscreen",exit:"exitFullscreen",rootEvents:["fullscreenchange"],mediaEvents:[],element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};z.fullscreenElement===void 0&&(ot.enter="webkitRequestFullScreen",ot.exit=z.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",ot.rootEvents=["webkitfullscreenchange"],ot.mediaEvents=["webkitbeginfullscreen","webkitendfullscreen"],ot.element="webkitFullscreenElement",ot.error="webkitfullscreenerror",ot.enabled="webkitFullscreenEnabled");var Ha,Sd=()=>{var r,e;return Ha||(Ha=(e=(r=z)==null?void 0:r.createElement)==null?void 0:e.call(r,"video"),Ha)},gm=async(r=Sd())=>{if(!r)return!1;let e=r.volume;return r.volume=e/2+.1,await Ra(0),r.volume!==e},Ry=(r=Sd())=>typeof(r==null?void 0:r.requestPictureInPicture)=="function",ky=(r=Sd())=>{let e=z[ot.enabled];return!e&&r&&(e="webkitSupportsFullscreen"in r),e},xd=ky(),vm=Ry(),Em=!!D.WebKitPlaybackTargetAvailabilityEvent,ym=!!D.chrome;var Va,bm=gm().then(r=>(Va=r,Va)),wy=Object.values(di),Id=r=>Ga(r.media,e=>[Es.SUBTITLES,Es.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),Dy=r=>Ga(r.media,e=>e.mode===xa.SHOWING&&[Es.SUBTITLES,Es.CAPTIONS].includes(e.kind)),Vt={MEDIA_PAUSED:{get:function(r){let{media:e}=r;return e?e.paused:!0},mediaEvents:["play","playing","pause","emptied"]},MEDIA_HAS_PLAYED:{get:function(r){let{media:e}=r;return e?!e.paused:!1},mediaEvents:["playing","emptied"]},MEDIA_ENDED:{get:function(r){let{media:e}=r;return e?e.ended:!1},mediaEvents:["seeked","ended","emptied"]},MEDIA_PLAYBACK_RATE:{get:function(r){let{media:e}=r;return!e||typeof e.playbackRate=="undefined"?1:e.playbackRate},mediaEvents:["ratechange","loadstart"]},MEDIA_MUTED:{get:function(r){let{media:e}=r;return!e||typeof e.muted=="undefined"?!1:e.muted},mediaEvents:["volumechange"]},MEDIA_VOLUME:{get:function(r){let{media:e}=r;return!e||typeof e.volume=="undefined"?1:Number(e.volume)},mediaEvents:["volumechange"]},MEDIA_VOLUME_LEVEL:{get:function(r){let{media:e}=r,t="high";if(!e||typeof e.volume=="undefined")return t;let{muted:i,volume:s}=e;return s===0||i?t="off":s<.5?t="low":s<.75&&(t="medium"),t},mediaEvents:["volumechange"]},MEDIA_CURRENT_TIME:{get:function(r){let{media:e}=r;return!e||typeof e.currentTime=="undefined"?0:e.currentTime},mediaEvents:["timeupdate","loadedmetadata"]},MEDIA_DURATION:{get:function(r){let{media:e}=r;return!e||!Number.isFinite(e.duration)?NaN:e.duration},mediaEvents:["durationchange","loadedmetadata","emptied"]},MEDIA_SEEKABLE:{get:function(r){var e;let{media:t}=r;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;let i=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!i&&!s))return[Number(i.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress"]},MEDIA_LOADING:{get:function(r){var e;return((e=r.media)==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},MEDIA_BUFFERED:{get:function(r){var e,t,i;let s=(e=r.media)==null?void 0:e.buffered;return Array.from((i=(t=r.media)==null?void 0:t.buffered)!=null?i:[]).map((n,a)=>[Number(s.start(a)).toFixed(3),Number(s.end(a)).toFixed(3)])},mediaEvents:["progress","emptied"]},MEDIA_STREAM_TYPE:{get:function(r){let{media:e}=r;if(!e)return;let{streamType:t}=e;if(wy.includes(t)){if(t===di.UNKNOWN){let s=r.getAttribute("defaultstreamtype");return[di.LIVE,di.ON_DEMAND].includes(s)?s:void 0}return t}let i=e.duration;if(i===1/0)return di.LIVE;if(Number.isFinite(i))return di.ON_DEMAND;{let s=r.getAttribute("defaultstreamtype");if([di.LIVE,di.ON_DEMAND].includes(s))return s}},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},MEDIA_TARGET_LIVE_WINDOW:{get:function(r){let{media:e}=r;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,i=Vt.MEDIA_STREAM_TYPE.get(r);return(t==null||Number.isNaN(t))&&i===di.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},MEDIA_TIME_IS_LIVE:{get:function(r){let{media:e}=r;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(Vt.MEDIA_STREAM_TYPE.get(r)==="live"))return!1;let i=e.seekable;if(!i)return!0;if(!i.length)return!1;let s=r.hasAttribute("liveedgeoffset")?Number(r.getAttribute("liveedgeoffset")):10,n=i.end(i.length-1)-s;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},MEDIA_IS_FULLSCREEN:{get:function(r,e){var t;let i=r.media;if(i&&z[ot.element]===void 0&&"webkitDisplayingFullscreen"in i)return i.webkitDisplayingFullscreen&&i.webkitPresentationMode==="fullscreen";let s;return e?s=z[ot.element]?e.target:null:s=(t=r.getRootNode().fullscreenElement)!=null?t:z[ot.element],pn(r.fullscreenElement,s)},rootEvents:ot.rootEvents,mediaEvents:ot.mediaEvents},MEDIA_IS_PIP:{get:function(r,e){var t;let i=r.media;if(!i)return!1;if(e)return e.type=="enterpictureinpicture";{let s=(t=r.getRootNode().pictureInPictureElement)!=null?t:z.pictureInPictureElement;return pn(i,s)}},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},MEDIA_IS_CASTING:{get:function(r,e){var t;let{media:i}=r;if(!i)return!1;let s=(t=D.CastableVideoElement)==null?void 0:t.castElement,n=pn(i,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(r,e){if(!Em)return ri.UNSUPPORTED;if(!!e&&e.availability!=="available"&&e.availability==="not-available")return ri.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"]},MEDIA_CAST_UNAVAILABLE:{get:function(){var r;let e=(r=D.CastableVideoElement)==null?void 0:r.castState;if(!ym||!e)return ri.UNSUPPORTED;if(!e.includes("CONNECT"))return ri.UNAVAILABLE},mediaEvents:["castchange"]},MEDIA_FULLSCREEN_UNAVAILABLE:{get:function(){return xd?void 0:ri.UNAVAILABLE}},MEDIA_PIP_UNAVAILABLE:{get:function(){return vm?void 0:ri.UNSUPPORTED}},MEDIA_RENDITION_UNAVAILABLE:{get:function(r){var e;let{media:t}=r;if(!t)return ri.UNSUPPORTED;if(!t.videoRenditions)return ri.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return ri.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_VOLUME_UNAVAILABLE:{get:function(r){if(Va!==void 0&&!Va)return ri.UNSUPPORTED;let{media:e}=r;if(e&&typeof e.volume=="undefined")return ri.UNAVAILABLE},mediaEvents:["loadstart"]},MEDIA_SUBTITLES_LIST:{get:function(r){return Id(r).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},MEDIA_SUBTITLES_SHOWING:{get:function(r){return r.hasAttribute("defaultsubtitles")&&!r.hasAttribute(S.MEDIA_HAS_PLAYED)&&!r.hasAttribute(S.MEDIA_SUBTITLES_SHOWING)&&Vi(r,!0),Dy(r).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"]},MEDIA_RENDITION_LIST:{get:function(r){var e;let{media:t}=r;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]]},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},MEDIA_RENDITION_SELECTED:{get:function(r){var e,t,i;let{media:s}=r;return(i=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:i.id},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]}},Ka={MEDIA_PLAY_REQUEST:(r,e,t)=>{var i;let s=Vt.MEDIA_STREAM_TYPE.get(t),n=t.getAttribute("noautoseektolive")===null;s==di.LIVE&&n&&Ka.MEDIA_SEEK_TO_LIVE_REQUEST(r),(i=r.play())==null||i.catch(()=>{})},MEDIA_PAUSE_REQUEST:r=>r.pause(),MEDIA_MUTE_REQUEST:r=>r.muted=!0,MEDIA_UNMUTE_REQUEST:r=>{r.muted=!1,r.volume===0&&(r.volume=.25)},MEDIA_VOLUME_REQUEST:(r,e,t)=>{let i=e.detail;if(r.volume=i,i>0&&r.muted&&(r.muted=!1),!t.hasAttribute("novolumepref"))try{D.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch{}},MEDIA_ENTER_FULLSCREEN_REQUEST:(r,e,t)=>{if(!xd){console.warn("Fullscreen support is unavailable; not entering fullscreen");return}z.pictureInPictureElement&&z.exitPictureInPicture(),t[ot.enter]?t.fullscreenElement[ot.enter]():r.webkitEnterFullscreen?r.webkitEnterFullscreen():r.requestFullscreen?r.requestFullscreen():console.warn("MediaChrome: Fullscreen not supported")},MEDIA_EXIT_FULLSCREEN_REQUEST:()=>{z[ot.exit]()},MEDIA_ENTER_PIP_REQUEST:r=>{if(!z.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!r.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}z[ot.element]&&z[ot.exit]();let e=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};r.requestPictureInPicture().catch(t=>{if(t.code===11)if(r.readyState===0&&r.preload==="none"){let i=()=>{r.removeEventListener("loadedmetadata",s),r.preload="none"},s=()=>{r.requestPictureInPicture().catch(e),i()};r.addEventListener("loadedmetadata",s),r.preload="metadata",setTimeout(()=>{r.readyState===0&&e(),i()},1e3)}else throw t;else throw t})},MEDIA_EXIT_PIP_REQUEST:()=>{z.pictureInPictureElement&&z.exitPictureInPicture()},MEDIA_ENTER_CAST_REQUEST:r=>{var e;!((e=D.CastableVideoElement)!=null&&e.castEnabled)||(z[ot.element]&&z[ot.exit](),r.requestCast())},MEDIA_EXIT_CAST_REQUEST:async()=>{var r;(r=D.CastableVideoElement)!=null&&r.castElement&&D.CastableVideoElement.exitCast()},MEDIA_SEEK_REQUEST:(r,e)=>{let t=e.detail;(r.readyState>0||r.readyState===void 0)&&(r.currentTime=t)},MEDIA_PLAYBACK_RATE_REQUEST:(r,e)=>{r.playbackRate=e.detail},MEDIA_PREVIEW_REQUEST:(r,e,t)=>{var i;if(!r)return;let s=e.detail;s===null&&t.propagateMediaState(S.MEDIA_PREVIEW_TIME,void 0),t.propagateMediaState(S.MEDIA_PREVIEW_TIME,s);let[n]=Ga(r,{kind:Es.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)||(i=r.querySelector('track[label="thumbnails"]'))==null?void 0:i.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:(r,e,t)=>{let i=Id(t),{detail:s=[]}=e;_d(xa.SHOWING,i,s)},MEDIA_DISABLE_SUBTITLES_REQUEST:(r,e,t)=>{let i=Id(t),{detail:s=[]}=e;_d(xa.DISABLED,i,s)},MEDIA_AIRPLAY_REQUEST:r=>{if(!!r){if(!(r.webkitShowPlaybackTargetPicker&&D.WebKitPlaybackTargetAvailabilityEvent)){console.warn("received a request to select AirPlay but AirPlay is not supported in this environment");return}r.webkitShowPlaybackTargetPicker()}},MEDIA_SEEK_TO_LIVE_REQUEST:r=>{let e=r.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}r.currentTime=e.end(e.length-1)},MEDIA_RENDITION_REQUEST:(r,e)=>{if(!(r!=null&&r.videoRenditions)){console.warn("MediaController: Rendition selection not supported by this media.");return}let t=e.detail,i=[...r.videoRenditions].findIndex(s=>s.id==t);r.videoRenditions.selectedIndex!=i&&(r.videoRenditions.selectedIndex=i)}};var kd=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Nr=(r,e,t)=>(kd(r,e,"read from private field"),t?t.call(r):e.get(r)),Wa=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Tm=(r,e,t,i)=>(kd(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),_s=(r,e,t)=>(kd(r,e,"access private method"),t),dr,En,As,yn,qa,Ld,Lm=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],Cy=10,_m=0,Kt={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"},Ya=class extends Fa{constructor(){super(),Wa(this,As),Wa(this,qa),Wa(this,dr,new lr(this,Kt.HOTKEYS)),Wa(this,En,void 0),Vt.MEDIA_VOLUME_UNAVAILABLE.get(this)===void 0&&bm.then(()=>{this.propagateMediaState(S.MEDIA_VOLUME_UNAVAILABLE,Vt.MEDIA_VOLUME_UNAVAILABLE.get(this))}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this),Object.keys(Ka).forEach(e=>{let t=`_handle${Ia(e,!0)}`;this[t]=i=>{if(i.stopPropagation(),!this.media){console.warn("MediaController: No media available.");return}Ka[e](this.media,i,this)},this.addEventListener(ne[e],this[t])}),this._mediaStatePropagators={},Object.keys(Vt).forEach(e=>{this._mediaStatePropagators[e]=t=>{this.propagateMediaState(wr[e],Vt[e].get(this,t))}}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(Kt.NO_HOTKEYS,Kt.HOTKEYS,Kt.DEFAULT_STREAM_TYPE,Kt.DEFAULT_SUBTITLES)}get fullscreenElement(){var e;return(e=Nr(this,En))!=null?e:this}set fullscreenElement(e){this.hasAttribute(Kt.FULLSCREEN_ELEMENT)&&this.removeAttribute(Kt.FULLSCREEN_ELEMENT),Tm(this,En,e)}attributeChangedCallback(e,t,i){var s;if(e===Kt.NO_HOTKEYS)i!==t&&i===""?(this.hasAttribute(Kt.HOTKEYS)&&console.warn("Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):i!==t&&i===null&&this.enableHotkeys();else if(e===Kt.HOTKEYS)Nr(this,dr).value=i;else if(e===Kt.DEFAULT_SUBTITLES&&i!==t&&i==="")Vi(this,!0);else if(e===Kt.DEFAULT_STREAM_TYPE)this.propagateMediaState(wr.MEDIA_STREAM_TYPE);else if(e===Kt.FULLSCREEN_ELEMENT){let n=i?(s=this.getRootNode())==null?void 0:s.getElementById(i):void 0;Tm(this,En,n)}super.attributeChangedCallback(e,t,i)}mediaSetCallback(e){if(super.mediaSetCallback(e),e.hasAttribute("tabindex")||(e.tabIndex=-1),Object.keys(Vt).forEach(t=>{let{mediaEvents:i,rootEvents:s,textTracksEvents:n,videoRenditionsEvents:a}=Vt[t],o=this._mediaStatePropagators[t];i==null||i.forEach(l=>{e.addEventListener(l,o),o()}),s==null||s.forEach(l=>{this.getRootNode().addEventListener(l,o),o()}),n==null||n.forEach(l=>{var d;(d=e.textTracks)==null||d.addEventListener(l,o),o()}),a==null||a.forEach(l=>{var d;(d=e.videoRenditions)==null||d.addEventListener(l,o),o()})}),!this.hasAttribute("novolumepref"))try{let t=D.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(Vt).forEach(t=>{let{mediaEvents:i,rootEvents:s,textTracksEvents:n,videoRenditionsEvents:a}=Vt[t],o=this._mediaStatePropagators[t];i==null||i.forEach(l=>{e.removeEventListener(l,o)}),s==null||s.forEach(l=>{this.getRootNode().removeEventListener(l,o)}),n==null||n.forEach(l=>{var d;(d=e.textTracks)==null||d.removeEventListener(l,o)}),a==null||a.forEach(l=>{var d;(d=e.videoRenditions)==null||d.removeEventListener(l,o),o()})}),this.propagateMediaState(wr.MEDIA_PAUSED,!0)}propagateMediaState(e,t){let i=Im(this.mediaStateReceivers,e);if(xm(this.mediaStateReceivers,e,t),i===Im(this.mediaStateReceivers,e))return;let s=e.toLowerCase(),n=new D.CustomEvent(zf[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 i=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=Uy(e,i,s);Object.keys(ne).forEach(a=>{e.addEventListener(ne[a],this[`_handle${Ia(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(ne).forEach(s=>{e.removeEventListener(ne[s],this[`_handle${Ia(s,!0)}`])})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),Object.keys(Vt).forEach(s=>{let n=Vt[s];xm([e],wr[s],n.get(this))}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,i=t.indexOf(e);i<0||t.splice(i,1)}enableHotkeys(){this.addEventListener("keydown",_s(this,qa,Ld))}disableHotkeys(){this.removeEventListener("keydown",_s(this,qa,Ld)),this.removeEventListener("keyup",_s(this,As,yn))}get hotkeys(){return Nr(this,dr)}keyboardShortcutHandler(e){var t,i,s,n;if(((n=(s=(t=e.target.getAttribute(Kt.KEYS_USED))==null?void 0:t.split(" "))!=null?s:(i=e.target)==null?void 0:i.keysUsed)!=null?n:[]).map(m=>m==="Space"?" ":m).filter(Boolean).includes(e.key))return;let o,l,d,c,u,h=Cy;if(!Nr(this,dr).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&Nr(this,dr).contains("nospace")))switch(e.key){case" ":case"k":o=this.getAttribute(S.MEDIA_PAUSED)!=null?ne.MEDIA_PLAY_REQUEST:ne.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new D.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"m":o=this.getAttribute(S.MEDIA_VOLUME_LEVEL)==="off"?ne.MEDIA_UNMUTE_REQUEST:ne.MEDIA_MUTE_REQUEST,this.dispatchEvent(new D.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"f":o=this.getAttribute(S.MEDIA_IS_FULLSCREEN)!=null?ne.MEDIA_EXIT_FULLSCREEN_REQUEST:ne.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new D.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"c":Vi(this);break;case"ArrowLeft":l=this.getAttribute(S.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:_m,c=Math.max(d-h,0),u=new D.CustomEvent(ne.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:_m,c=Math.max(d+h,0),u=new D.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break;default:break}}};dr=new WeakMap;En=new WeakMap;As=new WeakSet;yn=function(r){let{key:e}=r;if(!Lm.includes(e)){this.removeEventListener("keyup",_s(this,As,yn));return}this.keyboardShortcutHandler(r)};qa=new WeakSet;Ld=function(r){let{metaKey:e,altKey:t,key:i}=r;if(e||t||!Lm.includes(i)){this.removeEventListener("keyup",_s(this,As,yn));return}[" ","ArrowLeft","ArrowRight"].includes(i)&&!(Nr(this,dr).contains(`no${i.toLowerCase()}`)||i===" "&&Nr(this,dr).contains("nospace"))&&r.preventDefault(),this.addEventListener("keyup",_s(this,As,yn),{once:!0})};var My=Object.values(S),Oy=Object.values(wr),wd=r=>{var e,t,i,s;let{observedAttributes:n}=r.constructor;!n&&((e=r.nodeName)==null?void 0:e.includes("-"))&&(D.customElements.upgrade(r),{observedAttributes:n}=r.constructor);let a=(s=(i=(t=r==null?void 0:r.getAttribute)==null?void 0:t.call(r,_e.MEDIA_CHROME_ATTRIBUTES))==null?void 0:i.split)==null?void 0:s.call(i,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>My.includes(o)):[]},Py=r=>{var e,t;return((e=r.nodeName)==null?void 0:e.includes("-"))&&!!D.customElements.get((t=r.nodeName)==null?void 0:t.toLowerCase())&&!(r instanceof D.customElements.get(r.nodeName.toLowerCase()))&&D.customElements.upgrade(r),Oy.some(i=>i in r)},Rd=r=>Py(r)||!!wd(r).length,Am=r=>{var e;return(e=r==null?void 0:r.join)==null?void 0:e.call(r,":")},Sm={[S.MEDIA_SUBTITLES_LIST]:Or,[S.MEDIA_SUBTITLES_SHOWING]:Or,[S.MEDIA_SEEKABLE]:Am,[S.MEDIA_BUFFERED]:r=>r==null?void 0:r.map(Am).join(" "),[S.MEDIA_PREVIEW_COORDS]:r=>r==null?void 0:r.join(" "),[S.MEDIA_RENDITION_LIST]:Xf},Ny=async(r,e,t)=>{var i,s;if(r.isConnected||await Ra(0),typeof t=="boolean"||t==null)return Ge(r,e,t);if(typeof t=="number")return Ye(r,e,t);if(typeof t=="string")return Xe(r,e,t);if(Array.isArray(t)&&!t.length)return r.removeAttribute(e);let n=(s=(i=Sm[e])==null?void 0:i.call(Sm,t))!=null?s:t;return r.setAttribute(e,n)},Fy=r=>{var e;return!!((e=r.closest)!=null&&e.call(r,'*[slot="media"]'))},Pr=(r,e)=>{if(Fy(r))return;let t=(s,n)=>{var a,o;Rd(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=>Pr(u,n))},i=r==null?void 0:r.nodeName.toLowerCase();if(i.includes("-")&&!Rd(r)){D.customElements.whenDefined(i).then(()=>{t(r,e)});return}t(r,e)},xm=(r,e,t)=>{r.forEach(i=>{if(e in i){i[e]=t;return}let s=wd(i),n=e.toLowerCase();!s.includes(n)||Ny(i,n,t)})},Im=(r,e)=>{for(let t of r){if(e in t)return t[e];let i=wd(t),s=e.toLowerCase();if(!!i.includes(s))return t.getAttribute(s)}},Uy=(r,e,t)=>{Pr(r,e);let i=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)};r.addEventListener(ne.REGISTER_MEDIA_STATE_RECEIVER,i),r.addEventListener(ne.UNREGISTER_MEDIA_STATE_RECEIVER,s);let n=c=>{c.forEach(u=>{let{addedNodes:h=[],removedNodes:m=[],type:g,target:E,attributeName:T}=u;g==="childList"?(Array.prototype.forEach.call(h,A=>Pr(A,e)),Array.prototype.forEach.call(m,A=>Pr(A,t))):g==="attributes"&&T===_e.MEDIA_CHROME_ATTRIBUTES&&(Rd(E)?e(E):t(E))})},a=[],o=c=>{let u=c.target;u.name!=="media"&&(a.forEach(h=>Pr(h,t)),a=[...u.assignedElements({flatten:!0})],a.forEach(h=>Pr(h,e)))};r.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(r,{childList:!0,attributes:!0,subtree:!0}),()=>{Pr(r,t),r.removeEventListener("slotchange",o),l.disconnect(),r.removeEventListener(ne.REGISTER_MEDIA_STATE_RECEIVER,i),r.removeEventListener(ne.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};D.customElements.get("media-controller")||D.customElements.define("media-controller",Ya);var Dd=Ya;var By=Object.defineProperty,$y=(r,e,t)=>e in r?By(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Gy=(r,e,t)=>($y(r,typeof e!="symbol"?e+"":e,t),t),km=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},cr=(r,e,t)=>(km(r,e,"read from private field"),t?t.call(r):e.get(r)),Cd=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},ja=(r,e,t,i)=>(km(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Ai,za,Xa,wm=z.createElement("template"),Rm=`
|
|
220
220
|
height: var(--thumb-height);
|
|
221
221
|
width: var(--media-range-thumb-width, 10px);
|
|
222
222
|
border: var(--media-range-thumb-border, none);
|
|
@@ -227,7 +227,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
227
227
|
transition: var(--media-range-thumb-transition, none);
|
|
228
228
|
transform: var(--media-range-thumb-transform, none);
|
|
229
229
|
opacity: var(--media-range-thumb-opacity, 1);
|
|
230
|
-
`,
|
|
230
|
+
`,Md=`
|
|
231
231
|
min-width: 40px;
|
|
232
232
|
height: var(--track-height);
|
|
233
233
|
border: var(--media-range-track-border, none);
|
|
@@ -240,7 +240,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
240
240
|
transition: var(--media-range-track-transition, none);
|
|
241
241
|
transform: translate(var(--media-range-track-translate-x, 0), var(--media-range-track-translate-y, 0));
|
|
242
242
|
cursor: pointer;
|
|
243
|
-
`;
|
|
243
|
+
`;wm.innerHTML=`
|
|
244
244
|
<style>
|
|
245
245
|
:host {
|
|
246
246
|
--thumb-height: var(--media-range-thumb-height, 10px);
|
|
@@ -298,19 +298,19 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
298
298
|
|
|
299
299
|
input[type=range]::-webkit-slider-thumb {
|
|
300
300
|
-webkit-appearance: none;
|
|
301
|
-
${
|
|
301
|
+
${Rm}
|
|
302
302
|
|
|
303
303
|
margin-top: calc(calc(0px - var(--thumb-height) + var(--track-height)) / 2);
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
|
|
307
307
|
input[type=range]::-moz-range-thumb {
|
|
308
|
-
${
|
|
308
|
+
${Rm}
|
|
309
309
|
translate: var(--media-range-track-translate-x, 0) var(--media-range-track-translate-y, 0);
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
-
input[type=range]::-webkit-slider-runnable-track { ${
|
|
313
|
-
input[type=range]::-moz-range-track { ${
|
|
312
|
+
input[type=range]::-webkit-slider-runnable-track { ${Md} }
|
|
313
|
+
input[type=range]::-moz-range-track { ${Md} }
|
|
314
314
|
input[type=range]::-ms-track {
|
|
315
315
|
|
|
316
316
|
width: 100%;
|
|
@@ -320,7 +320,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
320
320
|
border-color: transparent;
|
|
321
321
|
color: transparent;
|
|
322
322
|
|
|
323
|
-
${
|
|
323
|
+
${Md}
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
#background,
|
|
@@ -383,7 +383,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
383
383
|
<div id="hoverzone"></div>
|
|
384
384
|
<input id="range" type="range" min="0" max="1000" step="any" value="0">
|
|
385
385
|
</div>
|
|
386
|
-
`;var Fr=class extends D.HTMLElement{constructor(){super(),
|
|
386
|
+
`;var Fr=class extends D.HTMLElement{constructor(){super(),Gy(this,"thumbWidth"),Cd(this,Ai,void 0),Cd(this,za,()=>{if(this.range.matches(":focus-visible")){let{style:t}=ze(this.shadowRoot,":host");t.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),Cd(this,Xa,()=>{let{style:t}=ze(this.shadowRoot,":host");t.removeProperty("--_focus-visible-box-shadow")}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(wm.content.cloneNode(!0)));let{style:e}=ze(this.shadowRoot,":host");e.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-block))`),this.container=this.shadowRoot.querySelector("#container"),this.range=this.shadowRoot.querySelector("#range"),this.range.addEventListener("input",this.updateBar.bind(this)),this.thumbWidth=parseInt(getComputedStyle(this).getPropertyValue("--media-range-thumb-width")||"10",10)}static get observedAttributes(){return["disabled","aria-disabled",_e.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===_e.MEDIA_CONTROLLER?(t&&((n=(s=cr(this,Ai))==null?void 0:s.unassociateElement)==null||n.call(s,this),ja(this,Ai,null)),i&&(ja(this,Ai,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=cr(this,Ai))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==i)&&(i==null?this.range.removeAttribute(e):this.range.setAttribute(e,i))}connectedCallback(){var e,t,i;let s=this.getAttribute(_e.MEDIA_CONTROLLER);s&&(ja(this,Ai,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=cr(this,Ai))==null?void 0:t.associateElement)==null||i.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",cr(this,za)),this.shadowRoot.addEventListener("focusout",cr(this,Xa))}disconnectedCallback(){var e,t;(t=(e=cr(this,Ai))==null?void 0:e.unassociateElement)==null||t.call(e,this),ja(this,Ai,null),this.shadowRoot.removeEventListener("focusin",cr(this,za)),this.shadowRoot.removeEventListener("focusout",cr(this,Xa))}updatePointerBar(e){let t=this.range.getBoundingClientRect(),i=(e.clientX-t.left)/t.width;i=Math.max(0,Math.min(1,i));let{style:s}=ze(this.shadowRoot,"#pointer");s.setProperty("width",`${i*t.width}px`)}updateBar(){let e=this.getBarColors(),t="linear-gradient(to right, ",i=0;e.forEach(n=>{n[1]<i||(t=t+`${n[0]} ${i}%, ${n[0]} ${n[1]}%,`,i=n[1])}),t=t.slice(0,t.length-1)+")";let{style:s}=ze(this.shadowRoot,"#range");s.setProperty("--media-range-track-progress-internal",t)}getRelativeValues(){let{range:e}=this;return{relativeValue:e.value-e.min,relativeMax:e.max-e.min}}getBarColors(){let e=this.range,{relativeValue:t,relativeMax:i}=this.getRelativeValues(),s=t/i*100,n=0;return!!t&&t<i&&(n=this.thumbWidth*(.5-s/100)/e.offsetWidth*100),[["var(--media-range-bar-color, var(--media-primary-color, rgb(238 238 238)))",s+n],["var(--media-range-track-color, transparent)",100]]}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};Ai=new WeakMap;za=new WeakMap;Xa=new WeakMap;D.customElements.get("media-chrome-range")||D.customElements.define("media-chrome-range",Fr);var Dm=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Qa=(r,e,t)=>(Dm(r,e,"read from private field"),t?t.call(r):e.get(r)),Hy=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Za=(r,e,t,i)=>(Dm(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Si,Cm=z.createElement("template");Cm.innerHTML=`
|
|
387
387
|
<style>
|
|
388
388
|
:host {
|
|
389
389
|
|
|
@@ -409,7 +409,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
409
409
|
</style>
|
|
410
410
|
|
|
411
411
|
<slot></slot>
|
|
412
|
-
`;var
|
|
412
|
+
`;var Od=class extends D.HTMLElement{constructor(){super(),Hy(this,Si,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Cm.content.cloneNode(!0))),this.shadowRoot.querySelector("slot").addEventListener("slotchange",({target:e})=>{let t=e.assignedElements({flatten:!0}).every(n=>["media-time-range","media-volume-range"].includes(n.nodeName.toLowerCase())),{style:i}=ze(this.shadowRoot,":host"),s=t?"unset":"initial";i.setProperty("--_range-auto-size",s)})}static get observedAttributes(){return[_e.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===_e.MEDIA_CONTROLLER&&(t&&((n=(s=Qa(this,Si))==null?void 0:s.unassociateElement)==null||n.call(s,this),Za(this,Si,null)),i&&(Za(this,Si,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=Qa(this,Si))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,i;let s=this.getAttribute(_e.MEDIA_CONTROLLER);s&&(Za(this,Si,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=Qa(this,Si))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Qa(this,Si))==null?void 0:e.unassociateElement)==null||t.call(e,this),Za(this,Si,null)}};Si=new WeakMap;D.customElements.get("media-control-bar")||D.customElements.define("media-control-bar",Od);var Mm=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Ja=(r,e,t)=>(Mm(r,e,"read from private field"),t?t.call(r):e.get(r)),Vy=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},eo=(r,e,t,i)=>(Mm(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),xi,Om=z.createElement("template");Om.innerHTML=`
|
|
413
413
|
<style>
|
|
414
414
|
:host {
|
|
415
415
|
font: var(--media-font,
|
|
@@ -442,11 +442,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
442
442
|
}
|
|
443
443
|
</style>
|
|
444
444
|
<slot></slot>
|
|
445
|
-
`;var Ki=class extends D.HTMLElement{constructor(){super(),
|
|
445
|
+
`;var Ki=class extends D.HTMLElement{constructor(){super(),Vy(this,xi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Om.content.cloneNode(!0)));let{style:e}=ze(this.shadowRoot,":host");e.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`)}static get observedAttributes(){return[_e.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===_e.MEDIA_CONTROLLER&&(t&&((n=(s=Ja(this,xi))==null?void 0:s.unassociateElement)==null||n.call(s,this),eo(this,xi,null)),i&&(eo(this,xi,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=Ja(this,xi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,i;let s=this.getAttribute(_e.MEDIA_CONTROLLER);s&&(eo(this,xi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=Ja(this,xi))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Ja(this,xi))==null?void 0:e.unassociateElement)==null||t.call(e,this),eo(this,xi,null)}};xi=new WeakMap;D.customElements.get("media-text-display")||D.customElements.define("media-text-display",Ki);var Nm=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Pm=(r,e,t)=>(Nm(r,e,"read from private field"),t?t.call(r):e.get(r)),Ky=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Wy=(r,e,t,i)=>(Nm(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),bn,Pd=class extends Ki{constructor(){super(),Ky(this,bn,void 0),Wy(this,bn,this.shadowRoot.querySelector("slot")),Pm(this,bn).textContent=Ti(0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_DURATION]}attributeChangedCallback(e,t,i){e===S.MEDIA_DURATION&&(Pm(this,bn).textContent=Ti(i)),super.attributeChangedCallback(e,t,i)}get mediaDuration(){return Ue(this,S.MEDIA_DURATION)}set mediaDuration(e){Ye(this,S.MEDIA_DURATION,e)}};bn=new WeakMap;D.customElements.get("media-duration-display")||D.customElements.define("media-duration-display",Pd);var $m=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Nd=(r,e,t)=>($m(r,e,"read from private field"),t?t.call(r):e.get(r)),qy=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Yy=(r,e,t,i)=>($m(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Ss,ci={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},Fm=[...Object.values(ci),S.MEDIA_CURRENT_TIME,S.MEDIA_DURATION,S.MEDIA_SEEKABLE],Um=["Enter"," "],jy=" / ",Bm=(r,{timesSep:e=jy}={})=>{var t,i,s,n;let a=r.hasAttribute(ci.REMAINING),o=r.hasAttribute(ci.SHOW_DURATION),l=(t=r.mediaCurrentTime)!=null?t:0,[,d]=(i=r.mediaSeekable)!=null?i:[],c=(n=(s=r.mediaDuration)!=null?s:d)!=null?n:0,u=a?Ti(0-(c-l)):Ti(l);return o?`${u}${e}${Ti(c)}`:u},zy="video not loaded, unknown time.",Xy=r=>{var e;let t=r.mediaCurrentTime,[,i]=(e=r.mediaSeekable)!=null?e:[],s=r.mediaDuration||i;if(t==null||s==null){r.setAttribute("aria-valuetext",zy);return}let n=r.hasAttribute(ci.REMAINING),a=r.hasAttribute(ci.SHOW_DURATION),o=n?Dr(0-(s-t)):Dr(t);if(!a){r.setAttribute("aria-valuetext",o);return}let l=Dr(s),d=`${o} of ${l}`;r.setAttribute("aria-valuetext",d)},Fd=class extends Ki{constructor(){super(),qy(this,Ss,void 0),Yy(this,Ss,this.shadowRoot.querySelector("slot")),Nd(this,Ss).innerHTML=`${Bm(this)}`;let{style:e}=ze(this.shadowRoot,":host:not([notoggle])");e.setProperty("cursor","pointer");let{style:t}=ze(this.shadowRoot,":host(:hover:not([notoggle]))");t.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))")}static get observedAttributes(){return[...super.observedAttributes,...Fm,"disabled"]}connectedCallback(){this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Dt.PLAYBACK_TIME());let e=t=>{let{key:i}=t;if(!Um.includes(i)){this.removeEventListener("keyup",e);return}this.toggleTimeDisplay()};this.addEventListener("keydown",t=>{let{metaKey:i,altKey:s,key:n}=t;if(i||s||!Um.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,i){Fm.includes(e)?this.update():e==="disabled"&&i!==t&&(i==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,i)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return Ke(this,ci.REMAINING)}set remaining(e){Ge(this,ci.REMAINING,e)}get showDuration(){return Ke(this,ci.SHOW_DURATION)}set showDuration(e){Ge(this,ci.SHOW_DURATION,e)}get noToggle(){return Ke(this,ci.NO_TOGGLE)}set noToggle(e){Ge(this,ci.NO_TOGGLE,e)}get mediaDuration(){return Ue(this,S.MEDIA_DURATION)}set mediaDuration(e){Ye(this,S.MEDIA_DURATION,e)}get mediaCurrentTime(){return Ue(this,S.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){Ye(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=Bm(this);Xy(this),e!==Nd(this,Ss).innerHTML&&(Nd(this,Ss).innerHTML=e)}};Ss=new WeakMap;D.customElements.get("media-time-display")||D.customElements.define("media-time-display",Fd);var Qy=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
446
446
|
<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"/>
|
|
447
|
-
</svg>`,
|
|
447
|
+
</svg>`,Zy=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
448
448
|
<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"/>
|
|
449
|
-
</svg>`,
|
|
449
|
+
</svg>`,Km=z.createElement("template");Km.innerHTML=`
|
|
450
450
|
<style>
|
|
451
451
|
:host([aria-checked="true"]) slot[name=off] {
|
|
452
452
|
display: none !important;
|
|
@@ -459,16 +459,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
459
459
|
</style>
|
|
460
460
|
|
|
461
461
|
<slot name="icon">
|
|
462
|
-
<slot name="on">${
|
|
463
|
-
<slot name="off">${
|
|
462
|
+
<slot name="on">${Qy}</slot>
|
|
463
|
+
<slot name="off">${Zy}</slot>
|
|
464
464
|
</slot>
|
|
465
|
-
`;var
|
|
466
|
-
<slot name="icon">${
|
|
467
|
-
`;var
|
|
465
|
+
`;var Gm=r=>{r.setAttribute("aria-checked",Ad(r))},Ud=class extends We{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_SUBTITLES_LIST,S.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:Km,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Dt.CLOSED_CAPTIONS()),Gm(this)}attributeChangedCallback(e,t,i){e===S.MEDIA_SUBTITLES_SHOWING&&Gm(this),super.attributeChangedCallback(e,t,i)}get mediaSubtitlesList(){return Hm(this,S.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Vm(this,S.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Hm(this,S.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Vm(this,S.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){Vi(this)}},Hm=(r,e)=>{let t=r.getAttribute(e);return t?vn(t):[]},Vm=(r,e,t)=>{if(!(t!=null&&t.length)){r.removeAttribute(e);return}let i=Or(t);r.getAttribute(e)!==i&&r.setAttribute(e,i)};D.customElements.get("media-captions-button")||D.customElements.define("media-captions-button",Ud);var xs={SEEK_OFFSET:"seekoffset"},to=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)">${to}</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>`,Wm=z.createElement("template");Wm.innerHTML=`
|
|
466
|
+
<slot name="icon">${Jy}</slot>
|
|
467
|
+
`;var eb=0,Bd=class extends We{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_CURRENT_TIME,xs.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Wm,...e})}connectedCallback(){this.seekOffset=Ue(this,xs.SEEK_OFFSET,to),super.connectedCallback()}attributeChangedCallback(e,t,i){e===xs.SEEK_OFFSET&&(this.seekOffset=Ue(this,xs.SEEK_OFFSET,to)),super.attributeChangedCallback(e,t,i)}get seekOffset(){return Ue(this,xs.SEEK_OFFSET,to)}set seekOffset(e){Ye(this,xs.SEEK_OFFSET,e),this.setAttribute("aria-label",je.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),ka(wa(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Ue(this,S.MEDIA_CURRENT_TIME,eb)}set mediaCurrentTime(e){Ye(this,S.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new D.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};D.customElements.get("media-seek-forward-button")||D.customElements.define("media-seek-forward-button",Bd);var tb=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
468
468
|
<path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
|
|
469
|
-
</svg>`,
|
|
469
|
+
</svg>`,ib=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
470
470
|
<path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
|
|
471
|
-
</svg>`,
|
|
471
|
+
</svg>`,Ym=z.createElement("template");Ym.innerHTML=`
|
|
472
472
|
<style>
|
|
473
473
|
:host([${S.MEDIA_IS_FULLSCREEN}]) slot:not([name=exit]):not([name=icon]) {
|
|
474
474
|
display: none !important;
|
|
@@ -481,10 +481,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
481
481
|
</style>
|
|
482
482
|
|
|
483
483
|
<slot name="icon">
|
|
484
|
-
<slot name="enter">${
|
|
485
|
-
<slot name="exit">${
|
|
484
|
+
<slot name="enter">${tb}</slot>
|
|
485
|
+
<slot name="exit">${ib}</slot>
|
|
486
486
|
</slot>
|
|
487
|
-
`;var
|
|
487
|
+
`;var qm=r=>{let e=r.mediaIsFullscreen?je.EXIT_FULLSCREEN():je.ENTER_FULLSCREEN();r.setAttribute("aria-label",e)},$d=class extends We{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_FULLSCREEN,S.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Ym,...e})}connectedCallback(){qm(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===S.MEDIA_IS_FULLSCREEN&&qm(this),super.attributeChangedCallback(e,t,i)}get mediaFullscreenUnavailable(){return et(this,S.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){Xe(this,S.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return Ke(this,S.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){Ge(this,S.MEDIA_IS_FULLSCREEN,e)}handleClick(){let e=this.mediaIsFullscreen?ne.MEDIA_EXIT_FULLSCREEN_REQUEST:ne.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new D.CustomEvent(e,{composed:!0,bubbles:!0}))}};D.customElements.get("media-fullscreen-button")||D.customElements.define("media-fullscreen-button",$d);var{MEDIA_TIME_IS_LIVE:io,MEDIA_PAUSED:Tn}=S,{MEDIA_SEEK_TO_LIVE_REQUEST:rb,MEDIA_PLAY_REQUEST:sb}=ne,nb='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',zm=z.createElement("template");zm.innerHTML=`
|
|
488
488
|
<style>
|
|
489
489
|
|
|
490
490
|
slot[name=indicator] > *,
|
|
@@ -507,16 +507,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
507
507
|
|
|
508
508
|
</style>
|
|
509
509
|
|
|
510
|
-
<slot name="indicator">${
|
|
510
|
+
<slot name="indicator">${nb}</slot>
|
|
511
511
|
|
|
512
512
|
<slot name="spacer"> </slot><slot name="text">LIVE</slot>
|
|
513
|
-
`;var
|
|
513
|
+
`;var jm=r=>{let e=r.mediaPaused||!r.mediaTimeIsLive,t=e?je.SEEK_LIVE():je.PLAYING_LIVE();r.setAttribute("aria-label",t),e?r.removeAttribute("aria-disabled"):r.setAttribute("aria-disabled","true")},Gd=class extends We{static get observedAttributes(){return[...super.observedAttributes,Tn,io]}constructor(e={}){super({slotTemplate:zm,...e})}connectedCallback(){jm(this),super.connectedCallback()}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),jm(this)}get mediaPaused(){return Ke(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ge(this,S.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return Ke(this,S.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){Ge(this,S.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new D.CustomEvent(rb,{composed:!0,bubbles:!0})),this.hasAttribute(Tn)&&this.dispatchEvent(new D.CustomEvent(sb,{composed:!0,bubbles:!0})))}};D.customElements.get("media-live-button")||D.customElements.define("media-live-button",Gd);var{MEDIA_VOLUME_LEVEL:_n}=S,ab=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
514
514
|
<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"/>
|
|
515
|
-
</svg>`,
|
|
515
|
+
</svg>`,Xm=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
516
516
|
<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"/>
|
|
517
|
-
</svg>`,
|
|
517
|
+
</svg>`,ob=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
518
518
|
<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"/>
|
|
519
|
-
</svg>`,
|
|
519
|
+
</svg>`,Zm=z.createElement("template");Zm.innerHTML=`
|
|
520
520
|
<style>
|
|
521
521
|
|
|
522
522
|
:host(:not([${_n}])) slot:not([name=high]):not([name=icon]),
|
|
@@ -538,14 +538,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
538
538
|
</style>
|
|
539
539
|
|
|
540
540
|
<slot name="icon">
|
|
541
|
-
<slot name="off">${
|
|
542
|
-
<slot name="low">${
|
|
543
|
-
<slot name="medium">${
|
|
544
|
-
<slot name="high">${
|
|
541
|
+
<slot name="off">${ab}</slot>
|
|
542
|
+
<slot name="low">${Xm}</slot>
|
|
543
|
+
<slot name="medium">${Xm}</slot>
|
|
544
|
+
<slot name="high">${ob}</slot>
|
|
545
545
|
</slot>
|
|
546
|
-
`;var
|
|
546
|
+
`;var Qm=r=>{let t=r.mediaVolumeLevel==="off"?je.UNMUTE():je.MUTE();r.setAttribute("aria-label",t)},Hd=class extends We{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:Zm,...e})}connectedCallback(){Qm(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===S.MEDIA_VOLUME_LEVEL&&Qm(this),super.attributeChangedCallback(e,t,i)}get mediaVolumeLevel(){return et(this,S.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){Xe(this,S.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e=this.mediaVolumeLevel==="off"?ne.MEDIA_UNMUTE_REQUEST:ne.MEDIA_MUTE_REQUEST;this.dispatchEvent(new D.CustomEvent(e,{composed:!0,bubbles:!0}))}};D.customElements.get("media-mute-button")||D.customElements.define("media-mute-button",Hd);var Jm=`<svg aria-hidden="true" viewBox="0 0 28 24">
|
|
547
547
|
<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"/>
|
|
548
|
-
</svg>`,
|
|
548
|
+
</svg>`,tp=z.createElement("template");tp.innerHTML=`
|
|
549
549
|
<style>
|
|
550
550
|
:host([${S.MEDIA_IS_PIP}]) slot:not([name=exit]):not([name=icon]) {
|
|
551
551
|
display: none !important;
|
|
@@ -558,14 +558,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
558
558
|
</style>
|
|
559
559
|
|
|
560
560
|
<slot name="icon">
|
|
561
|
-
<slot name="enter">${
|
|
562
|
-
<slot name="exit">${
|
|
561
|
+
<slot name="enter">${Jm}</slot>
|
|
562
|
+
<slot name="exit">${Jm}</slot>
|
|
563
563
|
</slot>
|
|
564
|
-
`;var
|
|
564
|
+
`;var ep=r=>{let e=r.mediaIsPip?je.EXIT_PIP():je.ENTER_PIP();r.setAttribute("aria-label",e)},Vd=class extends We{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_IS_PIP,S.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:tp,...e})}connectedCallback(){ep(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===S.MEDIA_IS_PIP&&ep(this),super.attributeChangedCallback(e,t,i)}get mediaPipUnavailable(){return et(this,S.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){Xe(this,S.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return Ke(this,S.MEDIA_IS_PIP)}set mediaIsPip(e){Ge(this,S.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?ne.MEDIA_EXIT_PIP_REQUEST:ne.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new D.CustomEvent(e,{composed:!0,bubbles:!0}))}};D.customElements.get("media-pip-button")||D.customElements.define("media-pip-button",Vd);var lb=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
565
565
|
<path d="m6 21 15-9L6 3v18Z"/>
|
|
566
|
-
</svg>`,
|
|
566
|
+
</svg>`,db=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
567
567
|
<path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
|
|
568
|
-
</svg>`,
|
|
568
|
+
</svg>`,rp=z.createElement("template");rp.innerHTML=`
|
|
569
569
|
<style>
|
|
570
570
|
:host([${S.MEDIA_PAUSED}]) slot[name=pause] {
|
|
571
571
|
display: none !important;
|
|
@@ -577,12 +577,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
577
577
|
</style>
|
|
578
578
|
|
|
579
579
|
<slot name="icon">
|
|
580
|
-
<slot name="play">${
|
|
581
|
-
<slot name="pause">${
|
|
580
|
+
<slot name="play">${lb}</slot>
|
|
581
|
+
<slot name="pause">${db}</slot>
|
|
582
582
|
</slot>
|
|
583
|
-
`;var
|
|
583
|
+
`;var ip=r=>{let e=r.mediaPaused?je.PLAY():je.PAUSE();r.setAttribute("aria-label",e)},Kd=class extends We{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PAUSED,S.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:rp,...e})}connectedCallback(){ip(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===S.MEDIA_PAUSED&&ip(this),super.attributeChangedCallback(e,t,i)}get mediaPaused(){return Ke(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ge(this,S.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?ne.MEDIA_PLAY_REQUEST:ne.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new D.CustomEvent(e,{composed:!0,bubbles:!0}))}};D.customElements.get("media-play-button")||D.customElements.define("media-play-button",Kd);var cb=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},ro=(r,e,t)=>(cb(r,e,"read from private field"),t?t.call(r):e.get(r)),ub=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Is,Wd={RATES:"rates"},Yd=[1,1.25,1.5,1.75,2],Ls=1,sp=z.createElement("template");sp.innerHTML=`
|
|
584
584
|
<span id="container"></span>
|
|
585
|
-
`;var
|
|
585
|
+
`;var qd=class extends We{constructor(e={}){super({slotTemplate:sp,...e}),ub(this,Is,new lr(this,Wd.RATES,{defaultValue:Yd})),this.container=this.shadowRoot.querySelector("#container"),this.container.innerHTML=`${Ls}x`}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PLAYBACK_RATE,Wd.RATES]}attributeChangedCallback(e,t,i){if(e===Wd.RATES&&(ro(this,Is).value=i),e===S.MEDIA_PLAYBACK_RATE){let s=i?+i:Number.NaN,n=Number.isNaN(s)?Ls:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Dt.PLAYBACK_RATE({playbackRate:n}));return}super.attributeChangedCallback(e,t,i)}get rates(){return ro(this,Is)}set rates(e){e?Array.isArray(e)&&(ro(this,Is).value=e.join(" ")):ro(this,Is).value=""}get mediaPlaybackRate(){return Ue(this,S.MEDIA_PLAYBACK_RATE,Ls)}set mediaPlaybackRate(e){Ye(this,S.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let i=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),s=(t=(e=i.find(a=>a>this.mediaPlaybackRate))!=null?e:i[0])!=null?t:Ls,n=new D.CustomEvent(ne.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}};Is=new WeakMap;D.customElements.get("media-playback-rate-button")||D.customElements.define("media-playback-rate-button",qd);var Ii={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},np=z.createElement("template");np.innerHTML=`
|
|
586
586
|
<style>
|
|
587
587
|
:host {
|
|
588
588
|
pointer-events: none;
|
|
@@ -604,9 +604,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
604
604
|
</style>
|
|
605
605
|
|
|
606
606
|
<img part="poster img" aria-hidden="true" id="image"/>
|
|
607
|
-
`;var
|
|
608
|
-
<slot name="icon">${
|
|
609
|
-
`;var
|
|
607
|
+
`;var hb=r=>{r.style.removeProperty("background-image")},fb=(r,e)=>{r.style["background-image"]=`url('${e}')`},jd=class extends D.HTMLElement{static get observedAttributes(){return[Ii.PLACEHOLDER_SRC,Ii.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(np.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,i){e===Ii.SRC&&(i==null?this.image.removeAttribute(Ii.SRC):this.image.setAttribute(Ii.SRC,i)),e===Ii.PLACEHOLDER_SRC&&(i==null?hb(this.image):fb(this.image,i))}get placeholderSrc(){return et(this,Ii.PLACEHOLDER_SRC)}set placeholderSrc(e){Xe(this,Ii.SRC,e)}get src(){return et(this,Ii.SRC)}set src(e){Xe(this,Ii.SRC,e)}};D.customElements.get("media-poster-image")||D.customElements.define("media-poster-image",jd);var Rs={SEEK_OFFSET:"seekoffset"},so=30,mb=`<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)">${so}</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>`,ap=z.createElement("template");ap.innerHTML=`
|
|
608
|
+
<slot name="icon">${mb}</slot>
|
|
609
|
+
`;var pb=0,zd=class extends We{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_CURRENT_TIME,Rs.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:ap,...e})}connectedCallback(){this.seekOffset=Ue(this,Rs.SEEK_OFFSET,so),super.connectedCallback()}attributeChangedCallback(e,t,i){e===Rs.SEEK_OFFSET&&(this.seekOffset=Ue(this,Rs.SEEK_OFFSET,so)),super.attributeChangedCallback(e,t,i)}get seekOffset(){return Ue(this,Rs.SEEK_OFFSET,so)}set seekOffset(e){Ye(this,Rs.SEEK_OFFSET,e),this.setAttribute("aria-label",je.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),ka(wa(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Ue(this,S.MEDIA_CURRENT_TIME,pb)}set mediaCurrentTime(e){Ye(this,S.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new D.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};D.customElements.get("media-seek-backward-button")||D.customElements.define("media-seek-backward-button",zd);var lp=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},op=(r,e,t)=>(lp(r,e,"read from private field"),t?t.call(r):e.get(r)),gb=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},vb=(r,e,t,i)=>(lp(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),An,Xd=class extends Ki{constructor(){super(),gb(this,An,void 0),vb(this,An,this.shadowRoot.querySelector("slot")),op(this,An).textContent=Ti(0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,i){e===S.MEDIA_PREVIEW_TIME&&i!=null&&(op(this,An).textContent=Ti(i)),super.attributeChangedCallback(e,t,i)}get mediaPreviewTime(){return Ue(this,S.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){Ye(this,S.MEDIA_PREVIEW_TIME,e)}};An=new WeakMap;D.customElements.get("media-preview-time-display")||D.customElements.define("media-preview-time-display",Xd);var dp=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},no=(r,e,t)=>(dp(r,e,"read from private field"),t?t.call(r):e.get(r)),Eb=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},ao=(r,e,t,i)=>(dp(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Li,cp=z.createElement("template");cp.innerHTML=`
|
|
610
610
|
<style>
|
|
611
611
|
:host {
|
|
612
612
|
box-sizing: border-box;
|
|
@@ -620,7 +620,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
620
620
|
}
|
|
621
621
|
</style>
|
|
622
622
|
<img crossorigin loading="eager" decoding="async">
|
|
623
|
-
`;var
|
|
623
|
+
`;var Qd=class extends D.HTMLElement{constructor(){super(),Eb(this,Li,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(cp.content.cloneNode(!0)))}static get observedAttributes(){return[_e.MEDIA_CONTROLLER,S.MEDIA_PREVIEW_IMAGE,S.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,i;let s=this.getAttribute(_e.MEDIA_CONTROLLER);s&&(ao(this,Li,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=no(this,Li))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=no(this,Li))==null?void 0:e.unassociateElement)==null||t.call(e,this),ao(this,Li,null)}attributeChangedCallback(e,t,i){var s,n,a,o,l;[S.MEDIA_PREVIEW_IMAGE,S.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===_e.MEDIA_CONTROLLER&&(t&&((n=(s=no(this,Li))==null?void 0:s.unassociateElement)==null||n.call(s,this),ao(this,Li,null)),i&&(ao(this,Li,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=no(this,Li))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return et(this,S.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){Xe(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[i,s,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:c,minWidth:u,minHeight:h}=l,m=Math.min(parseInt(d)/n,parseInt(c)/a),g=Math.max(parseInt(u)/n,parseInt(h)/a),E=m<1,T=E?m:g>1?g:1,{style:A}=ze(this.shadowRoot,":host"),R=ze(this.shadowRoot,"img").style,x=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 w=()=>{R.width=`${this.imgWidth*T}px`,R.height=`${this.imgHeight*T}px`,R.display="block"};x.src!==o&&(x.onload=()=>{this.imgWidth=x.naturalWidth,this.imgHeight=x.naturalHeight,w()},x.src=o,w()),w(),R.transform=`translate(-${i*T}px, -${s*T}px)`}};Li=new WeakMap;D.customElements.get("media-preview-thumbnail")||D.customElements.define("media-preview-thumbnail",Qd);var ac=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},dt=(r,e,t)=>(ac(r,e,"read from private field"),t?t.call(r):e.get(r)),Ct=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},ur=(r,e,t,i)=>(ac(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Sn=(r,e,t)=>(ac(r,e,"access private method"),t),xn,oo,In,fo,mo,lo,Jd,ec,up,co,tc,uo,ks,Ln,ic,po,go,ho,rc,sc,hp,yb="video not loaded, unknown time.",Zd=r=>{let e=r.range,t=Dr(+e.value),i=Dr(+e.max),s=t&&i?`${t} of ${i}`:yb;e.setAttribute("aria-valuetext",s)},fp=z.createElement("template");fp.innerHTML=`
|
|
624
624
|
<style>
|
|
625
625
|
:host {
|
|
626
626
|
--media-preview-border-radius: 3px;
|
|
@@ -725,7 +725,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
725
725
|
|
|
726
726
|
</slot>
|
|
727
727
|
</div>
|
|
728
|
-
`;var
|
|
728
|
+
`;var nc=class extends Fr{constructor(){super(),Ct(this,lo),Ct(this,ec),Ct(this,co),Ct(this,ho),Ct(this,sc),Ct(this,xn,void 0),Ct(this,oo,void 0),Ct(this,In,void 0),Ct(this,fo,void 0),Ct(this,mo,void 0),Ct(this,uo,t=>{if([...dt(this,xn)].some(c=>t.composedPath().includes(c)))return;this.updatePointerBar(t);let i=this.mediaDuration;if(!i)return;let s=this.range.getBoundingClientRect(),n=(t.clientX-s.left-this.thumbWidth/2)/(s.width-this.thumbWidth);n=Math.max(0,Math.min(1,n));let a=Sn(this,co,tc).call(this,dt(this,oo),n),{style:o}=ze(this.shadowRoot,"#preview-rail");o.transform=`translateX(${a})`;let l=n*i,d=new D.CustomEvent(ne.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:l});this.dispatchEvent(d)}),Ct(this,ks,!1),Ct(this,Ln,t=>{var i;(!t.composedPath().includes(this)||[...dt(this,xn)].some(s=>t.composedPath().includes(s)))&&((i=D.window)==null||i.removeEventListener("pointermove",dt(this,Ln)),ur(this,ks,!1),dt(this,po).call(this))}),Ct(this,ic,()=>{var t;(t=D.window)==null||t.addEventListener("pointermove",dt(this,uo),!1)}),Ct(this,po,()=>{var t;(t=D.window)==null||t.removeEventListener("pointermove",dt(this,uo));let i=new D.CustomEvent(ne.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:null});this.dispatchEvent(i)}),Ct(this,go,()=>{var t;let i=this.getAttribute(S.MEDIA_DURATION);!dt(this,ks)&&i&&(ur(this,ks,!0),dt(this,ic).call(this),(t=D.window)==null||t.addEventListener("pointermove",dt(this,Ln),!1))}),this.container.appendChild(fp.content.cloneNode(!0)),this.range.addEventListener("input",()=>{cancelAnimationFrame(this._refreshId);let i=this.range.value,s=new D.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i});this.dispatchEvent(s)}),this._refreshBar=()=>{let t=(performance.now()-this._updateTimestamp)/1e3;this.range.value=this.mediaCurrentTime+t*this.mediaPlaybackRate,this.updateBar(),this.updateCurrentBox(),this._refreshId=requestAnimationFrame(this._refreshBar)},ur(this,xn,this.shadowRoot.querySelectorAll('[part~="box"]')),ur(this,oo,this.shadowRoot.querySelector('[part~="preview-box"]')),ur(this,In,this.shadowRoot.querySelector('[part~="current-box"]'));let e=getComputedStyle(this);ur(this,fo,parseInt(e.getPropertyValue("--media-box-padding-left"))),ur(this,mo,parseInt(e.getPropertyValue("--media-box-padding-right"))),Sn(this,ho,rc).call(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(){this.range.setAttribute("aria-label",Dt.SEEK()),super.connectedCallback()}disconnectedCallback(){cancelAnimationFrame(this._refreshId),super.disconnectedCallback()}attributeChangedCallback(e,t,i){var s,n,a,o,l;(e===S.MEDIA_CURRENT_TIME||e===S.MEDIA_PAUSED||e===S.MEDIA_ENDED||e===S.MEDIA_LOADING)&&(this._updateTimestamp=performance.now(),this.range.value=this.mediaCurrentTime,Zd(this),this.updateBar(),this.updateCurrentBox(),cancelAnimationFrame(this._refreshId),!this.mediaPaused&&!this.mediaLoading&&(this._refreshId=requestAnimationFrame(this._refreshBar))),e===S.MEDIA_DURATION&&(this.range.max=(n=(s=dt(this,lo,Jd))!=null?s:this.mediaDuration)!=null?n:1e3,Zd(this),this.updateBar(),this.updateCurrentBox()),e===S.MEDIA_SEEKABLE&&(this.range.min=(a=dt(this,ec,up))!=null?a:0,this.range.max=(l=(o=dt(this,lo,Jd))!=null?o:this.mediaDuration)!=null?l:1e3,Zd(this),this.updateBar()),e===S.MEDIA_BUFFERED&&this.updateBar(),e==="disabled"&&(i==null?Sn(this,ho,rc).call(this):Sn(this,sc,hp).call(this)),super.attributeChangedCallback(e,t,i)}get mediaPaused(){return Ke(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ge(this,S.MEDIA_PAUSED,e)}get mediaLoading(){return Ke(this,S.MEDIA_LOADING)}set mediaLoading(e){Ge(this,S.MEDIA_LOADING,e)}get mediaDuration(){return Ue(this,S.MEDIA_DURATION)}set mediaDuration(e){Ye(this,S.MEDIA_DURATION,e)}get mediaCurrentTime(){return Ue(this,S.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){Ye(this,S.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return Ue(this,S.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){Ye(this,S.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(S.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(i=>+i)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(S.MEDIA_BUFFERED);return}let t=e.map((i,s)=>`${i}:${s}`).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 mediaPreviewImage(){return et(this,S.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){Xe(this,S.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return Ue(this,S.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){Ye(this,S.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return Ke(this,S.MEDIA_ENDED)}set mediaEnded(e){Ge(this,S.MEDIA_ENDED,e)}getRelativeValues(){let e=super.getRelativeValues();return this.mediaEnded?{...e,relativeValue:e.relativeMax}:e}getBarColors(){var e;let t=super.getBarColors(),{range:i}=this,s=i.max-i.min,n=this.mediaBuffered;if(!n.length||!Number.isFinite(s)||s<=0)return t;let a;if(this.mediaEnded)a=s;else{let l=this.mediaCurrentTime,[,d=i.min]=(e=n.find(([c,u])=>c<=l&&l<=u))!=null?e:[];a=d-i.min}let o=a/s*100;return t.splice(1,0,["var(--media-time-range-buffered-color, rgb(255 255 255 / .4))",o]),t}updateCurrentBox(){if(!dt(this,In).assignedElements().length)return;let e=this.range.value/(this.range.max-this.range.min),t=Sn(this,co,tc).call(this,dt(this,In),e),{style:i}=ze(this.shadowRoot,"#current-rail");i.transform=`translateX(${t})`}};xn=new WeakMap;oo=new WeakMap;In=new WeakMap;fo=new WeakMap;mo=new WeakMap;lo=new WeakSet;Jd=function(){var r;let[,e]=(r=this.mediaSeekable)!=null?r:[];return e};ec=new WeakSet;up=function(){var r;let[e]=(r=this.mediaSeekable)!=null?r:[];return e};co=new WeakSet;tc=function(r,e){var t;let i=`${e*100*100}%`,s=r.offsetWidth;if(!s)return i;let n=(t=this.getAttribute("bounds")?Cr(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?t:this,a=this.range.getBoundingClientRect(),o=n.getBoundingClientRect(),l=(dt(this,fo)-(a.left-o.left-s/2))/a.width*100,d=(o.right-a.left-s/2-dt(this,mo))/a.width*100;return Number.isNaN(l)||(i=`max(${l*100}%, ${i})`),Number.isNaN(d)||(i=`min(${i}, ${d*100}%)`),i};uo=new WeakMap;ks=new WeakMap;Ln=new WeakMap;ic=new WeakMap;po=new WeakMap;go=new WeakMap;ho=new WeakSet;rc=function(){this.addEventListener("pointermove",dt(this,go),!1)};sc=new WeakSet;hp=function(){var r;(r=D.window)==null||r.removeEventListener("pointermove",dt(this,Ln)),this.removeEventListener("pointermove",dt(this,go)),ur(this,ks,!1),dt(this,po).call(this)};D.customElements.get("media-time-range")||D.customElements.define("media-time-range",nc);var pp=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},ws=(r,e,t)=>(pp(r,e,"read from private field"),t?t.call(r):e.get(r)),oc=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Ds=(r,e,t,i)=>(pp(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Ri,vo,Eo,mp={LOADING_DELAY:"loadingdelay"},gp=500,vp=z.createElement("template"),bb=`
|
|
729
729
|
<svg aria-hidden="true" viewBox="0 0 100 100">
|
|
730
730
|
<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">
|
|
731
731
|
<animateTransform
|
|
@@ -738,13 +738,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
738
738
|
repeatCount="indefinite" />
|
|
739
739
|
</path>
|
|
740
740
|
</svg>
|
|
741
|
-
`;
|
|
741
|
+
`;vp.innerHTML=`
|
|
742
742
|
<style>
|
|
743
743
|
:host {
|
|
744
744
|
display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
|
|
745
745
|
vertical-align: middle;
|
|
746
746
|
box-sizing: border-box;
|
|
747
|
-
--_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${
|
|
747
|
+
--_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${gp}ms);
|
|
748
748
|
}
|
|
749
749
|
|
|
750
750
|
#status {
|
|
@@ -783,12 +783,12 @@ svg, img, ::slotted(svg), ::slotted(img) {
|
|
|
783
783
|
}
|
|
784
784
|
</style>
|
|
785
785
|
|
|
786
|
-
<slot name="icon">${
|
|
786
|
+
<slot name="icon">${bb}</slot>
|
|
787
787
|
<div id="status" role="status" aria-live="polite">${Dt.MEDIA_LOADING()}</div>
|
|
788
|
-
`;var
|
|
788
|
+
`;var lc=class extends D.HTMLElement{constructor(){if(super(),oc(this,Ri,void 0),oc(this,vo,gp),oc(this,Eo,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),i=vp.content.cloneNode(!0);t.appendChild(i)}let{style:e}=ze(this.shadowRoot,":host");Ds(this,Eo,e)}static get observedAttributes(){return[_e.MEDIA_CONTROLLER,S.MEDIA_PAUSED,S.MEDIA_LOADING,mp.LOADING_DELAY]}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===mp.LOADING_DELAY&&t!==i?this.loadingDelay=Number(i):e===_e.MEDIA_CONTROLLER&&(t&&((n=(s=ws(this,Ri))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ds(this,Ri,null)),i&&(Ds(this,Ri,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=ws(this,Ri))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,i;let s=this.getAttribute(_e.MEDIA_CONTROLLER);s&&(Ds(this,Ri,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=ws(this,Ri))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=ws(this,Ri))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ds(this,Ri,null)}get loadingDelay(){return ws(this,vo)}set loadingDelay(e){Ds(this,vo,e),ws(this,Eo).setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return Ke(this,S.MEDIA_PAUSED)}set mediaPaused(e){Ge(this,S.MEDIA_PAUSED,e)}get mediaLoading(){return Ke(this,S.MEDIA_LOADING)}set mediaLoading(e){Ge(this,S.MEDIA_LOADING,e)}};Ri=new WeakMap;vo=new WeakMap;Eo=new WeakMap;D.customElements.get("media-loading-indicator")||D.customElements.define("media-loading-indicator",lc);var Tb=100,_b=1,Ab=r=>r.mediaMuted?0:Math.round(r.mediaVolume*r.range.max),Sb=({value:r,max:e})=>`${Math.round(r/e*100)}%`,dc=class extends Fr{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_VOLUME,S.MEDIA_MUTED,S.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.max=Tb,this.range.addEventListener("input",()=>{let t=this.range.value/this.range.max,i=new D.CustomEvent(ne.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:t});this.dispatchEvent(i)})}connectedCallback(){this.range.setAttribute("aria-label",Dt.VOLUME()),super.connectedCallback()}attributeChangedCallback(e,t,i){if(e===S.MEDIA_VOLUME||e===S.MEDIA_MUTED){let s=Ab(this);this.range.value=s,this.range.setAttribute("aria-valuetext",Sb(this.range)),this.updateBar()}super.attributeChangedCallback(e,t,i)}get mediaVolume(){return Ue(this,S.MEDIA_VOLUME,_b)}set mediaVolume(e){Ye(this,S.MEDIA_VOLUME,e)}get mediaMuted(){return Ke(this,S.MEDIA_MUTED)}set mediaMuted(e){Ge(this,S.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return et(this,S.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){Xe(this,S.MEDIA_VOLUME_UNAVAILABLE,e)}};D.customElements.get("media-volume-range")||D.customElements.define("media-volume-range",dc);var mc=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},It=(r,e,t)=>(mc(r,e,"read from private field"),t?t.call(r):e.get(r)),ni=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},ui=(r,e,t,i)=>(mc(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Wi=(r,e,t)=>(mc(r,e,"access private method"),t),ki,hr,Ms,Rn,yo,bo,cc,Cs,uc,kn,To,_o,hc,fc,Ep,pc,yp,xb=`
|
|
789
789
|
<svg aria-hidden="true" viewBox="0 1 24 24" part="select-indicator indicator">
|
|
790
790
|
<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"/>
|
|
791
|
-
</svg>`;function fr(r,e,t){let i=z.createElement("media-chrome-option");i.part.add("option"),i.value=e,i.selected=t;let s=z.createElement("span");return s.textContent=r,i.append(s),i}function qi(r,e){let t=r.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):r.shadowRoot.querySelector(`[name="${e}"] > svg`).cloneNode(!0)}var
|
|
791
|
+
</svg>`;function fr(r,e,t){let i=z.createElement("media-chrome-option");i.part.add("option"),i.value=e,i.selected=t;let s=z.createElement("span");return s.textContent=r,i.append(s),i}function qi(r,e){let t=r.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):r.shadowRoot.querySelector(`[name="${e}"] > svg`).cloneNode(!0)}var bp=z.createElement("template");bp.innerHTML=`
|
|
792
792
|
<style>
|
|
793
793
|
:host {
|
|
794
794
|
font: var(--media-font,
|
|
@@ -833,8 +833,8 @@ svg, img, ::slotted(svg), ::slotted(img) {
|
|
|
833
833
|
</style>
|
|
834
834
|
<slot name="header"></slot>
|
|
835
835
|
<slot id="container"></slot>
|
|
836
|
-
<slot name="select-indicator" hidden>${
|
|
837
|
-
`;var wi=class extends D.HTMLElement{constructor(e={}){super(),ni(this,bo),ni(this,kn),ni(this,_o),ni(this,
|
|
836
|
+
<slot name="select-indicator" hidden>${xb}</slot>
|
|
837
|
+
`;var wi=class extends D.HTMLElement{constructor(e={}){super(),ni(this,bo),ni(this,kn),ni(this,_o),ni(this,fc),ni(this,pc),ni(this,ki,void 0),ni(this,hr,""),ni(this,Ms,null),ni(this,Rn,!1),ni(this,yo,t=>{this.handleClick(t)}),ni(this,Cs,t=>{let{key:i}=t;if(i==="Escape"){this.removeEventListener("keyup",It(this,Cs));return}if(i==="Meta"){ui(this,Rn,!1);return}Wi(this,bo,cc).call(this,t)}),ni(this,uc,t=>{let{key:i,altKey:s}=t;if(s){this.removeEventListener("keyup",It(this,Cs));return}if(i==="Meta"){ui(this,Rn,!0);return}if(this.keysUsed.includes(i)&&t.preventDefault(),It(this,Rn)&&this.keysUsed.includes(i)){Wi(this,bo,cc).call(this,t);return}this.addEventListener("keyup",It(this,Cs),{once:!0})}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=bp.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 i of t.target.assignedNodes({flatten:!0}))i.nodeType===3&&i.textContent.trim()===""&&i.remove()})}static get observedAttributes(){return["disabled",_e.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(i=>i.value===e);!t||Wi(this,_o,hc).call(this,t)}focus(){var e;(e=this.selectedOptions[0])==null||e.focus()}enable(){this.addEventListener("click",It(this,yo)),this.addEventListener("keydown",It(this,uc))}disable(){this.removeEventListener("click",It(this,yo)),this.removeEventListener("keyup",It(this,Cs))}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===_e.MEDIA_CONTROLLER?(t&&((n=(s=It(this,ki))==null?void 0:s.unassociateElement)==null||n.call(s,this),ui(this,ki,null)),i&&(ui(this,ki,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=It(this,ki))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&i!==t&&(i==null?this.enable():this.disable())}connectedCallback(){var e,t,i;this.hasAttribute("disabled")||this.enable(),this.hasAttribute("role")||this.setAttribute("role","listbox");let s=this.getAttribute(_e.MEDIA_CONTROLLER);s&&(ui(this,ki,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=It(this,ki))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=It(this,ki))==null?void 0:e.unassociateElement)==null||t.call(e,this),ui(this,ki,null)}get keysUsed(){return["Enter"," ","ArrowDown","ArrowUp","Home","End"]}handleSelection(e,t){let i=Wi(this,kn,To).call(this,e);!i||Wi(this,_o,hc).call(this,i,t)}handleMovement(e){let{key:t}=e,i=this.options,s=Wi(this,kn,To).call(this,e);s||(s=i.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=i[0];break;case"End":n=i[i.length-1];break;default:n=Wi(this,fc,Ep).call(this,t);break}n&&(i.forEach(a=>a.setAttribute("tabindex","-1")),n.setAttribute("tabindex","0"),n.focus())}handleClick(e){let t=Wi(this,kn,To).call(this,e);!t||t.hasAttribute("disabled")||(this.options.forEach(i=>i.setAttribute("tabindex","-1")),t.setAttribute("tabindex","0"),this.handleSelection(e,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"))}};ki=new WeakMap;hr=new WeakMap;Ms=new WeakMap;Rn=new WeakMap;yo=new WeakMap;bo=new WeakSet;cc=function(r){let{key:e}=r;e==="Enter"||e===" "?this.handleSelection(r,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"):this.handleMovement(r)};Cs=new WeakMap;uc=new WeakMap;kn=new WeakSet;To=function(r){let e=r.composedPath(),t=e.findIndex(i=>i.nodeName==="MEDIA-CHROME-OPTION");return e[t]};_o=new WeakSet;hc=function(r,e){let t=[...this.selectedOptions];(!this.hasAttribute("aria-multiselectable")||this.getAttribute("aria-multiselectable")!=="true")&&this.options.forEach(i=>i.selected=!1),e?r.selected=!r.selected:r.selected=!0,this.selectedOptions.some((i,s)=>i!=t[s])&&this.dispatchEvent(new Event("change"))};fc=new WeakSet;Ep=function(r){Wi(this,pc,yp).call(this);let e=this.options,t=e.findIndex(d=>d.getAttribute("tabindex")==="0");ui(this,hr,It(this,hr)+r);let i=It(this,hr).split("").every(d=>d===r),s=e.slice(t+(i?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(It(this,hr))),n=e.slice(0,t-(i?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(It(this,hr))),a=[],o=[];return i&&(a=e.slice(t+(i?1:0)).filter(d=>d.textContent.startsWith(r)),o=e.slice(0,t-(i?1:0)).filter(d=>d.textContent.startsWith(r))),[...s,...n,...a,...o][0]};pc=new WeakSet;yp=function(){clearTimeout(It(this,Ms)),ui(this,Ms,null),ui(this,Ms,setTimeout(()=>{ui(this,hr,""),ui(this,Ms,null)},500))};D.customElements.get("media-chrome-listbox")||D.customElements.define("media-chrome-listbox",wi);var Tc=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Ec=(r,e,t)=>(Tc(r,e,"read from private field"),t?t.call(r):e.get(r)),gc=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},vc=(r,e,t,i)=>(Tc(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Tp=(r,e,t)=>(Tc(r,e,"access private method"),t),Ao,Os,So,yc,_p=z.createElement("template");_p.innerHTML=`
|
|
838
838
|
<style>
|
|
839
839
|
:host {
|
|
840
840
|
cursor: pointer;
|
|
@@ -869,7 +869,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
|
|
|
869
869
|
}
|
|
870
870
|
</style>
|
|
871
871
|
<slot></slot>
|
|
872
|
-
`;var mr={VALUE:"value",SELECTED:"selected",DISABLED:"disabled"},xo=class extends D.HTMLElement{constructor(){super(),
|
|
872
|
+
`;var mr={VALUE:"value",SELECTED:"selected",DISABLED:"disabled"},xo=class extends D.HTMLElement{constructor(){super(),gc(this,So),gc(this,Ao,!1),gc(this,Os,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(_p.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){vc(this,Ao,!0),this.setAttribute("aria-selected",e?"true":"false")}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex",-1),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false")}disable(){this.removeAttribute("tabindex")}attributeChangedCallback(e,t,i){e===mr.SELECTED&&!Ec(this,Ao)?this.setAttribute("aria-selected",i!=null?"true":"false"):e===mr.DISABLED&&i!==t&&(i==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(mr.DISABLED)||this.enable(),this.setAttribute("role","option"),vc(this,Os,bc(this,this.parentNode)),Tp(this,So,yc).call(this)}disconnectedCallback(){this.disable(),Tp(this,So,yc).call(this),vc(this,Os,null)}handleClick(){}};Ao=new WeakMap;Os=new WeakMap;So=new WeakSet;yc=function(){var r;let e=(r=Ec(this,Os))==null?void 0:r.options;if(!e)return;let t=e.filter(i=>i.getAttribute("aria-selected")==="true").pop();t||(t=e[0]),Ec(this,Os).getAttribute("aria-multiselectable")!=="true"&&e.forEach(i=>{i.setAttribute("tabindex","-1"),i.setAttribute("aria-selected","false")}),t==null||t.setAttribute("tabindex","0"),t==null||t.setAttribute("aria-selected","true")};function bc(r,e){if(!r)return null;let{host:t}=r.getRootNode();return!e&&t?bc(r,t):e!=null&&e.options?e:bc(e,e==null?void 0:e.parentNode)}D.customElements.get("media-chrome-option")||D.customElements.define("media-chrome-option",xo);var Sc=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},ie=(r,e,t)=>(Sc(r,e,"read from private field"),t?t.call(r):e.get(r)),Lt=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Mt=(r,e,t,i)=>(Sc(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Yi=(r,e,t)=>(Sc(r,e,"access private method"),t),Di,Ps,wn,Ns,mt,Dn,tt,Ci,Cn,Ur,Fs,Io,_c,Ap,Ac,Sp,Us,Mn,xc,xp,Lo,Ic,Ip=z.createElement("template");Ip.innerHTML=`
|
|
873
873
|
<style>
|
|
874
874
|
:host {
|
|
875
875
|
font: var(--media-font,
|
|
@@ -921,43 +921,43 @@ svg, img, ::slotted(svg), ::slotted(img) {
|
|
|
921
921
|
<slot></slot>
|
|
922
922
|
</media-chrome-listbox>
|
|
923
923
|
</slot>
|
|
924
|
-
`;var Mi=class extends D.HTMLElement{constructor(){var e;super(),Lt(this,
|
|
924
|
+
`;var Mi=class extends D.HTMLElement{constructor(){var e;super(),Lt(this,_c),Lt(this,Ac),Lt(this,Us),Lt(this,xc),Lt(this,Lo),Lt(this,Di,void 0),Lt(this,Ps,void 0),Lt(this,wn,void 0),Lt(this,Ns,!0),Lt(this,mt,void 0),Lt(this,Dn,void 0),Lt(this,tt,void 0),Lt(this,Ci,void 0),Lt(this,Cn,!1),Lt(this,Ur,i=>{let{key:s}=i;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",ie(this,Ur));return}i.composedPath().includes(ie(this,mt))&&(s==="Enter"||s===" ")?ie(this,Ps).call(this):s==="Escape"&&!ie(this,Ci).hidden&&Yi(this,Us,Mn).call(this)}),Lt(this,Fs,i=>{let{metaKey:s,altKey:n,key:a}=i;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",ie(this,Ur));return}i.preventDefault(),this.addEventListener("keyup",ie(this,Ur),{once:!0})}),Lt(this,Io,i=>{i.composedPath().includes(this)||ie(this,Ci).hidden||Yi(this,Us,Mn).call(this)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ip.content.cloneNode(!0)));let{style:t}=ze(this.shadowRoot,":host");t.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),Mt(this,Ps,Yi(this,_c,Ap).bind(this)),Mt(this,wn,Yi(this,Ac,Sp).bind(this)),(e=this.init)==null||e.call(this),Mt(this,mt,this.shadowRoot.querySelector("[part=button]")),Mt(this,tt,this.shadowRoot.querySelector("[part=listbox]")),Mt(this,Dn,this.shadowRoot.querySelector("slot[name=button]")),ie(this,Dn).addEventListener("slotchange",()=>{let i=ie(this,Dn).assignedElements()[0];!i||(this.disable(),Mt(this,mt,i),ie(this,mt).preventClick=!0,ie(this,mt).hasAttribute("disabled")&&Mt(this,Ns,!1),ie(this,Ns)?(this.enable(),ie(this,mt).setAttribute("aria-haspopup","listbox")):this.disable())}),Mt(this,Ci,this.shadowRoot.querySelector("slot[name=listbox]")),ie(this,Ci).addEventListener("slotchange",()=>{this.disable(),Mt(this,tt,ie(this,Ci).assignedElements()[0]||ie(this,tt)),this.enable()})}static get observedAttributes(){return["disabled",_e.MEDIA_CONTROLLER]}enable(){ie(this,mt).removeAttribute("disabled"),ie(this,mt).addEventListener("click",ie(this,Ps)),ie(this,mt).addEventListener("keydown",ie(this,Fs)),ie(this,tt).addEventListener("keydown",ie(this,Fs)),Yi(this,Lo,Ic).call(this),ie(this,tt).addEventListener("change",ie(this,wn)),z.addEventListener("click",ie(this,Io))}disable(){ie(this,mt).setAttribute("disabled",""),ie(this,mt).removeEventListener("click",ie(this,Ps)),ie(this,mt).removeEventListener("keydown",ie(this,Fs)),ie(this,mt).removeEventListener("keyup",ie(this,Ur)),ie(this,tt).removeEventListener("keydown",ie(this,Fs)),ie(this,tt).removeEventListener("keyup",ie(this,Ur)),ie(this,tt).addEventListener("change",ie(this,wn)),z.removeEventListener("click",ie(this,Io))}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===_e.MEDIA_CONTROLLER?(t&&((n=(s=ie(this,Di))==null?void 0:s.unassociateElement)==null||n.call(s,this),Mt(this,Di,null),ie(this,tt).removeAttribute(_e.MEDIA_CONTROLLER)),i&&(Mt(this,Di,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=ie(this,Di))==null?void 0:o.associateElement)==null||l.call(o,this),ie(this,tt).setAttribute(_e.MEDIA_CONTROLLER,i))):e==="disabled"&&i!==t&&(i==null?(Mt(this,Ns,!0),this.enable()):(Mt(this,Ns,!1),this.disable()))}connectedCallback(){var e,t,i;this.hasAttribute("disabled")||this.enable();let s=this.getAttribute(_e.MEDIA_CONTROLLER);s&&(Mt(this,Di,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=ie(this,Di))==null?void 0:t.associateElement)==null||i.call(t,this),ie(this,tt).setAttribute(_e.MEDIA_CONTROLLER,s))}disconnectedCallback(){var e,t;this.disable(),(t=(e=ie(this,Di))==null?void 0:e.unassociateElement)==null||t.call(e,this),Mt(this,Di,null),ie(this,tt).removeAttribute(_e.MEDIA_CONTROLLER)}get keysUsed(){return["Enter","Escape"," ","ArrowUp","ArrowDown","f","c","k","m"]}};Di=new WeakMap;Ps=new WeakMap;wn=new WeakMap;Ns=new WeakMap;mt=new WeakMap;Dn=new WeakMap;tt=new WeakMap;Ci=new WeakMap;Cn=new WeakMap;Ur=new WeakMap;Fs=new WeakMap;Io=new WeakMap;_c=new WeakSet;Ap=function(){Yi(this,Us,Mn).call(this)};Ac=new WeakSet;Sp=function(){Yi(this,Us,Mn).call(this,!0)};Us=new WeakSet;Mn=function(r){ie(this,Ci).hidden=!ie(this,Ci).hidden||r,Yi(this,Lo,Ic).call(this,r),ie(this,Ci).hidden?(this.shadowRoot.activeElement===ie(this,tt)||ie(this,tt).contains(this.shadowRoot.activeElement))&&ie(this,mt).focus():(ie(this,tt).focus(),Yi(this,xc,xp).call(this))};xc=new WeakSet;xp=function(){var r;if(ie(this,tt).offsetWidth===0)return;let e=ie(this,mt).getBoundingClientRect();if(this.hasAttribute("mediacontroller")||ie(this,mt).hasAttribute("mediacontroller")||ie(this,tt).hasAttribute("mediacontroller")){ie(this,tt).style.zIndex="1",ie(this,tt).style.bottom="unset",ie(this,tt).style.top=e.height+"px";return}let t=(r=this.getAttribute("bounds")?Cr(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?r:this,i=ie(this,tt).offsetWidth,s=t.getBoundingClientRect(),n=-Math.max(e.x+i-s.right,0);ie(this,tt).style.left=`${n}px`};Lo=new WeakSet;Ic=function(r=!1){Mt(this,Cn,!ie(this,Cn)||r),ie(this,mt).setAttribute("aria-expanded",ie(this,Cn))};D.customElements.get("media-chrome-selectmenu")||D.customElements.define("media-chrome-selectmenu",Mi);var Dc=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Ib=(r,e,t)=>(Dc(r,e,"read from private field"),t?t.call(r):e.get(r)),Lc=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Lb=(r,e,t,i)=>(Dc(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Rc=(r,e,t)=>(Dc(r,e,"access private method"),t),ko,kc,kp,Ro,wc,Rb=`
|
|
925
925
|
<svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
|
|
926
926
|
<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"/>
|
|
927
|
-
</svg>`,Lp=z.createElement("template");Lp.innerHTML=`
|
|
928
|
-
<slot name="captions-indicator" hidden>${_b}</slot>
|
|
929
|
-
`;var wo=class extends wi{constructor(){super({slotTemplate:Lp}),Ic(this,Rc),Ic(this,Ro),Ic(this,ko,void 0)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",S.MEDIA_SUBTITLES_LIST,S.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===S.MEDIA_SUBTITLES_LIST&&t!==i?Lc(this,Rc,Ip).call(this):e===S.MEDIA_SUBTITLES_SHOWING&&t!==i?this.value=i: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",Lc(this,Ro,kc))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Lc(this,Ro,kc))}get mediaSubtitlesList(){return Sp(this,S.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){xp(this,S.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Sp(this,S.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){xp(this,S.MEDIA_SUBTITLES_SHOWING,e)}};ko=new WeakMap;Rc=new WeakSet;Ip=function(){var r;if(bb(this,ko)===JSON.stringify(this.mediaSubtitlesList))return;Tb(this,ko,JSON.stringify(this.mediaSubtitlesList));let e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.value,i=fr(this.formatOptionText("Off"),"off",t);i.prepend(qi(this,"select-indicator")),e.append(i);let s=this.mediaSubtitlesList;for(let n of s){let a=fr(this.formatOptionText(n.label,n),$a(n),this.value==$a(n));a.prepend(qi(this,"select-indicator")),((r=n.kind)!=null?r:"subs")==="captions"&&a.append(qi(this,"captions-indicator")),e.append(a)}};Ro=new WeakSet;kc=function(){if(Vi(this,!1),!this.value)return;let r=new D.CustomEvent(ne.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};var Sp=(r,e)=>{let t=r.getAttribute(e);return t?vn(t):[]},xp=(r,e,t)=>{if(!(t!=null&&t.length)){r.removeAttribute(e);return}let i=Or(t);r.getAttribute(e)!==i&&r.setAttribute(e,i)};D.customElements.get("media-captions-listbox")||D.customElements.define("media-captions-listbox",wo);var Do=class extends Mi{init(){let e=z.createElement("media-captions-button");e.part.add("button"),e.preventClick=!0;let t=z.createElement("media-captions-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, indicator");let i=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");i.textContent="",s.textContent="",i.append(e),s.append(t)}};D.customElements.get("media-captions-selectmenu")||D.customElements.define("media-captions-selectmenu",Do);var Rp=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Co=(r,e,t)=>(Rp(r,e,"read from private field"),t?t.call(r):e.get(r)),Dc=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},On=(r,e,t)=>(Rp(r,e,"access private method"),t),Bs,Pn,Mo,Oo,Mc,Cc={RATES:"rates"},Po=class extends wi{constructor(){super(),Dc(this,Pn),Dc(this,Oo),Dc(this,Bs,new lr(this,Cc.RATES,{defaultValue:qd})),On(this,Pn,Mo).call(this)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",S.MEDIA_PLAYBACK_RATE,Cc.RATES]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===S.MEDIA_PLAYBACK_RATE&&t!=i?this.value=i:e===Cc.RATES&&t!=i&&(Co(this,Bs).value=i,On(this,Pn,Mo).call(this))}get rates(){return Co(this,Bs)}set rates(e){e?Array.isArray(e)&&(Co(this,Bs).value=e.join(" ")):Co(this,Bs).value="",On(this,Pn,Mo).call(this)}get mediaPlaybackRate(){return Ue(this,S.MEDIA_PLAYBACK_RATE,Ls)}set mediaPlaybackRate(e){Ye(this,S.MEDIA_PLAYBACK_RATE,e)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",On(this,Oo,Mc))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",On(this,Oo,Mc))}};Bs=new WeakMap;Pn=new WeakSet;Mo=function(){let r=this.shadowRoot.querySelector("#container");r.textContent="";for(let e of this.rates){let t=fr(this.formatOptionText(`${e}x`,e),e,this.mediaPlaybackRate==e);t.prepend(qi(this,"select-indicator")),r.append(t)}};Oo=new WeakSet;Mc=function(){if(!this.value)return;let r=new D.CustomEvent(ne.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};D.customElements.get("media-playback-rate-listbox")||D.customElements.define("media-playback-rate-listbox",Po);var No=class extends Mi{init(){let e=z.createElement("media-playback-rate-button");e.part.add("button"),e.preventClick=!0;let t=z.createElement("media-playback-rate-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, indicator");let i=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");i.textContent="",s.textContent="",i.append(e),s.append(t)}};D.customElements.get("media-playback-rate-selectmenu")||D.customElements.define("media-playback-rate-selectmenu",No);var Fc=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},kp=(r,e,t)=>(Fc(r,e,"read from private field"),t?t.call(r):e.get(r)),Fo=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Oc=(r,e,t,i)=>(Fc(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Uo=(r,e,t)=>(Fc(r,e,"access private method"),t),Nn,Go,Bo,Pc,$o,Nc,Ho=class extends wi{constructor(){super(...arguments),Fo(this,Bo),Fo(this,$o),Fo(this,Nn,[]),Fo(this,Go,void 0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_LIST,S.MEDIA_RENDITION_SELECTED]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===S.MEDIA_RENDITION_SELECTED&&t!==i?this.value=i!=null?i:"auto":e===S.MEDIA_RENDITION_LIST&&t!==i&&(Oc(this,Nn,jf(i)),Uo(this,Bo,Pc).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Uo(this,$o,Nc))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Uo(this,$o,Nc))}get mediaRenditionList(){return kp(this,Nn)}set mediaRenditionList(e){Oc(this,Nn,e),Uo(this,Bo,Pc).call(this)}get mediaRenditionSelected(){return et(this,S.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Xe(this,S.MEDIA_RENDITION_SELECTED,e)}};Nn=new WeakMap;Go=new WeakMap;Bo=new WeakSet;Pc=function(){if(kp(this,Go)===JSON.stringify(this.mediaRenditionList))return;Oc(this,Go,JSON.stringify(this.mediaRenditionList));let r=this.mediaRenditionList.sort((s,n)=>n.height-s.height),e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.mediaRenditionSelected;for(let s of r){let n=this.formatOptionText(`${Math.min(s.width,s.height)}p`,s),a=fr(n,`${s.id}`,s.selected&&!t);a.prepend(qi(this,"select-indicator")),e.append(a)}let i=fr(this.formatOptionText("Auto"),"auto",t);i.prepend(qi(this,"select-indicator")),e.append(i)};$o=new WeakSet;Nc=function(){if(this.value==null)return;let r=new D.CustomEvent(ne.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};D.customElements.get("media-rendition-listbox")||D.customElements.define("media-rendition-listbox",Ho);var Ab=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
930
|
-
<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" />
|
|
931
927
|
</svg>`,wp=z.createElement("template");wp.innerHTML=`
|
|
932
|
-
<slot name="
|
|
933
|
-
`;var Uc=class extends We{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_SELECTED,S.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:wp})}get mediaRenditionSelected(){return et(this,S.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Xe(this,S.MEDIA_RENDITION_SELECTED,e)}};D.customElements.get("media-rendition-button")||D.customElements.define("media-rendition-button",Uc);var Vo=class extends Mi{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_SELECTED,S.MEDIA_RENDITION_UNAVAILABLE]}init(){let e=z.createElement("media-rendition-button");e.part.add("button"),e.preventClick=!0;let t=z.createElement("media-rendition-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, indicator");let i=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");i.textContent="",s.textContent="",i.append(e),s.append(t)}};D.customElements.get("media-rendition-selectmenu")||D.customElements.define("media-rendition-selectmenu",Vo);var Sl=XE(Dp(),1);function Sb(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Eg={exports:{}};(function(r,e){(function(t){var i=/^(?=((?:[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=i.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}};r.exports=o})()})(Eg);var ah=Eg.exports;function Cp(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,i)}return t}function zt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Cp(Object(t),!0).forEach(function(i){xb(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Cp(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}function xb(r,e,t){return e=Lb(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function pt(){return pt=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=t[i])}return r},pt.apply(this,arguments)}function Ib(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var i=t.call(r,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Lb(r){var e=Ib(r,"string");return typeof e=="symbol"?e:String(e)}var ce=Number.isFinite||function(r){return typeof r=="number"&&isFinite(r)},y=function(r){return r.MEDIA_ATTACHING="hlsMediaAttaching",r.MEDIA_ATTACHED="hlsMediaAttached",r.MEDIA_DETACHING="hlsMediaDetaching",r.MEDIA_DETACHED="hlsMediaDetached",r.BUFFER_RESET="hlsBufferReset",r.BUFFER_CODECS="hlsBufferCodecs",r.BUFFER_CREATED="hlsBufferCreated",r.BUFFER_APPENDING="hlsBufferAppending",r.BUFFER_APPENDED="hlsBufferAppended",r.BUFFER_EOS="hlsBufferEos",r.BUFFER_FLUSHING="hlsBufferFlushing",r.BUFFER_FLUSHED="hlsBufferFlushed",r.MANIFEST_LOADING="hlsManifestLoading",r.MANIFEST_LOADED="hlsManifestLoaded",r.MANIFEST_PARSED="hlsManifestParsed",r.LEVEL_SWITCHING="hlsLevelSwitching",r.LEVEL_SWITCHED="hlsLevelSwitched",r.LEVEL_LOADING="hlsLevelLoading",r.LEVEL_LOADED="hlsLevelLoaded",r.LEVEL_UPDATED="hlsLevelUpdated",r.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",r.LEVELS_UPDATED="hlsLevelsUpdated",r.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",r.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",r.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",r.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",r.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",r.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",r.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",r.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",r.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",r.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",r.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",r.CUES_PARSED="hlsCuesParsed",r.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",r.INIT_PTS_FOUND="hlsInitPtsFound",r.FRAG_LOADING="hlsFragLoading",r.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",r.FRAG_LOADED="hlsFragLoaded",r.FRAG_DECRYPTED="hlsFragDecrypted",r.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",r.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",r.FRAG_PARSING_METADATA="hlsFragParsingMetadata",r.FRAG_PARSED="hlsFragParsed",r.FRAG_BUFFERED="hlsFragBuffered",r.FRAG_CHANGED="hlsFragChanged",r.FPS_DROP="hlsFpsDrop",r.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",r.ERROR="hlsError",r.DESTROYING="hlsDestroying",r.KEY_LOADING="hlsKeyLoading",r.KEY_LOADED="hlsKeyLoaded",r.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",r.BACK_BUFFER_REACHED="hlsBackBufferReached",r}({}),pe=function(r){return r.NETWORK_ERROR="networkError",r.MEDIA_ERROR="mediaError",r.KEY_SYSTEM_ERROR="keySystemError",r.MUX_ERROR="muxError",r.OTHER_ERROR="otherError",r}({}),B=function(r){return r.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",r.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",r.KEY_SYSTEM_NO_SESSION="keySystemNoSession",r.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",r.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",r.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",r.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",r.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",r.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",r.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",r.MANIFEST_LOAD_ERROR="manifestLoadError",r.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",r.MANIFEST_PARSING_ERROR="manifestParsingError",r.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",r.LEVEL_EMPTY_ERROR="levelEmptyError",r.LEVEL_LOAD_ERROR="levelLoadError",r.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",r.LEVEL_PARSING_ERROR="levelParsingError",r.LEVEL_SWITCH_ERROR="levelSwitchError",r.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",r.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",r.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",r.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",r.FRAG_LOAD_ERROR="fragLoadError",r.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",r.FRAG_DECRYPT_ERROR="fragDecryptError",r.FRAG_PARSING_ERROR="fragParsingError",r.FRAG_GAP="fragGap",r.REMUX_ALLOC_ERROR="remuxAllocError",r.KEY_LOAD_ERROR="keyLoadError",r.KEY_LOAD_TIMEOUT="keyLoadTimeOut",r.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",r.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",r.BUFFER_APPEND_ERROR="bufferAppendError",r.BUFFER_APPENDING_ERROR="bufferAppendingError",r.BUFFER_STALLED_ERROR="bufferStalledError",r.BUFFER_FULL_ERROR="bufferFullError",r.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",r.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",r.INTERNAL_EXCEPTION="internalException",r.INTERNAL_ABORTED="aborted",r.UNKNOWN="unknown",r}({}),$r=function(){},ou={trace:$r,debug:$r,log:$r,warn:$r,info:$r,error:$r},Un=ou;function Rb(r){let e=self.console[r];return e?e.bind(self.console,`[${r}] >`):$r}function kb(r,...e){e.forEach(function(t){Un[t]=r[t]?r[t].bind(r):Rb(t)})}function wb(r,e){if(self.console&&r===!0||typeof r=="object"){kb(r,"debug","log","info","warn","error");try{Un.log(`Debug logs enabled for "${e}" in hls.js version 1.4.8`)}catch{Un=ou}}else Un=ou}var M=Un,Db=/^(\d+)x(\d+)$/,Mp=/(.+?)=(".*?"|.*?)(?:,|$)/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 i=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)i[s]=parseInt(t.slice(s*2,s*2+2),16);return i}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 i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=Db.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,i={},s='"';for(Mp.lastIndex=0;(t=Mp.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();i[a]=n}return i}};function Cb(r){return r!=="ID"&&r!=="CLASS"&&r!=="START-DATE"&&r!=="DURATION"&&r!=="END-DATE"&&r!=="END-ON-NEXT"}function Mb(r){return r==="SCTE35-OUT"||r==="SCTE35-IN"}var tl=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let i=t.attr;for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==i[s]){M.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=pt(new Qe({}),i,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let i=new Date(this.attr["END-DATE"]);ce(i.getTime())&&(this._endDate=i)}}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)}},Ws=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}}},Ve={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},il=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Ve.AUDIO]:null,[Ve.VIDEO]:null,[Ve.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let i=e.split("@",2),s=[];i.length===1?s[0]=t?t.byteRangeEndOffset:0:s[0]=parseInt(i[1]),s[1]=parseInt(i[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=ah.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},Bn=class extends il{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 Ws,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 i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[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),i=t.length;if(i>1||i===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,i,s,n,a=!1){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:i,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[Ve.AUDIO]=null,e[Ve.VIDEO]=null,e[Ve.AUDIOVIDEO]=null}},lu=class extends il{constructor(e,t,i,s,n){super(i),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 Ws,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)}},Ob=10,du=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,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>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||Ob}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 oh(r){return Uint8Array.from(atob(r),e=>e.charCodeAt(0))}function Pb(r){let e=yg(r).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function Nb(r){let e=function(i,s,n){let a=i[s];i[s]=i[n],i[n]=a};e(r,0,3),e(r,1,2),e(r,4,5),e(r,6,7)}function Fb(r){let e=r.split(":"),t=null;if(e[0]==="data"&&e.length===2){let i=e[1].split(";"),s=i[i.length-1].split(",");if(s.length===2){let n=s[0]==="base64",a=s[1];n?(i.splice(-1,1),t=oh(a)):t=Pb(a)}}return t}function yg(r){return Uint8Array.from(unescape(encodeURIComponent(r)),e=>e.charCodeAt(0))}var st={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},jt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Op(r){switch(r){case jt.FAIRPLAY:return st.FAIRPLAY;case jt.PLAYREADY:return st.PLAYREADY;case jt.WIDEVINE:return st.WIDEVINE;case jt.CLEARKEY:return st.CLEARKEY}}var bg={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Ub(r){if(r===bg.WIDEVINE)return st.WIDEVINE}function Pp(r){switch(r){case st.FAIRPLAY:return jt.FAIRPLAY;case st.PLAYREADY:return jt.PLAYREADY;case st.WIDEVINE:return jt.WIDEVINE;case st.CLEARKEY:return jt.CLEARKEY}}function $c(r){let{drmSystems:e,widevineLicenseUrl:t}=r,i=e?[st.FAIRPLAY,st.WIDEVINE,st.PLAYREADY,st.CLEARKEY].filter(s=>!!e[s]):[];return!i[st.WIDEVINE]&&t&&i.push(st.WIDEVINE),i}var Tg=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Bb(r,e,t,i){let s;switch(r){case st.FAIRPLAY:s=["cenc","sinf"];break;case st.WIDEVINE:case st.PLAYREADY:s=["cenc"];break;case st.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${r}`)}return $b(s,e,t,i)}function $b(r,e,t,i){return[{initDataTypes:r,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function Gr(r,e,t){return Uint8Array.prototype.slice?r.slice(e,t):new Uint8Array(Array.prototype.slice.call(r,e,t))}var lh=(r,e)=>e+10<=r.length&&r[e]===73&&r[e+1]===68&&r[e+2]===51&&r[e+3]<255&&r[e+4]<255&&r[e+6]<128&&r[e+7]<128&&r[e+8]<128&&r[e+9]<128,_g=(r,e)=>e+10<=r.length&&r[e]===51&&r[e+1]===68&&r[e+2]===73&&r[e+3]<255&&r[e+4]<255&&r[e+6]<128&&r[e+7]<128&&r[e+8]<128&&r[e+9]<128,rl=(r,e)=>{let t=e,i=0;for(;lh(r,e);){i+=10;let s=_l(r,e+6);i+=s,_g(r,e+10)&&(i+=10),e+=i}if(i>0)return r.subarray(t,t+i)},_l=(r,e)=>{let t=0;return t=(r[e]&127)<<21,t|=(r[e+1]&127)<<14,t|=(r[e+2]&127)<<7,t|=r[e+3]&127,t},Gb=(r,e)=>lh(r,e)&&_l(r,e+6)+10<=r.length-e,Hb=r=>{let e=Sg(r);for(let t=0;t<e.length;t++){let i=e[t];if(Ag(i))return jb(i)}},Ag=r=>r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp",Vb=r=>{let e=String.fromCharCode(r[0],r[1],r[2],r[3]),t=_l(r,4),i=10;return{type:e,size:t,data:r.subarray(i,i+t)}},Sg=r=>{let e=0,t=[];for(;lh(r,e);){let i=_l(r,e+6);e+=10;let s=e+i;for(;e+8<s;){let n=Vb(r.subarray(e)),a=Kb(n);a&&t.push(a),e+=n.size+10}_g(r,e)&&(e+=10)}return t},Kb=r=>r.type==="PRIV"?Wb(r):r.type[0]==="W"?Yb(r):qb(r),Wb=r=>{if(r.size<2)return;let e=Bi(r.data,!0),t=new Uint8Array(r.data.subarray(e.length+1));return{key:r.type,info:e,data:t.buffer}},qb=r=>{if(r.size<2)return;if(r.type==="TXXX"){let t=1,i=Bi(r.data.subarray(t),!0);t+=i.length+1;let s=Bi(r.data.subarray(t));return{key:r.type,info:i,data:s}}let e=Bi(r.data.subarray(1));return{key:r.type,data:e}},Yb=r=>{if(r.type==="WXXX"){if(r.size<2)return;let t=1,i=Bi(r.data.subarray(t),!0);t+=i.length+1;let s=Bi(r.data.subarray(t));return{key:r.type,info:i,data:s}}let e=Bi(r.data);return{key:r.type,data:e}},jb=r=>{if(r.data.byteLength===8){let e=new Uint8Array(r.data),t=e[3]&1,i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}},Bi=(r,e=!1)=>{let t=zb();if(t){let d=t.decode(r);if(e){let c=d.indexOf("\0");return c!==-1?d.substring(0,c):d}return d.replace(/\0/g,"")}let i=r.length,s,n,a,o="",l=0;for(;l<i;){if(s=r[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=r[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=r[l++],a=r[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o},Gc;function zb(){return!Gc&&typeof self.TextDecoder!="undefined"&&(Gc=new self.TextDecoder("utf-8")),Gc}var Oi={hexDump:function(r){let e="";for(let t=0;t<r.length;t++){let i=r[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}},sl=Math.pow(2,32)-1,Xb=[].push,xg={video:1,audio:2,id3:3,text:4};function Rt(r){return String.fromCharCode.apply(null,r)}function Ig(r,e){let t=r[e]<<8|r[e+1];return t<0?65536+t:t}function be(r,e){let t=Lg(r,e);return t<0?4294967296+t:t}function Lg(r,e){return r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}function Hc(r,e,t){r[e]=t>>24,r[e+1]=t>>16&255,r[e+2]=t>>8&255,r[e+3]=t&255}function Pe(r,e){let t=[];if(!e.length)return t;let i=r.byteLength;for(let s=0;s<i;){let n=be(r,s),a=Rt(r.subarray(s+4,s+8)),o=n>1?s+n:i;if(a===e[0])if(e.length===1)t.push(r.subarray(s+8,o));else{let l=Pe(r.subarray(s+8,o),e.slice(1));l.length&&Xb.apply(t,l)}s=o}return t}function Qb(r){let e=[],t=r[0],i=8,s=be(r,i);i+=4;let n=0,a=0;t===0?i+=8:i+=16,i+=2;let o=r.length+a,l=Ig(r,i);i+=2;for(let d=0;d<l;d++){let c=i,u=be(r,c);c+=4;let h=u&2147483647;if((u&2147483648)>>>31===1)return M.warn("SIDX has hierarchical references (not supported)"),null;let g=be(r,c);c+=4,e.push({referenceSize:h,subsegmentDuration:g,info:{duration:g/s,start:o,end:o+h-1}}),o+=h,c+=4,i=c}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function Rg(r){let e=[],t=Pe(r,["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=be(a,l),c=Pe(n,["mdia","mdhd"])[0];if(c){o=c[0],l=o===0?12:20;let u=be(c,l),h=Pe(n,["mdia","hdlr"])[0];if(h){let f=Rt(h.subarray(8,12)),g={soun:Ve.AUDIO,vide:Ve.VIDEO}[f];if(g){let E=Pe(n,["mdia","minf","stbl","stsd"])[0],T;E&&(T=Rt(E.subarray(12,16))),e[d]={timescale:u,type:g},e[g]={timescale:u,id:d,codec:T}}}}}}return Pe(r,["moov","mvex","trex"]).forEach(s=>{let n=be(s,4),a=e[n];a&&(a.default={duration:be(s,12),flags:be(s,20)})}),e}function Zb(r,e){if(!r||!e)return r;let t=e.keyId;return t&&e.isCommonEncryption&&Pe(r,["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=kg(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: ${Oi.hexDump(g)} -> ${Oi.hexDump(t)}`),f.set(t,8))}})})}),r}function kg(r){let e=Pe(r,["schm"])[0];if(e){let t=Rt(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return Pe(r,["schi","tenc"])[0]}return M.error("[eme] missing 'schm' box"),null}function Jb(r,e){return Pe(e,["moof","traf"]).reduce((t,i)=>{let s=Pe(i,["tfdt"])[0],n=s[0],a=Pe(i,["tfhd"]).reduce((o,l)=>{let d=be(l,4),c=r[d];if(c){let u=be(s,4);if(n===1){if(u===sl)return M.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;u*=sl+1,u+=be(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 eT(r,e){let t=0,i=0,s=0,n=Pe(r,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=Pe(o,["tfhd"])[0],d=be(l,4),c=e[d];if(!c)continue;let u=c.default,h=be(l,0)|(u==null?void 0:u.flags),f=u==null?void 0:u.duration;h&8&&(h&2?f=be(l,12):f=be(l,8));let g=c.timescale||9e4,E=Pe(o,["trun"]);for(let T=0;T<E.length;T++){if(t=tT(E[T]),!t&&f){let A=be(E[T],4);t=f*A}c.type===Ve.VIDEO?i+=t/g:c.type===Ve.AUDIO&&(s+=t/g)}}if(i===0&&s===0){let a=0,o=Pe(r,["sidx"]);for(let l=0;l<o.length;l++){let d=Qb(o[l]);d!=null&&d.references&&(a+=d.references.reduce((c,u)=>c+u.info.duration||0,0))}return a}return i||s}function tT(r){let e=be(r,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let i=0,s=be(r,4);for(let n=0;n<s;n++){if(e&256){let a=be(r,t);i+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return i}function iT(r,e,t){Pe(e,["moof","traf"]).forEach(i=>{Pe(i,["tfhd"]).forEach(s=>{let n=be(s,4),a=r[n];if(!a)return;let o=a.timescale||9e4;Pe(i,["tfdt"]).forEach(l=>{let d=l[0],c=be(l,4);if(d===0)c-=t*o,c=Math.max(c,0),Hc(l,4,c);else{c*=Math.pow(2,32),c+=be(l,8),c-=t*o,c=Math.max(c,0);let u=Math.floor(c/(sl+1)),h=Math.floor(c%(sl+1));Hc(l,4,u),Hc(l,8,h)}})})})}function rT(r){let e={valid:null,remainder:null},t=Pe(r,["moof"]);if(t){if(t.length<2)return e.remainder=r,e}else return e;let i=t[t.length-1];return e.valid=Gr(r,0,i.byteOffset-8),e.remainder=Gr(r,i.byteOffset-8),e}function Hr(r,e){let t=new Uint8Array(r.length+e.length);return t.set(r),t.set(e,r.length),t}function Np(r,e){let t=[],i=e.samples,s=e.timescale,n=e.id,a=!1;return Pe(i,["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=be(f,4);return g===1&&(E*=Math.pow(2,32),E+=be(f,8)),E/s})[0];return h!==void 0&&(r=h),Pe(u,["tfhd"]).map(f=>{let g=be(f,4),E=be(f,0)&16777215,T=(E&1)!==0,A=(E&2)!==0,R=(E&8)!==0,x=0,N=(E&16)!==0,w=0,$=(E&32)!==0,O=8;g===n&&(T&&(O+=8),A&&(O+=4),R&&(x=be(f,O),O+=4),N&&(w=be(f,O),O+=4),$&&(O+=4),e.type==="video"&&(a=sT(e.codec)),Pe(u,["trun"]).map(H=>{let q=H[0],P=be(H,0)&16777215,X=(P&1)!==0,j=0,Ae=(P&4)!==0,Ee=(P&256)!==0,ye=0,we=(P&512)!==0,Se=0,Z=(P&1024)!==0,ae=(P&2048)!==0,se=0,xe=be(H,4),Ie=8;X&&(j=be(H,Ie),Ie+=4),Ae&&(Ie+=4);let $e=j+d;for(let ht=0;ht<xe;ht++){if(Ee?(ye=be(H,Ie),Ie+=4):ye=x,we?(Se=be(H,Ie),Ie+=4):Se=w,Z&&(Ie+=4),ae&&(q===0?se=be(H,Ie):se=Lg(H,Ie),Ie+=4),e.type===Ve.VIDEO){let V=0;for(;V<Se;){let J=be(i,$e);if($e+=4,nT(a,i[$e])){let Re=i.subarray($e,$e+J);wg(Re,a?2:1,r+se/s,t)}$e+=J,V+=J+4}}r+=ye/s}}))})})}),t}function sT(r){if(!r)return!1;let e=r.indexOf("."),t=e<0?r:r.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function nT(r,e){if(r){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function wg(r,e,t,i){let s=Dg(r),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=Ig(s,n);if(n+=2,h===49){let f=be(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,x=new Uint8Array(R);if(A){x[0]=E;for(let N=1;N<R;N++)x[N]=s[n++]}i.push({type:g,payloadType:a,pts:t,bytes:x})}}}}}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++];i.push({payloadType:a,pts:t,uuid:u.join(""),userData:Bi(f),userDataBytes:f})}}else if(o<c)n+=o;else if(o>c)break}}function Dg(r){let e=r.byteLength,t=[],i=1;for(;i<e-2;)r[i]===0&&r[i+1]===0&&r[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return r;let s=e-t.length,n=new Uint8Array(s),a=0;for(i=0;i<s;a++,i++)a===t[0]&&(a++,t.shift()),n[i]=r[a];return n}function aT(r){let e=r[0],t="",i="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;Rt(r.subarray(d,d+1))!=="\0";)t+=Rt(r.subarray(d,d+1)),d+=1;for(t+=Rt(r.subarray(d,d+1)),d+=1;Rt(r.subarray(d,d+1))!=="\0";)i+=Rt(r.subarray(d,d+1)),d+=1;i+=Rt(r.subarray(d,d+1)),d+=1,s=be(r,12),n=be(r,16),o=be(r,20),l=be(r,24),d=28}else if(e===1){d+=4,s=be(r,d),d+=4;let u=be(r,d);d+=4;let h=be(r,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=be(r,d),d+=4,l=be(r,d),d+=4;Rt(r.subarray(d,d+1))!=="\0";)t+=Rt(r.subarray(d,d+1)),d+=1;for(t+=Rt(r.subarray(d,d+1)),d+=1;Rt(r.subarray(d,d+1))!=="\0";)i+=Rt(r.subarray(d,d+1)),d+=1;i+=Rt(r.subarray(d,d+1)),d+=1}let c=r.subarray(d,r.byteLength);return{schemeIdUri:t,value:i,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:c}}function oT(r,...e){let t=e.length,i=8,s=t;for(;s--;)i+=e[s].byteLength;let n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=i&255,n.set(r,4),s=0,i=8;s<t;s++)n.set(e[s],i),i+=e[s].byteLength;return n}function lT(r,e,t){if(r.byteLength!==16)throw new RangeError("Invalid system id");let i,s;if(e){i=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 i=0,s=new Uint8Array;let n;i>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),oT([112,115,115,104],new Uint8Array([i,0,0,0]),r,n,s,a,t||new Uint8Array)}function dT(r){if(!(r instanceof ArrayBuffer)||r.byteLength<32)return null;let e={version:0,systemId:"",kids:null,data:null},t=new DataView(r),i=t.getUint32(0);if(r.byteLength!==i&&i>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=Oi.hexDump(new Uint8Array(r,12,16));let n=t.getUint32(28);if(e.version===0){if(i-32<n)return null;e.data=new Uint8Array(r,32,n)}else if(e.version===1){e.kids=[];for(let a=0;a<n;a++)e.kids.push(new Uint8Array(r,32+a*16,16))}return e}var Wo={},Vr=class{static clearKeyUriToKeyIdMap(){Wo={}}constructor(e,t,i,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=i,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 jt.FAIRPLAY:case jt.WIDEVINE:case jt.PLAYREADY:case jt.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 i=cT(e);return new Vr(this.method,this.uri,"identity",this.keyFormatVersions,i)}let t=Fb(this.uri);if(t)switch(this.keyFormat){case jt.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case jt.PLAYREADY:{let i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=lT(i,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=oh(c).subarray(0,16);Nb(u),this.keyId=u}}break}default:{let i=t.subarray(0,16);if(i.length!==16){let s=new Uint8Array(16);s.set(i,16-i.length),i=s}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=Wo[this.uri];if(!i){let s=Object.keys(Wo).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,s),Wo[this.uri]=i}this.keyId=i}return this}};function cT(r){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=r>>8*(15-t)&255;return e}var Cg=/\{\$([a-zA-Z0-9-_]+)\}/g;function Fp(r){return Cg.test(r)}function qt(r,e,t){if(r.variableList!==null||r.hasVariableRefs)for(let i=t.length;i--;){let s=t[i],n=e[s];n&&(e[s]=cu(r,n))}}function cu(r,e){if(r.variableList!==null||r.hasVariableRefs){let t=r.variableList;return e.replace(Cg,i=>{let s=i.substring(2,i.length-1),n=t==null?void 0:t[s];return n===void 0?(r.playlistParsingError||(r.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),i):n})}return e}function Up(r,e,t){let i=r.variableList;i||(r.variableList=i={});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){r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in i?r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):i[s]=n||""}function uT(r,e,t){let i=e.IMPORT;if(t&&i in t){let s=r.variableList;s||(r.variableList=s={}),s[i]=t[i]}else r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function Al(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}var hT={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}},Bp=Al();function fT(r,e){let t=hT[e];return!!t&&t[r.slice(0,4)]===!0}function Vc(r,e){var t;return(t=Bp==null?void 0:Bp.isTypeSupported(`${e||"video"}/mp4;codecs="${r}"`))!=null?t:!1}var $p=/#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,Gp=/#EXT-X-MEDIA:(.*)/g,mT=/^#EXT(?:INF|-X-TARGETDURATION):/m,Hp=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),pT=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("|")),Zt=class{static findGroup(e,t){for(let i=0;i<e.length;i++){let s=e[i];if(s.id===t)return s}}static convertAVC1ToAVCOTI(e){let t=e.split(".");if(t.length>2){let i=t.shift()+".";return i+=parseInt(t.shift()).toString(16),i+=("000"+parseInt(t.shift()).toString(16)).slice(-4),i}return e}static resolve(e,t){return ah.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return mT.test(e)}static parseMasterPlaylist(e,t){let i=Fp(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];$p.lastIndex=0;let a;for(;(a=$p.exec(e))!=null;)if(a[1]){var o;let d=new Qe(a[1]);qt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let c=cu(s,a[2]),u={attrs:d,bitrate:d.decimalInteger("AVERAGE-BANDWIDTH")||d.decimalInteger("BANDWIDTH"),name:d.NAME,url:Zt.resolve(c,t)},h=d.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),gT((d.CODECS||"").split(/[ ,]+/).filter(f=>f),u),u.videoCodec&&u.videoCodec.indexOf("avc1")!==-1&&(u.videoCodec=Zt.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);qt(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=Vp(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);qt(s,u,["NAME","VALUE","QUERYPARAM"]),Up(s,u,t)}break}case"CONTENT-STEERING":{let u=new Qe(c);qt(s,u,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:Zt.resolve(u["SERVER-URI"],t),pathwayId:u["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=Kp(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,i){let s,n={},a=i.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(Gp.lastIndex=0;(s=Gp.exec(e))!==null;){let d=new Qe(s[1]),c=d.TYPE;if(c){let u=o[c],h=n[c]||[];n[c]=h,qt(i,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?Zt.resolve(d.URI,t):""};if(u!=null&&u.length){let g=Zt.findGroup(u,f.groupId)||u[0];Wp(f,g,"audioCodec"),Wp(f,g,"textCodec")}h.push(f)}}return n}static parseLevelPlaylist(e,t,i,s,n,a){let o=new du(t),l=o.fragments,d=null,c=0,u=0,h=0,f=0,g=null,E=new Bn(s,t),T,A,R,x=-1,N=!1;for(Hp.lastIndex=0,o.m3u8=e,o.hasVariableRefs=Fp(e);(T=Hp.exec(e))!==null;){N&&(N=!1,E=new Bn(s,t),E.start=h,E.sn=c,E.cc=f,E.level=i,d&&(E.initSegment=d,E.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null));let H=T[1];if(H){E.duration=parseFloat(H);let q=(" "+T[2]).slice(1);E.title=q||null,E.tagList.push(q?["INF",H,q]:["INF",H])}else if(T[3]){if(ce(E.duration)){E.start=h,R&&jp(E,R,o),E.sn=c,E.level=i,E.cc=f,E.urlId=n,l.push(E);let q=(" "+T[3]).slice(1);E.relurl=cu(o,q),qp(E,g),g=E,h+=E.duration,c++,u=0,N=!0}}else if(T[4]){let q=(" "+T[4]).slice(1);g?E.setByteRange(q,g):E.setByteRange(q)}else if(T[5])E.rawProgramDateTime=(" "+T[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),x===-1&&(x=l.length);else{if(T=T[0].match(pT),!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 q=(" "+T[A]).slice(1),P=(" "+T[A+1]).slice(1),X=T[A+2]?(" "+T[A+2]).slice(1):"";switch(q){case"PLAYLIST-TYPE":o.type=P.toUpperCase();break;case"MEDIA-SEQUENCE":c=o.startSN=parseInt(P);break;case"SKIP":{let j=new Qe(P);qt(o,j,["RECENTLY-REMOVED-DATERANGES"]);let Ae=j.decimalInteger("SKIPPED-SEGMENTS");if(ce(Ae)){o.skippedSegments=Ae;for(let ye=Ae;ye--;)l.unshift(null);c+=Ae}let Ee=j.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([q]);break;case"BITRATE":E.tagList.push([q,P]);break;case"DATERANGE":{let j=new Qe(P);qt(o,j,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),qt(o,j,j.clientAttrs);let Ae=new tl(j,o.dateRanges[j.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 j=new Qe(P);qt(o,j,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in j?uT(o,j,a):Up(o,j,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(P);break;case"KEY":{let j=Vp(P,t,o);if(j.isSupported()){if(j.method==="NONE"){R=void 0;break}R||(R={}),R[j.keyFormat]&&(R=pt({},R)),R[j.keyFormat]=j}else M.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${P}"`);break}case"START":o.startTimeOffset=Kp(P);break;case"MAP":{let j=new Qe(P);if(qt(o,j,["BYTERANGE","URI"]),E.duration){let Ae=new Bn(s,t);Yp(Ae,j,i,R),d=Ae,E.initSegment=d,d.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=d.rawProgramDateTime)}else Yp(E,j,i,R),d=E,N=!0;break}case"SERVER-CONTROL":{let j=new Qe(P);o.canBlockReload=j.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=j.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&j.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=j.optionalFloat("PART-HOLD-BACK",0),o.holdBack=j.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{let j=new Qe(P);o.partTarget=j.decimalFloatingPoint("PART-TARGET");break}case"PART":{let j=o.partList;j||(j=o.partList=[]);let Ae=u>0?j[j.length-1]:void 0,Ee=u++,ye=new Qe(P);qt(o,ye,["BYTERANGE","URI"]);let we=new lu(ye,E,t,Ee,Ae);j.push(we),E.duration+=we.duration;break}case"PRELOAD-HINT":{let j=new Qe(P);qt(o,j,["URI"]),o.preloadHint=j;break}case"RENDITION-REPORT":{let j=new Qe(P);qt(o,j,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(j);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&&(qp(E,g),E.cc=f,o.fragmentHint=E,R&&jp(E,R,o));let w=l.length,$=l[0],O=l[w-1];if(h+=o.skippedSegments*o.targetduration,h>0&&w&&O){o.averagetargetduration=h/w;let H=O.sn;o.endSN=H!=="initSegment"?H: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,x>0&&vT(l,x),o}};function Vp(r,e,t){var i,s;let n=new Qe(r);qt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(i=n.METHOD)!=null?i:"",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?Zt.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Vr(a,u,c,h,l)}function Kp(r){let t=new Qe(r).decimalFloatingPoint("TIME-OFFSET");return ce(t)?t:null}function gT(r,e){["video","audio","text"].forEach(t=>{let i=r.filter(s=>fT(s,t));if(i.length){let s=i.filter(n=>n.lastIndexOf("avc1",0)===0||n.lastIndexOf("mp4a",0)===0);e[`${t}Codec`]=s.length>0?s[0]:i[0],r=r.filter(n=>i.indexOf(n)===-1)}}),e.unknownCodecs=r}function Wp(r,e,t){let i=e[t];i&&(r[t]=i)}function vT(r,e){let t=r[e];for(let i=e;i--;){let s=r[i];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function qp(r,e){r.rawProgramDateTime?r.programDateTime=Date.parse(r.rawProgramDateTime):e!=null&&e.programDateTime&&(r.programDateTime=e.endProgramDateTime),ce(r.programDateTime)||(r.programDateTime=null,r.rawProgramDateTime=null)}function Yp(r,e,t,i){r.relurl=e.URI,e.BYTERANGE&&r.setByteRange(e.BYTERANGE),r.level=t,r.sn="initSegment",i&&(r.levelkeys=i),r.initSegment=null}function jp(r,e,t){r.levelkeys=e;let{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&i.push(r)}var Fe={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},ge={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function zp(r){let{type:e}=r;switch(e){case Fe.AUDIO_TRACK:return ge.AUDIO;case Fe.SUBTITLE_TRACK:return ge.SUBTITLE;default:return ge.MAIN}}function Kc(r,e){let t=r.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var uu=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(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,i=t.pLoader,s=t.loader,n=i||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:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Fe.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(e,t){let{id:i,level:s,url:n,deliveryDirectives:a}=t;this.load({id:i,level:s,responseType:"text",type:Fe.LEVEL,url:n,deliveryDirectives:a})}onAudioTrackLoading(e,t){let{id:i,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:Fe.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){let{id:i,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:Fe.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;let i=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===Fe.MANIFEST?n=i.manifestLoadPolicy.default:n=pt({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part){let d;if(e.type===Fe.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Fe.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Fe.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=pt({},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(),Zt.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,i,s){let n=this.hls,a=e.data,o=Kc(e,i),l=Zt.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,i,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}=Zt.parseMasterPlaylistMedia(a,o,l);E.length&&!E.some(x=>!x.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(y.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,i,s,n){let a=this.hls,{id:o,level:l,type:d}=i,c=Kc(e,i),u=ce(o)?o:0,h=ce(l)?l:u,f=zp(i),g=Zt.parseLevelPlaylist(e.data,c,h,f,u,this.variableList);if(d===Fe.MANIFEST){let E={attrs:new Qe({}),bitrate:0,details:g,name:"",url:c};a.trigger(y.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(),i.levelDetails=g,this.handlePlaylistLoaded(g,e,t,i,s,n)}handleManifestParsingError(e,t,i,s,n){this.hls.trigger(y.ERROR,{type:pe.NETWORK_ERROR,details:B.MANIFEST_PARSING_ERROR,fatal:t.type===Fe.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,i=!1,s,n){let a=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===Fe.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Fe.AUDIO_TRACK||e.type===Fe.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 Fe.MANIFEST:l=i?B.MANIFEST_LOAD_TIMEOUT:B.MANIFEST_LOAD_ERROR,d=!0;break;case Fe.LEVEL:l=i?B.LEVEL_LOAD_TIMEOUT:B.LEVEL_LOAD_ERROR,d=!1;break;case Fe.AUDIO_TRACK:l=i?B.AUDIO_TRACK_LOAD_TIMEOUT:B.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Fe.SUBTITLE_TRACK:l=i?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=zt({url:h,data:void 0},s)}this.hls.trigger(y.ERROR,u)}handlePlaylistLoaded(e,t,i,s,n,a){let o=this.hls,{type:l,level:d,id:c,groupId:u,deliveryDirectives:h}=s,f=Kc(t,s),g=zp(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(y.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:i});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let T=e.playlistParsingError;if(T){o.trigger(y.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:i});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case Fe.MANIFEST:case Fe.LEVEL:o.trigger(y.LEVEL_LOADED,{details:e,level:E||0,id:c||0,stats:i,networkDetails:n,deliveryDirectives:h});break;case Fe.AUDIO_TRACK:o.trigger(y.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:i,networkDetails:n,deliveryDirectives:h});break;case Fe.SUBTITLE_TRACK:o.trigger(y.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:i,networkDetails:n,deliveryDirectives:h});break}}};function Mg(r,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=r,e.dispatchEvent(t)}function Og(r,e){let t=r.mode;if(t==="disabled"&&(r.mode="hidden"),r.cues&&!r.cues.getCueById(e.id))try{if(r.addCue(e),!r.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){M.debug(`[texttrack-utils]: ${i}`);let s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,r.addCue(s)}t==="disabled"&&(r.mode=t)}function Vs(r){let e=r.mode;if(e==="disabled"&&(r.mode="hidden"),r.cues)for(let t=r.cues.length;t--;)r.removeCue(r.cues[t]);e==="disabled"&&(r.mode=e)}function hu(r,e,t,i){let s=r.mode;if(s==="disabled"&&(r.mode="hidden"),r.cues&&r.cues.length>0){let n=yT(r.cues,e,t);for(let a=0;a<n.length;a++)(!i||i(n[a]))&&r.removeCue(n[a])}s==="disabled"&&(r.mode=s)}function ET(r,e){if(e<r[0].startTime)return 0;let t=r.length-1;if(e>r[t].endTime)return-1;let i=0,s=t;for(;i<=s;){let n=Math.floor((s+i)/2);if(e<r[n].startTime)s=n-1;else if(e>r[n].startTime&&i<t)i=n+1;else return n}return r[i].startTime-e<e-r[s].startTime?i:s}function yT(r,e,t){let i=[],s=ET(r,e);if(s>-1)for(let n=s,a=r.length;n<a;n++){let o=r[n];if(o.startTime>=e&&o.endTime<=t)i.push(o);else if(o.startTime>t)return i}return i}var pi={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},bT=.25;function fu(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var qo=(()=>{let r=fu();try{new r(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Wc(r,e){return r.getTime()/1e3-e}function TT(r){return Uint8Array.from(r.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var mu=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(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){let{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){!this.id3Track||(Vs(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 i=e[t];if(i.kind==="metadata"&&i.label==="id3")return Mg(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:s}}}=this;if(!i&&!s)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=fu();for(let o=0;o<n.length;o++){let l=n[o].type;if(l===pi.emsg&&!i||!s)continue;let d=Sg(n[o].data);if(d){let c=n[o].pts,u=c+n[o].duration;u>qo&&(u=qo),u-c<=0&&(u=c+bT);for(let f=0;f<d.length;f++){let g=d[f];if(!Ag(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 i;let s=(i=this.id3Track)==null?void 0:i.cues;if(s)for(let n=s.length;n--;){let a=s[n];a.type===t&&a.startTime<e&&a.endTime===qo&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,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===pi.audioId3&&l:s==="video"?d=c=>c.type===pi.emsg&&o:d=c=>c.type===pi.audioId3&&l||c.type===pi.emsg&&o,hu(n,t,i,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:i,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){let c=Object.keys(i).filter(u=>!a.includes(u));for(let u=c.length;u--;){let h=c[u];Object.keys(i[h].cues).forEach(f=>{s.removeCue(i[h].cues[f])}),delete i[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=fu();for(let c=0;c<a.length;c++){let u=a[c],h=n[u],f=i[u],g=(f==null?void 0:f.cues)||{},E=(f==null?void 0:f.durationKnown)||!1,T=Wc(h.startDate,l),A=qo,R=h.endDate;if(R)A=Wc(R,l),E=!0;else if(h.endOnNext&&!E){let N=a.reduce((w,$)=>{let O=n[$];return O.class===h.class&&O.id!==$&&O.startDate>h.startDate&&w.push(O),w},[]).sort((w,$)=>w.startDate.getTime()-$.startDate.getTime())[0];N&&(A=Wc(N.startDate,l),E=!0)}let x=Object.keys(h.attr);for(let N=0;N<x.length;N++){let w=x[N];if(!Cb(w))continue;let $=g[w];if($)E&&!f.durationKnown&&($.endTime=A);else{let O=h.attr[w];$=new d(T,A,""),Mb(w)&&(O=TT(O)),$.value={key:w,data:O},$.type=pi.dateRange,$.id=u,this.id3Track.addCue($),g[w]=$}}i[u]={cues:g,dateRange:h,durationKnown:E}}}},pu=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:i,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&i||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,i=this.levelDetails;if(e===null||t===null||i===null)return null;let s=i.edge,n=e-t-this.edgeStalled,a=s-i.totalduration,o=s-(this.config.lowLatencyMode&&i.partTarget||i.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 i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(y.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(y.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 i;t.details===B.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.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 i=this.computeLatency();if(i===null)return;this._latency=i;let{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1)return;let a=this.targetLatency;if(a===null)return;let o=i-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}},gu=["NONE","TYPE-0","TYPE-1",null],$n={No:"",Yes:"YES",v2:"v2"};function _T(r,e){let{canSkipUntil:t,canSkipDateRanges:i,endSN:s}=r,n=e!==void 0?e-s:0;return t&&n<t?i?$n.v2:$n.Yes:$n.No}var nl=class{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}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}},Kr=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 qc(r,e){let t=e.startPTS;if(ce(t)){let i=0,s;e.sn>r.sn?(i=t-r.start,s=r):(i=r.start-t,s=e),s.duration!==i&&(s.duration=i)}else e.sn>r.sn?r.cc===e.cc&&r.minEndPTS?e.start=r.start+(r.minEndPTS-r.start):e.start=r.start+r.duration:e.start=Math.max(r.start-e.duration,0)}function Pg(r,e,t,i,s,n){i-t<=0&&(M.warn("Fragment should have a positive duration",e),i=t+e.duration,n=s+e.duration);let o=t,l=i,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(i,c),i=Math.max(i,c),n=Math.max(n,e.endDTS)}let u=t-e.start;e.start!==0&&(e.start=t),e.duration=i-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=i,e.minEndPTS=l,e.endDTS=n;let h=e.sn;if(!r||h<r.startSN||h>r.endSN)return 0;let f,g=h-r.startSN,E=r.fragments;for(E[g]=e,f=g;f>0;f--)qc(E[f],E[f-1]);for(f=g;f<E.length-1;f++)qc(E[f],E[f+1]);return r.fragmentHint&&qc(E[E.length-1],r.fragmentHint),r.PTSKnown=r.alignedSliding=!0,u}function AT(r,e){let t=null,i=r.fragments;for(let l=i.length-1;l>=0;l--){let d=i[l].initSegment;if(d){t=d;break}}r.fragmentHint&&delete r.fragmentHint.endPTS;let s=0,n;if(IT(r,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=ST(r.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),xT(r.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?Pg(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):Ng(r,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=r.driftStartTime,e.driftStart=r.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=r.driftEndTime,e.driftEnd=r.driftEnd,e.advancedDateTime=r.advancedDateTime}function ST(r,e,t){let i=pt({},r);return t&&t.forEach(s=>{delete i[s]}),Object.keys(e).forEach(s=>{let n=new tl(e[s].attr,i[s]);n.isValid?i[s]=n:M.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),i}function xT(r,e,t){if(r&&e){let i=0;for(let s=0,n=r.length;s<=n;s++){let a=r[s],o=e[s+i];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):i--}}}function IT(r,e,t){let i=e.skippedSegments,s=Math.max(r.startSN,e.startSN)-e.startSN,n=(r.fragmentHint?1:0)+(i?e.endSN:Math.min(r.endSN,e.endSN))-e.startSN,a=e.startSN-r.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;for(let d=s;d<=n;d++){let c=l[a+d],u=o[d];i&&!u&&d<i&&(u=e.fragments[d]=c),c&&u&&t(c,u)}}function Ng(r,e){let t=e.startSN+e.skippedSegments-r.startSN,i=r.fragments;t<0||t>=i.length||vu(e,i[t].start)}function vu(r,e){if(e){let t=r.fragments;for(let i=r.skippedSegments;i<t.length;i++)t[i].start+=e;r.fragmentHint&&(r.fragmentHint.start+=e)}}function LT(r,e=1/0){let t=1e3*r.targetduration;if(r.updated){let i=r.fragments,s=4;if(i.length&&t*s>e){let n=i[i.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function RT(r,e,t){if(!(r!=null&&r.details))return null;let i=r.details,s=i.fragments[e-i.startSN];return s||(s=i.fragmentHint,s&&s.sn===e)?s:e<i.startSN&&t&&t.sn===e?t:null}function Xp(r,e,t){var i;return r!=null&&r.details?Fg((i=r.details)==null?void 0:i.partList,e,t):null}function Fg(r,e,t){if(r)for(let i=r.length;i--;){let s=r[i];if(s.index===t&&s.fragment.sn===e)return s}return null}function al(r){switch(r.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 Qp(r,e){let t=al(e);return r.default[`${t?"timeout":"error"}Retry`]}function dh(r,e){let t=r.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*r.retryDelayMs,r.maxRetryDelayMs)}function Zp(r){return zt(zt({},r),{errorRetry:null,timeoutRetry:null})}function ol(r,e,t,i){return!!r&&e<r.maxNumRetry&&(kT(i)||!!t)}function kT(r){return r===0&&navigator.onLine===!1||!!r&&(r<400||r>499)}var Ug={search:function(r,e){let t=0,i=r.length-1,s=null,n=null;for(;t<=i;){s=(t+i)/2|0,n=r[s];let a=e(n);if(a>0)t=s+1;else if(a<0)i=s-1;else return n}return null}};function wT(r,e,t){if(e===null||!Array.isArray(r)||!r.length||!ce(e))return null;let i=r[0].programDateTime;if(e<(i||0))return null;let s=r[r.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<r.length;++n){let a=r[n];if(DT(e,t,a))return a}return null}function Vn(r,e,t=0,i=0){let s=null;if(r?s=e[r.sn-e[0].sn+1]||null:t===0&&e[0].start===0&&(s=e[0]),s&&Eu(t,i,s)===0)return s;let n=Ug.search(e,Eu.bind(null,t,i));return n&&(n!==r||!s)?n:s}function Eu(r=0,e=0,t){if(t.start<=r&&t.start+t.duration>r)return 0;let i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=r?1:t.start-i>r&&t.start?-1:0}function DT(r,e,t){let i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>r}function CT(r,e){return Ug.search(r,t=>t.cc<e?1:t.cc>e?-1:0)}var MT=3e5,Ft={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},hi={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},yu=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(y.ERROR,this.onError,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;!e||(e.off(y.ERROR,this.onError,this),e.off(y.ERROR,this.onErrorOut,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.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 i;if(t.fatal)return;let s=this.hls,n=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_GAP:case B.FRAG_PARSING_ERROR:case B.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Ft.SendAlternateToPenaltyBox;return}case B.LEVEL_EMPTY_ERROR:case B.LEVEL_PARSING_ERROR:{var a,o;let l=t.parent===ge.MAIN?t.level:s.loadLevel;t.details===B.LEVEL_EMPTY_ERROR&&!!((a=t.context)!=null&&(o=a.levelDetails)!=null&&o.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,l))}return;case B.LEVEL_LOAD_ERROR:case B.LEVEL_LOAD_TIMEOUT:typeof(n==null?void 0:n.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.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(n){let l=s.levels[s.loadLevel];if(l&&(n.type===Fe.AUDIO_TRACK&&n.groupId===l.audioGroupId||n.type===Fe.SUBTITLE_TRACK&&n.groupId===l.textGroupId)){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.loadLevel),t.errorAction.action=Ft.SendAlternateToPenaltyBox,t.errorAction.flags=hi.MoveAllAlternatesMatchingHost;return}}return;case B.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let l=s.levels[s.loadLevel],d=l==null?void 0:l.attrs["HDCP-LEVEL"];d&&(t.errorAction={action:Ft.SendAlternateToPenaltyBox,flags:hi.MoveAllAlternatesMatchingHDCP,hdcpLevel:d})}return;case B.BUFFER_ADD_CODEC_ERROR:case B.REMUX_ALLOC_ERROR:t.errorAction=this.getLevelSwitchAction(t,(i=t.level)!=null?i:s.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:Ft.DoNothing,flags:hi.None};return}if(t.type===pe.KEY_SYSTEM_ERROR){let l=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,l);return}}getPlaylistRetryOrSwitchAction(e,t){var i;let s=this.hls,n=Qp(s.config.playlistLoadPolicy,e),a=this.playlistError++,o=(i=e.response)==null?void 0:i.code;if(ol(n,a,al(e),o))return{action:Ft.RetryRequest,flags:hi.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,i=this.getVariantLevelIndex(e.frag),s=t.levels[i],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=Qp(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(ol(o,l,al(e),u))return{action:Ft.RetryRequest,flags:hi.None,retryConfig:o,retryCount:l}}let c=this.getLevelSwitchAction(e,i);return o&&(c.retryConfig=o,c.retryCount=l),c}getLevelSwitchAction(e,t){let i=this.hls;t==null&&(t=i.loadLevel);let s=this.hls.levels[t];if(s&&(s.loadError++,i.autoLevelEnabled)){var n,a;let o=-1,{levels:l,loadLevel:d,minAutoLevel:c,maxAutoLevel:u}=i,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 x=Vn(e.frag,R.fragments,e.frag.start);if(x!=null&&x.gap)continue}}else{if(f===Fe.AUDIO_TRACK&&g===A.audioGroupId||f===Fe.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&&i.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:Ft.SendAlternateToPenaltyBox,flags:hi.None,nextAutoLevel:o}}return{action:Ft.SendAlternateToPenaltyBox,flags:hi.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case Ft.DoNothing:break;case Ft.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,i=e.errorAction;if(!i)return;let{flags:s,hdcpLevel:n,nextAutoLevel:a}=i;switch(s){case hi.None:this.switchLevel(e,a);break;case hi.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(e));break;case hi.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=gu[gu.indexOf(n)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}i.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:i}=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=i[d];if(!c||OT(c,e,i[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:i}=this,s=i[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};s.lastErrorPerfMs=performance.now(),s.errors.push(t),s.details=e.details,i[e.urlId]=s}};function OT(r,e,t){if(performance.now()-r.lastErrorPerfMs>MT)return!0;let i=r.details;if(e.details===B.FRAG_GAP&&i&&e.frag){let s=e.frag.start,n=Vn(null,i.fragments,s);if(n&&!n.gap)return!0}if(t&&r.errors.length<t.errors.length){let s=r.errors[r.errors.length-1];if(i&&s.frag&&e.frag&&Math.abs(s.frag.start-e.frag.start)>i.targetduration*3)return!0}return!1}var Kn=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 i=t==null?void 0:t.renditionReports;if(i){let s=-1;for(let n=0;n<i.length;n++){let a=i[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=i[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 nl(a,o>=0?o:void 0,$n.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,i){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||i!=null&&i.live){if(s.reloaded(i),i&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:"MISSED"}`),i&&s.fragments.length>0&&AT(i,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,x=s.lastPartIndex,N=x!==-1,w=A===R,$=T?0:x;N?(d=w?R+1:A,c=w?$:x+1):d=R+1;let O=s.age,H=O+s.ageHeader,q=Math.min(H-s.partTarget,s.targetduration*1.5);if(q>0){if(i&&q>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${q} with playlist age: ${s.age}`),q=0;else{let P=Math.floor(q/s.targetduration);if(d+=P,c!==void 0){let X=Math.round(q%s.targetduration/s.partTarget);c+=X}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${O.toFixed(2)}s goal: ${q} skip sn ${P} to part ${c}`)}s.tuneInGoal=q}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,c),T||!w){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=LT(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,i,s){let n=_T(e,i);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,s=t.part,n=$n.No),new nl(i,s,n)}checkRetry(e){let t=e.details,i=al(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===Ft.RetryRequest||!s.resolved&&n===Ft.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(i&&(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=dh(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}},Yc,bu=class extends Kn{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(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.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 i=[],s={},n;t.levels.forEach(a=>{var o;let l=a.attrs;((o=a.audioCodec)==null?void 0:o.indexOf("mp4a.40.34"))!==-1&&(Yc||(Yc=/chrome|firefox/i.test(navigator.userAgent)),Yc&&(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 Kr(a),s[T]=n,i.push(n)),ll(n,"audio",d),ll(n,"text",g)}),this.filterAndSortMediaOptions(i,t)}filterAndSortMediaOptions(e,t){let i=[],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||Vc(f,"audio"))&&(!g||Vc(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(y.ERROR,{type:pe.MEDIA_ERROR,details:B.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:f,reason:f.message})}});return}t.audioTracks&&(i=t.audioTracks.filter(f=>!f.audioCodec||Vc(f.audioCodec,"audio")),Jp(i)),t.subtitles&&(s=t.subtitles,Jp(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:i,subtitleTracks:s,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:o,video:a,altAudio:!u&&i.some(f=>!!f.url)};this.hls.trigger(y.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(y.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 i=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,i===e&&a.details&&s&&n===o)return;this.log(`Switching to level ${e}${o?" with Pathway "+o:""} from level ${i}${n?" with Pathway "+n:""}`);let l=pt({},a,{level:e,maxBitrate:a.maxBitrate,attrs:a.attrs,uri:a.uri,urlId:a.urlId});delete l._attrs,delete l._urlId,this.hls.trigger(y.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===Fe.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(t!==void 0&&t.type===ge.MAIN){let i=this._levels[t.level];i!==void 0&&(i.loadError=0)}}onLevelLoaded(e,t){var i;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)):(i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,t){let i=this.currentLevel;if(!i)return;let s=this.hls.audioTracks[t.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==s){let n=-1;for(let a=0;a<i.audioGroupIds.length;a++)if(i.audioGroupIds[a]===s){n=a;break}n!==-1&&n!==i.urlId&&(i.urlId=n,this.canLoad&&this.startLoad())}}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){let s=i.urlId,n=i.uri;if(e)try{n=e.addDirectives(n)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}let a=i.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}/${i.url.length} ${n}`),this.clearTimer(),this.hls.trigger(y.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 i=(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(i),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(i)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(i)),n.urlId=0,!0):(this.steering&&this.steering.removeLevel(n),!1));this.hls.trigger(y.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(e,{levels:t}){t.forEach((i,s)=>{let{details:n}=i;n!=null&&n.fragments&&n.fragments.forEach(a=>{a.level=s})}),this._levels=t}};function ll(r,e,t){!t||(e==="audio"?(r.audioGroupIds||(r.audioGroupIds=[]),r.audioGroupIds[r.url.length-1]=t):e==="text"&&(r.textGroupIds||(r.textGroupIds=[]),r.textGroupIds[r.url.length-1]=t))}function Jp(r){let e={};r.forEach(t=>{let i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}var Tt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Tu=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(y.BUFFER_APPENDED,this.onBufferAppended,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(y.BUFFER_APPENDED,this.onBufferAppended,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let i=this.activePartLists[t];if(i)for(let s=i.length;s--;){let n=i[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:i}=this,s=Object.keys(i);for(let n=s.length;n--;){let a=i[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,i,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===i&&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:i,part:s}=e;if(!t||i.sn==="initSegment")return;let n=$s(i),a=this.fragments[n];if(!a)return;let o=!i.relurl;Object.keys(t).forEach(l=>{let d=i.elementaryStreams[l];if(!d)return;let c=t[l],u=o||d.partial===!0;a.range[l]=this.getBufferedTimes(i,s,u,c)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,a.body.endList&&(this.endListFragments[a.body.type]=a),Yo(a)||this.removeParts(i.sn-1,i.type)):this.removeFragment(a.body)}removeParts(e,t){let i=this.activePartLists[t];!i||(this.activePartLists[t]=i.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){let i=$s(e),s=this.fragments[i];!s&&t&&(s=this.fragments[i]={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,i,s){let n={time:[],partial:i},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,i,s,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let c=l[d];!c||Yo(c)&&(s=c.body.start-o,n=c.body.end+o,e>=s&&e<=n&&(i=Math.min(e-s,n-e),a<=i&&(t=c.body,a=i)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||Yo(t))}getState(e){let t=$s(e),i=this.fragments[t];return i?i.buffered?Yo(i)?Tt.PARTIAL:Tt.OK:Tt.APPENDING:Tt.NOT_LOADED}isTimeBuffered(e,t,i){let s,n;for(let a=0;a<i.length;a++){if(s=i.start(a)-this.bufferPadding,n=i.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){let{frag:i,part:s}=t;if(i.sn==="initSegment"||i.bitrateTest)return;let n=s?null:t,a=$s(i);this.fragments[a]={body:i,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:i,part:s,timeRanges:n}=t;if(i.sn==="initSegment")return;let a=i.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=$s(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,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!==i||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){let t=$s(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let i=this.activePartLists[e.type];if(i){let s=e.sn;this.activePartLists[e.type]=i.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 Yo(r){var e,t,i;return r.buffered&&(r.body.gap||((e=r.range.video)==null?void 0:e.partial)||((t=r.range.audio)==null?void 0:t.partial)||((i=r.range.audiovideo)==null?void 0:i.partial))}function $s(r){return`${r.type}_${r.level}_${r.urlId}_${r.sn}`}var eg=Math.pow(2,17),_u=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 i=e.url;if(!i)return Promise.reject(new mi({type:pe.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${i?"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){l(ig(e));return}let d=this.loader=e.loader=n?new n(s):new a(s),c=tg(e),u=Zp(s.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:eg};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 mi({type:pe.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:zt({url:i,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 mi({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 mi({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,i){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(ig(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),c=tg(e,t),u=Zp(s.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:eg};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};i(A),o(A)},onError:(f,g,E,T)=>{this.resetLoader(e,d),l(new mi({type:pe.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:zt({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 mi({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 mi({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 i=e.stats,s=t.stats,n=s.total;if(i.loaded+=s.loaded,n){let l=Math.round(e.duration/t.duration),d=Math.min(Math.round(i.loaded/n),l),u=(l-d)*Math.round(i.loaded/d);i.total=i.loaded+u}else i.total=Math.max(i.loaded,i.total);let a=i.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 tg(r,e=null){let t=e||r,i={frag:r,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(r.sn==="initSegment"&&((a=r.decryptdata)==null?void 0:a.method)==="AES-128"){let d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(i.resetIV=!0,o=s-16)}i.rangeStart=o,i.rangeEnd=l}return i}function ig(r,e){let t=new Error(`GAP ${r.gap?"tag":"attribute"} found`),i={type:pe.MEDIA_ERROR,details:B.FRAG_GAP,fatal:!1,frag:r,error:t,networkDetails:null};return e&&(i.part=e),(e||r).stats.aborted=!0,new mi(i)}var mi=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},Au=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let t in this.keyUriToKeyInfo){let i=this.keyUriToKeyInfo[t].loader;if(i){if(e&&e!==i.context.frag.type)return;i.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,i,s,n){return new mi({type:pe.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:i,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:i,cc:s}=e;for(let n=0;n<t.length;n++){let a=t[n];if(s<=a.cc&&(i==="initSegment"||a.sn==="initSegment"||i<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 i,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((i=o)!=null&&i.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 i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let s=this.emeController.loadKey(i);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,i))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(i)}loadKeyHTTP(e,t){let i=this.config,s=i.loader,n=new s(i);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=i.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,zt({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:i,url:s}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}},Su=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(){}},PT={length:0,start:()=>0,end:()=>0},qe=class{static isBuffered(e,t){try{if(e){let i=qe.getBuffered(e);for(let s=0;s<i.length;s++)if(t>=i.start(s)&&t<=i.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,i){try{if(e){let s=qe.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,i)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,i){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(i)for(let d=0;d<e.length;d++){let c=s.length;if(c){let u=s[c-1].end;e[d].start-u<i?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+i>=c&&t<u)o=c,l=u,n=l-t;else if(t+i<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),PT}}},Wn=class{constructor(e,t,i,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=jo(),this.buffering={audio:jo(),video:jo(),audiovideo:jo()},this.level=e,this.sn=t,this.id=i,this.size=s,this.part=n,this.partial=a}};function jo(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Bg(r,e){let t=null;for(let i=0,s=r.length;i<s;i++){let n=r[i];if(n&&n.cc===e){t=n;break}}return t}function NT(r,e,t){return!!(e.details&&(t.endCC>t.startCC||r&&r.cc<t.startCC))}function FT(r,e,t=0){let i=r.fragments,s=e.fragments;if(!s.length||!i.length){M.log("No fragments to align");return}let n=Bg(i,s[0].cc);if(!n||n&&!n.startPTS){M.log("No frag in previous level to align on");return}return n}function rg(r,e){if(r){let t=r.start+e;r.start=r.startPTS=t,r.endPTS=t+r.duration}}function ch(r,e){let t=e.fragments;for(let i=0,s=t.length;i<s;i++)rg(t[i],r);e.fragmentHint&&rg(e.fragmentHint,r),e.alignedSliding=!0}function UT(r,e,t){!e||(BT(r,t,e),!t.alignedSliding&&e.details&&$T(t,e.details),!t.alignedSliding&&e.details&&!t.skippedSegments&&Ng(e.details,t))}function BT(r,e,t){if(NT(r,t,e)){let i=FT(t.details,e);i&&ce(i.start)&&(M.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),ch(i.start,e))}}function $T(r,e){if(!e.fragments.length||!r.hasProgramDateTime||!e.hasProgramDateTime)return;let t=e.fragments[0].programDateTime,i=r.fragments[0].programDateTime,s=(i-t)/1e3+e.fragments[0].start;s&&ce(s)&&(M.log(`Adjusting PTS using programDateTime delta ${i-t}ms, sliding:${s.toFixed(3)} ${r.url} `),ch(s,r))}function $g(r,e){if(!r.hasProgramDateTime||!e.hasProgramDateTime)return;let t=r.fragments,i=e.fragments;if(!t.length||!i.length)return;let s=Math.round(i.length/2)-1,n=i[s],a=Bg(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);ch(d,r)}var xu=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)}},Iu=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 GT(r){let e=r.byteLength,t=e&&new DataView(r.buffer).getUint8(e-1);return t?Gr(r,0,e-t):r}var Lu=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),i=new Uint32Array(4);for(let s=0;s<4;s++)i[s]=t.getUint32(s*4);return i}initTable(){let e=this.sBox,t=this.invSBox,i=this.subMix,s=i[0],n=i[1],a=i[2],o=i[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],x=f[R],N=f[x],w=f[A]*257^A*16843008;s[g]=w<<24|w>>>8,n[g]=w<<16|w>>>16,a[g]=w<<8|w>>>24,o[g]=w,w=N*16843009^x*65537^R*257^g*16843008,d[A]=w<<24|w>>>8,c[A]=w<<16|w>>>16,u[A]=w<<8|w>>>24,h[A]=w,g?(g=R^f[f[f[N^R]]],E^=f[f[E]]):g=E=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),i=!0,s=0;for(;s<t.length&&i;)i=t[s]===this.key[s],s++;if(i)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,x;for(o=0;o<a;o++){if(o<n){R=d[o]=t[o];continue}x=R,o%n===0?(x=x<<8|x>>>24,x=u[x>>>24]<<24|u[x>>>16&255]<<16|u[x>>>8&255]<<8|u[x&255],x^=h[o/n|0]<<24):n>6&&o%n===4&&(x=u[x>>>24]<<24|u[x>>>16&255]<<16|u[x>>>8&255]<<8|u[x&255]),d[o]=R=(d[o-n]^x)>>>0}for(l=0;l<a;l++)o=a-l,l&3?x=d[o]:x=d[o-4],l<4||o<=4?c[l]=x:c[l]=g[u[x>>>24]]^E[u[x>>>16&255]]^T[u[x>>>8&255]]^A[u[x&255]],c[l]=c[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){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_(i),f=h[0],g=h[1],E=h[2],T=h[3],A=new Int32Array(e),R=new Int32Array(A.length),x,N,w,$,O,H,q,P,X,j,Ae,Ee,ye,we,Se=this.networkToHostOrderSwap;for(;t<A.length;){for(X=Se(A[t]),j=Se(A[t+1]),Ae=Se(A[t+2]),Ee=Se(A[t+3]),O=X^n[0],H=Ee^n[1],q=Ae^n[2],P=j^n[3],ye=4,we=1;we<s;we++)x=l[O>>>24]^d[H>>16&255]^c[q>>8&255]^u[P&255]^n[ye],N=l[H>>>24]^d[q>>16&255]^c[P>>8&255]^u[O&255]^n[ye+1],w=l[q>>>24]^d[P>>16&255]^c[O>>8&255]^u[H&255]^n[ye+2],$=l[P>>>24]^d[O>>16&255]^c[H>>8&255]^u[q&255]^n[ye+3],O=x,H=N,q=w,P=$,ye=ye+4;x=a[O>>>24]<<24^a[H>>16&255]<<16^a[q>>8&255]<<8^a[P&255]^n[ye],N=a[H>>>24]<<24^a[q>>16&255]<<16^a[P>>8&255]<<8^a[O&255]^n[ye+1],w=a[q>>>24]<<24^a[P>>16&255]<<16^a[O>>8&255]<<8^a[H&255]^n[ye+2],$=a[P>>>24]<<24^a[O>>16&255]<<16^a[H>>8&255]<<8^a[q&255]^n[ye+3],R[t]=Se(x^f),R[t+1]=Se($^g),R[t+2]=Se(w^E),R[t+3]=Se(N^T),f=X,g=j,E=Ae,T=Ee,t=t+4}return R.buffer}},HT=16,qn=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 i=self.crypto;i&&(this.subtle=i.subtle||i.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 i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?GT(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,i);let a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i)}softwareDecrypt(e,t,i){let{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Hr(a,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;s&&(i=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Lu),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,i),this.currentIV=Gr(o,-16).buffer,d||null}webCryptoDecrypt(e,t,i){let s=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new Iu(s,t)),this.fastAesKey.expandKey().then(n=>s?(this.logOnce("WebCrypto AES decrypt"),new xu(s,new Uint8Array(i)).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,i)))}onWebCryptoError(e,t,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i);let s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,i=e.length-e.length%HT;return i!==e.length&&(t=Gr(e,0,i),this.remainderData=Gr(e,i)),t}logOnce(e){!this.logEnabled||(M.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},VT={toString:function(r){let e="",t=r.length;for(let i=0;i<t;i++)e+=`[${r.start(i).toFixed(3)}-${r.end(i).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"},Yn=class extends Su{constructor(e,t,i,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 _u(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new qn(e.config),e.on(y.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 i=t.partList;if(i!=null&&i.length){let n=i[i.length-1];return qe.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 i=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.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:i,mediaBuffer:s,state:n}=this,a=i?i.currentTime:0,o=qe.bufferInfo(s||i,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)}}i&&(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,i){this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){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,i,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(y.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:i}=this;if(i.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)&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===Tt.PARTIAL&&i.removeFragment(e))}flushMainBuffer(e,t,i=null){if(!(e-t))return;let s={startOffset:e,endOffset:t,type:i};this.hls.trigger(y.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{if(!i||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{let{hls:s}=this,{payload:n}=i,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(y.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(y.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),i.payload=l,i})}return i}).then(i=>{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(i.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),i.frag===s&&n.trigger(y.FRAG_BUFFERED,{stats:o,frag:s,part:null,id:e.type}),this.tick()}).catch(i=>{this.state===W.STOPPED||this.state===W.ERROR||(this.warn(i),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 i,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:[${((i=e.startPTS)!=null?i:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?VT.toString(qe.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:i,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new Wn(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=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(y.KEY_LOADED,c),this.state===W.KEY_LOADING&&(this.state=W.IDLE),c}),this.hls.trigger(y.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),i=Math.max(e.start,i||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let c=a.partList;if(c&&s){i>e.end&&a.fragmentHint&&(e=a.fragmentHint);let u=this.getNextPart(c,e,i);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(i.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(y.FRAG_LOADING,{frag:e,part:h,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(c,i))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(i.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(y.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,i,s){return new Promise((n,a)=>{var o;let l=[],d=(o=i.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(y.FRAG_LOADED,h);let g=Xp(i,e.sn,u.index+1)||Fg(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(y.ERROR,t)}else this.hls.trigger(y.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:i,part:s,level:n}=t,a=self.performance.now();i.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(i,s,n,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:i}=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?Xp(o,n,a):null,d=l?l.fragment:RT(o,n,i);return d?(i&&i!==d&&(d.stats=i.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,i,s){var n;if(!e||this.state!==W.PARSING)return;let{data1:a,data2:o}=e,l=a;if(a&&o&&(l=Hr(a,o)),!((n=l)!=null&&n.length))return;let d={type:e.type,frag:t,part:i,chunkMeta:s,parent:t.type,data:l};this.hls.trigger(y.BUFFER_APPENDING,d),e.dropped&&e.independent&&!i&&this.flushBufferGap(t)}flushBufferGap(e){let t=this.media;if(!t)return;if(!qe.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let i=t.currentTime,s=qe.bufferInfo(t,i,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),i+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){let i=this.getLoadPosition();return ce(i)?this.getFwdBufferInfoAtPos(e,i,t):null}getFwdBufferInfoAtPos(e,t,i){let{config:{maxBufferHole:s}}=this,n=qe.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&n.nextStart<a.end)return qe.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){let{config:t}=this,i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e){let t=this.config,i=e||t.maxBufferLength;return t.maxMaxBufferLength>=i?(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,t=ge.MAIN){let i=this.fragmentTracker.getAppendedFrag(e,ge.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){let i=t.fragments,s=i.length;if(!s)return null;let{config:n}=this,a=i[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,i),this.startPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=i[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 i=this.fragmentTracker.getState(e);return(i===Tt.OK||i===Tt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,s,n){let a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&i.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s);if(l!==null&&i.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,i){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&&i<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 i=e[e.length-1];return i&&t>i.start&&i.loaded}getInitialLiveFragment(e,t){let i=this.fragPrevious,s=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),s=wT(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){let n=i.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];i.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=CT(t,i.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,i){let{config:s}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=i,{fragmentHint:l}=i,d=s.maxFragLookUpTolerance,c=i.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=Vn(n,a,e,f)}else h=a[a.length-1];if(h){let f=h.sn-i.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:i}=this;if(!i)return;let s=this.hls.liveSyncPosition,n=i.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&i.duration>s&&(n<s||!l)){let d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&i.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),i.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)}`),i.currentTime=s))}}alignPlaylists(e,t){let{levels:i,levelLastLoaded:s,fragPrevious:n}=this,a=s!==null?i[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){UT(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 i=this.startPosition;if(i<t&&(i=-1),i===-1||this.lastCurrentTime===-1){let s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&ce(n)?(i=t+n,n<0&&(i+=e.totalduration),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):e.live?i=this.hls.liveSyncPosition||t:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}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 i=t.frag;if(!i||i.type!==e||!this.levels)return;if(this.fragContextChanged(i)){var s;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}let n=t.details===B.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);let a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===Ft.RetryRequest&&d){var c;this.resetStartWhenNotLoaded((c=this.levelLastLoaded)!=null?c:i.level);let u=dh(d,l);this.warn(`Fragment ${i.sn} of ${e} ${i.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)===Ft.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,i=this.getFwdBufferInfo(this.mediaBuffer,t),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.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,i){if(!e)return;let s=qe.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,i),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,i,s){var n;let a=i.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:Pg(a,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS);return this.hls.trigger(y.LEVEL_PTS_UPDATED,{details:a,level:i,drift:h,type:d,frag:e,start:c.startPTS,end:c.endPTS}),!0}return l},!1))i.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 ${i.id} resetting transmuxer to fallback to playlist timing`);if(this.warn(l.message),this.hls.trigger(y.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 "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=W.PARSED,this.hls.trigger(y.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){if(e.event==="demuxerWorker"){var t,i,s;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((t=(i=this.levelLastLoaded)!=null?i:(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 Gg(){return self.SourceBuffer||self.WebKitSourceBuffer}function KT(){let r=Al();if(!r)return!1;let e=Gg(),t=r&&typeof r.isTypeSupported=="function"&&r.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function";return!!t&&!!i}function WT(){var r;let e=Gg();return typeof(e==null||(r=e.prototype)==null?void 0:r.changeType)=="function"}function qT(){return typeof __HLS_WORKER_BUNDLE__=="function"}function YT(){let r=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(r);return{worker:new self.Worker(e),objectURL:e}}function jT(r){let e=new self.URL(r,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function Pi(r="",e=9e4){return{type:r,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var dl=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,i,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,i){}demux(e,t){this.cachedData&&(e=Hr(this.cachedData,e),this.cachedData=null);let i=rl(e,0),s=i?i.length:0,n,a=this._audioTrack,o=this._id3Track,l=i?Hb(i):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&ce(l))&&(this.basePTS=zT(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:pi.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 Gb(e,s)?(i=rl(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:pi.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,n=s):s++;if(s===d&&n!==d){let c=Gr(e,n);this.cachedData?this.cachedData=Hr(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:Pi(),id3Track:o,textTrack:Pi()}}demuxSampleAes(e,t,i){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:Pi(),id3Track:this._id3Track,textTrack:Pi()}}destroy(){}},zT=(r,e,t)=>{if(ce(r))return r*90;let i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};function XT(r,e,t,i){let s,n,a,o,l=navigator.userAgent.toLowerCase(),d=i,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){r.trigger(y.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:${i}, 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),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&u>=6?n=u-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(u>=6&&a===1||/vivaldi/i.test(l))||!i&&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 Hg(r,e){return r[e]===255&&(r[e+1]&246)===240}function Vg(r,e){return r[e+1]&1?7:9}function uh(r,e){return(r[e+3]&3)<<11|r[e+4]<<3|(r[e+5]&224)>>>5}function QT(r,e){return e+5<r.length}function cl(r,e){return e+1<r.length&&Hg(r,e)}function ZT(r,e){return QT(r,e)&&Hg(r,e)&&uh(r,e)<=r.length-e}function JT(r,e){if(cl(r,e)){let t=Vg(r,e);if(e+t>=r.length)return!1;let i=uh(r,e);if(i<=t)return!1;let s=e+i;return s===r.length||cl(r,s)}return!1}function Kg(r,e,t,i,s){if(!r.samplerate){let n=XT(e,t,i,s);if(!n)return;r.config=n.config,r.samplerate=n.samplerate,r.channelCount=n.channelCount,r.codec=n.codec,r.manifestCodec=n.manifestCodec,M.log(`parsed codec:${r.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Wg(r){return 1024*9e4/r}function e_(r,e){let t=Vg(r,e);if(e+t<=r.length){let i=uh(r,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function qg(r,e,t,i,s){let n=Wg(r.samplerate),a=i+s*n,o=e_(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||r.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 Ru=class extends dl{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,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 i=(rl(e,0)||[]).length;for(let s=e.length;i<s;i++)if(JT(e,i))return M.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return ZT(e,t)}appendFrame(e,t,i){Kg(e,this.observer,t,i,e.manifestCodec);let s=qg(e,t,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},t_=/\/emsg[-/]ID3/i,ku=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,i,s){let n=this.videoTrack=Pi("video",1),a=this.audioTrack=Pi("audio",1),o=this.txtTrack=Pi("text",1);if(this.id3Track=Pi("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=Rg(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=xg.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 i=e,s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=Hr(this.remainderData,e));let o=rT(i);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=i;let a=this.extractID3Track(s,t);return n.samples=Np(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(t,this.timeOffset);return i.samples=Np(e,t),{videoTrack:t,audioTrack:Pi(),id3Track:s,textTrack:Pi()}}extractID3Track(e,t){let i=this.id3Track;if(e.samples.length){let s=Pe(e.samples,["emsg"]);s&&s.forEach(n=>{let a=aT(n);if(t_.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;i.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:pi.emsg,duration:l})}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},zo=null,i_=[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],r_=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],s_=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],n_=[0,1,1,4];function Yg(r,e,t,i,s){if(t+24>e.length)return;let n=jg(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=i+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return r.config=[],r.channelCount=n.channelCount,r.samplerate=n.sampleRate,r.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function jg(r,e){let t=r[e+1]>>3&3,i=r[e+1]>>1&3,s=r[e+2]>>4&15,n=r[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){let a=r[e+2]>>1&1,o=r[e+3]>>6,l=t===3?3-i:i===3?3:4,d=i_[l*14+s-1]*1e3,u=r_[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=s_[t][i],g=n_[i],E=f*8*g,T=Math.floor(f*d/u+a)*g;if(zo===null){let x=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);zo=x?parseInt(x[1]):0}return!!zo&&zo<=87&&i===2&&d>=224e3&&o===0&&(r[e+3]=r[e+3]|128),{sampleRate:u,channelCount:h,frameLength:T,samplesPerFrame:E}}}function hh(r,e){return r[e]===255&&(r[e+1]&224)===224&&(r[e+1]&6)!==0}function zg(r,e){return e+1<r.length&&hh(r,e)}function a_(r,e){return hh(r,e)&&4<=r.length-e}function o_(r,e){if(e+1<r.length&&hh(r,e)){let i=jg(r,e),s=4;i!=null&&i.frameLength&&(s=i.frameLength);let n=e+s;return n===r.length||zg(r,n)}return!1}var ul=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,i=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(i,i+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),i=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?i<<t|this.readBits(t):i}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,i=8,s;for(let n=0;n<e;n++)i!==0&&(s=this.readEG(),i=(t+s+256)%256),t=i===0?t:i}readSPS(){let e=0,t=0,i=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(),x=c(),N=d(1);N===0&&h(1),h(1),u()&&(e=c(),t=c(),i=c(),s=c());let w=[1,1];if(u()&&u())switch(l()){case 1:w=[1,1];break;case 2:w=[12,11];break;case 3:w=[10,11];break;case 4:w=[16,11];break;case 5:w=[40,33];break;case 6:w=[24,11];break;case 7:w=[20,11];break;case 8:w=[32,11];break;case 9:w=[80,33];break;case 10:w=[18,11];break;case 11:w=[15,11];break;case 12:w=[64,33];break;case 13:w=[160,99];break;case 14:w=[4,3];break;case 15:w=[3,2];break;case 16:w=[2,1];break;case 255:{w=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((R+1)*16-e*2-t*2),height:(2-N)*(x+1)*16-(N?2:4)*(i+s),pixelRatio:w}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},wu=class{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new qn(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,i){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,i)})}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)i.set(e.subarray(n,n+16),s);return i}getAvcDecryptedUnit(e,t){let i=new Uint8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(i.subarray(s,s+16),n);return e}decryptAvcSample(e,t,i,s,n){let a=Dg(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,i+1,s)})}decryptAvcSamples(e,t,i,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){s();return}let n=e[t].units;for(;!(i>=n.length);i++){let a=n[i];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,i,s,a),!this.decrypter.isSync()))return}}}},Ot=188,Ni=class{constructor(e,t,i){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=i}static probe(e){let t=Ni.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,i=Math.min(Ot*5,e.length-Ot)+1,s=0;for(;s<i;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=Ot)if(e[l]===71){if(o++,a===-1&&(a=l,a!==0&&(i=Math.min(a+Ot*99,e.length-Ot)+1)),n||(n=Du(e,l)===0),n&&o>1&&(a===0&&o>2||l+Ot>i))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:xg[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,s){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Ni.createTrack("video"),this._audioTrack=Ni.createTrack("audio",s),this._id3Track=Ni.createTrack("id3"),this._txtTrack=Ni.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,this._duration=s}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_avcTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,t,i=!1,s=!1){i||(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,x=e.length;if(this.remainderData&&(e=Hr(this.remainderData,e),x=e.length,this.remainderData=null),x<Ot&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let N=Math.max(0,Ni.syncOffset(e));x-=(x-N)%Ot,x<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,x,e.buffer.byteLength-x));let w=0;for(let O=N;O<x;O+=Ot)if(e[O]===71){let H=!!(e[O+1]&64),q=Du(e,O),P=(e[O+3]&48)>>4,X;if(P>1){if(X=O+5+e[O+4],X===O+Ot)continue}else X=O+4;switch(q){case c:H&&(u&&(n=Gs(u))&&this.parseAVCPES(a,d,n,!1),u={data:[],size:0}),u&&(u.data.push(e.subarray(X,O+Ot)),u.size+=O+Ot-X);break;case h:if(H){if(g&&(n=Gs(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+Ot)),g.size+=O+Ot-X);break;case f:H&&(E&&(n=Gs(E))&&this.parseID3PES(l,n),E={data:[],size:0}),E&&(E.data.push(e.subarray(X,O+Ot)),E.size+=O+Ot-X);break;case 0:H&&(X+=e[X]+1),R=this._pmtId=l_(e,X);break;case R:{H&&(X+=e[X]+1);let j=d_(e,X,this.typeSupported,i);c=j.avc,c>0&&(a.pid=c),h=j.audio,h>0&&(o.pid=h,o.segmentCodec=j.segmentCodec),f=j.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=q;break}}else w++;if(w>0){let O=new Error(`Found ${w} TS packet/s that do not start with 0x47`);this.observer.emit(y.ERROR,y.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:i,id3Track:s,textTrack:n}=e,a=i.pesData,o=t.pesData,l=s.pesData,d;if(a&&(d=Gs(a))?(this.parseAVCPES(i,n,d,!0),i.pesData=null):i.pesData=a,o&&(d=Gs(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=Gs(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,i){let s=this.demux(e,i,!0,!this.config.progressive),n=this.sampleAes=new wu(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(i=>{let{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{i(e)}):i(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{i(e)})})}destroy(){this._duration=0}parseAVCPES(e,t,i,s){let n=this.parseAVCNALu(e,i.data),a=this.avcSample,o,l=!1;i.data=null,a&&n.length&&!e.audFound&&(jc(a,e),a=this.avcSample=Xo(!1,i.pts,i.dts,"")),n.forEach(d=>{switch(d.type){case 1:{o=!0,a||(a=this.avcSample=Xo(!0,i.pts,i.dts,"")),a.frame=!0;let c=d.data;if(l&&c.length>4){let u=new ul(c).readSliceType();(u===2||u===4||u===7||u===9)&&(a.key=!0)}break}case 5:o=!0,a||(a=this.avcSample=Xo(!0,i.pts,i.dts,"")),a.key=!0,a.frame=!0;break;case 6:{o=!0,wg(d.data,1,i.pts,t.samples);break}case 7:if(o=!0,l=!0,!e.sps){let c=d.data,h=new ul(c).readSPS();e.width=h.width,e.height=h.height,e.pixelRatio=h.pixelRatio,e.sps=[c],e.duration=this._duration;let f=c.subarray(1,4),g="avc1.";for(let E=0;E<3;E++){let T=f[E].toString(16);T.length<2&&(T="0"+T),g+=T}e.codec=g}break;case 8:o=!0,e.pps||(e.pps=[d.data]);break;case 9:o=!1,e.audFound=!0,a&&jc(a,e),a=this.avcSample=Xo(!1,i.pts,i.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&&(jc(a,e),this.avcSample=null)}getLastNalUnit(e){var t;let i=this.avcSample,s;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){let n=i.units;s=n[n.length-1]}return s}parseAVCNALu(e,t){let i=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<i;){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<i?(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,i),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 i=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),i=s.missing}}let a,o;for(a=i,o=n.length;a<o-1&&!cl(n,a);a++);if(a!==i){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(y.ERROR,y.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,levelRetry:h,error:f,reason:u}),!h)return}Kg(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let u=Wg(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=qg(e,n,a,l,d),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(d++;a<o-1&&!cl(n,a);a++);}parseMPEGPES(e,t){let i=t.data,s=i.length,n=0,a=0,o=t.pts;if(o===void 0){M.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(zg(i,a)){let l=Yg(e,i,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 i=pt({},t,{type:this._avcTrack?pi.emsg:pi.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}};function Xo(r,e,t,i){return{key:r,frame:!1,pts:e,dts:t,units:[],debug:i,length:0}}function Du(r,e){return((r[e+1]&31)<<8)+r[e+2]}function l_(r,e){return(r[e+10]&31)<<8|r[e+11]}function d_(r,e,t,i){let s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=(r[e+1]&15)<<8|r[e+2],a=e+3+n-4,o=(r[e+10]&15)<<8|r[e+11];for(e+=12+o;e<a;){let l=Du(r,e);switch(r[e]){case 207:if(!i){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(!i){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+=((r[e+3]&15)<<8|r[e+4])+5}return s}function Gs(r){let e=0,t,i,s,n,a,o=r.data;if(!r||r.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(i=(t[4]<<8)+t[5],i&&i>r.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(r.size<=c)return null;r.size-=c;let u=new Uint8Array(r.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 i&&(i-=s+3),{data:u,pts:n,dts:a,len:i}}return null}function jc(r,e){if(r.units.length&&r.frame){if(r.pts===void 0){let t=e.samples,i=t.length;if(i){let s=t[i-1];r.pts=s.pts,r.dts=s.dts}else{e.dropped++;return}}e.samples.push(r)}r.debug.length&&M.log(r.pts+"/"+r.dts+":"+r.debug)}var Cu=class extends dl{resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,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 i=(rl(e,0)||[]).length;for(let s=e.length;i<s;i++)if(o_(e,i))return M.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return a_(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return Yg(e,t,i,this.basePTS,this.frameIndex)}},hl=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,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]),i=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:i};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 i=8,s=t.length,n=s;for(;s--;)i+=t[s].byteLength;let a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=i&255,a.set(e,4),s=0,i=8;s<n;s++)a.set(t[s],i),i+=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 i=Math.floor(t/(pr+1)),s=Math.floor(t%(pr+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,i>>24,i>>16&255,i>>8&255,i&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,i){return F.box(F.types.moof,F.mfhd(e),F.traf(i,t))}static moov(e){let t=e.length,i=[];for(;t--;)i[t]=F.trak(e[t]);return F.box.apply(null,[F.types.moov,F.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(F.mvex(e)))}static mvex(e){let t=e.length,i=[];for(;t--;)i[t]=F.trex(e[t]);return F.box.apply(null,[F.types.mvex,...i])}static mvhd(e,t){t*=e;let i=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,i>>24,i>>16&255,i>>8&255,i&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||[],i=new Uint8Array(4+t.length),s,n;for(s=0;s<t.length;s++)n=t[s].flags,i[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return F.box(F.types.sdtp,i)}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=[],i=[],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,i.push(a>>>8&255),i.push(a&255),i=i.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(i))),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,i=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(i/(pr+1)),o=Math.floor(i%(pr+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 i=F.sdtp(e),s=e.id,n=Math.floor(t/(pr+1)),a=Math.floor(t%(pr+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,i.length+16+20+8+16+8+8),i)}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 i=e.samples||[],s=i.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=i[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),i=new Uint8Array(F.FTYP.byteLength+t.byteLength);return i.set(F.FTYP),i.set(t,F.FTYP.byteLength),i}};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 Xg=9e4;function fh(r,e,t=1,i=!1){let s=r*e*t;return i?Math.round(s):s}function c_(r,e,t=1,i=!1){return fh(r,e,1/t,i)}function Fn(r,e=!1){return fh(r,1e3,1/Xg,e)}function u_(r,e=1){return fh(r,Xg,1/e)}var h_=10*1e3,sg=1024,f_=1152,Qo=null,zc=null,Gn=class{constructor(e,t,i,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=i,this.ISGenerated=!1,Qo===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Qo=a?parseInt(a[1]):0}if(zc===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);zc=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,i=e.reduce((s,n)=>{let a=n.pts-s;return a<-4294967296?(t=!0,ai(s,n.pts)):a>0?s:n.pts},e[0].pts);return t&&M.debug("PTS rollover detected"),i}remux(e,t,i,s,n,a,o,l){let d,c,u,h,f,g,E=n,T=n,A=e.pid>-1,R=t.pid>-1,x=t.samples.length,N=e.samples.length>0,w=o&&x>0||x>1;if((!A||N)&&(!R||w)||this.ISGenerated||o){this.ISGenerated||(u=this.generateIS(e,t,n,a));let O=this.isVideoContiguous,H=-1,q;if(w&&(H=m_(t.samples),!O&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,H>0){M.warn(`[mp4-remuxer]: Dropped ${H} out of ${x} video samples due to a missing keyframe`);let P=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(H),t.dropped+=H,T+=(t.samples[0].pts-P)/t.inputTimeScale,q=T}else H===-1&&(M.warn(`[mp4-remuxer]: No keyframe found out of ${x} video samples`),g=!1);if(this.ISGenerated){if(N&&w){let P=this.getVideoStartPts(t.samples),j=(ai(e.samples[0].pts,P)-P)/t.inputTimeScale;E+=Math.max(0,j),T+=Math.max(0,-j)}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,R||w||l===ge.AUDIO?T:void 0),w){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 w&&(d=this.remuxVideo(t,T,O,0));d&&(d.firstKeyFrame=H,d.independent=H!==-1,d.firstKeyFramePTS=q)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(f=Qg(i,n,this._initPTS,this._initDTS)),s.samples.length&&(h=Zg(s,n,this._initPTS))),{audio:c,video:d,initSegment:u,independent:g,text:h,id3:f}}generateIS(e,t,i,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*i):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*i);f=Math.min(f,ai(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,i,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(!i||c===null){let Z=t*n,ae=a[0].pts-ai(a[0].dts,a[0].pts);c=Z-ae}let R=d.baseTime*n/d.timescale;for(let Z=0;Z<l;Z++){let ae=a[Z];ae.pts=ai(ae.pts-R,c),ae.dts=ai(ae.dts-R,c),ae.dts<a[Z>0?Z-1:Z].dts&&(A=!0)}A&&a.sort(function(Z,ae){let se=Z.dts-ae.dts,xe=Z.pts-ae.pts;return se||xe}),f=a[0].dts,g=a[a.length-1].dts;let x=g-f,N=x?Math.round(x/(l-1)):h||e.inputTimeScale/30;if(i){let Z=f-c,ae=Z>N,se=Z<-1;if((ae||se)&&(ae?M.warn(`AVC: ${Fn(Z,!0)} ms (${Z}dts) hole between fragments detected, filling it`):M.warn(`AVC: ${Fn(-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: ${Fn(xe,!0)}/${Fn(f,!0)}, delta: ${Fn(Z,!0)} ms`)}}f=Math.max(0,f);let w=0,$=0;for(let Z=0;Z<l;Z++){let ae=a[Z],se=ae.units,xe=se.length,Ie=0;for(let $e=0;$e<xe;$e++)Ie+=se[$e].data.length;$+=Ie,w+=xe,ae.length=Ie,ae.dts=Math.max(ae.dts,f),E=Math.min(ae.pts,E),T=Math.max(ae.pts,T)}g=a[l-1].dts;let O=$+4*w+8,H;try{H=new Uint8Array(O)}catch(Z){this.observer.emit(y.ERROR,y.ERROR,{type:pe.MUX_ERROR,details:B.REMUX_ALLOC_ERROR,fatal:!1,error:Z,bytes:O,reason:`fail allocating video mdat ${O}`});return}let q=new DataView(H.buffer);q.setUint32(0,O),H.set(F.types.mdat,4);let P=!1,X=Number.POSITIVE_INFINITY,j=Number.POSITIVE_INFINITY,Ae=Number.NEGATIVE_INFINITY,Ee=Number.NEGATIVE_INFINITY;for(let Z=0;Z<l;Z++){let ae=a[Z],se=ae.units,xe=0;for(let ht=0,V=se.length;ht<V;ht++){let J=se[ht],Re=J.data,Je=J.data.byteLength;q.setUint32(u,Je),u+=4,H.set(Re,u),u+=Je,xe+=4+Je}let Ie;if(Z<l-1)h=a[Z+1].dts-ae.dts,Ie=a[Z+1].pts-ae.pts;else{let ht=this.config,V=Z>0?ae.dts-a[Z-1].dts:N;if(Ie=Z>0?ae.pts-a[Z-1].pts:N,ht.stretchShortVideoTrack&&this.nextAudioPts!==null){let J=Math.floor(ht.maxBufferHole*n),Re=(s?E+s*n:this.nextAudioPts)-ae.pts;Re>J?(h=Re-V,h<0?h=V:P=!0,M.log(`[mp4-remuxer]: It is approximately ${Re/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=V}else h=V}let $e=Math.round(ae.pts-ae.dts);X=Math.min(X,h),Ae=Math.max(Ae,h),j=Math.min(j,Ie),Ee=Math.max(Ee,Ie),o.push(new fl(ae.key,h,xe,$e))}if(o.length){if(Qo){if(Qo<70){let Z=o[0].flags;Z.dependsOn=2,Z.isNonSync=0}}else if(zc&&Ee-j<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 ae=0,se=o.length;ae<se;ae++){let xe=Z+o[ae].duration,Ie=Z+o[ae].cts;if(ae<se-1){let $e=xe+o[ae+1].cts;o[ae].duration=$e-Ie}else o[ae].duration=ae?o[ae-1].duration:N;o[ae].cts=0,Z=xe}}}h=P||!h?N:h,this.nextAvcDts=c=g+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let ye=F.moof(e.sequenceNumber++,f,pt({},e,{samples:o})),we="video",Se={data1:ye,data2:H,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,i,s,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=e.segmentCodec==="aac"?sg:f_,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,x=u.baseTime*a/u.timescale;if(this.isAudioContiguous=i=i||E.length&&A>0&&(s&&Math.abs(R-A)<9e3||Math.abs(ai(E[0].pts-x,R)-A)<20*c),E.forEach(function(we){we.pts=ai(we.pts-x,R)}),!i||A<0){if(E=E.filter(we=>we.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 we=this.config.maxAudioFramesDrift;for(let Se=0,Z=A;Se<E.length;Se++){let ae=E[Se],se=ae.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<h_&&g){let $e=Math.round(xe/c);Z=se-$e*c,Z<0&&($e--,Z+=c),Se===0&&(this.nextAudioPts=A=Z),M.warn(`[mp4-remuxer]: Injecting ${$e} audio frame @ ${(Z/a).toFixed(3)}s due to ${Math.round(1e3*xe/a)} ms gap.`);for(let ht=0;ht<$e;ht++){let V=Math.max(Z,0),J=hl.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);J||(M.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),J=ae.unit.subarray()),E.splice(Se,0,{unit:J,pts:V}),Z+=c,Se++}}ae.pts=Z,Z+=c}}let N=null,w=null,$,O=0,H=E.length;for(;H--;)O+=E[H].unit.byteLength;for(let we=0,Se=E.length;we<Se;we++){let Z=E[we],ae=Z.unit,se=Z.pts;if(w!==null){let Ie=f[we-1];Ie.duration=Math.round((se-w)/l)}else if(i&&e.segmentCodec==="aac"&&(se=A),N=se,O>0){O+=T;try{$=new Uint8Array(O)}catch(Ie){this.observer.emit(y.ERROR,y.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(ae,T);let xe=ae.byteLength;T+=xe,f.push(new fl(!0,d,xe,0)),w=se}let q=f.length;if(!q)return;let P=f[f.length-1];this.nextAudioPts=A=w+l*P.duration;let X=h?new Uint8Array(0):F.moof(e.sequenceNumber++,N/l,pt({},e,{samples:f}));e.samples=[];let j=N/a,Ae=A/a,ye={data1:X,data2:$,startPTS:j,endPTS:Ae,startDTS:j,endDTS:Ae,type:"audio",hasAudio:!0,hasVideo:!1,nb:q};return this.isAudioContiguous=!0,ye}remuxEmptyAudio(e,t,i,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*sg,g=Math.ceil((h-u)/f),E=hl.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 R=u+A*f;T.push({unit:E,pts:R,dts:R})}return e.samples=T,this.remuxAudio(e,t,i,!1)}};function ai(r,e){let t;if(e===null)return r;for(e<r?t=-8589934592:t=8589934592;Math.abs(r-e)>4294967296;)r+=t;return r}function m_(r){for(let e=0;e<r.length;e++)if(r[e].key)return e;return-1}function Qg(r,e,t,i){let s=r.samples.length;if(!s)return;let n=r.inputTimeScale;for(let o=0;o<s;o++){let l=r.samples[o];l.pts=ai(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=ai(l.dts-i.baseTime*n/i.timescale,e*n)/n}let a=r.samples;return r.samples=[],{samples:a}}function Zg(r,e,t){let i=r.samples.length;if(!i)return;let s=r.inputTimeScale;for(let a=0;a<i;a++){let o=r.samples[a];o.pts=ai(o.pts-t.baseTime*9e4/t.timescale,e*s)/s}r.samples.sort((a,o)=>a.pts-o.pts);let n=r.samples;return r.samples=[],{samples:n}}var fl=class{constructor(e,t,i,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=i,this.cts=s,this.flags=new Mu(e)}},Mu=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}},Ou=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,i,s){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(Zb(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:i}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let s=this.initData=Rg(e);t||(t=ng(s.audio,Ve.AUDIO)),i||(i=ng(s.video,Ve.VIDEO));let n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+i,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:i,initSegment:e,id:"main"}:M.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,i,s,n,a){var o,l;let{initPTS:d,lastEndTime:c}=this,u={audio:void 0,video:void 0,text:s,id3:i,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=eT(h,g),T=Jb(g,h),A=T===null?n:T;(p_(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 R=e?A-d.baseTime/d.timescale:c,x=R+E;iT(g,h,d.baseTime/d.timescale),E>0?this.lastEndTime=x:(M.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let N=!!g.audio,w=!!g.video,$="";N&&($+="audio"),w&&($+="video");let O={data1:h,startPTS:R,startDTS:R,endPTS:x,endDTS:x,type:$,hasAudio:N,hasVideo:w,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=Qg(i,n,d,d),s.samples.length&&(u.text=Zg(s,n,d)),u}};function p_(r,e,t,i){if(r===null)return!0;let s=Math.max(i,1),n=e-r.baseTime/r.timescale;return Math.abs(n-t)>s}function ng(r,e){let t=r==null?void 0:r.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===Ve.VIDEO?"avc1.42e01e":"mp4a.40.5"}var zi;try{zi=self.performance.now.bind(self.performance)}catch{M.debug("Unable to use Performance API on this environment"),zi=typeof self!="undefined"&&self.Date.now}var Xc=[{demux:ku,remux:Ou},{demux:Ni,remux:Gn},{demux:Ru,remux:Gn},{demux:Cu,remux:Gn}],ml=class{constructor(e,t,i,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=i,this.vendor=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,s){let n=i.transmuxing;n.executeStart=zi();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:x}=l,N=g_(a,t);if(N&&N.method==="AES-128"){let H=this.getDecrypter();if(H.isSync()){let q=H.softwareDecrypt(a,N.key.buffer,N.iv.buffer);if(i.part>-1&&(q=H.flush()),!q)return n.executeEnd=zi(),Qc(i);a=new Uint8Array(q)}else return this.decryptionPromise=H.webCryptoDecrypt(a,N.key.buffer,N.iv.buffer).then(q=>{let P=this.push(q,null,i);return this.decryptionPromise=null,P}),this.decryptionPromise}let w=this.needsProbing(c,u);if(w){let H=this.configureTransmuxer(a);if(H)return M.warn(`[transmuxer] ${H.message}`),this.observer.emit(y.ERROR,y.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:H,reason:H.message}),n.executeEnd=zi(),Qc(i)}(c||u||g||w)&&this.resetInitSegment(x,E,T,R,t),(c||g||w)&&this.resetInitialTimestamp(A),d||this.resetContiguity();let $=this.transmux(a,N,f,h,i),O=this.currentTransmuxState;return O.contiguous=!0,O.discontinuity=!1,O.trackSwitch=!1,n.executeEnd=zi(),$}flush(e){let t=e.transmuxing;t.executeStart=zi();let{decrypter:i,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=s;if(i){let u=i.flush();u&&a.push(this.push(u,null,e))}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=zi(),[Qc(e)];let c=l.flush(o);return el(c)?c.then(u=>(this.flushRemux(a,u,e),a)):(this.flushRemux(a,c,e),a)}flushRemux(e,t,i){let{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;M.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);let c=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:c,chunkMeta:i}),i.transmuxing.executeEnd=zi()}resetInitialTimestamp(e){let{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,s,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,i,s),o.resetInitSegment(e,t,i,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,i,s,n):a=this.transmuxUnencrypted(e,i,s,n),a}transmuxUnencrypted(e,t,i,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,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,i,s,n){return this.demuxer.demuxSampleAes(e,t,i).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,i,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:i,typeSupported:s,vendor:n}=this,a;for(let u=0,h=Xc.length;u<h;u++)if(Xc[u].demux.probe(e)){a=Xc[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(i,t,s,n)),(!o||!(o instanceof c))&&(this.demuxer=new c(i,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 qn(this.config)),e}};function g_(r,e){let t=null;return r.byteLength>0&&e!=null&&e.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var Qc=r=>({remuxResult:{},chunkMeta:r});function el(r){return"then"in r&&r.then instanceof Function}var Pu=class{constructor(e,t,i,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=i,this.duration=s,this.defaultInitPts=n||null}},Nu=class{constructor(e,t,i,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=i,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}},Jg={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__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 i:delete l._events[d]}function o(){this._events=new i,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,x;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(x=1,R=new Array(A-1);x<A;x++)R[x-1]=arguments[x];T.fn.apply(T.context,R)}else{var N=T.length,w;for(x=0;x<N;x++)switch(T[x].once&&this.removeListener(d,T[x].fn,void 0,!0),A){case 1:T[x].fn.call(T[x].context);break;case 2:T[x].fn.call(T[x].context,c);break;case 3:T[x].fn.call(T[x].context,c,u);break;case 4:T[x].fn.call(T[x].context,c,u,h);break;default:if(!R)for(w=1,R=new Array(A-1);w<A;w++)R[w-1]=arguments[w];T[x].fn.apply(T[x].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 i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,r.exports=o})(Jg);var v_=Jg.exports,mh=Sb(v_),Zc=Al()||{isTypeSupported:()=>!1},pl=class{constructor(e,t,i,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=i,this.onFlush=s;let a=(d,c)=>{c=c||{},c.frag=this.frag,c.id=this.id,d===y.ERROR&&(this.error=c.error),this.hls.trigger(d,c)};this.observer=new mh,this.observer.on(y.FRAG_DECRYPTED,a),this.observer.on(y.ERROR,a);let o={mp4:Zc.isTypeSupported("video/mp4"),mpeg:Zc.isTypeSupported("audio/mpeg"),mp3:Zc.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"&&(n.workerPath||qT())){try{n.workerPath?(M.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=jT(n.workerPath)):(M.log(`injecting Web Worker for "${t}"`),this.workerContext=YT()),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(y.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 ml(this.observer,o,n,l,t)}return}this.transmuxer=new ml(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,i,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),x=T?d.sn-T.sn:-1,N=this.part?d.part-this.part.index:-1,w=x===0&&d.id>1&&d.id===(T==null?void 0:T.stats.chunkCount),$=!R&&(x===1||x===0&&(N===1||w&&N<=0)),O=self.performance.now();(R||x||n.stats.parsing.start===0)&&(n.stats.parsing.start=O),a&&(N||!$)&&(a.stats.parsing.start=O);let H=!(T&&((u=n.initSegment)==null?void 0:u.url)===((h=T.initSegment)==null?void 0:h.url)),q=new Nu(A,$,l,R,g,H);if(!$||A||H){M.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
|
|
928
|
+
<slot name="captions-indicator" hidden>${Rb}</slot>
|
|
929
|
+
`;var wo=class extends wi{constructor(){super({slotTemplate:wp}),Lc(this,kc),Lc(this,Ro),Lc(this,ko,void 0)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",S.MEDIA_SUBTITLES_LIST,S.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===S.MEDIA_SUBTITLES_LIST&&t!==i?Rc(this,kc,kp).call(this):e===S.MEDIA_SUBTITLES_SHOWING&&t!==i?this.value=i: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",Rc(this,Ro,wc))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Rc(this,Ro,wc))}get mediaSubtitlesList(){return Lp(this,S.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Rp(this,S.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Lp(this,S.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Rp(this,S.MEDIA_SUBTITLES_SHOWING,e)}};ko=new WeakMap;kc=new WeakSet;kp=function(){var r;if(Ib(this,ko)===JSON.stringify(this.mediaSubtitlesList))return;Lb(this,ko,JSON.stringify(this.mediaSubtitlesList));let e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.value,i=fr(this.formatOptionText("Off"),"off",t);i.prepend(qi(this,"select-indicator")),e.append(i);let s=this.mediaSubtitlesList;for(let n of s){let a=fr(this.formatOptionText(n.label,n),$a(n),this.value==$a(n));a.prepend(qi(this,"select-indicator")),((r=n.kind)!=null?r:"subs")==="captions"&&a.append(qi(this,"captions-indicator")),e.append(a)}};Ro=new WeakSet;wc=function(){if(Vi(this,!1),!this.value)return;let r=new D.CustomEvent(ne.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};var Lp=(r,e)=>{let t=r.getAttribute(e);return t?vn(t):[]},Rp=(r,e,t)=>{if(!(t!=null&&t.length)){r.removeAttribute(e);return}let i=Or(t);r.getAttribute(e)!==i&&r.setAttribute(e,i)};D.customElements.get("media-captions-listbox")||D.customElements.define("media-captions-listbox",wo);var Do=class extends Mi{init(){let e=z.createElement("media-captions-button");e.part.add("button"),e.preventClick=!0;let t=z.createElement("media-captions-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, indicator");let i=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");i.textContent="",s.textContent="",i.append(e),s.append(t)}};D.customElements.get("media-captions-selectmenu")||D.customElements.define("media-captions-selectmenu",Do);var Dp=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Co=(r,e,t)=>(Dp(r,e,"read from private field"),t?t.call(r):e.get(r)),Cc=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},On=(r,e,t)=>(Dp(r,e,"access private method"),t),Bs,Pn,Mo,Oo,Oc,Mc={RATES:"rates"},Po=class extends wi{constructor(){super(),Cc(this,Pn),Cc(this,Oo),Cc(this,Bs,new lr(this,Mc.RATES,{defaultValue:Yd})),On(this,Pn,Mo).call(this)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",S.MEDIA_PLAYBACK_RATE,Mc.RATES]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===S.MEDIA_PLAYBACK_RATE&&t!=i?this.value=i:e===Mc.RATES&&t!=i&&(Co(this,Bs).value=i,On(this,Pn,Mo).call(this))}get rates(){return Co(this,Bs)}set rates(e){e?Array.isArray(e)&&(Co(this,Bs).value=e.join(" ")):Co(this,Bs).value="",On(this,Pn,Mo).call(this)}get mediaPlaybackRate(){return Ue(this,S.MEDIA_PLAYBACK_RATE,Ls)}set mediaPlaybackRate(e){Ye(this,S.MEDIA_PLAYBACK_RATE,e)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",On(this,Oo,Oc))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",On(this,Oo,Oc))}};Bs=new WeakMap;Pn=new WeakSet;Mo=function(){let r=this.shadowRoot.querySelector("#container");r.textContent="";for(let e of this.rates){let t=fr(this.formatOptionText(`${e}x`,e),e,this.mediaPlaybackRate==e);t.prepend(qi(this,"select-indicator")),r.append(t)}};Oo=new WeakSet;Oc=function(){if(!this.value)return;let r=new D.CustomEvent(ne.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};D.customElements.get("media-playback-rate-listbox")||D.customElements.define("media-playback-rate-listbox",Po);var No=class extends Mi{init(){let e=z.createElement("media-playback-rate-button");e.part.add("button"),e.preventClick=!0;let t=z.createElement("media-playback-rate-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, indicator");let i=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");i.textContent="",s.textContent="",i.append(e),s.append(t)}};D.customElements.get("media-playback-rate-selectmenu")||D.customElements.define("media-playback-rate-selectmenu",No);var Uc=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Cp=(r,e,t)=>(Uc(r,e,"read from private field"),t?t.call(r):e.get(r)),Fo=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Pc=(r,e,t,i)=>(Uc(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Uo=(r,e,t)=>(Uc(r,e,"access private method"),t),Nn,Go,Bo,Nc,$o,Fc,Ho=class extends wi{constructor(){super(...arguments),Fo(this,Bo),Fo(this,$o),Fo(this,Nn,[]),Fo(this,Go,void 0)}static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_LIST,S.MEDIA_RENDITION_SELECTED]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===S.MEDIA_RENDITION_SELECTED&&t!==i?this.value=i!=null?i:"auto":e===S.MEDIA_RENDITION_LIST&&t!==i&&(Pc(this,Nn,Qf(i)),Uo(this,Bo,Nc).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Uo(this,$o,Fc))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Uo(this,$o,Fc))}get mediaRenditionList(){return Cp(this,Nn)}set mediaRenditionList(e){Pc(this,Nn,e),Uo(this,Bo,Nc).call(this)}get mediaRenditionSelected(){return et(this,S.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Xe(this,S.MEDIA_RENDITION_SELECTED,e)}};Nn=new WeakMap;Go=new WeakMap;Bo=new WeakSet;Nc=function(){if(Cp(this,Go)===JSON.stringify(this.mediaRenditionList))return;Pc(this,Go,JSON.stringify(this.mediaRenditionList));let r=this.mediaRenditionList.sort((s,n)=>n.height-s.height),e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.mediaRenditionSelected;for(let s of r){let n=this.formatOptionText(`${Math.min(s.width,s.height)}p`,s),a=fr(n,`${s.id}`,s.selected&&!t);a.prepend(qi(this,"select-indicator")),e.append(a)}let i=fr(this.formatOptionText("Auto"),"auto",t);i.prepend(qi(this,"select-indicator")),e.append(i)};$o=new WeakSet;Fc=function(){if(this.value==null)return;let r=new D.CustomEvent(ne.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};D.customElements.get("media-rendition-listbox")||D.customElements.define("media-rendition-listbox",Ho);var kb=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
930
|
+
<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" />
|
|
931
|
+
</svg>`,Mp=z.createElement("template");Mp.innerHTML=`
|
|
932
|
+
<slot name="icon">${kb}</slot>
|
|
933
|
+
`;var Bc=class extends We{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_SELECTED,S.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:Mp})}get mediaRenditionSelected(){return et(this,S.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Xe(this,S.MEDIA_RENDITION_SELECTED,e)}};D.customElements.get("media-rendition-button")||D.customElements.define("media-rendition-button",Bc);var Vo=class extends Mi{static get observedAttributes(){return[...super.observedAttributes,S.MEDIA_RENDITION_SELECTED,S.MEDIA_RENDITION_UNAVAILABLE]}init(){let e=z.createElement("media-rendition-button");e.part.add("button"),e.preventClick=!0;let t=z.createElement("media-rendition-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, indicator");let i=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");i.textContent="",s.textContent="",i.append(e),s.append(t)}};D.customElements.get("media-rendition-selectmenu")||D.customElements.define("media-rendition-selectmenu",Vo);var Sl=JE(Op(),1);function wb(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Tg={exports:{}};(function(r,e){(function(t){var i=/^(?=((?:[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 m=o.parseURL(l);if(!m)throw new Error("Error trying to parse base URL.");if(!m.netLoc&&m.path&&m.path[0]!=="/"){var g=s.exec(m.path);m.netLoc=g[1],m.path=g[2]}m.netLoc&&!m.path&&(m.path="/");var E={scheme:m.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(E.netLoc=m.netLoc,h.path[0]!=="/"))if(!h.path)E.path=m.path,h.params||(E.params=m.params,h.query||(E.query=m.query));else{var T=m.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=i.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}};r.exports=o})()})(Tg);var oh=Tg.exports;function Pp(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,i)}return t}function zt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Pp(Object(t),!0).forEach(function(i){Db(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Pp(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}function Db(r,e,t){return e=Mb(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function pt(){return pt=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=t[i])}return r},pt.apply(this,arguments)}function Cb(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var i=t.call(r,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Mb(r){var e=Cb(r,"string");return typeof e=="symbol"?e:String(e)}var ce=Number.isFinite||function(r){return typeof r=="number"&&isFinite(r)},y=function(r){return r.MEDIA_ATTACHING="hlsMediaAttaching",r.MEDIA_ATTACHED="hlsMediaAttached",r.MEDIA_DETACHING="hlsMediaDetaching",r.MEDIA_DETACHED="hlsMediaDetached",r.BUFFER_RESET="hlsBufferReset",r.BUFFER_CODECS="hlsBufferCodecs",r.BUFFER_CREATED="hlsBufferCreated",r.BUFFER_APPENDING="hlsBufferAppending",r.BUFFER_APPENDED="hlsBufferAppended",r.BUFFER_EOS="hlsBufferEos",r.BUFFER_FLUSHING="hlsBufferFlushing",r.BUFFER_FLUSHED="hlsBufferFlushed",r.MANIFEST_LOADING="hlsManifestLoading",r.MANIFEST_LOADED="hlsManifestLoaded",r.MANIFEST_PARSED="hlsManifestParsed",r.LEVEL_SWITCHING="hlsLevelSwitching",r.LEVEL_SWITCHED="hlsLevelSwitched",r.LEVEL_LOADING="hlsLevelLoading",r.LEVEL_LOADED="hlsLevelLoaded",r.LEVEL_UPDATED="hlsLevelUpdated",r.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",r.LEVELS_UPDATED="hlsLevelsUpdated",r.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",r.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",r.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",r.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",r.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",r.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",r.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",r.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",r.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",r.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",r.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",r.CUES_PARSED="hlsCuesParsed",r.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",r.INIT_PTS_FOUND="hlsInitPtsFound",r.FRAG_LOADING="hlsFragLoading",r.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",r.FRAG_LOADED="hlsFragLoaded",r.FRAG_DECRYPTED="hlsFragDecrypted",r.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",r.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",r.FRAG_PARSING_METADATA="hlsFragParsingMetadata",r.FRAG_PARSED="hlsFragParsed",r.FRAG_BUFFERED="hlsFragBuffered",r.FRAG_CHANGED="hlsFragChanged",r.FPS_DROP="hlsFpsDrop",r.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",r.ERROR="hlsError",r.DESTROYING="hlsDestroying",r.KEY_LOADING="hlsKeyLoading",r.KEY_LOADED="hlsKeyLoaded",r.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",r.BACK_BUFFER_REACHED="hlsBackBufferReached",r}({}),pe=function(r){return r.NETWORK_ERROR="networkError",r.MEDIA_ERROR="mediaError",r.KEY_SYSTEM_ERROR="keySystemError",r.MUX_ERROR="muxError",r.OTHER_ERROR="otherError",r}({}),B=function(r){return r.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",r.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",r.KEY_SYSTEM_NO_SESSION="keySystemNoSession",r.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",r.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",r.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",r.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",r.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",r.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",r.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",r.MANIFEST_LOAD_ERROR="manifestLoadError",r.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",r.MANIFEST_PARSING_ERROR="manifestParsingError",r.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",r.LEVEL_EMPTY_ERROR="levelEmptyError",r.LEVEL_LOAD_ERROR="levelLoadError",r.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",r.LEVEL_PARSING_ERROR="levelParsingError",r.LEVEL_SWITCH_ERROR="levelSwitchError",r.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",r.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",r.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",r.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",r.FRAG_LOAD_ERROR="fragLoadError",r.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",r.FRAG_DECRYPT_ERROR="fragDecryptError",r.FRAG_PARSING_ERROR="fragParsingError",r.FRAG_GAP="fragGap",r.REMUX_ALLOC_ERROR="remuxAllocError",r.KEY_LOAD_ERROR="keyLoadError",r.KEY_LOAD_TIMEOUT="keyLoadTimeOut",r.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",r.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",r.BUFFER_APPEND_ERROR="bufferAppendError",r.BUFFER_APPENDING_ERROR="bufferAppendingError",r.BUFFER_STALLED_ERROR="bufferStalledError",r.BUFFER_FULL_ERROR="bufferFullError",r.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",r.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",r.INTERNAL_EXCEPTION="internalException",r.INTERNAL_ABORTED="aborted",r.UNKNOWN="unknown",r}({}),$r=function(){},lu={trace:$r,debug:$r,log:$r,warn:$r,info:$r,error:$r},Un=lu;function Ob(r){let e=self.console[r];return e?e.bind(self.console,`[${r}] >`):$r}function Pb(r,...e){e.forEach(function(t){Un[t]=r[t]?r[t].bind(r):Ob(t)})}function Nb(r,e){if(self.console&&r===!0||typeof r=="object"){Pb(r,"debug","log","info","warn","error");try{Un.log(`Debug logs enabled for "${e}" in hls.js version 1.4.8`)}catch{Un=lu}}else Un=lu}var M=Un,Fb=/^(\d+)x(\d+)$/,Np=/(.+?)=(".*?"|.*?)(?:,|$)/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 i=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)i[s]=parseInt(t.slice(s*2,s*2+2),16);return i}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 i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=Fb.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,i={},s='"';for(Np.lastIndex=0;(t=Np.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();i[a]=n}return i}};function Ub(r){return r!=="ID"&&r!=="CLASS"&&r!=="START-DATE"&&r!=="DURATION"&&r!=="END-DATE"&&r!=="END-ON-NEXT"}function Bb(r){return r==="SCTE35-OUT"||r==="SCTE35-IN"}var tl=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let i=t.attr;for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==i[s]){M.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=pt(new Qe({}),i,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let i=new Date(this.attr["END-DATE"]);ce(i.getTime())&&(this._endDate=i)}}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)}},Ws=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}}},Ve={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},il=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Ve.AUDIO]:null,[Ve.VIDEO]:null,[Ve.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let i=e.split("@",2),s=[];i.length===1?s[0]=t?t.byteRangeEndOffset:0:s[0]=parseInt(i[1]),s[1]=parseInt(i[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=oh.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},Bn=class extends il{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 Ws,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 i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[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),i=t.length;if(i>1||i===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,i,s,n,a=!1){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:i,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[Ve.AUDIO]=null,e[Ve.VIDEO]=null,e[Ve.AUDIOVIDEO]=null}},du=class extends il{constructor(e,t,i,s,n){super(i),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 Ws,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)}},$b=10,cu=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,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>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||$b}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 lh(r){return Uint8Array.from(atob(r),e=>e.charCodeAt(0))}function Gb(r){let e=_g(r).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function Hb(r){let e=function(i,s,n){let a=i[s];i[s]=i[n],i[n]=a};e(r,0,3),e(r,1,2),e(r,4,5),e(r,6,7)}function Vb(r){let e=r.split(":"),t=null;if(e[0]==="data"&&e.length===2){let i=e[1].split(";"),s=i[i.length-1].split(",");if(s.length===2){let n=s[0]==="base64",a=s[1];n?(i.splice(-1,1),t=lh(a)):t=Gb(a)}}return t}function _g(r){return Uint8Array.from(unescape(encodeURIComponent(r)),e=>e.charCodeAt(0))}var st={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},jt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Fp(r){switch(r){case jt.FAIRPLAY:return st.FAIRPLAY;case jt.PLAYREADY:return st.PLAYREADY;case jt.WIDEVINE:return st.WIDEVINE;case jt.CLEARKEY:return st.CLEARKEY}}var Ag={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Kb(r){if(r===Ag.WIDEVINE)return st.WIDEVINE}function Up(r){switch(r){case st.FAIRPLAY:return jt.FAIRPLAY;case st.PLAYREADY:return jt.PLAYREADY;case st.WIDEVINE:return jt.WIDEVINE;case st.CLEARKEY:return jt.CLEARKEY}}function Gc(r){let{drmSystems:e,widevineLicenseUrl:t}=r,i=e?[st.FAIRPLAY,st.WIDEVINE,st.PLAYREADY,st.CLEARKEY].filter(s=>!!e[s]):[];return!i[st.WIDEVINE]&&t&&i.push(st.WIDEVINE),i}var Sg=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Wb(r,e,t,i){let s;switch(r){case st.FAIRPLAY:s=["cenc","sinf"];break;case st.WIDEVINE:case st.PLAYREADY:s=["cenc"];break;case st.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${r}`)}return qb(s,e,t,i)}function qb(r,e,t,i){return[{initDataTypes:r,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function Gr(r,e,t){return Uint8Array.prototype.slice?r.slice(e,t):new Uint8Array(Array.prototype.slice.call(r,e,t))}var dh=(r,e)=>e+10<=r.length&&r[e]===73&&r[e+1]===68&&r[e+2]===51&&r[e+3]<255&&r[e+4]<255&&r[e+6]<128&&r[e+7]<128&&r[e+8]<128&&r[e+9]<128,xg=(r,e)=>e+10<=r.length&&r[e]===51&&r[e+1]===68&&r[e+2]===73&&r[e+3]<255&&r[e+4]<255&&r[e+6]<128&&r[e+7]<128&&r[e+8]<128&&r[e+9]<128,rl=(r,e)=>{let t=e,i=0;for(;dh(r,e);){i+=10;let s=_l(r,e+6);i+=s,xg(r,e+10)&&(i+=10),e+=i}if(i>0)return r.subarray(t,t+i)},_l=(r,e)=>{let t=0;return t=(r[e]&127)<<21,t|=(r[e+1]&127)<<14,t|=(r[e+2]&127)<<7,t|=r[e+3]&127,t},Yb=(r,e)=>dh(r,e)&&_l(r,e+6)+10<=r.length-e,jb=r=>{let e=Lg(r);for(let t=0;t<e.length;t++){let i=e[t];if(Ig(i))return eT(i)}},Ig=r=>r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp",zb=r=>{let e=String.fromCharCode(r[0],r[1],r[2],r[3]),t=_l(r,4),i=10;return{type:e,size:t,data:r.subarray(i,i+t)}},Lg=r=>{let e=0,t=[];for(;dh(r,e);){let i=_l(r,e+6);e+=10;let s=e+i;for(;e+8<s;){let n=zb(r.subarray(e)),a=Xb(n);a&&t.push(a),e+=n.size+10}xg(r,e)&&(e+=10)}return t},Xb=r=>r.type==="PRIV"?Qb(r):r.type[0]==="W"?Jb(r):Zb(r),Qb=r=>{if(r.size<2)return;let e=Bi(r.data,!0),t=new Uint8Array(r.data.subarray(e.length+1));return{key:r.type,info:e,data:t.buffer}},Zb=r=>{if(r.size<2)return;if(r.type==="TXXX"){let t=1,i=Bi(r.data.subarray(t),!0);t+=i.length+1;let s=Bi(r.data.subarray(t));return{key:r.type,info:i,data:s}}let e=Bi(r.data.subarray(1));return{key:r.type,data:e}},Jb=r=>{if(r.type==="WXXX"){if(r.size<2)return;let t=1,i=Bi(r.data.subarray(t),!0);t+=i.length+1;let s=Bi(r.data.subarray(t));return{key:r.type,info:i,data:s}}let e=Bi(r.data);return{key:r.type,data:e}},eT=r=>{if(r.data.byteLength===8){let e=new Uint8Array(r.data),t=e[3]&1,i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}},Bi=(r,e=!1)=>{let t=tT();if(t){let d=t.decode(r);if(e){let c=d.indexOf("\0");return c!==-1?d.substring(0,c):d}return d.replace(/\0/g,"")}let i=r.length,s,n,a,o="",l=0;for(;l<i;){if(s=r[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=r[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=r[l++],a=r[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o},Hc;function tT(){return!Hc&&typeof self.TextDecoder!="undefined"&&(Hc=new self.TextDecoder("utf-8")),Hc}var Oi={hexDump:function(r){let e="";for(let t=0;t<r.length;t++){let i=r[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}},sl=Math.pow(2,32)-1,iT=[].push,Rg={video:1,audio:2,id3:3,text:4};function Rt(r){return String.fromCharCode.apply(null,r)}function kg(r,e){let t=r[e]<<8|r[e+1];return t<0?65536+t:t}function be(r,e){let t=wg(r,e);return t<0?4294967296+t:t}function wg(r,e){return r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}function Vc(r,e,t){r[e]=t>>24,r[e+1]=t>>16&255,r[e+2]=t>>8&255,r[e+3]=t&255}function Pe(r,e){let t=[];if(!e.length)return t;let i=r.byteLength;for(let s=0;s<i;){let n=be(r,s),a=Rt(r.subarray(s+4,s+8)),o=n>1?s+n:i;if(a===e[0])if(e.length===1)t.push(r.subarray(s+8,o));else{let l=Pe(r.subarray(s+8,o),e.slice(1));l.length&&iT.apply(t,l)}s=o}return t}function rT(r){let e=[],t=r[0],i=8,s=be(r,i);i+=4;let n=0,a=0;t===0?i+=8:i+=16,i+=2;let o=r.length+a,l=kg(r,i);i+=2;for(let d=0;d<l;d++){let c=i,u=be(r,c);c+=4;let h=u&2147483647;if((u&2147483648)>>>31===1)return M.warn("SIDX has hierarchical references (not supported)"),null;let g=be(r,c);c+=4,e.push({referenceSize:h,subsegmentDuration:g,info:{duration:g/s,start:o,end:o+h-1}}),o+=h,c+=4,i=c}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function Dg(r){let e=[],t=Pe(r,["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=be(a,l),c=Pe(n,["mdia","mdhd"])[0];if(c){o=c[0],l=o===0?12:20;let u=be(c,l),h=Pe(n,["mdia","hdlr"])[0];if(h){let m=Rt(h.subarray(8,12)),g={soun:Ve.AUDIO,vide:Ve.VIDEO}[m];if(g){let E=Pe(n,["mdia","minf","stbl","stsd"])[0],T;E&&(T=Rt(E.subarray(12,16))),e[d]={timescale:u,type:g},e[g]={timescale:u,id:d,codec:T}}}}}}return Pe(r,["moov","mvex","trex"]).forEach(s=>{let n=be(s,4),a=e[n];a&&(a.default={duration:be(s,12),flags:be(s,20)})}),e}function sT(r,e){if(!r||!e)return r;let t=e.keyId;return t&&e.isCommonEncryption&&Pe(r,["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 m=Cg(h);if(m){let g=m.subarray(8,24);g.some(E=>E!==0)||(M.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Oi.hexDump(g)} -> ${Oi.hexDump(t)}`),m.set(t,8))}})})}),r}function Cg(r){let e=Pe(r,["schm"])[0];if(e){let t=Rt(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return Pe(r,["schi","tenc"])[0]}return M.error("[eme] missing 'schm' box"),null}function nT(r,e){return Pe(e,["moof","traf"]).reduce((t,i)=>{let s=Pe(i,["tfdt"])[0],n=s[0],a=Pe(i,["tfhd"]).reduce((o,l)=>{let d=be(l,4),c=r[d];if(c){let u=be(s,4);if(n===1){if(u===sl)return M.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;u*=sl+1,u+=be(s,8)}let h=c.timescale||9e4,m=u/h;if(isFinite(m)&&(o===null||m<o))return m}return o},null);return a!==null&&isFinite(a)&&(t===null||a<t)?a:t},null)}function aT(r,e){let t=0,i=0,s=0,n=Pe(r,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=Pe(o,["tfhd"])[0],d=be(l,4),c=e[d];if(!c)continue;let u=c.default,h=be(l,0)|(u==null?void 0:u.flags),m=u==null?void 0:u.duration;h&8&&(h&2?m=be(l,12):m=be(l,8));let g=c.timescale||9e4,E=Pe(o,["trun"]);for(let T=0;T<E.length;T++){if(t=oT(E[T]),!t&&m){let A=be(E[T],4);t=m*A}c.type===Ve.VIDEO?i+=t/g:c.type===Ve.AUDIO&&(s+=t/g)}}if(i===0&&s===0){let a=0,o=Pe(r,["sidx"]);for(let l=0;l<o.length;l++){let d=rT(o[l]);d!=null&&d.references&&(a+=d.references.reduce((c,u)=>c+u.info.duration||0,0))}return a}return i||s}function oT(r){let e=be(r,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let i=0,s=be(r,4);for(let n=0;n<s;n++){if(e&256){let a=be(r,t);i+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return i}function lT(r,e,t){Pe(e,["moof","traf"]).forEach(i=>{Pe(i,["tfhd"]).forEach(s=>{let n=be(s,4),a=r[n];if(!a)return;let o=a.timescale||9e4;Pe(i,["tfdt"]).forEach(l=>{let d=l[0],c=be(l,4);if(d===0)c-=t*o,c=Math.max(c,0),Vc(l,4,c);else{c*=Math.pow(2,32),c+=be(l,8),c-=t*o,c=Math.max(c,0);let u=Math.floor(c/(sl+1)),h=Math.floor(c%(sl+1));Vc(l,4,u),Vc(l,8,h)}})})})}function dT(r){let e={valid:null,remainder:null},t=Pe(r,["moof"]);if(t){if(t.length<2)return e.remainder=r,e}else return e;let i=t[t.length-1];return e.valid=Gr(r,0,i.byteOffset-8),e.remainder=Gr(r,i.byteOffset-8),e}function Hr(r,e){let t=new Uint8Array(r.length+e.length);return t.set(r),t.set(e,r.length),t}function Bp(r,e){let t=[],i=e.samples,s=e.timescale,n=e.id,a=!1;return Pe(i,["moof"]).map(l=>{let d=l.byteOffset-8;Pe(l,["traf"]).map(u=>{let h=Pe(u,["tfdt"]).map(m=>{let g=m[0],E=be(m,4);return g===1&&(E*=Math.pow(2,32),E+=be(m,8)),E/s})[0];return h!==void 0&&(r=h),Pe(u,["tfhd"]).map(m=>{let g=be(m,4),E=be(m,0)&16777215,T=(E&1)!==0,A=(E&2)!==0,R=(E&8)!==0,x=0,N=(E&16)!==0,w=0,$=(E&32)!==0,O=8;g===n&&(T&&(O+=8),A&&(O+=4),R&&(x=be(m,O),O+=4),N&&(w=be(m,O),O+=4),$&&(O+=4),e.type==="video"&&(a=cT(e.codec)),Pe(u,["trun"]).map(H=>{let q=H[0],P=be(H,0)&16777215,X=(P&1)!==0,j=0,Ae=(P&4)!==0,Ee=(P&256)!==0,ye=0,we=(P&512)!==0,Se=0,Z=(P&1024)!==0,ae=(P&2048)!==0,se=0,xe=be(H,4),Ie=8;X&&(j=be(H,Ie),Ie+=4),Ae&&(Ie+=4);let $e=j+d;for(let ht=0;ht<xe;ht++){if(Ee?(ye=be(H,Ie),Ie+=4):ye=x,we?(Se=be(H,Ie),Ie+=4):Se=w,Z&&(Ie+=4),ae&&(q===0?se=be(H,Ie):se=wg(H,Ie),Ie+=4),e.type===Ve.VIDEO){let V=0;for(;V<Se;){let J=be(i,$e);if($e+=4,uT(a,i[$e])){let Re=i.subarray($e,$e+J);Mg(Re,a?2:1,r+se/s,t)}$e+=J,V+=J+4}}r+=ye/s}}))})})}),t}function cT(r){if(!r)return!1;let e=r.indexOf("."),t=e<0?r:r.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function uT(r,e){if(r){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Mg(r,e,t,i){let s=Og(r),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=kg(s,n);if(n+=2,h===49){let m=be(s,n);if(n+=4,m===1195456820){let g=s[n++];if(g===3){let E=s[n++],T=31&E,A=64&E,R=A?2+T*3:0,x=new Uint8Array(R);if(A){x[0]=E;for(let N=1;N<R;N++)x[N]=s[n++]}i.push({type:g,payloadType:a,pts:t,bytes:x})}}}}}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,m=new Uint8Array(h);for(let g=0;g<h;g++)m[g]=s[n++];i.push({payloadType:a,pts:t,uuid:u.join(""),userData:Bi(m),userDataBytes:m})}}else if(o<c)n+=o;else if(o>c)break}}function Og(r){let e=r.byteLength,t=[],i=1;for(;i<e-2;)r[i]===0&&r[i+1]===0&&r[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return r;let s=e-t.length,n=new Uint8Array(s),a=0;for(i=0;i<s;a++,i++)a===t[0]&&(a++,t.shift()),n[i]=r[a];return n}function hT(r){let e=r[0],t="",i="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;Rt(r.subarray(d,d+1))!=="\0";)t+=Rt(r.subarray(d,d+1)),d+=1;for(t+=Rt(r.subarray(d,d+1)),d+=1;Rt(r.subarray(d,d+1))!=="\0";)i+=Rt(r.subarray(d,d+1)),d+=1;i+=Rt(r.subarray(d,d+1)),d+=1,s=be(r,12),n=be(r,16),o=be(r,20),l=be(r,24),d=28}else if(e===1){d+=4,s=be(r,d),d+=4;let u=be(r,d);d+=4;let h=be(r,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=be(r,d),d+=4,l=be(r,d),d+=4;Rt(r.subarray(d,d+1))!=="\0";)t+=Rt(r.subarray(d,d+1)),d+=1;for(t+=Rt(r.subarray(d,d+1)),d+=1;Rt(r.subarray(d,d+1))!=="\0";)i+=Rt(r.subarray(d,d+1)),d+=1;i+=Rt(r.subarray(d,d+1)),d+=1}let c=r.subarray(d,r.byteLength);return{schemeIdUri:t,value:i,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:c}}function fT(r,...e){let t=e.length,i=8,s=t;for(;s--;)i+=e[s].byteLength;let n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=i&255,n.set(r,4),s=0,i=8;s<t;s++)n.set(e[s],i),i+=e[s].byteLength;return n}function mT(r,e,t){if(r.byteLength!==16)throw new RangeError("Invalid system id");let i,s;if(e){i=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 i=0,s=new Uint8Array;let n;i>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),fT([112,115,115,104],new Uint8Array([i,0,0,0]),r,n,s,a,t||new Uint8Array)}function pT(r){if(!(r instanceof ArrayBuffer)||r.byteLength<32)return null;let e={version:0,systemId:"",kids:null,data:null},t=new DataView(r),i=t.getUint32(0);if(r.byteLength!==i&&i>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=Oi.hexDump(new Uint8Array(r,12,16));let n=t.getUint32(28);if(e.version===0){if(i-32<n)return null;e.data=new Uint8Array(r,32,n)}else if(e.version===1){e.kids=[];for(let a=0;a<n;a++)e.kids.push(new Uint8Array(r,32+a*16,16))}return e}var Wo={},Vr=class{static clearKeyUriToKeyIdMap(){Wo={}}constructor(e,t,i,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=i,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 jt.FAIRPLAY:case jt.WIDEVINE:case jt.PLAYREADY:case jt.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 i=gT(e);return new Vr(this.method,this.uri,"identity",this.keyFormatVersions,i)}let t=Vb(this.uri);if(t)switch(this.keyFormat){case jt.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case jt.PLAYREADY:{let i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=mT(i,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=lh(c).subarray(0,16);Hb(u),this.keyId=u}}break}default:{let i=t.subarray(0,16);if(i.length!==16){let s=new Uint8Array(16);s.set(i,16-i.length),i=s}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=Wo[this.uri];if(!i){let s=Object.keys(Wo).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,s),Wo[this.uri]=i}this.keyId=i}return this}};function gT(r){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=r>>8*(15-t)&255;return e}var Pg=/\{\$([a-zA-Z0-9-_]+)\}/g;function $p(r){return Pg.test(r)}function qt(r,e,t){if(r.variableList!==null||r.hasVariableRefs)for(let i=t.length;i--;){let s=t[i],n=e[s];n&&(e[s]=uu(r,n))}}function uu(r,e){if(r.variableList!==null||r.hasVariableRefs){let t=r.variableList;return e.replace(Pg,i=>{let s=i.substring(2,i.length-1),n=t==null?void 0:t[s];return n===void 0?(r.playlistParsingError||(r.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),i):n})}return e}function Gp(r,e,t){let i=r.variableList;i||(r.variableList=i={});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){r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in i?r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):i[s]=n||""}function vT(r,e,t){let i=e.IMPORT;if(t&&i in t){let s=r.variableList;s||(r.variableList=s={}),s[i]=t[i]}else r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function Al(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}var ET={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}},Hp=Al();function yT(r,e){let t=ET[e];return!!t&&t[r.slice(0,4)]===!0}function Kc(r,e){var t;return(t=Hp==null?void 0:Hp.isTypeSupported(`${e||"video"}/mp4;codecs="${r}"`))!=null?t:!1}var Vp=/#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,Kp=/#EXT-X-MEDIA:(.*)/g,bT=/^#EXT(?:INF|-X-TARGETDURATION):/m,Wp=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),TT=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("|")),Zt=class{static findGroup(e,t){for(let i=0;i<e.length;i++){let s=e[i];if(s.id===t)return s}}static convertAVC1ToAVCOTI(e){let t=e.split(".");if(t.length>2){let i=t.shift()+".";return i+=parseInt(t.shift()).toString(16),i+=("000"+parseInt(t.shift()).toString(16)).slice(-4),i}return e}static resolve(e,t){return oh.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return bT.test(e)}static parseMasterPlaylist(e,t){let i=$p(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];Vp.lastIndex=0;let a;for(;(a=Vp.exec(e))!=null;)if(a[1]){var o;let d=new Qe(a[1]);qt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let c=uu(s,a[2]),u={attrs:d,bitrate:d.decimalInteger("AVERAGE-BANDWIDTH")||d.decimalInteger("BANDWIDTH"),name:d.NAME,url:Zt.resolve(c,t)},h=d.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),_T((d.CODECS||"").split(/[ ,]+/).filter(m=>m),u),u.videoCodec&&u.videoCodec.indexOf("avc1")!==-1&&(u.videoCodec=Zt.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);qt(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=qp(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);qt(s,u,["NAME","VALUE","QUERYPARAM"]),Gp(s,u,t)}break}case"CONTENT-STEERING":{let u=new Qe(c);qt(s,u,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:Zt.resolve(u["SERVER-URI"],t),pathwayId:u["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=Yp(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,i){let s,n={},a=i.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(Kp.lastIndex=0;(s=Kp.exec(e))!==null;){let d=new Qe(s[1]),c=d.TYPE;if(c){let u=o[c],h=n[c]||[];n[c]=h,qt(i,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let m={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?Zt.resolve(d.URI,t):""};if(u!=null&&u.length){let g=Zt.findGroup(u,m.groupId)||u[0];jp(m,g,"audioCodec"),jp(m,g,"textCodec")}h.push(m)}}return n}static parseLevelPlaylist(e,t,i,s,n,a){let o=new cu(t),l=o.fragments,d=null,c=0,u=0,h=0,m=0,g=null,E=new Bn(s,t),T,A,R,x=-1,N=!1;for(Wp.lastIndex=0,o.m3u8=e,o.hasVariableRefs=$p(e);(T=Wp.exec(e))!==null;){N&&(N=!1,E=new Bn(s,t),E.start=h,E.sn=c,E.cc=m,E.level=i,d&&(E.initSegment=d,E.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null));let H=T[1];if(H){E.duration=parseFloat(H);let q=(" "+T[2]).slice(1);E.title=q||null,E.tagList.push(q?["INF",H,q]:["INF",H])}else if(T[3]){if(ce(E.duration)){E.start=h,R&&Qp(E,R,o),E.sn=c,E.level=i,E.cc=m,E.urlId=n,l.push(E);let q=(" "+T[3]).slice(1);E.relurl=uu(o,q),zp(E,g),g=E,h+=E.duration,c++,u=0,N=!0}}else if(T[4]){let q=(" "+T[4]).slice(1);g?E.setByteRange(q,g):E.setByteRange(q)}else if(T[5])E.rawProgramDateTime=(" "+T[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),x===-1&&(x=l.length);else{if(T=T[0].match(TT),!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 q=(" "+T[A]).slice(1),P=(" "+T[A+1]).slice(1),X=T[A+2]?(" "+T[A+2]).slice(1):"";switch(q){case"PLAYLIST-TYPE":o.type=P.toUpperCase();break;case"MEDIA-SEQUENCE":c=o.startSN=parseInt(P);break;case"SKIP":{let j=new Qe(P);qt(o,j,["RECENTLY-REMOVED-DATERANGES"]);let Ae=j.decimalInteger("SKIPPED-SEGMENTS");if(ce(Ae)){o.skippedSegments=Ae;for(let ye=Ae;ye--;)l.unshift(null);c+=Ae}let Ee=j.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":m++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([q]);break;case"BITRATE":E.tagList.push([q,P]);break;case"DATERANGE":{let j=new Qe(P);qt(o,j,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),qt(o,j,j.clientAttrs);let Ae=new tl(j,o.dateRanges[j.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 j=new Qe(P);qt(o,j,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in j?vT(o,j,a):Gp(o,j,t)}break}case"DISCONTINUITY-SEQUENCE":m=parseInt(P);break;case"KEY":{let j=qp(P,t,o);if(j.isSupported()){if(j.method==="NONE"){R=void 0;break}R||(R={}),R[j.keyFormat]&&(R=pt({},R)),R[j.keyFormat]=j}else M.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${P}"`);break}case"START":o.startTimeOffset=Yp(P);break;case"MAP":{let j=new Qe(P);if(qt(o,j,["BYTERANGE","URI"]),E.duration){let Ae=new Bn(s,t);Xp(Ae,j,i,R),d=Ae,E.initSegment=d,d.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=d.rawProgramDateTime)}else Xp(E,j,i,R),d=E,N=!0;break}case"SERVER-CONTROL":{let j=new Qe(P);o.canBlockReload=j.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=j.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&j.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=j.optionalFloat("PART-HOLD-BACK",0),o.holdBack=j.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{let j=new Qe(P);o.partTarget=j.decimalFloatingPoint("PART-TARGET");break}case"PART":{let j=o.partList;j||(j=o.partList=[]);let Ae=u>0?j[j.length-1]:void 0,Ee=u++,ye=new Qe(P);qt(o,ye,["BYTERANGE","URI"]);let we=new du(ye,E,t,Ee,Ae);j.push(we),E.duration+=we.duration;break}case"PRELOAD-HINT":{let j=new Qe(P);qt(o,j,["URI"]),o.preloadHint=j;break}case"RENDITION-REPORT":{let j=new Qe(P);qt(o,j,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(j);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&&(zp(E,g),E.cc=m,o.fragmentHint=E,R&&Qp(E,R,o));let w=l.length,$=l[0],O=l[w-1];if(h+=o.skippedSegments*o.targetduration,h>0&&w&&O){o.averagetargetduration=h/w;let H=O.sn;o.endSN=H!=="initSegment"?H: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=m,x>0&&AT(l,x),o}};function qp(r,e,t){var i,s;let n=new Qe(r);qt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(i=n.METHOD)!=null?i:"",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?Zt.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Vr(a,u,c,h,l)}function Yp(r){let t=new Qe(r).decimalFloatingPoint("TIME-OFFSET");return ce(t)?t:null}function _T(r,e){["video","audio","text"].forEach(t=>{let i=r.filter(s=>yT(s,t));if(i.length){let s=i.filter(n=>n.lastIndexOf("avc1",0)===0||n.lastIndexOf("mp4a",0)===0);e[`${t}Codec`]=s.length>0?s[0]:i[0],r=r.filter(n=>i.indexOf(n)===-1)}}),e.unknownCodecs=r}function jp(r,e,t){let i=e[t];i&&(r[t]=i)}function AT(r,e){let t=r[e];for(let i=e;i--;){let s=r[i];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function zp(r,e){r.rawProgramDateTime?r.programDateTime=Date.parse(r.rawProgramDateTime):e!=null&&e.programDateTime&&(r.programDateTime=e.endProgramDateTime),ce(r.programDateTime)||(r.programDateTime=null,r.rawProgramDateTime=null)}function Xp(r,e,t,i){r.relurl=e.URI,e.BYTERANGE&&r.setByteRange(e.BYTERANGE),r.level=t,r.sn="initSegment",i&&(r.levelkeys=i),r.initSegment=null}function Qp(r,e,t){r.levelkeys=e;let{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&i.push(r)}var Fe={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},ge={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Zp(r){let{type:e}=r;switch(e){case Fe.AUDIO_TRACK:return ge.AUDIO;case Fe.SUBTITLE_TRACK:return ge.SUBTITLE;default:return ge.MAIN}}function Wc(r,e){let t=r.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var hu=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(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,i=t.pLoader,s=t.loader,n=i||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:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Fe.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(e,t){let{id:i,level:s,url:n,deliveryDirectives:a}=t;this.load({id:i,level:s,responseType:"text",type:Fe.LEVEL,url:n,deliveryDirectives:a})}onAudioTrackLoading(e,t){let{id:i,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:Fe.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){let{id:i,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:Fe.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;let i=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===Fe.MANIFEST?n=i.manifestLoadPolicy.default:n=pt({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part){let d;if(e.type===Fe.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Fe.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Fe.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=pt({},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 m=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(),Zt.isMediaPlaylist(g)?this.handleTrackOrLevelPlaylist(d,c,u,h||null,m):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,i,s){let n=this.hls,a=e.data,o=Wc(e,i),l=Zt.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,i,l.playlistParsingError,s,t);return}let{contentSteering:d,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:m,variableList:g}=l;this.variableList=g;let{AUDIO:E=[],SUBTITLES:T,"CLOSED-CAPTIONS":A}=Zt.parseMasterPlaylistMedia(a,o,l);E.length&&!E.some(x=>!x.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(y.MANIFEST_LOADED,{levels:c,audioTracks:E,subtitles:T,captions:A,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:u,sessionKeys:h,startTimeOffset:m,variableList:g})}handleTrackOrLevelPlaylist(e,t,i,s,n){let a=this.hls,{id:o,level:l,type:d}=i,c=Wc(e,i),u=ce(o)?o:0,h=ce(l)?l:u,m=Zp(i),g=Zt.parseLevelPlaylist(e.data,c,h,m,u,this.variableList);if(d===Fe.MANIFEST){let E={attrs:new Qe({}),bitrate:0,details:g,name:"",url:c};a.trigger(y.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(),i.levelDetails=g,this.handlePlaylistLoaded(g,e,t,i,s,n)}handleManifestParsingError(e,t,i,s,n){this.hls.trigger(y.ERROR,{type:pe.NETWORK_ERROR,details:B.MANIFEST_PARSING_ERROR,fatal:t.type===Fe.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,i=!1,s,n){let a=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===Fe.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Fe.AUDIO_TRACK||e.type===Fe.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 Fe.MANIFEST:l=i?B.MANIFEST_LOAD_TIMEOUT:B.MANIFEST_LOAD_ERROR,d=!0;break;case Fe.LEVEL:l=i?B.LEVEL_LOAD_TIMEOUT:B.LEVEL_LOAD_ERROR,d=!1;break;case Fe.AUDIO_TRACK:l=i?B.AUDIO_TRACK_LOAD_TIMEOUT:B.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Fe.SUBTITLE_TRACK:l=i?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=zt({url:h,data:void 0},s)}this.hls.trigger(y.ERROR,u)}handlePlaylistLoaded(e,t,i,s,n,a){let o=this.hls,{type:l,level:d,id:c,groupId:u,deliveryDirectives:h}=s,m=Wc(t,s),g=Zp(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(y.ERROR,{type:pe.NETWORK_ERROR,details:B.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:A,reason:A.message,response:t,context:s,level:E,parent:g,networkDetails:n,stats:i});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let T=e.playlistParsingError;if(T){o.trigger(y.ERROR,{type:pe.NETWORK_ERROR,details:B.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:T,reason:T.message,response:t,context:s,level:E,parent:g,networkDetails:n,stats:i});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case Fe.MANIFEST:case Fe.LEVEL:o.trigger(y.LEVEL_LOADED,{details:e,level:E||0,id:c||0,stats:i,networkDetails:n,deliveryDirectives:h});break;case Fe.AUDIO_TRACK:o.trigger(y.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:i,networkDetails:n,deliveryDirectives:h});break;case Fe.SUBTITLE_TRACK:o.trigger(y.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:i,networkDetails:n,deliveryDirectives:h});break}}};function Ng(r,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=r,e.dispatchEvent(t)}function Fg(r,e){let t=r.mode;if(t==="disabled"&&(r.mode="hidden"),r.cues&&!r.cues.getCueById(e.id))try{if(r.addCue(e),!r.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){M.debug(`[texttrack-utils]: ${i}`);let s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,r.addCue(s)}t==="disabled"&&(r.mode=t)}function Vs(r){let e=r.mode;if(e==="disabled"&&(r.mode="hidden"),r.cues)for(let t=r.cues.length;t--;)r.removeCue(r.cues[t]);e==="disabled"&&(r.mode=e)}function fu(r,e,t,i){let s=r.mode;if(s==="disabled"&&(r.mode="hidden"),r.cues&&r.cues.length>0){let n=xT(r.cues,e,t);for(let a=0;a<n.length;a++)(!i||i(n[a]))&&r.removeCue(n[a])}s==="disabled"&&(r.mode=s)}function ST(r,e){if(e<r[0].startTime)return 0;let t=r.length-1;if(e>r[t].endTime)return-1;let i=0,s=t;for(;i<=s;){let n=Math.floor((s+i)/2);if(e<r[n].startTime)s=n-1;else if(e>r[n].startTime&&i<t)i=n+1;else return n}return r[i].startTime-e<e-r[s].startTime?i:s}function xT(r,e,t){let i=[],s=ST(r,e);if(s>-1)for(let n=s,a=r.length;n<a;n++){let o=r[n];if(o.startTime>=e&&o.endTime<=t)i.push(o);else if(o.startTime>t)return i}return i}var pi={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},IT=.25;function mu(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var qo=(()=>{let r=mu();try{new r(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function qc(r,e){return r.getTime()/1e3-e}function LT(r){return Uint8Array.from(r.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var pu=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(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){let{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){!this.id3Track||(Vs(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 i=e[t];if(i.kind==="metadata"&&i.label==="id3")return Ng(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:s}}}=this;if(!i&&!s)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=mu();for(let o=0;o<n.length;o++){let l=n[o].type;if(l===pi.emsg&&!i||!s)continue;let d=Lg(n[o].data);if(d){let c=n[o].pts,u=c+n[o].duration;u>qo&&(u=qo),u-c<=0&&(u=c+IT);for(let m=0;m<d.length;m++){let g=d[m];if(!Ig(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 i;let s=(i=this.id3Track)==null?void 0:i.cues;if(s)for(let n=s.length;n--;){let a=s[n];a.type===t&&a.startTime<e&&a.endTime===qo&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,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===pi.audioId3&&l:s==="video"?d=c=>c.type===pi.emsg&&o:d=c=>c.type===pi.audioId3&&l||c.type===pi.emsg&&o,fu(n,t,i,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:i,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){let c=Object.keys(i).filter(u=>!a.includes(u));for(let u=c.length;u--;){let h=c[u];Object.keys(i[h].cues).forEach(m=>{s.removeCue(i[h].cues[m])}),delete i[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=mu();for(let c=0;c<a.length;c++){let u=a[c],h=n[u],m=i[u],g=(m==null?void 0:m.cues)||{},E=(m==null?void 0:m.durationKnown)||!1,T=qc(h.startDate,l),A=qo,R=h.endDate;if(R)A=qc(R,l),E=!0;else if(h.endOnNext&&!E){let N=a.reduce((w,$)=>{let O=n[$];return O.class===h.class&&O.id!==$&&O.startDate>h.startDate&&w.push(O),w},[]).sort((w,$)=>w.startDate.getTime()-$.startDate.getTime())[0];N&&(A=qc(N.startDate,l),E=!0)}let x=Object.keys(h.attr);for(let N=0;N<x.length;N++){let w=x[N];if(!Ub(w))continue;let $=g[w];if($)E&&!m.durationKnown&&($.endTime=A);else{let O=h.attr[w];$=new d(T,A,""),Bb(w)&&(O=LT(O)),$.value={key:w,data:O},$.type=pi.dateRange,$.id=u,this.id3Track.addCue($),g[w]=$}}i[u]={cues:g,dateRange:h,durationKnown:E}}}},gu=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:i,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&i||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,i=this.levelDetails;if(e===null||t===null||i===null)return null;let s=i.edge,n=e-t-this.edgeStalled,a=s-i.totalduration,o=s-(this.config.lowLatencyMode&&i.partTarget||i.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 i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(y.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(y.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 i;t.details===B.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.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 i=this.computeLatency();if(i===null)return;this._latency=i;let{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1)return;let a=this.targetLatency;if(a===null)return;let o=i-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}},vu=["NONE","TYPE-0","TYPE-1",null],$n={No:"",Yes:"YES",v2:"v2"};function RT(r,e){let{canSkipUntil:t,canSkipDateRanges:i,endSN:s}=r,n=e!==void 0?e-s:0;return t&&n<t?i?$n.v2:$n.Yes:$n.No}var nl=class{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}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}},Kr=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 Yc(r,e){let t=e.startPTS;if(ce(t)){let i=0,s;e.sn>r.sn?(i=t-r.start,s=r):(i=r.start-t,s=e),s.duration!==i&&(s.duration=i)}else e.sn>r.sn?r.cc===e.cc&&r.minEndPTS?e.start=r.start+(r.minEndPTS-r.start):e.start=r.start+r.duration:e.start=Math.max(r.start-e.duration,0)}function Ug(r,e,t,i,s,n){i-t<=0&&(M.warn("Fragment should have a positive duration",e),i=t+e.duration,n=s+e.duration);let o=t,l=i,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(i,c),i=Math.max(i,c),n=Math.max(n,e.endDTS)}let u=t-e.start;e.start!==0&&(e.start=t),e.duration=i-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=i,e.minEndPTS=l,e.endDTS=n;let h=e.sn;if(!r||h<r.startSN||h>r.endSN)return 0;let m,g=h-r.startSN,E=r.fragments;for(E[g]=e,m=g;m>0;m--)Yc(E[m],E[m-1]);for(m=g;m<E.length-1;m++)Yc(E[m],E[m+1]);return r.fragmentHint&&Yc(E[E.length-1],r.fragmentHint),r.PTSKnown=r.alignedSliding=!0,u}function kT(r,e){let t=null,i=r.fragments;for(let l=i.length-1;l>=0;l--){let d=i[l].initSegment;if(d){t=d;break}}r.fragmentHint&&delete r.fragmentHint.endPTS;let s=0,n;if(CT(r,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=wT(r.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),DT(r.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?Ug(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):Bg(r,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=r.driftStartTime,e.driftStart=r.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=r.driftEndTime,e.driftEnd=r.driftEnd,e.advancedDateTime=r.advancedDateTime}function wT(r,e,t){let i=pt({},r);return t&&t.forEach(s=>{delete i[s]}),Object.keys(e).forEach(s=>{let n=new tl(e[s].attr,i[s]);n.isValid?i[s]=n:M.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),i}function DT(r,e,t){if(r&&e){let i=0;for(let s=0,n=r.length;s<=n;s++){let a=r[s],o=e[s+i];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):i--}}}function CT(r,e,t){let i=e.skippedSegments,s=Math.max(r.startSN,e.startSN)-e.startSN,n=(r.fragmentHint?1:0)+(i?e.endSN:Math.min(r.endSN,e.endSN))-e.startSN,a=e.startSN-r.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;for(let d=s;d<=n;d++){let c=l[a+d],u=o[d];i&&!u&&d<i&&(u=e.fragments[d]=c),c&&u&&t(c,u)}}function Bg(r,e){let t=e.startSN+e.skippedSegments-r.startSN,i=r.fragments;t<0||t>=i.length||Eu(e,i[t].start)}function Eu(r,e){if(e){let t=r.fragments;for(let i=r.skippedSegments;i<t.length;i++)t[i].start+=e;r.fragmentHint&&(r.fragmentHint.start+=e)}}function MT(r,e=1/0){let t=1e3*r.targetduration;if(r.updated){let i=r.fragments,s=4;if(i.length&&t*s>e){let n=i[i.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function OT(r,e,t){if(!(r!=null&&r.details))return null;let i=r.details,s=i.fragments[e-i.startSN];return s||(s=i.fragmentHint,s&&s.sn===e)?s:e<i.startSN&&t&&t.sn===e?t:null}function Jp(r,e,t){var i;return r!=null&&r.details?$g((i=r.details)==null?void 0:i.partList,e,t):null}function $g(r,e,t){if(r)for(let i=r.length;i--;){let s=r[i];if(s.index===t&&s.fragment.sn===e)return s}return null}function al(r){switch(r.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 eg(r,e){let t=al(e);return r.default[`${t?"timeout":"error"}Retry`]}function ch(r,e){let t=r.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*r.retryDelayMs,r.maxRetryDelayMs)}function tg(r){return zt(zt({},r),{errorRetry:null,timeoutRetry:null})}function ol(r,e,t,i){return!!r&&e<r.maxNumRetry&&(PT(i)||!!t)}function PT(r){return r===0&&navigator.onLine===!1||!!r&&(r<400||r>499)}var Gg={search:function(r,e){let t=0,i=r.length-1,s=null,n=null;for(;t<=i;){s=(t+i)/2|0,n=r[s];let a=e(n);if(a>0)t=s+1;else if(a<0)i=s-1;else return n}return null}};function NT(r,e,t){if(e===null||!Array.isArray(r)||!r.length||!ce(e))return null;let i=r[0].programDateTime;if(e<(i||0))return null;let s=r[r.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<r.length;++n){let a=r[n];if(FT(e,t,a))return a}return null}function Vn(r,e,t=0,i=0){let s=null;if(r?s=e[r.sn-e[0].sn+1]||null:t===0&&e[0].start===0&&(s=e[0]),s&&yu(t,i,s)===0)return s;let n=Gg.search(e,yu.bind(null,t,i));return n&&(n!==r||!s)?n:s}function yu(r=0,e=0,t){if(t.start<=r&&t.start+t.duration>r)return 0;let i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=r?1:t.start-i>r&&t.start?-1:0}function FT(r,e,t){let i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>r}function UT(r,e){return Gg.search(r,t=>t.cc<e?1:t.cc>e?-1:0)}var BT=3e5,Ft={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},hi={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},bu=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(y.ERROR,this.onError,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;!e||(e.off(y.ERROR,this.onError,this),e.off(y.ERROR,this.onErrorOut,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.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 i;if(t.fatal)return;let s=this.hls,n=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_GAP:case B.FRAG_PARSING_ERROR:case B.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Ft.SendAlternateToPenaltyBox;return}case B.LEVEL_EMPTY_ERROR:case B.LEVEL_PARSING_ERROR:{var a,o;let l=t.parent===ge.MAIN?t.level:s.loadLevel;t.details===B.LEVEL_EMPTY_ERROR&&!!((a=t.context)!=null&&(o=a.levelDetails)!=null&&o.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,l))}return;case B.LEVEL_LOAD_ERROR:case B.LEVEL_LOAD_TIMEOUT:typeof(n==null?void 0:n.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.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(n){let l=s.levels[s.loadLevel];if(l&&(n.type===Fe.AUDIO_TRACK&&n.groupId===l.audioGroupId||n.type===Fe.SUBTITLE_TRACK&&n.groupId===l.textGroupId)){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.loadLevel),t.errorAction.action=Ft.SendAlternateToPenaltyBox,t.errorAction.flags=hi.MoveAllAlternatesMatchingHost;return}}return;case B.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let l=s.levels[s.loadLevel],d=l==null?void 0:l.attrs["HDCP-LEVEL"];d&&(t.errorAction={action:Ft.SendAlternateToPenaltyBox,flags:hi.MoveAllAlternatesMatchingHDCP,hdcpLevel:d})}return;case B.BUFFER_ADD_CODEC_ERROR:case B.REMUX_ALLOC_ERROR:t.errorAction=this.getLevelSwitchAction(t,(i=t.level)!=null?i:s.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:Ft.DoNothing,flags:hi.None};return}if(t.type===pe.KEY_SYSTEM_ERROR){let l=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,l);return}}getPlaylistRetryOrSwitchAction(e,t){var i;let s=this.hls,n=eg(s.config.playlistLoadPolicy,e),a=this.playlistError++,o=(i=e.response)==null?void 0:i.code;if(ol(n,a,al(e),o))return{action:Ft.RetryRequest,flags:hi.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,i=this.getVariantLevelIndex(e.frag),s=t.levels[i],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=eg(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(ol(o,l,al(e),u))return{action:Ft.RetryRequest,flags:hi.None,retryConfig:o,retryCount:l}}let c=this.getLevelSwitchAction(e,i);return o&&(c.retryConfig=o,c.retryCount=l),c}getLevelSwitchAction(e,t){let i=this.hls;t==null&&(t=i.loadLevel);let s=this.hls.levels[t];if(s&&(s.loadError++,i.autoLevelEnabled)){var n,a;let o=-1,{levels:l,loadLevel:d,minAutoLevel:c,maxAutoLevel:u}=i,h=(n=e.frag)==null?void 0:n.type,{type:m,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 x=Vn(e.frag,R.fragments,e.frag.start);if(x!=null&&x.gap)continue}}else{if(m===Fe.AUDIO_TRACK&&g===A.audioGroupId||m===Fe.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&&i.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:Ft.SendAlternateToPenaltyBox,flags:hi.None,nextAutoLevel:o}}return{action:Ft.SendAlternateToPenaltyBox,flags:hi.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case Ft.DoNothing:break;case Ft.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,i=e.errorAction;if(!i)return;let{flags:s,hdcpLevel:n,nextAutoLevel:a}=i;switch(s){case hi.None:this.switchLevel(e,a);break;case hi.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(e));break;case hi.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=vu[vu.indexOf(n)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}i.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:i}=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=i[d];if(!c||$T(c,e,i[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:i}=this,s=i[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};s.lastErrorPerfMs=performance.now(),s.errors.push(t),s.details=e.details,i[e.urlId]=s}};function $T(r,e,t){if(performance.now()-r.lastErrorPerfMs>BT)return!0;let i=r.details;if(e.details===B.FRAG_GAP&&i&&e.frag){let s=e.frag.start,n=Vn(null,i.fragments,s);if(n&&!n.gap)return!0}if(t&&r.errors.length<t.errors.length){let s=r.errors[r.errors.length-1];if(i&&s.frag&&e.frag&&Math.abs(s.frag.start-e.frag.start)>i.targetduration*3)return!0}return!1}var Kn=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 i=t==null?void 0:t.renditionReports;if(i){let s=-1;for(let n=0;n<i.length;n++){let a=i[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=i[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 nl(a,o>=0?o:void 0,$n.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,i){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||i!=null&&i.live){if(s.reloaded(i),i&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:"MISSED"}`),i&&s.fragments.length>0&&kT(i,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,x=s.lastPartIndex,N=x!==-1,w=A===R,$=T?0:x;N?(d=w?R+1:A,c=w?$:x+1):d=R+1;let O=s.age,H=O+s.ageHeader,q=Math.min(H-s.partTarget,s.targetduration*1.5);if(q>0){if(i&&q>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${q} with playlist age: ${s.age}`),q=0;else{let P=Math.floor(q/s.targetduration);if(d+=P,c!==void 0){let X=Math.round(q%s.targetduration/s.partTarget);c+=X}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${O.toFixed(2)}s goal: ${q} skip sn ${P} to part ${c}`)}s.tuneInGoal=q}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,c),T||!w){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,m=(s.edge-h)*1e3,g=MT(s,m);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,i,s){let n=RT(e,i);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,s=t.part,n=$n.No),new nl(i,s,n)}checkRetry(e){let t=e.details,i=al(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===Ft.RetryRequest||!s.resolved&&n===Ft.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(i&&(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=ch(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}},jc,Tu=class extends Kn{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(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.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 i=[],s={},n;t.levels.forEach(a=>{var o;let l=a.attrs;((o=a.audioCodec)==null?void 0:o.indexOf("mp4a.40.34"))!==-1&&(jc||(jc=/chrome|firefox/i.test(navigator.userAgent)),jc&&(a.audioCodec=void 0));let{AUDIO:d,CODECS:c,"FRAME-RATE":u,"PATHWAY-ID":h,RESOLUTION:m,SUBTITLES:g}=l,T=`${`${h||"."}-`}${a.bitrate}-${m}-${u}-${c}`;n=s[T],n?n.addFallback(a):(n=new Kr(a),s[T]=n,i.push(n)),ll(n,"audio",d),ll(n,"text",g)}),this.filterAndSortMediaOptions(i,t)}filterAndSortMediaOptions(e,t){let i=[],s=[],n=!1,a=!1,o=!1,l=e.filter(({audioCodec:m,videoCodec:g,width:E,height:T,unknownCodecs:A})=>(n||(n=!!(E&&T)),a||(a=!!g),o||(o=!!m),!(A!=null&&A.length)&&(!m||Kc(m,"audio"))&&(!g||Kc(g,"video"))));if((n||a)&&o&&(l=l.filter(({videoCodec:m,width:g,height:E})=>!!m||!!(g&&E))),l.length===0){Promise.resolve().then(()=>{if(this.hls){let m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(y.ERROR,{type:pe.MEDIA_ERROR,details:B.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}t.audioTracks&&(i=t.audioTracks.filter(m=>!m.audioCodec||Kc(m.audioCodec,"audio")),ig(i)),t.subtitles&&(s=t.subtitles,ig(s));let d=l.slice(0);l.sort((m,g)=>m.attrs["HDCP-LEVEL"]!==g.attrs["HDCP-LEVEL"]?(m.attrs["HDCP-LEVEL"]||"")>(g.attrs["HDCP-LEVEL"]||"")?1:-1:m.bitrate!==g.bitrate?m.bitrate-g.bitrate:m.attrs["FRAME-RATE"]!==g.attrs["FRAME-RATE"]?m.attrs.decimalFloatingPoint("FRAME-RATE")-g.attrs.decimalFloatingPoint("FRAME-RATE"):m.attrs.SCORE!==g.attrs.SCORE?m.attrs.decimalFloatingPoint("SCORE")-g.attrs.decimalFloatingPoint("SCORE"):n&&m.height!==g.height?m.height-g.height:0);let c=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let m=0;m<d.length;m++)if(d[m].pathwayId===l[0].pathwayId){c=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===c){this._firstLevel=m,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${c.bitrate}`);break}let u=o&&!a,h={levels:l,audioTracks:i,subtitleTracks:s,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:o,video:a,altAudio:!u&&i.some(m=>!!m.url)};this.hls.trigger(y.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(y.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 i=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,i===e&&a.details&&s&&n===o)return;this.log(`Switching to level ${e}${o?" with Pathway "+o:""} from level ${i}${n?" with Pathway "+n:""}`);let l=pt({},a,{level:e,maxBitrate:a.maxBitrate,attrs:a.attrs,uri:a.uri,urlId:a.urlId});delete l._attrs,delete l._urlId,this.hls.trigger(y.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===Fe.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(t!==void 0&&t.type===ge.MAIN){let i=this._levels[t.level];i!==void 0&&(i.loadError=0)}}onLevelLoaded(e,t){var i;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)):(i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,t){let i=this.currentLevel;if(!i)return;let s=this.hls.audioTracks[t.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==s){let n=-1;for(let a=0;a<i.audioGroupIds.length;a++)if(i.audioGroupIds[a]===s){n=a;break}n!==-1&&n!==i.urlId&&(i.urlId=n,this.canLoad&&this.startLoad())}}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){let s=i.urlId,n=i.uri;if(e)try{n=e.addDirectives(n)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}let a=i.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}/${i.url.length} ${n}`),this.clearTimer(),this.hls.trigger(y.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 i=(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(i),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(i)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(i)),n.urlId=0,!0):(this.steering&&this.steering.removeLevel(n),!1));this.hls.trigger(y.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(e,{levels:t}){t.forEach((i,s)=>{let{details:n}=i;n!=null&&n.fragments&&n.fragments.forEach(a=>{a.level=s})}),this._levels=t}};function ll(r,e,t){!t||(e==="audio"?(r.audioGroupIds||(r.audioGroupIds=[]),r.audioGroupIds[r.url.length-1]=t):e==="text"&&(r.textGroupIds||(r.textGroupIds=[]),r.textGroupIds[r.url.length-1]=t))}function ig(r){let e={};r.forEach(t=>{let i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}var Tt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},_u=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(y.BUFFER_APPENDED,this.onBufferAppended,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(y.BUFFER_APPENDED,this.onBufferAppended,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let i=this.activePartLists[t];if(i)for(let s=i.length;s--;){let n=i[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:i}=this,s=Object.keys(i);for(let n=s.length;n--;){let a=i[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,i,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===i&&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:i,part:s}=e;if(!t||i.sn==="initSegment")return;let n=$s(i),a=this.fragments[n];if(!a)return;let o=!i.relurl;Object.keys(t).forEach(l=>{let d=i.elementaryStreams[l];if(!d)return;let c=t[l],u=o||d.partial===!0;a.range[l]=this.getBufferedTimes(i,s,u,c)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,a.body.endList&&(this.endListFragments[a.body.type]=a),Yo(a)||this.removeParts(i.sn-1,i.type)):this.removeFragment(a.body)}removeParts(e,t){let i=this.activePartLists[t];!i||(this.activePartLists[t]=i.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){let i=$s(e),s=this.fragments[i];!s&&t&&(s=this.fragments[i]={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,i,s){let n={time:[],partial:i},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,i,s,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let c=l[d];!c||Yo(c)&&(s=c.body.start-o,n=c.body.end+o,e>=s&&e<=n&&(i=Math.min(e-s,n-e),a<=i&&(t=c.body,a=i)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||Yo(t))}getState(e){let t=$s(e),i=this.fragments[t];return i?i.buffered?Yo(i)?Tt.PARTIAL:Tt.OK:Tt.APPENDING:Tt.NOT_LOADED}isTimeBuffered(e,t,i){let s,n;for(let a=0;a<i.length;a++){if(s=i.start(a)-this.bufferPadding,n=i.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){let{frag:i,part:s}=t;if(i.sn==="initSegment"||i.bitrateTest)return;let n=s?null:t,a=$s(i);this.fragments[a]={body:i,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:i,part:s,timeRanges:n}=t;if(i.sn==="initSegment")return;let a=i.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=$s(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,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!==i||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){let t=$s(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let i=this.activePartLists[e.type];if(i){let s=e.sn;this.activePartLists[e.type]=i.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 Yo(r){var e,t,i;return r.buffered&&(r.body.gap||((e=r.range.video)==null?void 0:e.partial)||((t=r.range.audio)==null?void 0:t.partial)||((i=r.range.audiovideo)==null?void 0:i.partial))}function $s(r){return`${r.type}_${r.level}_${r.urlId}_${r.sn}`}var rg=Math.pow(2,17),Au=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 i=e.url;if(!i)return Promise.reject(new mi({type:pe.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${i?"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){l(ng(e));return}let d=this.loader=e.loader=n?new n(s):new a(s),c=sg(e),u=tg(s.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:rg};e.stats=d.stats,d.load(c,h,{onSuccess:(m,g,E,T)=>{this.resetLoader(e,d);let A=m.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:(m,g,E,T)=>{this.resetLoader(e,d),l(new mi({type:pe.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:zt({url:i,data:void 0},m),error:new Error(`HTTP Error ${m.code} ${m.text}`),networkDetails:E,stats:T}))},onAbort:(m,g,E)=>{this.resetLoader(e,d),l(new mi({type:pe.NETWORK_ERROR,details:B.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:E,stats:m}))},onTimeout:(m,g,E)=>{this.resetLoader(e,d),l(new mi({type:pe.NETWORK_ERROR,details:B.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:E,stats:m}))},onProgress:(m,g,E,T)=>{t&&t({frag:e,part:null,payload:E,networkDetails:T})}})})}loadPart(e,t,i){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(ng(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),c=sg(e,t),u=tg(s.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:rg};t.stats=d.stats,d.load(c,h,{onSuccess:(m,g,E,T)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);let A={frag:e,part:t,payload:m.data,networkDetails:T};i(A),o(A)},onError:(m,g,E,T)=>{this.resetLoader(e,d),l(new mi({type:pe.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:zt({url:c.url,data:void 0},m),error:new Error(`HTTP Error ${m.code} ${m.text}`),networkDetails:E,stats:T}))},onAbort:(m,g,E)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new mi({type:pe.NETWORK_ERROR,details:B.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:E,stats:m}))},onTimeout:(m,g,E)=>{this.resetLoader(e,d),l(new mi({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:m}))}})})}updateStatsFromPart(e,t){let i=e.stats,s=t.stats,n=s.total;if(i.loaded+=s.loaded,n){let l=Math.round(e.duration/t.duration),d=Math.min(Math.round(i.loaded/n),l),u=(l-d)*Math.round(i.loaded/d);i.total=i.loaded+u}else i.total=Math.max(i.loaded,i.total);let a=i.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 sg(r,e=null){let t=e||r,i={frag:r,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(r.sn==="initSegment"&&((a=r.decryptdata)==null?void 0:a.method)==="AES-128"){let d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(i.resetIV=!0,o=s-16)}i.rangeStart=o,i.rangeEnd=l}return i}function ng(r,e){let t=new Error(`GAP ${r.gap?"tag":"attribute"} found`),i={type:pe.MEDIA_ERROR,details:B.FRAG_GAP,fatal:!1,frag:r,error:t,networkDetails:null};return e&&(i.part=e),(e||r).stats.aborted=!0,new mi(i)}var mi=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},Su=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let t in this.keyUriToKeyInfo){let i=this.keyUriToKeyInfo[t].loader;if(i){if(e&&e!==i.context.frag.type)return;i.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,i,s,n){return new mi({type:pe.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:i,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:i,cc:s}=e;for(let n=0;n<t.length;n++){let a=t[n];if(s<=a.cc&&(i==="initSegment"||a.sn==="initSegment"||i<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 i,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((i=o)!=null&&i.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 i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let s=this.emeController.loadKey(i);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,i))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(i)}loadKeyHTTP(e,t){let i=this.config,s=i.loader,n=new s(i);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=i.keyLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,m,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,m,g,E)=>{this.resetLoader(m),o(this.createKeyLoadError(t,B.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),g,zt({url:l.url,data:void 0},h)))},onTimeout:(h,m,g)=>{this.resetLoader(m),o(this.createKeyLoadError(t,B.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),g))},onAbort:(h,m,g)=>{this.resetLoader(m),o(this.createKeyLoadError(t,B.INTERNAL_ABORTED,new Error("key loading aborted"),g))}};n.load(l,c,u)})}resetLoader(e){let{frag:t,keyInfo:i,url:s}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}},xu=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(){}},GT={length:0,start:()=>0,end:()=>0},qe=class{static isBuffered(e,t){try{if(e){let i=qe.getBuffered(e);for(let s=0;s<i.length;s++)if(t>=i.start(s)&&t<=i.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,i){try{if(e){let s=qe.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,i)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,i){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(i)for(let d=0;d<e.length;d++){let c=s.length;if(c){let u=s[c-1].end;e[d].start-u<i?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+i>=c&&t<u)o=c,l=u,n=l-t;else if(t+i<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),GT}}},Wn=class{constructor(e,t,i,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=jo(),this.buffering={audio:jo(),video:jo(),audiovideo:jo()},this.level=e,this.sn=t,this.id=i,this.size=s,this.part=n,this.partial=a}};function jo(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Hg(r,e){let t=null;for(let i=0,s=r.length;i<s;i++){let n=r[i];if(n&&n.cc===e){t=n;break}}return t}function HT(r,e,t){return!!(e.details&&(t.endCC>t.startCC||r&&r.cc<t.startCC))}function VT(r,e,t=0){let i=r.fragments,s=e.fragments;if(!s.length||!i.length){M.log("No fragments to align");return}let n=Hg(i,s[0].cc);if(!n||n&&!n.startPTS){M.log("No frag in previous level to align on");return}return n}function ag(r,e){if(r){let t=r.start+e;r.start=r.startPTS=t,r.endPTS=t+r.duration}}function uh(r,e){let t=e.fragments;for(let i=0,s=t.length;i<s;i++)ag(t[i],r);e.fragmentHint&&ag(e.fragmentHint,r),e.alignedSliding=!0}function KT(r,e,t){!e||(WT(r,t,e),!t.alignedSliding&&e.details&&qT(t,e.details),!t.alignedSliding&&e.details&&!t.skippedSegments&&Bg(e.details,t))}function WT(r,e,t){if(HT(r,t,e)){let i=VT(t.details,e);i&&ce(i.start)&&(M.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),uh(i.start,e))}}function qT(r,e){if(!e.fragments.length||!r.hasProgramDateTime||!e.hasProgramDateTime)return;let t=e.fragments[0].programDateTime,i=r.fragments[0].programDateTime,s=(i-t)/1e3+e.fragments[0].start;s&&ce(s)&&(M.log(`Adjusting PTS using programDateTime delta ${i-t}ms, sliding:${s.toFixed(3)} ${r.url} `),uh(s,r))}function Vg(r,e){if(!r.hasProgramDateTime||!e.hasProgramDateTime)return;let t=r.fragments,i=e.fragments;if(!t.length||!i.length)return;let s=Math.round(i.length/2)-1,n=i[s],a=Hg(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);uh(d,r)}var Iu=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)}},Lu=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 YT(r){let e=r.byteLength,t=e&&new DataView(r.buffer).getUint8(e-1);return t?Gr(r,0,e-t):r}var Ru=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),i=new Uint32Array(4);for(let s=0;s<4;s++)i[s]=t.getUint32(s*4);return i}initTable(){let e=this.sBox,t=this.invSBox,i=this.subMix,s=i[0],n=i[1],a=i[2],o=i[3],l=this.invSubMix,d=l[0],c=l[1],u=l[2],h=l[3],m=new Uint32Array(256),g=0,E=0,T=0;for(T=0;T<256;T++)T<128?m[T]=T<<1:m[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=m[g],x=m[R],N=m[x],w=m[A]*257^A*16843008;s[g]=w<<24|w>>>8,n[g]=w<<16|w>>>16,a[g]=w<<8|w>>>24,o[g]=w,w=N*16843009^x*65537^R*257^g*16843008,d[A]=w<<24|w>>>8,c[A]=w<<16|w>>>16,u[A]=w<<8|w>>>24,h[A]=w,g?(g=R^m[m[m[N^R]]],E^=m[m[E]]):g=E=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),i=!0,s=0;for(;s<t.length&&i;)i=t[s]===this.key[s],s++;if(i)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,m=this.invSubMix,g=m[0],E=m[1],T=m[2],A=m[3],R,x;for(o=0;o<a;o++){if(o<n){R=d[o]=t[o];continue}x=R,o%n===0?(x=x<<8|x>>>24,x=u[x>>>24]<<24|u[x>>>16&255]<<16|u[x>>>8&255]<<8|u[x&255],x^=h[o/n|0]<<24):n>6&&o%n===4&&(x=u[x>>>24]<<24|u[x>>>16&255]<<16|u[x>>>8&255]<<8|u[x&255]),d[o]=R=(d[o-n]^x)>>>0}for(l=0;l<a;l++)o=a-l,l&3?x=d[o]:x=d[o-4],l<4||o<=4?c[l]=x:c[l]=g[u[x>>>24]]^E[u[x>>>16&255]]^T[u[x>>>8&255]]^A[u[x&255]],c[l]=c[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){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_(i),m=h[0],g=h[1],E=h[2],T=h[3],A=new Int32Array(e),R=new Int32Array(A.length),x,N,w,$,O,H,q,P,X,j,Ae,Ee,ye,we,Se=this.networkToHostOrderSwap;for(;t<A.length;){for(X=Se(A[t]),j=Se(A[t+1]),Ae=Se(A[t+2]),Ee=Se(A[t+3]),O=X^n[0],H=Ee^n[1],q=Ae^n[2],P=j^n[3],ye=4,we=1;we<s;we++)x=l[O>>>24]^d[H>>16&255]^c[q>>8&255]^u[P&255]^n[ye],N=l[H>>>24]^d[q>>16&255]^c[P>>8&255]^u[O&255]^n[ye+1],w=l[q>>>24]^d[P>>16&255]^c[O>>8&255]^u[H&255]^n[ye+2],$=l[P>>>24]^d[O>>16&255]^c[H>>8&255]^u[q&255]^n[ye+3],O=x,H=N,q=w,P=$,ye=ye+4;x=a[O>>>24]<<24^a[H>>16&255]<<16^a[q>>8&255]<<8^a[P&255]^n[ye],N=a[H>>>24]<<24^a[q>>16&255]<<16^a[P>>8&255]<<8^a[O&255]^n[ye+1],w=a[q>>>24]<<24^a[P>>16&255]<<16^a[O>>8&255]<<8^a[H&255]^n[ye+2],$=a[P>>>24]<<24^a[O>>16&255]<<16^a[H>>8&255]<<8^a[q&255]^n[ye+3],R[t]=Se(x^m),R[t+1]=Se($^g),R[t+2]=Se(w^E),R[t+3]=Se(N^T),m=X,g=j,E=Ae,T=Ee,t=t+4}return R.buffer}},jT=16,qn=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 i=self.crypto;i&&(this.subtle=i.subtle||i.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 i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?YT(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,i);let a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i)}softwareDecrypt(e,t,i){let{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Hr(a,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;s&&(i=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Ru),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,i),this.currentIV=Gr(o,-16).buffer,d||null}webCryptoDecrypt(e,t,i){let s=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new Lu(s,t)),this.fastAesKey.expandKey().then(n=>s?(this.logOnce("WebCrypto AES decrypt"),new Iu(s,new Uint8Array(i)).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,i)))}onWebCryptoError(e,t,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i);let s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,i=e.length-e.length%jT;return i!==e.length&&(t=Gr(e,0,i),this.remainderData=Gr(e,i)),t}logOnce(e){!this.logEnabled||(M.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},zT={toString:function(r){let e="",t=r.length;for(let i=0;i<t;i++)e+=`[${r.start(i).toFixed(3)}-${r.end(i).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"},Yn=class extends xu{constructor(e,t,i,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 Au(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new qn(e.config),e.on(y.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 i=t.partList;if(i!=null&&i.length){let n=i[i.length-1];return qe.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 i=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.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:i,mediaBuffer:s,state:n}=this,a=i?i.currentTime:0,o=qe.bufferInfo(s||i,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)}}i&&(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,i){this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){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,i,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(y.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:i}=this;if(i.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)&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===Tt.PARTIAL&&i.removeFragment(e))}flushMainBuffer(e,t,i=null){if(!(e-t))return;let s={startOffset:e,endOffset:t,type:i};this.hls.trigger(y.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{if(!i||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{let{hls:s}=this,{payload:n}=i,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(y.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(y.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),i.payload=l,i})}return i}).then(i=>{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(i.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),i.frag===s&&n.trigger(y.FRAG_BUFFERED,{stats:o,frag:s,part:null,id:e.type}),this.tick()}).catch(i=>{this.state===W.STOPPED||this.state===W.ERROR||(this.warn(i),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 i,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:[${((i=e.startPTS)!=null?i:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?zT.toString(qe.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:i,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new Wn(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=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(y.KEY_LOADED,c),this.state===W.KEY_LOADING&&(this.state=W.IDLE),c}),this.hls.trigger(y.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),i=Math.max(e.start,i||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let c=a.partList;if(c&&s){i>e.end&&a.fragmentHint&&(e=a.fragmentHint);let u=this.getNextPart(c,e,i);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(i.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=W.FRAG_LOADING;let m;return o?m=o.then(g=>!g||this.fragContextChanged(g.frag)?null:this.doFragPartsLoad(e,h,t,s)).catch(g=>this.handleFragLoadError(g)):m=this.doFragPartsLoad(e,h,t,s).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(y.FRAG_LOADING,{frag:e,part:h,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):m}else if(!e.url||this.loadedEndOfParts(c,i))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(i.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(y.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,i,s){return new Promise((n,a)=>{var o;let l=[],d=(o=i.details)==null?void 0:o.partList,c=u=>{this.fragmentLoader.loadPart(e,u,s).then(h=>{l[u.index]=h;let m=h.part;this.hls.trigger(y.FRAG_LOADED,h);let g=Jp(i,e.sn,u.index+1)||$g(d,e.sn,u.index+1);if(g)c(g);else return n({frag:e,part:m,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(y.ERROR,t)}else this.hls.trigger(y.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:i,part:s,level:n}=t,a=self.performance.now();i.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(i,s,n,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:i}=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?Jp(o,n,a):null,d=l?l.fragment:OT(o,n,i);return d?(i&&i!==d&&(d.stats=i.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,i,s){var n;if(!e||this.state!==W.PARSING)return;let{data1:a,data2:o}=e,l=a;if(a&&o&&(l=Hr(a,o)),!((n=l)!=null&&n.length))return;let d={type:e.type,frag:t,part:i,chunkMeta:s,parent:t.type,data:l};this.hls.trigger(y.BUFFER_APPENDING,d),e.dropped&&e.independent&&!i&&this.flushBufferGap(t)}flushBufferGap(e){let t=this.media;if(!t)return;if(!qe.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let i=t.currentTime,s=qe.bufferInfo(t,i,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),i+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){let i=this.getLoadPosition();return ce(i)?this.getFwdBufferInfoAtPos(e,i,t):null}getFwdBufferInfoAtPos(e,t,i){let{config:{maxBufferHole:s}}=this,n=qe.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&n.nextStart<a.end)return qe.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){let{config:t}=this,i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e){let t=this.config,i=e||t.maxBufferLength;return t.maxMaxBufferLength>=i?(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,t=ge.MAIN){let i=this.fragmentTracker.getAppendedFrag(e,ge.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){let i=t.fragments,s=i.length;if(!s)return null;let{config:n}=this,a=i[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,i),this.startPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=i[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 i=this.fragmentTracker.getState(e);return(i===Tt.OK||i===Tt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,s,n){let a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&i.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s);if(l!==null&&i.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,i){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&&i<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 i=e[e.length-1];return i&&t>i.start&&i.loaded}getInitialLiveFragment(e,t){let i=this.fragPrevious,s=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),s=NT(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){let n=i.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];i.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=UT(t,i.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,i){let{config:s}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=i,{fragmentHint:l}=i,d=s.maxFragLookUpTolerance,c=i.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 m=e>t-d?0:d;h=Vn(n,a,e,m)}else h=a[a.length-1];if(h){let m=h.sn-i.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[m+1];h.sn<o&&this.fragmentTracker.getState(T)!==Tt.OK?h=T:h=null}}return h}synchronizeToLiveEdge(e){let{config:t,media:i}=this;if(!i)return;let s=this.hls.liveSyncPosition,n=i.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&i.duration>s&&(n<s||!l)){let d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&i.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),i.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)}`),i.currentTime=s))}}alignPlaylists(e,t){let{levels:i,levelLastLoaded:s,fragPrevious:n}=this,a=s!==null?i[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){KT(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 i=this.startPosition;if(i<t&&(i=-1),i===-1||this.lastCurrentTime===-1){let s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&ce(n)?(i=t+n,n<0&&(i+=e.totalduration),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):e.live?i=this.hls.liveSyncPosition||t:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}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 i=t.frag;if(!i||i.type!==e||!this.levels)return;if(this.fragContextChanged(i)){var s;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}let n=t.details===B.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);let a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===Ft.RetryRequest&&d){var c;this.resetStartWhenNotLoaded((c=this.levelLastLoaded)!=null?c:i.level);let u=ch(d,l);this.warn(`Fragment ${i.sn} of ${e} ${i.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)===Ft.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,i=this.getFwdBufferInfo(this.mediaBuffer,t),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.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,i){if(!e)return;let s=qe.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,i),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,i,s){var n;let a=i.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:Ug(a,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS);return this.hls.trigger(y.LEVEL_PTS_UPDATED,{details:a,level:i,drift:h,type:d,frag:e,start:c.startPTS,end:c.endPTS}),!0}return l},!1))i.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 ${i.id} resetting transmuxer to fallback to playlist timing`);if(this.warn(l.message),this.hls.trigger(y.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 "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=W.PARSED,this.hls.trigger(y.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){if(e.event==="demuxerWorker"){var t,i,s;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((t=(i=this.levelLastLoaded)!=null?i:(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 Kg(){return self.SourceBuffer||self.WebKitSourceBuffer}function XT(){let r=Al();if(!r)return!1;let e=Kg(),t=r&&typeof r.isTypeSupported=="function"&&r.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function";return!!t&&!!i}function QT(){var r;let e=Kg();return typeof(e==null||(r=e.prototype)==null?void 0:r.changeType)=="function"}function ZT(){return typeof __HLS_WORKER_BUNDLE__=="function"}function JT(){let r=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(r);return{worker:new self.Worker(e),objectURL:e}}function e_(r){let e=new self.URL(r,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function Pi(r="",e=9e4){return{type:r,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var dl=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,i,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,i){}demux(e,t){this.cachedData&&(e=Hr(this.cachedData,e),this.cachedData=null);let i=rl(e,0),s=i?i.length:0,n,a=this._audioTrack,o=this._id3Track,l=i?jb(i):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&ce(l))&&(this.basePTS=t_(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:pi.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 Yb(e,s)?(i=rl(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:pi.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,n=s):s++;if(s===d&&n!==d){let c=Gr(e,n);this.cachedData?this.cachedData=Hr(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:Pi(),id3Track:o,textTrack:Pi()}}demuxSampleAes(e,t,i){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:Pi(),id3Track:this._id3Track,textTrack:Pi()}}destroy(){}},t_=(r,e,t)=>{if(ce(r))return r*90;let i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};function i_(r,e,t,i){let s,n,a,o,l=navigator.userAgent.toLowerCase(),d=i,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){r.trigger(y.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:${i}, 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),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&u>=6?n=u-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(u>=6&&a===1||/vivaldi/i.test(l))||!i&&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 Wg(r,e){return r[e]===255&&(r[e+1]&246)===240}function qg(r,e){return r[e+1]&1?7:9}function hh(r,e){return(r[e+3]&3)<<11|r[e+4]<<3|(r[e+5]&224)>>>5}function r_(r,e){return e+5<r.length}function cl(r,e){return e+1<r.length&&Wg(r,e)}function s_(r,e){return r_(r,e)&&Wg(r,e)&&hh(r,e)<=r.length-e}function n_(r,e){if(cl(r,e)){let t=qg(r,e);if(e+t>=r.length)return!1;let i=hh(r,e);if(i<=t)return!1;let s=e+i;return s===r.length||cl(r,s)}return!1}function Yg(r,e,t,i,s){if(!r.samplerate){let n=i_(e,t,i,s);if(!n)return;r.config=n.config,r.samplerate=n.samplerate,r.channelCount=n.channelCount,r.codec=n.codec,r.manifestCodec=n.manifestCodec,M.log(`parsed codec:${r.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function jg(r){return 1024*9e4/r}function a_(r,e){let t=qg(r,e);if(e+t<=r.length){let i=hh(r,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function zg(r,e,t,i,s){let n=jg(r.samplerate),a=i+s*n,o=a_(e,t),l;if(o){let{frameLength:u,headerLength:h}=o,m=h+u,g=Math.max(0,t+m-e.length);g?(l=new Uint8Array(m-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+m);let E={unit:l,pts:a};return g||r.samples.push(E),{sample:E,length:m,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 ku=class extends dl{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,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 i=(rl(e,0)||[]).length;for(let s=e.length;i<s;i++)if(n_(e,i))return M.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return s_(e,t)}appendFrame(e,t,i){Yg(e,this.observer,t,i,e.manifestCodec);let s=zg(e,t,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},o_=/\/emsg[-/]ID3/i,wu=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,i,s){let n=this.videoTrack=Pi("video",1),a=this.audioTrack=Pi("audio",1),o=this.txtTrack=Pi("text",1);if(this.id3Track=Pi("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=Dg(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=Rg.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 i=e,s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=Hr(this.remainderData,e));let o=dT(i);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=i;let a=this.extractID3Track(s,t);return n.samples=Bp(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(t,this.timeOffset);return i.samples=Bp(e,t),{videoTrack:t,audioTrack:Pi(),id3Track:s,textTrack:Pi()}}extractID3Track(e,t){let i=this.id3Track;if(e.samples.length){let s=Pe(e.samples,["emsg"]);s&&s.forEach(n=>{let a=hT(n);if(o_.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;i.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:pi.emsg,duration:l})}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},zo=null,l_=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],d_=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],c_=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],u_=[0,1,1,4];function Xg(r,e,t,i,s){if(t+24>e.length)return;let n=Qg(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=i+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return r.config=[],r.channelCount=n.channelCount,r.samplerate=n.sampleRate,r.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function Qg(r,e){let t=r[e+1]>>3&3,i=r[e+1]>>1&3,s=r[e+2]>>4&15,n=r[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){let a=r[e+2]>>1&1,o=r[e+3]>>6,l=t===3?3-i:i===3?3:4,d=l_[l*14+s-1]*1e3,u=d_[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,m=c_[t][i],g=u_[i],E=m*8*g,T=Math.floor(m*d/u+a)*g;if(zo===null){let x=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);zo=x?parseInt(x[1]):0}return!!zo&&zo<=87&&i===2&&d>=224e3&&o===0&&(r[e+3]=r[e+3]|128),{sampleRate:u,channelCount:h,frameLength:T,samplesPerFrame:E}}}function fh(r,e){return r[e]===255&&(r[e+1]&224)===224&&(r[e+1]&6)!==0}function Zg(r,e){return e+1<r.length&&fh(r,e)}function h_(r,e){return fh(r,e)&&4<=r.length-e}function f_(r,e){if(e+1<r.length&&fh(r,e)){let i=Qg(r,e),s=4;i!=null&&i.frameLength&&(s=i.frameLength);let n=e+s;return n===r.length||Zg(r,n)}return!1}var ul=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,i=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(i,i+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),i=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?i<<t|this.readBits(t):i}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,i=8,s;for(let n=0;n<e;n++)i!==0&&(s=this.readEG(),i=(t+s+256)%256),t=i===0?t:i}readSPS(){let e=0,t=0,i=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),m=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),m(),m(),n=c(),o=0;o<n;o++)m();g(),h(1);let R=c(),x=c(),N=d(1);N===0&&h(1),h(1),u()&&(e=c(),t=c(),i=c(),s=c());let w=[1,1];if(u()&&u())switch(l()){case 1:w=[1,1];break;case 2:w=[12,11];break;case 3:w=[10,11];break;case 4:w=[16,11];break;case 5:w=[40,33];break;case 6:w=[24,11];break;case 7:w=[20,11];break;case 8:w=[32,11];break;case 9:w=[80,33];break;case 10:w=[18,11];break;case 11:w=[15,11];break;case 12:w=[64,33];break;case 13:w=[160,99];break;case 14:w=[4,3];break;case 15:w=[3,2];break;case 16:w=[2,1];break;case 255:{w=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((R+1)*16-e*2-t*2),height:(2-N)*(x+1)*16-(N?2:4)*(i+s),pixelRatio:w}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},Du=class{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new qn(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,i){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,i)})}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)i.set(e.subarray(n,n+16),s);return i}getAvcDecryptedUnit(e,t){let i=new Uint8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(i.subarray(s,s+16),n);return e}decryptAvcSample(e,t,i,s,n){let a=Og(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,i+1,s)})}decryptAvcSamples(e,t,i,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){s();return}let n=e[t].units;for(;!(i>=n.length);i++){let a=n[i];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,i,s,a),!this.decrypter.isSync()))return}}}},Ot=188,Ni=class{constructor(e,t,i){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=i}static probe(e){let t=Ni.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,i=Math.min(Ot*5,e.length-Ot)+1,s=0;for(;s<i;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=Ot)if(e[l]===71){if(o++,a===-1&&(a=l,a!==0&&(i=Math.min(a+Ot*99,e.length-Ot)+1)),n||(n=Cu(e,l)===0),n&&o>1&&(a===0&&o>2||l+Ot>i))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:Rg[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,s){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Ni.createTrack("video"),this._audioTrack=Ni.createTrack("audio",s),this._id3Track=Ni.createTrack("id3"),this._txtTrack=Ni.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,this._duration=s}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_avcTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,t,i=!1,s=!1){i||(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,m=l.pid,g=o.pesData,E=l.pesData,T=null,A=this.pmtParsed,R=this._pmtId,x=e.length;if(this.remainderData&&(e=Hr(this.remainderData,e),x=e.length,this.remainderData=null),x<Ot&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let N=Math.max(0,Ni.syncOffset(e));x-=(x-N)%Ot,x<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,x,e.buffer.byteLength-x));let w=0;for(let O=N;O<x;O+=Ot)if(e[O]===71){let H=!!(e[O+1]&64),q=Cu(e,O),P=(e[O+3]&48)>>4,X;if(P>1){if(X=O+5+e[O+4],X===O+Ot)continue}else X=O+4;switch(q){case c:H&&(u&&(n=Gs(u))&&this.parseAVCPES(a,d,n,!1),u={data:[],size:0}),u&&(u.data.push(e.subarray(X,O+Ot)),u.size+=O+Ot-X);break;case h:if(H){if(g&&(n=Gs(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+Ot)),g.size+=O+Ot-X);break;case m:H&&(E&&(n=Gs(E))&&this.parseID3PES(l,n),E={data:[],size:0}),E&&(E.data.push(e.subarray(X,O+Ot)),E.size+=O+Ot-X);break;case 0:H&&(X+=e[X]+1),R=this._pmtId=m_(e,X);break;case R:{H&&(X+=e[X]+1);let j=p_(e,X,this.typeSupported,i);c=j.avc,c>0&&(a.pid=c),h=j.audio,h>0&&(o.pid=h,o.segmentCodec=j.segmentCodec),m=j.id3,m>0&&(l.pid=m),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=q;break}}else w++;if(w>0){let O=new Error(`Found ${w} TS packet/s that do not start with 0x47`);this.observer.emit(y.ERROR,y.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:i,id3Track:s,textTrack:n}=e,a=i.pesData,o=t.pesData,l=s.pesData,d;if(a&&(d=Gs(a))?(this.parseAVCPES(i,n,d,!0),i.pesData=null):i.pesData=a,o&&(d=Gs(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=Gs(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,i){let s=this.demux(e,i,!0,!this.config.progressive),n=this.sampleAes=new Du(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(i=>{let{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{i(e)}):i(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{i(e)})})}destroy(){this._duration=0}parseAVCPES(e,t,i,s){let n=this.parseAVCNALu(e,i.data),a=this.avcSample,o,l=!1;i.data=null,a&&n.length&&!e.audFound&&(zc(a,e),a=this.avcSample=Xo(!1,i.pts,i.dts,"")),n.forEach(d=>{switch(d.type){case 1:{o=!0,a||(a=this.avcSample=Xo(!0,i.pts,i.dts,"")),a.frame=!0;let c=d.data;if(l&&c.length>4){let u=new ul(c).readSliceType();(u===2||u===4||u===7||u===9)&&(a.key=!0)}break}case 5:o=!0,a||(a=this.avcSample=Xo(!0,i.pts,i.dts,"")),a.key=!0,a.frame=!0;break;case 6:{o=!0,Mg(d.data,1,i.pts,t.samples);break}case 7:if(o=!0,l=!0,!e.sps){let c=d.data,h=new ul(c).readSPS();e.width=h.width,e.height=h.height,e.pixelRatio=h.pixelRatio,e.sps=[c],e.duration=this._duration;let m=c.subarray(1,4),g="avc1.";for(let E=0;E<3;E++){let T=m[E].toString(16);T.length<2&&(T="0"+T),g+=T}e.codec=g}break;case 8:o=!0,e.pps||(e.pps=[d.data]);break;case 9:o=!1,e.audFound=!0,a&&zc(a,e),a=this.avcSample=Xo(!1,i.pts,i.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&&(zc(a,e),this.avcSample=null)}getLastNalUnit(e){var t;let i=this.avcSample,s;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){let n=i.units;s=n[n.length-1]}return s}parseAVCNALu(e,t){let i=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<i;){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 m={data:t.subarray(u,o-s-1),type:h};a.push(m)}else{let m=this.getLastNalUnit(e.samples);if(m&&(n&&o<=4-n&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-n)),d=o-s-1,d>0)){let g=new Uint8Array(m.data.byteLength+d);g.set(m.data,0),g.set(t.subarray(0,d),m.data.byteLength),m.data=g,m.state=0}}o<i?(c=t[o]&31,u=o,h=c,s=0):s=-1}else s=0}if(u>=0&&s>=0){let m={data:t.subarray(u,i),type:h,state:s};a.push(m)}if(a.length===0){let m=this.getLastNalUnit(e.samples);if(m){let g=new Uint8Array(m.data.byteLength+t.byteLength);g.set(m.data,0),g.set(t,m.data.byteLength),m.data=g}}return e.naluState=s,a}parseAACPES(e,t){let i=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 m=new Uint8Array(h+n.byteLength);m.set(s.sample.unit,0),m.set(n,h),n=m}else{let m=h-u;s.sample.unit.set(n.subarray(0,u),m),e.samples.push(s.sample),i=s.missing}}let a,o;for(a=i,o=n.length;a<o-1&&!cl(n,a);a++);if(a!==i){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 m=new Error(u);if(M.warn(`parsing error: ${u}`),this.observer.emit(y.ERROR,y.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,levelRetry:h,error:m,reason:u}),!h)return}Yg(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let u=jg(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=zg(e,n,a,l,d),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(d++;a<o-1&&!cl(n,a);a++);}parseMPEGPES(e,t){let i=t.data,s=i.length,n=0,a=0,o=t.pts;if(o===void 0){M.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(Zg(i,a)){let l=Xg(e,i,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 i=pt({},t,{type:this._avcTrack?pi.emsg:pi.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}};function Xo(r,e,t,i){return{key:r,frame:!1,pts:e,dts:t,units:[],debug:i,length:0}}function Cu(r,e){return((r[e+1]&31)<<8)+r[e+2]}function m_(r,e){return(r[e+10]&31)<<8|r[e+11]}function p_(r,e,t,i){let s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=(r[e+1]&15)<<8|r[e+2],a=e+3+n-4,o=(r[e+10]&15)<<8|r[e+11];for(e+=12+o;e<a;){let l=Cu(r,e);switch(r[e]){case 207:if(!i){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(!i){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+=((r[e+3]&15)<<8|r[e+4])+5}return s}function Gs(r){let e=0,t,i,s,n,a,o=r.data;if(!r||r.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(i=(t[4]<<8)+t[5],i&&i>r.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(r.size<=c)return null;r.size-=c;let u=new Uint8Array(r.size);for(let h=0,m=o.length;h<m;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 i&&(i-=s+3),{data:u,pts:n,dts:a,len:i}}return null}function zc(r,e){if(r.units.length&&r.frame){if(r.pts===void 0){let t=e.samples,i=t.length;if(i){let s=t[i-1];r.pts=s.pts,r.dts=s.dts}else{e.dropped++;return}}e.samples.push(r)}r.debug.length&&M.log(r.pts+"/"+r.dts+":"+r.debug)}var Mu=class extends dl{resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,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 i=(rl(e,0)||[]).length;for(let s=e.length;i<s;i++)if(f_(e,i))return M.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return h_(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return Xg(e,t,i,this.basePTS,this.frameIndex)}},hl=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,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]),i=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:i};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 i=8,s=t.length,n=s;for(;s--;)i+=t[s].byteLength;let a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=i&255,a.set(e,4),s=0,i=8;s<n;s++)a.set(t[s],i),i+=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 i=Math.floor(t/(pr+1)),s=Math.floor(t%(pr+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,i>>24,i>>16&255,i>>8&255,i&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,i){return F.box(F.types.moof,F.mfhd(e),F.traf(i,t))}static moov(e){let t=e.length,i=[];for(;t--;)i[t]=F.trak(e[t]);return F.box.apply(null,[F.types.moov,F.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(F.mvex(e)))}static mvex(e){let t=e.length,i=[];for(;t--;)i[t]=F.trex(e[t]);return F.box.apply(null,[F.types.mvex,...i])}static mvhd(e,t){t*=e;let i=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,i>>24,i>>16&255,i>>8&255,i&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||[],i=new Uint8Array(4+t.length),s,n;for(s=0;s<t.length;s++)n=t[s].flags,i[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return F.box(F.types.sdtp,i)}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=[],i=[],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,i.push(a>>>8&255),i.push(a&255),i=i.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(i))),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,i=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(i/(pr+1)),o=Math.floor(i%(pr+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 i=F.sdtp(e),s=e.id,n=Math.floor(t/(pr+1)),a=Math.floor(t%(pr+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,i.length+16+20+8+16+8+8),i)}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 i=e.samples||[],s=i.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=i[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),i=new Uint8Array(F.FTYP.byteLength+t.byteLength);return i.set(F.FTYP),i.set(t,F.FTYP.byteLength),i}};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 Jg=9e4;function mh(r,e,t=1,i=!1){let s=r*e*t;return i?Math.round(s):s}function g_(r,e,t=1,i=!1){return mh(r,e,1/t,i)}function Fn(r,e=!1){return mh(r,1e3,1/Jg,e)}function v_(r,e=1){return mh(r,Jg,1/e)}var E_=10*1e3,og=1024,y_=1152,Qo=null,Xc=null,Gn=class{constructor(e,t,i,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=i,this.ISGenerated=!1,Qo===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Qo=a?parseInt(a[1]):0}if(Xc===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);Xc=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,i=e.reduce((s,n)=>{let a=n.pts-s;return a<-4294967296?(t=!0,ai(s,n.pts)):a>0?s:n.pts},e[0].pts);return t&&M.debug("PTS rollover detected"),i}remux(e,t,i,s,n,a,o,l){let d,c,u,h,m,g,E=n,T=n,A=e.pid>-1,R=t.pid>-1,x=t.samples.length,N=e.samples.length>0,w=o&&x>0||x>1;if((!A||N)&&(!R||w)||this.ISGenerated||o){this.ISGenerated||(u=this.generateIS(e,t,n,a));let O=this.isVideoContiguous,H=-1,q;if(w&&(H=b_(t.samples),!O&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,H>0){M.warn(`[mp4-remuxer]: Dropped ${H} out of ${x} video samples due to a missing keyframe`);let P=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(H),t.dropped+=H,T+=(t.samples[0].pts-P)/t.inputTimeScale,q=T}else H===-1&&(M.warn(`[mp4-remuxer]: No keyframe found out of ${x} video samples`),g=!1);if(this.ISGenerated){if(N&&w){let P=this.getVideoStartPts(t.samples),j=(ai(e.samples[0].pts,P)-P)/t.inputTimeScale;E+=Math.max(0,j),T+=Math.max(0,-j)}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,R||w||l===ge.AUDIO?T:void 0),w){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 w&&(d=this.remuxVideo(t,T,O,0));d&&(d.firstKeyFrame=H,d.independent=H!==-1,d.firstKeyFramePTS=q)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(m=e0(i,n,this._initPTS,this._initDTS)),s.samples.length&&(h=t0(s,n,this._initPTS))),{audio:c,video:d,initSegment:u,independent:g,text:h,id3:m}}generateIS(e,t,i,s){let n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS,c=!d||s,u="audio/mp4",h,m,g;if(c&&(h=m=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=m=n[0].pts-Math.round(g*i):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*i);m=Math.min(m,ai(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:m,timescale:g}):h=g=void 0,{tracks:l,initPTS:h,timescale:g}}remuxVideo(e,t,i,s){let n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS,c=this.nextAvcDts,u=8,h=this.videoSampleDuration,m,g,E=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,A=!1;if(!i||c===null){let Z=t*n,ae=a[0].pts-ai(a[0].dts,a[0].pts);c=Z-ae}let R=d.baseTime*n/d.timescale;for(let Z=0;Z<l;Z++){let ae=a[Z];ae.pts=ai(ae.pts-R,c),ae.dts=ai(ae.dts-R,c),ae.dts<a[Z>0?Z-1:Z].dts&&(A=!0)}A&&a.sort(function(Z,ae){let se=Z.dts-ae.dts,xe=Z.pts-ae.pts;return se||xe}),m=a[0].dts,g=a[a.length-1].dts;let x=g-m,N=x?Math.round(x/(l-1)):h||e.inputTimeScale/30;if(i){let Z=m-c,ae=Z>N,se=Z<-1;if((ae||se)&&(ae?M.warn(`AVC: ${Fn(Z,!0)} ms (${Z}dts) hole between fragments detected, filling it`):M.warn(`AVC: ${Fn(-Z,!0)} ms (${Z}dts) overlapping between fragments detected`),!se||c>=a[0].pts)){m=c;let xe=a[0].pts-Z;a[0].dts=m,a[0].pts=xe,M.log(`Video: First PTS/DTS adjusted: ${Fn(xe,!0)}/${Fn(m,!0)}, delta: ${Fn(Z,!0)} ms`)}}m=Math.max(0,m);let w=0,$=0;for(let Z=0;Z<l;Z++){let ae=a[Z],se=ae.units,xe=se.length,Ie=0;for(let $e=0;$e<xe;$e++)Ie+=se[$e].data.length;$+=Ie,w+=xe,ae.length=Ie,ae.dts=Math.max(ae.dts,m),E=Math.min(ae.pts,E),T=Math.max(ae.pts,T)}g=a[l-1].dts;let O=$+4*w+8,H;try{H=new Uint8Array(O)}catch(Z){this.observer.emit(y.ERROR,y.ERROR,{type:pe.MUX_ERROR,details:B.REMUX_ALLOC_ERROR,fatal:!1,error:Z,bytes:O,reason:`fail allocating video mdat ${O}`});return}let q=new DataView(H.buffer);q.setUint32(0,O),H.set(F.types.mdat,4);let P=!1,X=Number.POSITIVE_INFINITY,j=Number.POSITIVE_INFINITY,Ae=Number.NEGATIVE_INFINITY,Ee=Number.NEGATIVE_INFINITY;for(let Z=0;Z<l;Z++){let ae=a[Z],se=ae.units,xe=0;for(let ht=0,V=se.length;ht<V;ht++){let J=se[ht],Re=J.data,Je=J.data.byteLength;q.setUint32(u,Je),u+=4,H.set(Re,u),u+=Je,xe+=4+Je}let Ie;if(Z<l-1)h=a[Z+1].dts-ae.dts,Ie=a[Z+1].pts-ae.pts;else{let ht=this.config,V=Z>0?ae.dts-a[Z-1].dts:N;if(Ie=Z>0?ae.pts-a[Z-1].pts:N,ht.stretchShortVideoTrack&&this.nextAudioPts!==null){let J=Math.floor(ht.maxBufferHole*n),Re=(s?E+s*n:this.nextAudioPts)-ae.pts;Re>J?(h=Re-V,h<0?h=V:P=!0,M.log(`[mp4-remuxer]: It is approximately ${Re/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=V}else h=V}let $e=Math.round(ae.pts-ae.dts);X=Math.min(X,h),Ae=Math.max(Ae,h),j=Math.min(j,Ie),Ee=Math.max(Ee,Ie),o.push(new fl(ae.key,h,xe,$e))}if(o.length){if(Qo){if(Qo<70){let Z=o[0].flags;Z.dependsOn=2,Z.isNonSync=0}}else if(Xc&&Ee-j<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=m;for(let ae=0,se=o.length;ae<se;ae++){let xe=Z+o[ae].duration,Ie=Z+o[ae].cts;if(ae<se-1){let $e=xe+o[ae+1].cts;o[ae].duration=$e-Ie}else o[ae].duration=ae?o[ae-1].duration:N;o[ae].cts=0,Z=xe}}}h=P||!h?N:h,this.nextAvcDts=c=g+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let ye=F.moof(e.sequenceNumber++,m,pt({},e,{samples:o})),we="video",Se={data1:ye,data2:H,startPTS:E/n,endPTS:(T+h)/n,startDTS:m/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,i,s,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=e.segmentCodec==="aac"?og:y_,c=d*l,u=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,m=[],g=n!==void 0,E=e.samples,T=h?0:8,A=this.nextAudioPts||-1,R=t*a,x=u.baseTime*a/u.timescale;if(this.isAudioContiguous=i=i||E.length&&A>0&&(s&&Math.abs(R-A)<9e3||Math.abs(ai(E[0].pts-x,R)-A)<20*c),E.forEach(function(we){we.pts=ai(we.pts-x,R)}),!i||A<0){if(E=E.filter(we=>we.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 we=this.config.maxAudioFramesDrift;for(let Se=0,Z=A;Se<E.length;Se++){let ae=E[Se],se=ae.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<E_&&g){let $e=Math.round(xe/c);Z=se-$e*c,Z<0&&($e--,Z+=c),Se===0&&(this.nextAudioPts=A=Z),M.warn(`[mp4-remuxer]: Injecting ${$e} audio frame @ ${(Z/a).toFixed(3)}s due to ${Math.round(1e3*xe/a)} ms gap.`);for(let ht=0;ht<$e;ht++){let V=Math.max(Z,0),J=hl.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);J||(M.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),J=ae.unit.subarray()),E.splice(Se,0,{unit:J,pts:V}),Z+=c,Se++}}ae.pts=Z,Z+=c}}let N=null,w=null,$,O=0,H=E.length;for(;H--;)O+=E[H].unit.byteLength;for(let we=0,Se=E.length;we<Se;we++){let Z=E[we],ae=Z.unit,se=Z.pts;if(w!==null){let Ie=m[we-1];Ie.duration=Math.round((se-w)/l)}else if(i&&e.segmentCodec==="aac"&&(se=A),N=se,O>0){O+=T;try{$=new Uint8Array(O)}catch(Ie){this.observer.emit(y.ERROR,y.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(ae,T);let xe=ae.byteLength;T+=xe,m.push(new fl(!0,d,xe,0)),w=se}let q=m.length;if(!q)return;let P=m[m.length-1];this.nextAudioPts=A=w+l*P.duration;let X=h?new Uint8Array(0):F.moof(e.sequenceNumber++,N/l,pt({},e,{samples:m}));e.samples=[];let j=N/a,Ae=A/a,ye={data1:X,data2:$,startPTS:j,endPTS:Ae,startDTS:j,endDTS:Ae,type:"audio",hasAudio:!0,hasVideo:!1,nb:q};return this.isAudioContiguous=!0,ye}remuxEmptyAudio(e,t,i,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,m=o*og,g=Math.ceil((h-u)/m),E=hl.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 R=u+A*m;T.push({unit:E,pts:R,dts:R})}return e.samples=T,this.remuxAudio(e,t,i,!1)}};function ai(r,e){let t;if(e===null)return r;for(e<r?t=-8589934592:t=8589934592;Math.abs(r-e)>4294967296;)r+=t;return r}function b_(r){for(let e=0;e<r.length;e++)if(r[e].key)return e;return-1}function e0(r,e,t,i){let s=r.samples.length;if(!s)return;let n=r.inputTimeScale;for(let o=0;o<s;o++){let l=r.samples[o];l.pts=ai(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=ai(l.dts-i.baseTime*n/i.timescale,e*n)/n}let a=r.samples;return r.samples=[],{samples:a}}function t0(r,e,t){let i=r.samples.length;if(!i)return;let s=r.inputTimeScale;for(let a=0;a<i;a++){let o=r.samples[a];o.pts=ai(o.pts-t.baseTime*9e4/t.timescale,e*s)/s}r.samples.sort((a,o)=>a.pts-o.pts);let n=r.samples;return r.samples=[],{samples:n}}var fl=class{constructor(e,t,i,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=i,this.cts=s,this.flags=new Ou(e)}},Ou=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}},Pu=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,i,s){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(sT(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:i}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let s=this.initData=Dg(e);t||(t=lg(s.audio,Ve.AUDIO)),i||(i=lg(s.video,Ve.VIDEO));let n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+i,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:i,initSegment:e,id:"main"}:M.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,i,s,n,a){var o,l;let{initPTS:d,lastEndTime:c}=this,u={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};ce(c)||(c=this.lastEndTime=n||0);let h=t.samples;if(!(h!=null&&h.length))return u;let m={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&&(m.tracks=this.initTracks,this.emitInitSegment=!1);let E=aT(h,g),T=nT(g,h),A=T===null?n:T;(T_(d,A,n,E)||m.timescale!==d.timescale&&a)&&(m.initPTS=A-n,d&&d.timescale===1&&M.warn(`Adjusting initPTS by ${m.initPTS-d.baseTime}`),this.initPTS=d={baseTime:m.initPTS,timescale:1});let R=e?A-d.baseTime/d.timescale:c,x=R+E;lT(g,h,d.baseTime/d.timescale),E>0?this.lastEndTime=x:(M.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let N=!!g.audio,w=!!g.video,$="";N&&($+="audio"),w&&($+="video");let O={data1:h,startPTS:R,startDTS:R,endPTS:x,endDTS:x,type:$,hasAudio:N,hasVideo:w,nb:1,dropped:0};return u.audio=O.type==="audio"?O:void 0,u.video=O.type!=="audio"?O:void 0,u.initSegment=m,u.id3=e0(i,n,d,d),s.samples.length&&(u.text=t0(s,n,d)),u}};function T_(r,e,t,i){if(r===null)return!0;let s=Math.max(i,1),n=e-r.baseTime/r.timescale;return Math.abs(n-t)>s}function lg(r,e){let t=r==null?void 0:r.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===Ve.VIDEO?"avc1.42e01e":"mp4a.40.5"}var zi;try{zi=self.performance.now.bind(self.performance)}catch{M.debug("Unable to use Performance API on this environment"),zi=typeof self!="undefined"&&self.Date.now}var Qc=[{demux:wu,remux:Pu},{demux:Ni,remux:Gn},{demux:ku,remux:Gn},{demux:Mu,remux:Gn}],ml=class{constructor(e,t,i,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=i,this.vendor=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,s){let n=i.transmuxing;n.executeStart=zi();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);let{contiguous:d,discontinuity:c,trackSwitch:u,accurateTimeOffset:h,timeOffset:m,initSegmentChange:g}=s||o,{audioCodec:E,videoCodec:T,defaultInitPts:A,duration:R,initSegmentData:x}=l,N=__(a,t);if(N&&N.method==="AES-128"){let H=this.getDecrypter();if(H.isSync()){let q=H.softwareDecrypt(a,N.key.buffer,N.iv.buffer);if(i.part>-1&&(q=H.flush()),!q)return n.executeEnd=zi(),Zc(i);a=new Uint8Array(q)}else return this.decryptionPromise=H.webCryptoDecrypt(a,N.key.buffer,N.iv.buffer).then(q=>{let P=this.push(q,null,i);return this.decryptionPromise=null,P}),this.decryptionPromise}let w=this.needsProbing(c,u);if(w){let H=this.configureTransmuxer(a);if(H)return M.warn(`[transmuxer] ${H.message}`),this.observer.emit(y.ERROR,y.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:H,reason:H.message}),n.executeEnd=zi(),Zc(i)}(c||u||g||w)&&this.resetInitSegment(x,E,T,R,t),(c||g||w)&&this.resetInitialTimestamp(A),d||this.resetContiguity();let $=this.transmux(a,N,m,h,i),O=this.currentTransmuxState;return O.contiguous=!0,O.discontinuity=!1,O.trackSwitch=!1,n.executeEnd=zi(),$}flush(e){let t=e.transmuxing;t.executeStart=zi();let{decrypter:i,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=s;if(i){let u=i.flush();u&&a.push(this.push(u,null,e))}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=zi(),[Zc(e)];let c=l.flush(o);return el(c)?c.then(u=>(this.flushRemux(a,u,e),a)):(this.flushRemux(a,c,e),a)}flushRemux(e,t,i){let{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;M.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);let c=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:c,chunkMeta:i}),i.transmuxing.executeEnd=zi()}resetInitialTimestamp(e){let{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,s,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,i,s),o.resetInitSegment(e,t,i,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,i,s,n):a=this.transmuxUnencrypted(e,i,s,n),a}transmuxUnencrypted(e,t,i,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,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,i,s,n){return this.demuxer.demuxSampleAes(e,t,i).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,i,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:i,typeSupported:s,vendor:n}=this,a;for(let u=0,h=Qc.length;u<h;u++)if(Qc[u].demux.probe(e)){a=Qc[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(i,t,s,n)),(!o||!(o instanceof c))&&(this.demuxer=new c(i,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 qn(this.config)),e}};function __(r,e){let t=null;return r.byteLength>0&&e!=null&&e.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var Zc=r=>({remuxResult:{},chunkMeta:r});function el(r){return"then"in r&&r.then instanceof Function}var Nu=class{constructor(e,t,i,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=i,this.duration=s,this.defaultInitPts=n||null}},Fu=class{constructor(e,t,i,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=i,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}},i0={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__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 m=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],m]:l._events[g].push(m):(l._events[g]=m,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new i:delete l._events[d]}function o(){this._events=new i,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,m=u.length,g=new Array(m);h<m;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,m,g){var E=t?t+d:d;if(!this._events[E])return!1;var T=this._events[E],A=arguments.length,R,x;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,m),!0;case 6:return T.fn.call(T.context,c,u,h,m,g),!0}for(x=1,R=new Array(A-1);x<A;x++)R[x-1]=arguments[x];T.fn.apply(T.context,R)}else{var N=T.length,w;for(x=0;x<N;x++)switch(T[x].once&&this.removeListener(d,T[x].fn,void 0,!0),A){case 1:T[x].fn.call(T[x].context);break;case 2:T[x].fn.call(T[x].context,c);break;case 3:T[x].fn.call(T[x].context,c,u);break;case 4:T[x].fn.call(T[x].context,c,u,h);break;default:if(!R)for(w=1,R=new Array(A-1);w<A;w++)R[w-1]=arguments[w];T[x].fn.apply(T[x].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 m=t?t+d:d;if(!this._events[m])return this;if(!c)return a(this,m),this;var g=this._events[m];if(g.fn)g.fn===c&&(!h||g.once)&&(!u||g.context===u)&&a(this,m);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[m]=T.length===1?T[0]:T:a(this,m)}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 i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,r.exports=o})(i0);var A_=i0.exports,ph=wb(A_),Jc=Al()||{isTypeSupported:()=>!1},pl=class{constructor(e,t,i,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=i,this.onFlush=s;let a=(d,c)=>{c=c||{},c.frag=this.frag,c.id=this.id,d===y.ERROR&&(this.error=c.error),this.hls.trigger(d,c)};this.observer=new ph,this.observer.on(y.FRAG_DECRYPTED,a),this.observer.on(y.ERROR,a);let o={mp4:Jc.isTypeSupported("video/mp4"),mpeg:Jc.isTypeSupported("audio/mpeg"),mp3:Jc.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"&&(n.workerPath||ZT())){try{n.workerPath?(M.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=e_(n.workerPath)):(M.log(`injecting Web Worker for "${t}"`),this.workerContext=JT()),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(y.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 ml(this.observer,o,n,l,t)}return}this.transmuxer=new ml(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,i,s,n,a,o,l,d,c){var u,h;d.transmuxing.start=self.performance.now();let{transmuxer:m}=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),x=T?d.sn-T.sn:-1,N=this.part?d.part-this.part.index:-1,w=x===0&&d.id>1&&d.id===(T==null?void 0:T.stats.chunkCount),$=!R&&(x===1||x===0&&(N===1||w&&N<=0)),O=self.performance.now();(R||x||n.stats.parsing.start===0)&&(n.stats.parsing.start=O),a&&(N||!$)&&(a.stats.parsing.start=O);let H=!(T&&((u=n.initSegment)==null?void 0:u.url)===((h=T.initSegment)==null?void 0:h.url)),q=new Fu(A,$,l,R,g,H);if(!$||A||H){M.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
|
|
934
934
|
discontinuity: ${A}
|
|
935
935
|
trackSwitch: ${R}
|
|
936
936
|
contiguous: ${$}
|
|
937
937
|
accurateTimeOffset: ${l}
|
|
938
938
|
timeOffset: ${g}
|
|
939
|
-
initSegmentChange: ${H}`);let P=new Pu(i,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:q},e instanceof ArrayBuffer?[e]:[]);else if(f){let P=f.push(e,E,d,q);el(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 i=t.flush(e);el(i)||t.async?(el(i)||(i=Promise.resolve(i)),i.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(i,e)}}transmuxerError(e,t,i){!this.hls||(this.error=e,this.hls.trigger(y.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data,i=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,i.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)}},E_=250,Jc=2,y_=.1,b_=.05,Fu=class{constructor(e,t,i,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=i,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:i,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||!qe.getBuffered(s).length)return;let c=qe.bufferInfo(s,a,0),u=c.len>0,h=c.nextStart||0;if(!u&&!h)return;if(o){let A=c.len>Jc,R=!h||t&&t.start<=a||h-a>Jc&&!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:Jc,w=this.fragmentTracker.getPartialFragment(a);if(A>0&&(A<=N||w)){this._trySkipBufferHole(w);return}}let g=self.performance.now();if(n===null){this.stalled=g;return}let E=g-n;if(!o&&E>=E_&&(this._reportStall(c),!this.media))return;let T=qe.bufferInfo(s,a,i.maxBufferHole);this._tryFixBufferStall(T,E)}_tryFixBufferStall(e,t){let{config:i,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>i.maxBufferHole||e.nextStart&&e.nextStart-a<i.maxBufferHole)&&t>i.highBufferWatchdogPeriod*1e3&&(M.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:i,stallReported:s}=this;if(!s&&i){this.stallReported=!0;let n=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(e)})`);M.warn(n.message),t.trigger(y.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){let{config:t,hls:i,media:s}=this;if(s===null)return 0;let n=s.currentTime,a=qe.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+b_,n+y_);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}`);i.trigger(y.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:i,nudgeRetry:s}=this;if(i===null)return;let n=i.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),i.currentTime=a,t.trigger(y.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(y.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}},T_=100,Uu=class extends Yn{constructor(e,t,i){super(e,t,i,"[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(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(y.ERROR,this.onError,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(y.ERROR,this.onError,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:i}=this;if(this.stopLoad(),this.setInterval(T_),this.level=-1,!this.startFragRequested){let s=i.startLevel;s===-1&&(i.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=i.nextAutoLevel),this.level=i.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:i,level:s}=this,n=i==null||(e=i[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 i=self.performance.now(),s=this.retryDate;(!s||i>=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:i,media:s}=this,{config:n,nextLoadLevel:a}=e;if(t===null||!s&&(this.startFragRequested||!n.startFragPrefetch)||this.altAudio&&this.audioOnly||!(i!=null&&i[a]))return;let o=i[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(y.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,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?Ve.AUDIO:Ve.VIDEO,R=(A===Ve.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;R&&this.afterBufferFlushed(R,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,i){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,i)):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 i,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?i=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:i=0}else i=0;let a=this.getBufferedFrag(t.currentTime+i);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 i=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new Fu(this.config,i,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 i=this.getMainFwdBufferInfo();if(i===null||i.len===0){this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(y.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 i=!1,s=!1,n;t.levels.forEach(a=>{n=a.audioCodec,n&&(n.indexOf("mp4a.40.2")!==-1&&(i=!0),n.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=i&&s&&!WT(),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:i}=this;if(!i||this.state!==W.IDLE)return;let s=i[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(s.details))&&(this.state=W.WAITING_LEVEL)}onLevelLoaded(e,t){var i;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||(i=l.details)!=null&&i.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(y.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:i,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}let o=a[i.level],l=o.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}let d=o.videoCodec,c=l.PTSKnown||!l.live,u=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new pl(this.hls,ge.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=s?s.index:-1,E=g!==-1,T=new Wn(i.level,i.sn,i.stats.chunkCount,n.byteLength,g,E),A=this.initPTS[i.cc];f.push(n,u,h,d,i,s,l.totalduration,c,T,A)}onAudioTrackSwitching(e,t){let i=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;i&&(n.trigger(y.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(y.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let i=t.id,s=!!this.hls.audioTracks[i].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 i=t.tracks,s,n,a=!1;for(let o in i){let l=i[o];if(l.id==="main"){if(n=o,s=l,o==="video"){let d=i[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:i,part:s}=t;if(i&&i.type!==ge.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===W.PARSED&&(this.state=W.IDLE);return}let n=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}onError(e,t){var i;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&&((i=t.context)==null?void 0:i.type)===Fe.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||!qe.getBuffered(e).length){let i=this.state!==W.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,i)}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!==Ve.AUDIO||this.audioOnly&&!this.altAudio){let i=(t===Ve.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,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,i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}let s=qe.getBuffered(e),a=(s.length?s.start(0):0)-i;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),i+=a,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${t}`),e.currentTime=i}}_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(i=>{let{hls:s}=this;if(!i||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(y.FRAG_LOADED,i),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let i="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 N=l.initSegment||l;this._bufferInitSegment(c,g.tracks,N,a),s.trigger(y.FRAG_PARSING_INIT_SEGMENT,{frag:N,id:i,tracks:g.tracks})}let R=g.initPTS,x=g.timescale;ce(R)&&(this.initPTS[l.cc]={baseTime:R,timescale:x},s.trigger(y.INIT_PTS_FOUND,{frag:l,id:i,initPTS:R,timescale:x}))}let A=l.sn!==(E==null?void 0:E.startSN);if(u&&n.independent!==!1){if(E){let{startPTS:R,endPTS:x,startDTS:N,endDTS:w}=u;if(d)d.elementaryStreams[u.type]={startPTS:R,endPTS:x,startDTS:N,endDTS:w};else if(u.firstKeyFrame&&u.independent&&a.id===1&&(this.couldBacktrack=!0),u.dropped&&u.independent){let $=this.getMainFwdBufferInfo(),O=($?$.end:this.getLoadPosition())+this.config.maxBufferHole,H=u.firstKeyFramePTS?u.firstKeyFramePTS:R;if(A&&O<H-this.config.maxBufferHole){this.backtrack(l);return}l.setElementaryStreamInfo(u.type,l.start,x,l.start,w,!0)}l.setElementaryStreamInfo(u.type,R,x,N,w),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(u,l,d,a)}}else if(A&&n.independent===!1){this.backtrack(l);return}if(T){let{startPTS:R,endPTS:x,startDTS:N,endDTS:w}=T;d&&(d.elementaryStreams[Ve.AUDIO]={startPTS:R,endPTS:x,startDTS:N,endDTS:w}),l.setElementaryStreamInfo(Ve.AUDIO,R,x,N,w),this.bufferFragmentData(T,l,d,a)}if(E&&f!=null&&(t=f.samples)!=null&&t.length){let R={id:i,frag:l,details:E,samples:f.samples};s.trigger(y.FRAG_PARSING_METADATA,R)}if(E&&h){let R={id:i,frag:l,details:E,samples:h.samples};s.trigger(y.FRAG_PARSING_USERDATA,R)}}_bufferInitSegment(e,t,i,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(y.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let c=t[l].initSegment;c!=null&&c.byteLength&&this.hls.trigger(y.BUFFER_APPENDING,{type:l,data:c,frag:i,part:null,chunkMeta:s,parent:i.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 i=e.currentTime;if(qe.isBuffered(e,i)?t=this.getAppendedFrag(i):qe.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.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(y.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(y.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,i=this.currentFrag;if(i&&ce(t)&&ce(i.programDateTime)){let s=i.programDateTime+(t-i.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,i=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_=i}sample(e,t){let i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*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_}},Bu=class{constructor(e,t,i,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_=i,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_:i,fast_:s,ttfb_:n}=this;i.halfLife!==e&&(this.slow_=new gr(e,i.getEstimate(),i.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 i=8*t,s=e/1e3,n=i/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){let t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,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(){}},$u=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 Bu(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){let{hls:e}=this;e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var i;let s=t.frag;this.ignoreFragment(s)||(this.fragCurrent=s,this.partCurrent=(i=t.part)!=null?i:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,i,s){let n=e+i/t,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let i=this.hls.config,{total:s,bwEstimate:n}=t.stats;ce(s)&&ce(n)&&(this.lastLevelLoadSec=8*s/n),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}_abandonRulesCheck(){let{fragCurrent:e,partCurrent:t,hls:i}=this,{autoLevelEnabled:s,media:n}=i;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=i.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}=i,x=A[e.level],N=o.total||Math.max(o.loaded,Math.round(l*x.maxBitrate/8)),w=d-g;w<1&&E&&(w=Math.min(d,o.loaded*8/T));let $=E?o.loaded*1e3/w:0,O=$?(N-o.loaded)/$:N*8/T+u/1e3;if(O<=f)return;let H=$?$*8:T,q=Number.POSITIVE_INFINITY,P;for(P=e.level-1;P>R;P--){let X=A[P].maxBitrate;if(q=this.getTimeToLoadFrag(u/1e3,H,l*X,!A[P].details),q<f)break}q>=O||q>l*10||(i.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;
|
|
940
|
-
Time to underbuffer: ${
|
|
939
|
+
initSegmentChange: ${H}`);let P=new Nu(i,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:q},e instanceof ArrayBuffer?[e]:[]);else if(m){let P=m.push(e,E,d,q);el(P)?(m.async=!0,P.then(X=>{this.handleTransmuxComplete(X)}).catch(X=>{this.transmuxerError(X,d,"transmuxer-interface push error")})):(m.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 i=t.flush(e);el(i)||t.async?(el(i)||(i=Promise.resolve(i)),i.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(i,e)}}transmuxerError(e,t,i){!this.hls||(this.error=e,this.hls.trigger(y.ERROR,{type:pe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data,i=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,i.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)}},S_=250,eu=2,x_=.1,I_=.05,Uu=class{constructor(e,t,i,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=i,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:i,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||!qe.getBuffered(s).length)return;let c=qe.bufferInfo(s,a,0),u=c.len>0,h=c.nextStart||0;if(!u&&!h)return;if(o){let A=c.len>eu,R=!h||t&&t.start<=a||h-a>eu&&!this.fragmentTracker.getPartialFragment(a);if(A||R)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var m;let A=Math.max(h,c.start||0)-a,R=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,N=(R==null||(m=R.details)==null?void 0:m.live)?R.details.targetduration*2:eu,w=this.fragmentTracker.getPartialFragment(a);if(A>0&&(A<=N||w)){this._trySkipBufferHole(w);return}}let g=self.performance.now();if(n===null){this.stalled=g;return}let E=g-n;if(!o&&E>=S_&&(this._reportStall(c),!this.media))return;let T=qe.bufferInfo(s,a,i.maxBufferHole);this._tryFixBufferStall(T,E)}_tryFixBufferStall(e,t){let{config:i,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>i.maxBufferHole||e.nextStart&&e.nextStart-a<i.maxBufferHole)&&t>i.highBufferWatchdogPeriod*1e3&&(M.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:i,stallReported:s}=this;if(!s&&i){this.stallReported=!0;let n=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(e)})`);M.warn(n.message),t.trigger(y.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){let{config:t,hls:i,media:s}=this;if(s===null)return 0;let n=s.currentTime,a=qe.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,m=!1;if(n===0){let g=h.getAppendedFrag(0,ge.MAIN);g&&o<g.end&&(m=!0)}if(!m){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+I_,n+x_);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}`);i.trigger(y.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:i,nudgeRetry:s}=this;if(i===null)return;let n=i.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),i.currentTime=a,t.trigger(y.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(y.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}},L_=100,Bu=class extends Yn{constructor(e,t,i){super(e,t,i,"[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(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(y.ERROR,this.onError,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(y.ERROR,this.onError,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:i}=this;if(this.stopLoad(),this.setInterval(L_),this.level=-1,!this.startFragRequested){let s=i.startLevel;s===-1&&(i.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=i.nextAutoLevel),this.level=i.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:i,level:s}=this,n=i==null||(e=i[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 i=self.performance.now(),s=this.retryDate;(!s||i>=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:i,media:s}=this,{config:n,nextLoadLevel:a}=e;if(t===null||!s&&(this.startFragRequested||!n.startFragPrefetch)||this.altAudio&&this.audioOnly||!(i!=null&&i[a]))return;let o=i[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(y.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 m=this.backtrackFragment?this.backtrackFragment.start:l.end,g=this.getNextFragment(m,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,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,m)){if(!g.gap){let A=this.audioOnly&&!this.altAudio?Ve.AUDIO:Ve.VIDEO,R=(A===Ve.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;R&&this.afterBufferFlushed(R,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,m))}loadFragment(e,t,i){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,i)):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 i,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?i=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:i=0}else i=0;let a=this.getBufferedFrag(t.currentTime+i);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 i=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new Uu(this.config,i,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 i=this.getMainFwdBufferInfo();if(i===null||i.len===0){this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(y.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 i=!1,s=!1,n;t.levels.forEach(a=>{n=a.audioCodec,n&&(n.indexOf("mp4a.40.2")!==-1&&(i=!0),n.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=i&&s&&!QT(),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:i}=this;if(!i||this.state!==W.IDLE)return;let s=i[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(s.details))&&(this.state=W.WAITING_LEVEL)}onLevelLoaded(e,t){var i;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||(i=l.details)!=null&&i.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(y.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:i,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}let o=a[i.level],l=o.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}let d=o.videoCodec,c=l.PTSKnown||!l.live,u=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),m=this.transmuxer=this.transmuxer||new pl(this.hls,ge.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=s?s.index:-1,E=g!==-1,T=new Wn(i.level,i.sn,i.stats.chunkCount,n.byteLength,g,E),A=this.initPTS[i.cc];m.push(n,u,h,d,i,s,l.totalduration,c,T,A)}onAudioTrackSwitching(e,t){let i=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;i&&(n.trigger(y.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(y.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let i=t.id,s=!!this.hls.audioTracks[i].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 i=t.tracks,s,n,a=!1;for(let o in i){let l=i[o];if(l.id==="main"){if(n=o,s=l,o==="video"){let d=i[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:i,part:s}=t;if(i&&i.type!==ge.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===W.PARSED&&(this.state=W.IDLE);return}let n=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}onError(e,t){var i;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&&((i=t.context)==null?void 0:i.type)===Fe.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||!qe.getBuffered(e).length){let i=this.state!==W.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,i)}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!==Ve.AUDIO||this.audioOnly&&!this.altAudio){let i=(t===Ve.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,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,i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}let s=qe.getBuffered(e),a=(s.length?s.start(0):0)-i;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),i+=a,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${t}`),e.currentTime=i}}_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(i=>{let{hls:s}=this;if(!i||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(y.FRAG_LOADED,i),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let i="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:m,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 N=l.initSegment||l;this._bufferInitSegment(c,g.tracks,N,a),s.trigger(y.FRAG_PARSING_INIT_SEGMENT,{frag:N,id:i,tracks:g.tracks})}let R=g.initPTS,x=g.timescale;ce(R)&&(this.initPTS[l.cc]={baseTime:R,timescale:x},s.trigger(y.INIT_PTS_FOUND,{frag:l,id:i,initPTS:R,timescale:x}))}let A=l.sn!==(E==null?void 0:E.startSN);if(u&&n.independent!==!1){if(E){let{startPTS:R,endPTS:x,startDTS:N,endDTS:w}=u;if(d)d.elementaryStreams[u.type]={startPTS:R,endPTS:x,startDTS:N,endDTS:w};else if(u.firstKeyFrame&&u.independent&&a.id===1&&(this.couldBacktrack=!0),u.dropped&&u.independent){let $=this.getMainFwdBufferInfo(),O=($?$.end:this.getLoadPosition())+this.config.maxBufferHole,H=u.firstKeyFramePTS?u.firstKeyFramePTS:R;if(A&&O<H-this.config.maxBufferHole){this.backtrack(l);return}l.setElementaryStreamInfo(u.type,l.start,x,l.start,w,!0)}l.setElementaryStreamInfo(u.type,R,x,N,w),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(u,l,d,a)}}else if(A&&n.independent===!1){this.backtrack(l);return}if(T){let{startPTS:R,endPTS:x,startDTS:N,endDTS:w}=T;d&&(d.elementaryStreams[Ve.AUDIO]={startPTS:R,endPTS:x,startDTS:N,endDTS:w}),l.setElementaryStreamInfo(Ve.AUDIO,R,x,N,w),this.bufferFragmentData(T,l,d,a)}if(E&&m!=null&&(t=m.samples)!=null&&t.length){let R={id:i,frag:l,details:E,samples:m.samples};s.trigger(y.FRAG_PARSING_METADATA,R)}if(E&&h){let R={id:i,frag:l,details:E,samples:h.samples};s.trigger(y.FRAG_PARSING_USERDATA,R)}}_bufferInitSegment(e,t,i,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(y.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let c=t[l].initSegment;c!=null&&c.byteLength&&this.hls.trigger(y.BUFFER_APPENDING,{type:l,data:c,frag:i,part:null,chunkMeta:s,parent:i.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 i=e.currentTime;if(qe.isBuffered(e,i)?t=this.getAppendedFrag(i):qe.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.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(y.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(y.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,i=this.currentFrag;if(i&&ce(t)&&ce(i.programDateTime)){let s=i.programDateTime+(t-i.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,i=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_=i}sample(e,t){let i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*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_}},$u=class{constructor(e,t,i,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_=i,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_:i,fast_:s,ttfb_:n}=this;i.halfLife!==e&&(this.slow_=new gr(e,i.getEstimate(),i.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 i=8*t,s=e/1e3,n=i/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){let t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,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(){}},Gu=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 $u(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){let{hls:e}=this;e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var i;let s=t.frag;this.ignoreFragment(s)||(this.fragCurrent=s,this.partCurrent=(i=t.part)!=null?i:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,i,s){let n=e+i/t,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let i=this.hls.config,{total:s,bwEstimate:n}=t.stats;ce(s)&&ce(n)&&(this.lastLevelLoadSec=8*s/n),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}_abandonRulesCheck(){let{fragCurrent:e,partCurrent:t,hls:i}=this,{autoLevelEnabled:s,media:n}=i;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=i.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 m=c.len/h;if(m>=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}=i,x=A[e.level],N=o.total||Math.max(o.loaded,Math.round(l*x.maxBitrate/8)),w=d-g;w<1&&E&&(w=Math.min(d,o.loaded*8/T));let $=E?o.loaded*1e3/w:0,O=$?(N-o.loaded)/$:N*8/T+u/1e3;if(O<=m)return;let H=$?$*8:T,q=Number.POSITIVE_INFINITY,P;for(P=e.level-1;P>R;P--){let X=A[P].maxBitrate;if(q=this.getTimeToLoadFrag(u/1e3,H,l*X,!A[P].details),q<m)break}q>=O||q>l*10||(i.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;
|
|
940
|
+
Time to underbuffer: ${m.toFixed(3)} s
|
|
941
941
|
Estimated load time for current fragment: ${O.toFixed(3)} s
|
|
942
942
|
Estimated load time for down switch fragment: ${q.toFixed(3)} s
|
|
943
943
|
TTFB estimate: ${g}
|
|
944
944
|
Current BW estimate: ${ce(T)?(T/1024).toFixed(3):"Unknown"} Kb/s
|
|
945
945
|
New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
|
|
946
|
-
Aborting and switching to level ${P}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),i.trigger(y.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}onFragLoaded(e,{frag:t,part:i}){let s=i?i.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=i?i.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:i,id:t.type};this.onFragBuffered(y.FRAG_BUFFERED,n),t.bitrateTest=!1}}}onFragBuffered(e,t){let{frag:i,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:i.stats;if(n.aborted||this.ignoreFragment(i))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(),i.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 i=this.getNextABRAutoLevel();if(e!==-1){let s=this.hls.levels;if(s.length>Math.max(e,i)&&s[e].loadError<=s[i].loadError)return e}return e!==-1&&(i=Math.min(e,i)),i}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:i}=this,{maxAutoLevel:s,config:n,minAutoLevel:a,media:o}=i,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=i.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,i,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 x=i;x>=t;x--){let N=u[x];if(!N||g&&N.codecSet!==g){N&&(A=Math.min(x,A),R=Math.max(x,R));continue}R!==-1&&M.trace(`[abr] Skipped level(s) ${A}-${R} with CODECS:"${u[R].attrs.CODECS}"; not compatible with "${h.attrs.CODECS}"`);let w=N.details,$=(d?w==null?void 0:w.partTarget:w==null?void 0:w.averagetargetduration)||E,O;x<=c?O=n*e:O=a*e;let H=u[x].maxBitrate,q=this.getTimeToLoadFrag(T,O,H*$,w===void 0);if(M.trace(`[abr] level:${x} adjustedbw-bitrate:${Math.round(O-H)} avgDuration:${$.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:${q.toFixed(1)}`),O>H&&(q===0||!ce(q)||f&&!this.bitrateTestDelay||q<s))return x}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}},gl=class{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let{chunks:e,dataLength:t}=this,i;if(e.length)e.length===1?i=e[0]:i=__(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}};function __(r,e){let t=new Uint8Array(e),i=0;for(let s=0;s<r.length;s++){let n=r[s];t.set(n,i),i+=n.length}return t}var ag=100,Gu=class extends Yn{constructor(e,t,i){super(e,t,i,"[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(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(y.ERROR,this.onError,this),e.on(y.BUFFER_RESET,this.onBufferReset,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(y.ERROR,this.onError,this),e.off(y.BUFFER_RESET,this.onBufferReset,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:n}){if(i==="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(ag),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:i,trackId:s}=this,n=i==null||(e=i[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 i=performance.now(),s=this.retryDate;(!s||i>=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 i=this.waitingData;if(i){let{frag:s,part:n,cache:a,complete:o}=i;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=qe.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);Eu(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:i,trackId:s}=this,n=e.config;if(!(t!=null&&t[s])||!i&&(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,Ve.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(y.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&&i){let w=this.getLoadPosition();c&&u.attrs!==c.attrs&&(A=w),o.PTSKnown&&w<T&&(d.end>T||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=T+.05)}let R=this.getNextFragment(A,o),x=!1;if(R&&this.isLoopLoading(R,A)&&(x=!!R.gap,R=this.getNextFragmentLoopLoading(R,o,d,ge.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 w=this.getAppendedFrag(R.start,ge.MAIN);if(w===null||(x||(x=!!w.gap||!!N&&h.len===0),N&&!x||x&&d.nextStart&&d.nextStart<w.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(i=>new Kr(i))}onAudioTrackSwitching(e,t){let i=!!t.url;this.trackId=t.id;let{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),i?this.setInterval(ag):this.resetTransmuxer(),i?(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(y.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var i;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||(i=o.details)!=null&&i.live){let d=this.mainDetails;if(n.fragments[0]||(n.deltaUpdateFailed=!0),n.deltaUpdateFailed||!d)return;!o.details&&n.hasProgramDateTime&&d.hasProgramDateTime?($g(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:i,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 ${i.sn} of level ${i.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(i.start);return}let u=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new pl(this.hls,ge.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let f=this.initPTS[i.cc],g=(t=i.initSegment)==null?void 0:t.data;if(f!==void 0){let T=s?s.index:-1,A=T!==-1,R=new Wn(i.level,i.sn,i.stats.chunkCount,n.byteLength,T,A);h.push(n,g,u,"",i,s,c.totalduration,!1,R,f)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);let{cache:E}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new gl,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 i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:i,part:s}=t;if(i.type!==ge.AUDIO){if(!this.loadedmetadata&&i.type===ge.MAIN){let n=this.videoBuffer||this.media;n&&qe.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(i.sn!=="initSegment"){this.fragPrevious=i;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(y.AUDIO_TRACK_SWITCHED,zt({},n)))}this.fragBufferedComplete(i,s)}onError(e,t){var i;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&&((i=t.context)==null?void 0:i.type)===Fe.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===Ve.AUDIO&&(this.bufferFlushed=!0,this.state===W.ENDED&&(this.state=W.IDLE))}_handleTransmuxComplete(e){var t;let i="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(y.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:i,tracks:E.tracks})}if(h){let{startPTS:T,endPTS:A,startDTS:R,endDTS:x}=h;d&&(d.elementaryStreams[Ve.AUDIO]={startPTS:T,endPTS:A,startDTS:R,endDTS:x}),l.setElementaryStreamInfo(Ve.AUDIO,T,A,R,x),this.bufferFragmentData(h,l,d,a)}if(g!=null&&(t=g.samples)!=null&&t.length){let T=pt({id:i,frag:l,details:u},g);s.trigger(y.FRAG_PARSING_METADATA,T)}if(f){let T=pt({id:i,frag:l,details:u},f);s.trigger(y.FRAG_PARSING_USERDATA,T)}}_bufferInitSegment(e,t,i){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(y.BUFFER_CODECS,e);let n=s.initSegment;if(n!=null&&n.byteLength){let a={type:"audio",frag:t,part:null,chunkMeta:i,parent:t.type,data:n};this.hls.trigger(y.BUFFER_APPENDING,a)}this.tick()}loadFragment(e,t,i){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,i))}else this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){let{hls:t,media:i,bufferedTrack:s}=this,n=s==null?void 0:s.attrs,a=e.attrs;i&&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(y.AUDIO_TRACK_SWITCHED,zt({},e))}},Hu=class extends Kn{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(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(y.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:i,groupId:s,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==s){this.warn(`Track with id:${i} and group:${s} not found in active group ${a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`audio-track ${i} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,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 i=t.audioGroupIds[t.urlId];if(this.groupId!==i){this.groupId=i||null;let s=this.tracks.filter(a=>!i||a.groupId===i);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:${i}`),this.hls.trigger(y.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===Fe.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 i=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(y.AUDIO_TRACK_SWITCHING,zt({},s)),s.details&&!s.details.live)return;let o=this.switchParams(s.url,i==null?void 0:i.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 i=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(i.message),this.hls.trigger(y.ERROR,{type:pe.MEDIA_ERROR,details:B.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++){let s=t[i];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 i=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 ${i} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(y.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:e||null})}}};function e0(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(!A_(r[t].attrs,e[t].attrs))return!1;return!0}function A_(r,e){let t=r["STABLE-RENDITION-ID"];return t?t===e["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>r[i]!==e[i])}var og=500,Vu=class extends Yn{constructor(e,t,i){super(e,t,i,"[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(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.ERROR,this.onError,this),e.on(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.ERROR,this.onError,this),e.off(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=W.IDLE,this.setInterval(og),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:i,success:s}=t;if(this.fragPrevious=i,this.state=W.IDLE,!s)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=i.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}let l=i.start+i.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(e,t){let{startOffset:i,endOffset:s}=t;if(i===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(i,n,ge.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===ge.MAIN){var i;(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let i=t.frag;(i==null?void 0:i.type)===ge.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==W.STOPPED&&(this.state=W.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(e0(this.levels,t)){this.levels=t.map(i=>new Kr(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{let s=new Kr(i);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 i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(og)}onSubtitleTrackLoaded(e,t){var i;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||(i=l.details)!=null&&i.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,vu(s,d))):s.hasProgramDateTime&&c.hasProgramDateTime?($g(s,c),d=s.fragments[0].start):u&&(d=u.start,vu(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&&(Vn(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:i}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){let a=performance.now();this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(y.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(y.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,i=t[e];if(!t.length||!i||!i.details)return;let{config:s}=this,n=this.getLoadPosition(),a=qe.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,ge.MAIN),c=i.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=Vn(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)===Tt.NOT_LOADED&&(E=R)}this.fragmentTracker.getState(E)===Tt.NOT_LOADED&&this.loadFragment(E,i,o)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,i){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,i))}get mediaBufferTimeRanges(){return new Ku(this.tracksBuffered[this.currentTrackId]||[])}},Ku=class{constructor(e){this.buffered=void 0;let t=(i,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}}}},Wu=class extends Kn{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(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(y.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),eu(this.media.textTracks).forEach(t=>{Vs(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:i,details:s}=t,{trackId:n}=this,a=this.tracksInGroup[n];if(!a){this.warn(`Invalid subtitle track id ${i}`);return}let o=a.details;a.details=t.details,this.log(`subtitle track ${i} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,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 i=t.textGroupIds[t.urlId],s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){let n=this.tracks.filter(l=>!i||l.groupId===i);this.tracksInGroup=n;let a=this.findTrackId(s==null?void 0:s.name)||this.findTrackId();this.groupId=i||null;let o={subtitleTracks:n};this.log(`Updating subtitle tracks, ${n.length} track(s) found in "${i}" group-id`),this.hls.trigger(y.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 i=0;i<t.length;i++){let s=t[i];if((!this.selectDefaultTrack||s.default)&&(!e||e===s.name))return s.id}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Fe.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 i=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 ${i}`),this.hls.trigger(y.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(e){let{media:t,trackId:i}=this;if(!t)return;let s=eu(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[i];o&&(o.mode="disabled")}let a=n[e];a&&(a.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var i;let s=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(e===-1||(i=s[e])!=null&&i.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(y.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(y.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1,t=eu(this.media.textTracks);for(let i=0;i<t.length;i++)if(t[i].mode==="hidden")e=i;else if(t[i].mode==="showing"){e=i;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}};function eu(r){let e=[];for(let t=0;t<r.length;t++){let i=r[t];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(r[t])}return e}var qu=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t){let i=this.queues[t];i.push(e),i.length===1&&this.buffers[t]&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,i=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),i}executeNext(e){let{buffers:t,queues:i}=this,s=t[e],n=i[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]}},lg=Al(),dg=/([ha]vc.)(?:\.[^.,]+)+/,Yu=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:i}=this;M.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(y.MEDIA_ATTACHED,{media:t})),i&&i.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:i}=this;t&&t.src!==i&&M.error(`Media element src was set while attaching MediaSource (${i} > ${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(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.BUFFER_RESET,this.onBufferReset,this),e.on(y.BUFFER_APPENDING,this.onBufferAppending,this),e.on(y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.BUFFER_EOS,this.onBufferEos,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.FRAG_PARSED,this.onFragParsed,this),e.on(y.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.BUFFER_RESET,this.onBufferReset,this),e.off(y.BUFFER_APPENDING,this.onBufferAppending,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.BUFFER_EOS,this.onBufferEos,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.FRAG_PARSED,this.onFragParsed,this),e.off(y.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new qu(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,M.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let i=this.media=t.media;if(i&&lg){let s=this.mediaSource=new lg;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(s),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:i}=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),i&&self.URL.revokeObjectURL(i),e.src===i?(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(y.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(i){M.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(e,t){let i=this.getSourceBufferTypes().length;Object.keys(t).forEach(s=>{if(i){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(dg,"$1"),h=(l||o).replace(dg,"$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]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(e,t){let{operationQueue:i}=this,s={execute:()=>{let n=this.sourceBuffer[e];n&&(M.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),i.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{M.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,n)}};i.append(s,e)}onBufferAppending(e,t){let{hls:i,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 x=this.sourceBuffer[o];if(x){let N=A-x.timestampOffset;Math.abs(N)>=.1&&(M.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${A} (delta: ${N}) sn: ${l.sn})`),x.timestampOffset=A)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let x=self.performance.now();u.executeEnd=u.end=x,f.first===0&&(f.first=x),g&&g.first===0&&(g.first=x);let{sourceBuffer:N}=this,w={};for(let $ in N)w[$]=qe.getBuffered(N[$]);this.appendError=0,this.hls.trigger(y.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:c,parent:l.type,timeRanges:w})},onError:x=>{M.error(`[buffer-controller]: Error encountered while trying to append to the ${o} SourceBuffer`,x);let N={type:pe.MEDIA_ERROR,parent:l.type,details:B.BUFFER_APPEND_ERROR,frag:l,part:d,chunkMeta:c,error:x,err:x,fatal:!1};x.code===DOMException.QUOTA_EXCEEDED_ERR?N.details=B.BUFFER_FULL_ERROR:(this.appendError++,N.details=B.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(M.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),N.fatal=!0)),i.trigger(y.ERROR,N)}};s.append(R,o)}onBufferFlushing(e,t){let{operationQueue:i}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(y.BUFFER_FLUSHED,{type:n})},onError:a=>{M.warn(`[buffer-controller]: Failed to remove from ${n} SourceBuffer`,a)}});t.type?i.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{i.append(s(n),n)})}onFragParsed(e,t){let{frag:i,part:s}=t,n=[],a=s?s.elementaryStreams:i.elementaryStreams;a[Ve.AUDIOVIDEO]?n.push("audiovideo"):(a[Ve.AUDIO]&&n.push("audio"),a[Ve.VIDEO]&&n.push("video"));let o=()=>{let l=self.performance.now();i.stats.buffering.end=l,s&&(s.stats.buffering.end=l);let d=s?s.stats:i.stats;this.hls.trigger(y.FRAG_BUFFERED,{frag:i,part:s,stats:d,id:i.type})};n.length===0&&M.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.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:i,sourceBuffer:s}=this;if(!i||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=i.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=qe.getBuffered(h);if(f.length>0&&c>f.start(0)){if(e.trigger(y.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(y.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(y.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:i,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=i.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,i=e.fragments;if(i.length&&e.live&&t!=null&&t.setLiveSeekableRange){let n=Math.max(0,i[0].start),a=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,a)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:i}=this,s=Object.keys(i).length;if(s&&!e||s===2){this.createSourceBuffers(i),this.pendingTracks={};let n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(y.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(y.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:i}=this;if(!i)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]=i.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(y.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 i=new Error(`${e} SourceBuffer error`);M.error(`[buffer-controller]: ${i}`,t),this.hls.trigger(y.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_APPENDING_ERROR,error:i,fatal:!1});let s=this.operationQueue.current(e);s&&s.onError(t)}removeExecutor(e,t,i){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(i,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:i,sourceBuffer:s}=this,n=s[t];if(!n){M.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),i.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:i}=this,s=t.map(n=>i.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{let a=this.sourceBuffer[n];a!=null&&a.updating||i.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,i){let s=this.sourceBuffer[e];if(!s)return;let n=i.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(i=>{t.removeEventListener(i.event,i.listener)})}},cg={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},t0=function(e){let t=e;return cg.hasOwnProperty(e)&&(t=cg[e]),String.fromCharCode(t)},fi=15,ji=100,S_={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},x_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},I_={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},L_={25:2,26:4,29:6,30:8,31:10,27:13,28:15},R_=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],ju=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let i=typeof t=="function"?t():t;M.log(`${this.time} [${e}] ${i}`)}}},Br=function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t},vl=class{constructor(e,t,i,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=i||!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 i=0;i<t.length;i++){let s=t[i];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}},zu=class{constructor(e,t,i,s,n,a){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new vl(t,i,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()}},Xu=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<ji;t++)this.chars.push(new zu);this.logger=e,this.pos=0,this.currPenState=new vl}equals(e){let t=!0;for(let i=0;i<ji;i++)if(!this.chars[i].equals(e.chars[i])){t=!1;break}return t}copy(e){for(let t=0;t<ji;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<ji;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>ji&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ji)}moveCursor(e){let t=this.pos+e;if(e>1)for(let i=this.pos+1;i<t+1;i++)this.chars[i].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=t0(e);if(this.pos>=ji){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<ji;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 i=0;i<ji;i++){let s=this.chars[i].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}},Hn=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<fi;t++)this.rows.push(new Xu(e));this.logger=e,this.currRow=fi-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<fi;e++)this.rows[e].clear();this.currRow=fi-1}equals(e){let t=!0;for(let i=0;i<fi;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<fi;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<fi;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<fi;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 i=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);i.setCursor(e.indent),e.color=i.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=[],i="",s=-1;for(let n=0;n<fi;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?i="["+t.join(" | ")+"]":i=t.join(`
|
|
947
|
-
`)),i}getTextAndFormat(){return this.rows}},El=class{constructor(e,t,i){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 Hn(i),this.nonDisplayedMemory=new Hn(i),this.lastOutputScreen=new Hn(i),this.currRollUpRow=this.displayedMemory.rows[fi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[fi-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 i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);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 i=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[i]}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))}},yl=class{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;let s=new ju;this.channels=[null,new El(e,t,s),new El(e+1,i,s)],this.cmdHistory=hg(),this.logger=s}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let i,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,"["+Br([t[o],t[o+1]])+"] -> ("+Br([s,n])+")"),i=this.parseCmd(s,n),i||(i=this.parseMidrow(s,n)),i||(i=this.parsePAC(s,n)),i||(i=this.parseBackgroundAttributes(s,n)),!i&&(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?")}!i&&!a&&this.logger.log(2,"Couldn't parse cleaned data "+Br([s,n])+" orig: "+Br([t[o],t[o+1]]))}}parseCmd(e,t){let{cmdHistory:i}=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(ug(e,t,i))return Hs(null,null,i),this.logger.log(3,"Repeated command ("+Br([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),Hs(e,t,i),this.currentChannel=a,!0}parseMidrow(e,t){let i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let s=this.channels[i];return s?(s.ccMIDROW(t),this.logger.log(3,"MIDROW ("+Br([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let i,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(ug(e,t,s))return Hs(null,null,s),!0;let o=e<=23?1:2;t>=64&&t<=95?i=o===1?S_[e]:I_[e]:i=o===1?x_[e]:L_[e];let l=this.channels[o];return l?(l.setPAC(this.interpretPAC(i,t)),Hs(e,t,s),this.currentChannel=o,!0):!1}interpretPAC(e,t){let i,s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?i=t-96:i=t-64,s.underline=(i&1)===1,i<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((i-16)/2)*4,s}parseChars(e,t){let i,s=null,n=null;if(e>=25?(i=2,n=e-8):(i=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 '"+t0(a)+"' in channel "+i),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);if(s){let a=Br(s);this.logger.log(3,"Char codes = "+a.join(",")),Hs(e,t,this.cmdHistory)}return s}parseBackgroundAttributes(e,t){let i=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(i||s))return!1;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=R_[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),Hs(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=hg()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let i=this.channels[t];i&&i.cueSplitAtTime(e)}}};function Hs(r,e,t){t.a=r,t.b=e}function ug(r,e,t){return t.a===r&&t.b===e}function hg(){return{a:null,b:null}}var Ks=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,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}},ph=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;let r=["","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 i(o){return t(r,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="",x=!0,N="auto",w="start",$=50,O="middle",H=50,q="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 R},set:function(P){let X=i(P);if(X===!1)throw new SyntaxError("An invalid or illegal string was specified.");R=X,this.hasBeenReset=!0}})),Object.defineProperty(c,"snapToLines",n({},u,{get:function(){return x},set:function(P){x=!!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 w},set:function(P){let X=s(P);if(!X)throw new SyntaxError("An invalid or illegal string was specified.");w=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 H},set:function(P){if(P<0||P>100)throw new Error("Size must be between 0 and 100.");H=P,this.hasBeenReset=!0}})),Object.defineProperty(c,"align",n({},u,{get:function(){return q},set:function(P){let X=s(P);if(!X)throw new SyntaxError("An invalid or illegal string was specified.");q=X,this.hasBeenReset=!0}})),c.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),Qu=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function i0(r){function e(i,s,n,a){return(i|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}let t=r.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 Zu=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let s=0;s<i.length;++s)if(t===i[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 i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}};function r0(r,e,t,i){let s=i?r.split(i):[r];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 Ju=new ph(0,0,""),Zo=Ju.align==="middle"?"middle":"center";function k_(r,e,t){let i=r;function s(){let o=i0(r);if(o===null)throw new Error("Malformed timestamp: "+i);return r=r.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){let d=new Zu;r0(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",Zo,"end"]);break;case"position":g=f.split(","),d.percent(h,g[0]),g.length===2&&d.alt("positionAlign",g[1],["start",Zo,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",Zo,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let c=d.get("line","auto");c==="auto"&&Ju.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",Zo);let u=d.get("position","auto");u==="auto"&&Ju.position===50&&(u=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=u}function a(){r=r.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),r.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);r=r.slice(3),a(),e.endTime=s(),a(),n(r,e)}function s0(r){return r.replace(/<br(?: \/)?>/gi,`
|
|
948
|
-
`)}var
|
|
946
|
+
Aborting and switching to level ${P}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),i.trigger(y.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}onFragLoaded(e,{frag:t,part:i}){let s=i?i.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=i?i.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:i,id:t.type};this.onFragBuffered(y.FRAG_BUFFERED,n),t.bitrateTest=!1}}}onFragBuffered(e,t){let{frag:i,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:i.stats;if(n.aborted||this.ignoreFragment(i))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(),i.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 i=this.getNextABRAutoLevel();if(e!==-1){let s=this.hls.levels;if(s.length>Math.max(e,i)&&s[e].loadError<=s[i].loadError)return e}return e!==-1&&(i=Math.min(e,i)),i}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:i}=this,{maxAutoLevel:s,config:n,minAutoLevel:a,media:o}=i,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=i.mainForwardBufferInfo,h=(u?u.len:0)/d,m=this.findBestLevel(c,a,s,h,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(m>=0)return m;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 m=this.findBestLevel(c,a,s,h+g,E,T),Math.max(m,0)}findBestLevel(e,t,i,s,n,a){var o;let{fragCurrent:l,partCurrent:d,lastLoadedFragLevel:c}=this,{levels:u}=this.hls,h=u[c],m=!!(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 x=i;x>=t;x--){let N=u[x];if(!N||g&&N.codecSet!==g){N&&(A=Math.min(x,A),R=Math.max(x,R));continue}R!==-1&&M.trace(`[abr] Skipped level(s) ${A}-${R} with CODECS:"${u[R].attrs.CODECS}"; not compatible with "${h.attrs.CODECS}"`);let w=N.details,$=(d?w==null?void 0:w.partTarget:w==null?void 0:w.averagetargetduration)||E,O;x<=c?O=n*e:O=a*e;let H=u[x].maxBitrate,q=this.getTimeToLoadFrag(T,O,H*$,w===void 0);if(M.trace(`[abr] level:${x} adjustedbw-bitrate:${Math.round(O-H)} avgDuration:${$.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:${q.toFixed(1)}`),O>H&&(q===0||!ce(q)||m&&!this.bitrateTestDelay||q<s))return x}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}},gl=class{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let{chunks:e,dataLength:t}=this,i;if(e.length)e.length===1?i=e[0]:i=R_(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}};function R_(r,e){let t=new Uint8Array(e),i=0;for(let s=0;s<r.length;s++){let n=r[s];t.set(n,i),i+=n.length}return t}var dg=100,Hu=class extends Yn{constructor(e,t,i){super(e,t,i,"[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(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(y.ERROR,this.onError,this),e.on(y.BUFFER_RESET,this.onBufferReset,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(y.ERROR,this.onError,this),e.off(y.BUFFER_RESET,this.onBufferReset,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:n}){if(i==="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(dg),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:i,trackId:s}=this,n=i==null||(e=i[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 i=performance.now(),s=this.retryDate;(!s||i>=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 i=this.waitingData;if(i){let{frag:s,part:n,cache:a,complete:o}=i;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=qe.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);yu(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:i,trackId:s}=this,n=e.config;if(!(t!=null&&t[s])||!i&&(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,Ve.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(y.BUFFER_EOS,{type:"audio"}),this.state=W.ENDED;return}let h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,ge.MAIN),m=d.len,g=this.getMaxBufferLength(h==null?void 0:h.len);if(m>=g&&!u)return;let T=o.fragments[0].start,A=d.end;if(u&&i){let w=this.getLoadPosition();c&&u.attrs!==c.attrs&&(A=w),o.PTSKnown&&w<T&&(d.end>T||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=T+.05)}let R=this.getNextFragment(A,o),x=!1;if(R&&this.isLoopLoading(R,A)&&(x=!!R.gap,R=this.getNextFragmentLoopLoading(R,o,d,ge.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 w=this.getAppendedFrag(R.start,ge.MAIN);if(w===null||(x||(x=!!w.gap||!!N&&h.len===0),N&&!x||x&&d.nextStart&&d.nextStart<w.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(i=>new Kr(i))}onAudioTrackSwitching(e,t){let i=!!t.url;this.trackId=t.id;let{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),i?this.setInterval(dg):this.resetTransmuxer(),i?(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(y.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var i;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||(i=o.details)!=null&&i.live){let d=this.mainDetails;if(n.fragments[0]||(n.deltaUpdateFailed=!0),n.deltaUpdateFailed||!d)return;!o.details&&n.hasProgramDateTime&&d.hasProgramDateTime?(Vg(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:i,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 ${i.sn} of level ${i.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(i.start);return}let u=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new pl(this.hls,ge.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let m=this.initPTS[i.cc],g=(t=i.initSegment)==null?void 0:t.data;if(m!==void 0){let T=s?s.index:-1,A=T!==-1,R=new Wn(i.level,i.sn,i.stats.chunkCount,n.byteLength,T,A);h.push(n,g,u,"",i,s,c.totalduration,!1,R,m)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);let{cache:E}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new gl,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 i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:i,part:s}=t;if(i.type!==ge.AUDIO){if(!this.loadedmetadata&&i.type===ge.MAIN){let n=this.videoBuffer||this.media;n&&qe.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(i.sn!=="initSegment"){this.fragPrevious=i;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(y.AUDIO_TRACK_SWITCHED,zt({},n)))}this.fragBufferedComplete(i,s)}onError(e,t){var i;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&&((i=t.context)==null?void 0:i.type)===Fe.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===Ve.AUDIO&&(this.bufferFlushed=!0,this.state===W.ENDED&&(this.state=W.IDLE))}_handleTransmuxComplete(e){var t;let i="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:m,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(y.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:i,tracks:E.tracks})}if(h){let{startPTS:T,endPTS:A,startDTS:R,endDTS:x}=h;d&&(d.elementaryStreams[Ve.AUDIO]={startPTS:T,endPTS:A,startDTS:R,endDTS:x}),l.setElementaryStreamInfo(Ve.AUDIO,T,A,R,x),this.bufferFragmentData(h,l,d,a)}if(g!=null&&(t=g.samples)!=null&&t.length){let T=pt({id:i,frag:l,details:u},g);s.trigger(y.FRAG_PARSING_METADATA,T)}if(m){let T=pt({id:i,frag:l,details:u},m);s.trigger(y.FRAG_PARSING_USERDATA,T)}}_bufferInitSegment(e,t,i){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(y.BUFFER_CODECS,e);let n=s.initSegment;if(n!=null&&n.byteLength){let a={type:"audio",frag:t,part:null,chunkMeta:i,parent:t.type,data:n};this.hls.trigger(y.BUFFER_APPENDING,a)}this.tick()}loadFragment(e,t,i){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,i))}else this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){let{hls:t,media:i,bufferedTrack:s}=this,n=s==null?void 0:s.attrs,a=e.attrs;i&&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(y.AUDIO_TRACK_SWITCHED,zt({},e))}},Vu=class extends Kn{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(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(y.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:i,groupId:s,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==s){this.warn(`Track with id:${i} and group:${s} not found in active group ${a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`audio-track ${i} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,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 i=t.audioGroupIds[t.urlId];if(this.groupId!==i){this.groupId=i||null;let s=this.tracks.filter(a=>!i||a.groupId===i);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:${i}`),this.hls.trigger(y.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===Fe.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 i=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(y.AUDIO_TRACK_SWITCHING,zt({},s)),s.details&&!s.details.live)return;let o=this.switchParams(s.url,i==null?void 0:i.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 i=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(i.message),this.hls.trigger(y.ERROR,{type:pe.MEDIA_ERROR,details:B.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++){let s=t[i];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 i=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 ${i} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(y.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:e||null})}}};function r0(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(!k_(r[t].attrs,e[t].attrs))return!1;return!0}function k_(r,e){let t=r["STABLE-RENDITION-ID"];return t?t===e["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>r[i]!==e[i])}var cg=500,Ku=class extends Yn{constructor(e,t,i){super(e,t,i,"[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(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.ERROR,this.onError,this),e.on(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.ERROR,this.onError,this),e.off(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=W.IDLE,this.setInterval(cg),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:i,success:s}=t;if(this.fragPrevious=i,this.state=W.IDLE,!s)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=i.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}let l=i.start+i.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(e,t){let{startOffset:i,endOffset:s}=t;if(i===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(i,n,ge.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===ge.MAIN){var i;(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let i=t.frag;(i==null?void 0:i.type)===ge.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==W.STOPPED&&(this.state=W.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(r0(this.levels,t)){this.levels=t.map(i=>new Kr(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{let s=new Kr(i);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 i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(cg)}onSubtitleTrackLoaded(e,t){var i;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||(i=l.details)!=null&&i.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,Eu(s,d))):s.hasProgramDateTime&&c.hasProgramDateTime?(Vg(s,c),d=s.fragments[0].start):u&&(d=u.start,Eu(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&&(Vn(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:i}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){let a=performance.now();this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(y.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(y.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,i=t[e];if(!t.length||!i||!i.details)return;let{config:s}=this,n=this.getLoadPosition(),a=qe.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,ge.MAIN),c=i.details,u=this.getMaxBufferLength(d==null?void 0:d.len)+c.levelTargetDuration;if(l>u)return;let h=c.fragments,m=h.length,g=c.edge,E=null,T=this.fragPrevious;if(o<g){let A=s.maxFragLookUpTolerance,R=o>g-A?0:A;E=Vn(T,h,Math.max(h[0].start,o),R),!E&&T&&T.start<h[0].start&&(E=h[0])}else E=h[m-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)===Tt.NOT_LOADED&&(E=R)}this.fragmentTracker.getState(E)===Tt.NOT_LOADED&&this.loadFragment(E,i,o)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,i){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,i))}get mediaBufferTimeRanges(){return new Wu(this.tracksBuffered[this.currentTrackId]||[])}},Wu=class{constructor(e){this.buffered=void 0;let t=(i,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}}}},qu=class extends Kn{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(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(y.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),tu(this.media.textTracks).forEach(t=>{Vs(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:i,details:s}=t,{trackId:n}=this,a=this.tracksInGroup[n];if(!a){this.warn(`Invalid subtitle track id ${i}`);return}let o=a.details;a.details=t.details,this.log(`subtitle track ${i} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,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 i=t.textGroupIds[t.urlId],s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){let n=this.tracks.filter(l=>!i||l.groupId===i);this.tracksInGroup=n;let a=this.findTrackId(s==null?void 0:s.name)||this.findTrackId();this.groupId=i||null;let o={subtitleTracks:n};this.log(`Updating subtitle tracks, ${n.length} track(s) found in "${i}" group-id`),this.hls.trigger(y.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 i=0;i<t.length;i++){let s=t[i];if((!this.selectDefaultTrack||s.default)&&(!e||e===s.name))return s.id}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Fe.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 i=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 ${i}`),this.hls.trigger(y.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(e){let{media:t,trackId:i}=this;if(!t)return;let s=tu(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[i];o&&(o.mode="disabled")}let a=n[e];a&&(a.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var i;let s=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(e===-1||(i=s[e])!=null&&i.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(y.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(y.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1,t=tu(this.media.textTracks);for(let i=0;i<t.length;i++)if(t[i].mode==="hidden")e=i;else if(t[i].mode==="showing"){e=i;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}};function tu(r){let e=[];for(let t=0;t<r.length;t++){let i=r[t];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(r[t])}return e}var Yu=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t){let i=this.queues[t];i.push(e),i.length===1&&this.buffers[t]&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,i=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),i}executeNext(e){let{buffers:t,queues:i}=this,s=t[e],n=i[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]}},ug=Al(),hg=/([ha]vc.)(?:\.[^.,]+)+/,ju=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:i}=this;M.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(y.MEDIA_ATTACHED,{media:t})),i&&i.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:i}=this;t&&t.src!==i&&M.error(`Media element src was set while attaching MediaSource (${i} > ${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(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.BUFFER_RESET,this.onBufferReset,this),e.on(y.BUFFER_APPENDING,this.onBufferAppending,this),e.on(y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.BUFFER_EOS,this.onBufferEos,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.FRAG_PARSED,this.onFragParsed,this),e.on(y.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.BUFFER_RESET,this.onBufferReset,this),e.off(y.BUFFER_APPENDING,this.onBufferAppending,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.BUFFER_EOS,this.onBufferEos,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.FRAG_PARSED,this.onFragParsed,this),e.off(y.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Yu(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,M.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let i=this.media=t.media;if(i&&ug){let s=this.mediaSource=new ug;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(s),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:i}=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),i&&self.URL.revokeObjectURL(i),e.src===i?(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(y.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(i){M.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(e,t){let i=this.getSourceBufferTypes().length;Object.keys(t).forEach(s=>{if(i){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(hg,"$1"),h=(l||o).replace(hg,"$1");if(u!==h){let m=`${d};codecs=${l||o}`;this.appendChangeType(s,m),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]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(e,t){let{operationQueue:i}=this,s={execute:()=>{let n=this.sourceBuffer[e];n&&(M.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),i.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{M.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,n)}};i.append(s,e)}onBufferAppending(e,t){let{hls:i,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 m=l.stats.buffering,g=d?d.stats.buffering:null;m.start===0&&(m.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 x=this.sourceBuffer[o];if(x){let N=A-x.timestampOffset;Math.abs(N)>=.1&&(M.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${A} (delta: ${N}) sn: ${l.sn})`),x.timestampOffset=A)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let x=self.performance.now();u.executeEnd=u.end=x,m.first===0&&(m.first=x),g&&g.first===0&&(g.first=x);let{sourceBuffer:N}=this,w={};for(let $ in N)w[$]=qe.getBuffered(N[$]);this.appendError=0,this.hls.trigger(y.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:c,parent:l.type,timeRanges:w})},onError:x=>{M.error(`[buffer-controller]: Error encountered while trying to append to the ${o} SourceBuffer`,x);let N={type:pe.MEDIA_ERROR,parent:l.type,details:B.BUFFER_APPEND_ERROR,frag:l,part:d,chunkMeta:c,error:x,err:x,fatal:!1};x.code===DOMException.QUOTA_EXCEEDED_ERR?N.details=B.BUFFER_FULL_ERROR:(this.appendError++,N.details=B.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(M.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),N.fatal=!0)),i.trigger(y.ERROR,N)}};s.append(R,o)}onBufferFlushing(e,t){let{operationQueue:i}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(y.BUFFER_FLUSHED,{type:n})},onError:a=>{M.warn(`[buffer-controller]: Failed to remove from ${n} SourceBuffer`,a)}});t.type?i.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{i.append(s(n),n)})}onFragParsed(e,t){let{frag:i,part:s}=t,n=[],a=s?s.elementaryStreams:i.elementaryStreams;a[Ve.AUDIOVIDEO]?n.push("audiovideo"):(a[Ve.AUDIO]&&n.push("audio"),a[Ve.VIDEO]&&n.push("video"));let o=()=>{let l=self.performance.now();i.stats.buffering.end=l,s&&(s.stats.buffering.end=l);let d=s?s.stats:i.stats;this.hls.trigger(y.FRAG_BUFFERED,{frag:i,part:s,stats:d,id:i.type})};n.length===0&&M.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.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:i,sourceBuffer:s}=this;if(!i||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=i.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 m=qe.getBuffered(h);if(m.length>0&&c>m.start(0)){if(e.trigger(y.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(y.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(h.ended&&m.end(m.length-1)-o<l*2){M.info(`[buffer-controller]: Cannot flush ${u} back buffer while SourceBuffer is in ended state`);return}e.trigger(y.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:i,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=i.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,i=e.fragments;if(i.length&&e.live&&t!=null&&t.setLiveSeekableRange){let n=Math.max(0,i[0].start),a=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,a)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:i}=this,s=Object.keys(i).length;if(s&&!e||s===2){this.createSourceBuffers(i),this.pendingTracks={};let n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(y.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(y.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:i}=this;if(!i)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]=i.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(y.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 i=new Error(`${e} SourceBuffer error`);M.error(`[buffer-controller]: ${i}`,t),this.hls.trigger(y.ERROR,{type:pe.MEDIA_ERROR,details:B.BUFFER_APPENDING_ERROR,error:i,fatal:!1});let s=this.operationQueue.current(e);s&&s.onError(t)}removeExecutor(e,t,i){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(i,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:i,sourceBuffer:s}=this,n=s[t];if(!n){M.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),i.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:i}=this,s=t.map(n=>i.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{let a=this.sourceBuffer[n];a!=null&&a.updating||i.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,i){let s=this.sourceBuffer[e];if(!s)return;let n=i.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(i=>{t.removeEventListener(i.event,i.listener)})}},fg={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},s0=function(e){let t=e;return fg.hasOwnProperty(e)&&(t=fg[e]),String.fromCharCode(t)},fi=15,ji=100,w_={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},D_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},C_={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},M_={25:2,26:4,29:6,30:8,31:10,27:13,28:15},O_=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],zu=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let i=typeof t=="function"?t():t;M.log(`${this.time} [${e}] ${i}`)}}},Br=function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t},vl=class{constructor(e,t,i,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=i||!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 i=0;i<t.length;i++){let s=t[i];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}},Xu=class{constructor(e,t,i,s,n,a){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new vl(t,i,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()}},Qu=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<ji;t++)this.chars.push(new Xu);this.logger=e,this.pos=0,this.currPenState=new vl}equals(e){let t=!0;for(let i=0;i<ji;i++)if(!this.chars[i].equals(e.chars[i])){t=!1;break}return t}copy(e){for(let t=0;t<ji;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<ji;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>ji&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ji)}moveCursor(e){let t=this.pos+e;if(e>1)for(let i=this.pos+1;i<t+1;i++)this.chars[i].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=s0(e);if(this.pos>=ji){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<ji;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 i=0;i<ji;i++){let s=this.chars[i].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}},Hn=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<fi;t++)this.rows.push(new Qu(e));this.logger=e,this.currRow=fi-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<fi;e++)this.rows[e].clear();this.currRow=fi-1}equals(e){let t=!0;for(let i=0;i<fi;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<fi;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<fi;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<fi;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 i=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);i.setCursor(e.indent),e.color=i.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=[],i="",s=-1;for(let n=0;n<fi;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?i="["+t.join(" | ")+"]":i=t.join(`
|
|
947
|
+
`)),i}getTextAndFormat(){return this.rows}},El=class{constructor(e,t,i){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 Hn(i),this.nonDisplayedMemory=new Hn(i),this.lastOutputScreen=new Hn(i),this.currRollUpRow=this.displayedMemory.rows[fi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[fi-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 i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);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 i=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[i]}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))}},yl=class{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;let s=new zu;this.channels=[null,new El(e,t,s),new El(e+1,i,s)],this.cmdHistory=pg(),this.logger=s}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let i,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,"["+Br([t[o],t[o+1]])+"] -> ("+Br([s,n])+")"),i=this.parseCmd(s,n),i||(i=this.parseMidrow(s,n)),i||(i=this.parsePAC(s,n)),i||(i=this.parseBackgroundAttributes(s,n)),!i&&(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?")}!i&&!a&&this.logger.log(2,"Couldn't parse cleaned data "+Br([s,n])+" orig: "+Br([t[o],t[o+1]]))}}parseCmd(e,t){let{cmdHistory:i}=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(mg(e,t,i))return Hs(null,null,i),this.logger.log(3,"Repeated command ("+Br([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),Hs(e,t,i),this.currentChannel=a,!0}parseMidrow(e,t){let i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let s=this.channels[i];return s?(s.ccMIDROW(t),this.logger.log(3,"MIDROW ("+Br([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let i,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(mg(e,t,s))return Hs(null,null,s),!0;let o=e<=23?1:2;t>=64&&t<=95?i=o===1?w_[e]:C_[e]:i=o===1?D_[e]:M_[e];let l=this.channels[o];return l?(l.setPAC(this.interpretPAC(i,t)),Hs(e,t,s),this.currentChannel=o,!0):!1}interpretPAC(e,t){let i,s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?i=t-96:i=t-64,s.underline=(i&1)===1,i<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((i-16)/2)*4,s}parseChars(e,t){let i,s=null,n=null;if(e>=25?(i=2,n=e-8):(i=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 '"+s0(a)+"' in channel "+i),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);if(s){let a=Br(s);this.logger.log(3,"Char codes = "+a.join(",")),Hs(e,t,this.cmdHistory)}return s}parseBackgroundAttributes(e,t){let i=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(i||s))return!1;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=O_[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),Hs(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=pg()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let i=this.channels[t];i&&i.cueSplitAtTime(e)}}};function Hs(r,e,t){t.a=r,t.b=e}function mg(r,e,t){return t.a===r&&t.b===e}function pg(){return{a:null,b:null}}var Ks=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,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}},gh=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;let r=["","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 i(o){return t(r,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="",m=!1,g=o,E=l,T=d,A=null,R="",x=!0,N="auto",w="start",$=50,O="middle",H=50,q="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 m},set:function(P){m=!!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 R},set:function(P){let X=i(P);if(X===!1)throw new SyntaxError("An invalid or illegal string was specified.");R=X,this.hasBeenReset=!0}})),Object.defineProperty(c,"snapToLines",n({},u,{get:function(){return x},set:function(P){x=!!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 w},set:function(P){let X=s(P);if(!X)throw new SyntaxError("An invalid or illegal string was specified.");w=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 H},set:function(P){if(P<0||P>100)throw new Error("Size must be between 0 and 100.");H=P,this.hasBeenReset=!0}})),Object.defineProperty(c,"align",n({},u,{get:function(){return q},set:function(P){let X=s(P);if(!X)throw new SyntaxError("An invalid or illegal string was specified.");q=X,this.hasBeenReset=!0}})),c.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),Zu=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function n0(r){function e(i,s,n,a){return(i|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}let t=r.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 Ju=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let s=0;s<i.length;++s)if(t===i[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 i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}};function a0(r,e,t,i){let s=i?r.split(i):[r];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 eh=new gh(0,0,""),Zo=eh.align==="middle"?"middle":"center";function P_(r,e,t){let i=r;function s(){let o=n0(r);if(o===null)throw new Error("Malformed timestamp: "+i);return r=r.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){let d=new Ju;a0(o,function(h,m){let g;switch(h){case"region":for(let E=t.length-1;E>=0;E--)if(t[E].id===m){d.set(h,t[E].region);break}break;case"vertical":d.alt(h,m,["rl","lr"]);break;case"line":g=m.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",Zo,"end"]);break;case"position":g=m.split(","),d.percent(h,g[0]),g.length===2&&d.alt("positionAlign",g[1],["start",Zo,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,m);break;case"align":d.alt(h,m,["start",Zo,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let c=d.get("line","auto");c==="auto"&&eh.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",Zo);let u=d.get("position","auto");u==="auto"&&eh.position===50&&(u=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=u}function a(){r=r.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),r.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);r=r.slice(3),a(),e.endTime=s(),a(),n(r,e)}function o0(r){return r.replace(/<br(?: \/)?>/gi,`
|
|
948
|
+
`)}var th=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Zu,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 i(){let n=t.buffer,a=0;for(n=o0(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
|
|
949
949
|
`;)++a;let o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
|
|
950
|
-
`&&++a,t.buffer=n.slice(a),o}function s(n){
|
|
950
|
+
`&&++a,t.buffer=n.slice(a),o}function s(n){a0(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=i();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=i(),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 gh(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{P_(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+=`
|
|
951
951
|
`),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+=`
|
|
952
952
|
|
|
953
|
-
`,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}},
|
|
953
|
+
`,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}},N_=/\r\n|\n\r|\n|\r/g,iu=function(e,t,i=0){return e.slice(i,i+t.length)===t},F_=function(e){let t=parseInt(e.slice(-3)),i=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(i)||!ce(s)||!ce(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*s,t+=60*60*1e3*n,t},ru=function(e){let t=5381,i=e.length;for(;i;)t=t*33^e.charCodeAt(--i);return(t>>>0).toString()};function vh(r,e,t){return ru(r.toString())+ru(e.toString())+ru(t)}var U_=function(e,t,i){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=i};function B_(r,e,t,i,s,n,a){let o=new th,l=Bi(new Uint8Array(r)).trim().replace(N_,`
|
|
954
954
|
`).split(`
|
|
955
|
-
`),d=[],c=e?
|
|
956
|
-
`)}),o.flush()}var
|
|
957
|
-
`:(n=i.childNodes)!=null&&n.length?o0(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function N_(r,e,t){let i="http://www.w3.org/ns/ttml#styling",s=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=r!=null&&r.hasAttribute("style")?r.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{let d=nu(e,i,l)||nu(r,i,l)||nu(s,i,l);return d&&(o[l]=d),o},{})}function nu(r,e,t){return r&&r.hasAttributeNS(e,t)?r.getAttributeNS(e,t):null}function pg(r){return new Error(`Could not parse ttml timestamp ${r}`)}function au(r,e){if(!r)return null;let t=i0(r);return t===null&&(n0.test(r)?t=F_(r,e):a0.test(r)&&(t=U_(r,e))),t}function F_(r,e){let t=n0.exec(r),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function U_(r,e){let t=a0.exec(r),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}var th=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=gg(),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 Ks(this,"textTrack1"),i=new Ks(this,"textTrack2"),s=new Ks(this,"textTrack3"),n=new Ks(this,"textTrack4");this.cea608Parser1=new yl(1,t,i),this.cea608Parser2=new yl(3,s,n)}e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,i,s,n){let a=!1;for(let o=n.length;o--;){let l=n[o],d=$_(l[0],l[1],t,i);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],i),a=!0,d/(i-t)>.5))return}if(a||n.push([t,i]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,i,s)}else{let o=this.Cues.newCue(null,t,i,s);this.hls.trigger(y.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:n}){let{unparsedVttFrags:a}=this;i==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(y.FRAG_LOADED,o)}))}getExistingTrack(e){let{media:t}=this;if(t)for(let i=0;i<t.textTracks.length;i++){let s=t.textTracks[i];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:i,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(e);if(o)i[e]=o,Vs(i[e]),Mg(i[e],s);else{let l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,i[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let i=t.label,s={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,i){let s=this.media;if(!!s)return s.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{Vs(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=gg(),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 i=0;i<t.length;i++)Vs(t[i])}onSubtitleTracksUpdated(e,t){let i=t.subtitleTracks||[],s=i.some(n=>n.textCodec===ru);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(e0(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,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(B_(a[u],o)){c=a[u];break}c&&(d=c)}if(d)Vs(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(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){let t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&i)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{let s=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!s)return;let n=`textTrack${s[1]}`,a=this.captionsProperties[n];!a||(a.label=i.name,i.lang&&(a.languageCode=i.lang),a.media=i)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){let{cea608Parser1:i,cea608Parser2:s,lastSn:n,lastPartIndex:a}=this;if(!(!this.enabled||!(i&&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||(i.reset(),s.reset()),this.lastSn=d,this.lastPartIndex=c}}onFragLoaded(e,t){let{frag:i,payload:s}=t;if(i.type===ge.SUBTITLE)if(s.byteLength){let n=i.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[i.level],l=this.vttCCs;l[i.cc]||(l[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===ru?this._parseIMSC1(i,s):this._parseVTTs(t)}}else this.hls.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){let i=this.hls;fg(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),i.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{M.log(`Failed to parse IMSC1: ${s}`),i.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;let{frag:i,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[i.cc]&&o===-1){a.push(e);return}let l=this.hls,d=(t=i.initSegment)!=null&&t.data?Hr(i.initSegment.data,new Uint8Array(s)):s;M_(d,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,c=>{this._appendCues(c,i.level),l.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},c=>{let u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(i,s),M.log(`Failed to parse VTT cue: ${c}`),!(u&&o>i.cc)&&l.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:c})})}_fallbackToIMSC1(e,t){let i=this.tracks[e.level];i.textCodec||fg(t,this.initPTS[e.cc],()=>{i.textCodec=ru,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){let i=this.hls;if(this.config.renderTextTracksNatively){let s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>Og(s,n))}else{let s=this.tracks[t];if(!s)return;let n=s.default?"default":"subtitles"+t;i.trigger(y.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){let{frag:i}=t;i.type===ge.SUBTITLE&&this.onFragLoaded(y.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){let{cea608Parser1:i,cea608Parser2:s}=this;if(!this.enabled||!(i&&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);i.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:s,type:n}){let{media:a}=this;if(!(!a||a.currentTime<i)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>hu(o[l],t,i))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>hu(o[l],t,s))}}}extractCea608Data(e){let t=[[],[]],i=e[0]&31,s=2;for(let n=0;n<i;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 B_(r,e){return!!r&&r.label===e.name&&!(r.textTrack1||r.textTrack2)}function $_(r,e,t,i){return Math.min(e,i)-Math.max(r,t)}function gg(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var jn=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(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){let i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.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 i=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,jn.getMaxLevelByMediaSize(i,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 i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.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(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){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>=i)&&s(o,e[a+1])){n=a;break}}return n}},ih=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(y.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let i=this.hls.config;if(i.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),i.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,i){let s=performance.now();if(t){if(this.lastTime){let n=s-this.lastTime,a=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(y.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:i}),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(y.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,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)}},Jo="[eme]",vr=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=vr.CDMCleanupPromise?[vr.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=M.debug.bind(M,Jo),this.log=M.log.bind(M,Jo),this.warn=M.warn.bind(M,Jo),this.error=M.error.bind(M,Jo),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(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(y.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(y.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:i}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===st.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){let{drmSystems:t}=this.config,i=t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,i=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(i),n=t.map(a=>a.videoCodec).filter(i);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 Yt?o(u):o(new Yt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_ACCESS,error:u,fatal:!0},u.message))})};l(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${i}`;return Tg===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return i(e,t)}getMediaKeysPromise(e,t,i){let s=Bb(e,t,i,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:i}){this.log(`Creating key-system session "${t}" keyId: ${Oi.hexDump(e.keyId||[])}`);let s=i.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let i=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,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 Oi.hexDump(e.keyId)}updateKeySession(e,t){var i;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Oi.hexDump(((i=e.decryptdata)==null?void 0:i.keyId)||[])}
|
|
958
|
-
} (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,i)=>{let s=$c(this.config),n=e.map(Op).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=Pp(a);o?t(o):i(new Error(`Unable to find format for key-system "${a}"`))}).catch(i)})}loadKey(e){let t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),s=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[i];return n||(n=this.keyIdToKeySessionPromise[i]=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 Yt?this.hls.trigger(y.ERROR,e.data):this.hls.trigger(y.ERROR,{type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){let s=Op(e.keyFormat),n=s?[s]:$c(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=$c(this.config)),e.length===0)throw new Yt({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:i}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),i===null)return;let s,n;if(t==="sinf"&&this.config.drmSystems[st.FAIRPLAY]){let c=Rt(new Uint8Array(i));try{let u=oh(JSON.parse(c).sinf),h=kg(new Uint8Array(u));if(!h)return;s=h.subarray(8,24),n=st.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{let c=dT(i);if(c===null)return;c.version===0&&c.systemId===bg.WIDEVINE&&c.data&&(s=c.data.subarray(8,24)),n=Ub(c.systemId)}if(!n||!s)return;let a=Oi.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=Oi.hexDump(h.keyId);if(a===f||h.uri.replace(/-/g,"").indexOf(a)!==-1){d=o[f],delete o[f],h.pssh=new Uint8Array(i),h.keyId=s,d=o[a]=d.then(()=>this.generateRequestWithPreferredKeySession(u,t,i,"encrypted-event-key-match"));break}}d||(d=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:c,mediaKeys:u})=>{var h;this.throwIfDestroyed();let f=new Vr("ISO-23001-7",a,(h=Pp(c))!=null?h:"");return f.pssh=new Uint8Array(i),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,i,"encrypted-event-no-match")})})),d.catch(c=>this.handleError(c))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){let i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let s=Promise.all(i).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}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,i,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,i,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,i=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(i===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: ${i?i.byteLength:null})`);let c=new mh;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===st.FAIRPLAY&&(this.updateKeySession(e,yg("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 Yt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?f(new Yt({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,i).then(()=>{var h;this.log(`Request generated for key-session "${(h=e.mediaKeysSession)==null?void 0:h.sessionId}" keyId: ${d}`)}).catch(h=>{throw new Yt({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,i)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Oi.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Oi.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,i=t.loader,s=new i(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 Yt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:zt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,g)=>{o(new Yt({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,i){return new Promise((s,n)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new Yt({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(i=>this.updateKeySession(e,new Uint8Array(i)).catch(s=>{throw new Yt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}setupLicenseXHR(e,t,i,s){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,i,s)}).catch(a=>{if(!i.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,i,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 i=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=i.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new Yt({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 i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.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={},Vr.clearKeyUriToKeyIdMap();let i=t.length;vr.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(()=>{i&&(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 i=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:i}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),t.onmessage=null,t.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.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}`)})}}};vr.CDMCleanupPromise=void 0;var Yt=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}},G_=1,Wt={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},H_="h",Fi=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:Wt.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===Wt.VIDEO||o===Wt.AUDIO||o==Wt.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:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||Fi.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){let e=this.hls;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHED,this.onMediaDetached,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHED,this.onMediaDetached,this),e.off(y.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 i,s;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:G_,sf:H_,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){pt(t,this.createData());let i=t.ot===Wt.INIT||t.ot===Wt.VIDEO||t.ot===Wt.MUXED;if(this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){let s=Fi.toHeaders(t);if(!Object.keys(s).length)return;e.headers||(e.headers={}),pt(e.headers,s)}else{let s=Fi.toQuery(t);if(!s)return;e.url=Fi.appendQueryToUri(e.url,s)}}getObjectType(e){let{type:t}=e;if(t==="subtitle")return Wt.TIMED_TEXT;if(e.sn==="initSegment")return Wt.INIT;if(t==="audio")return Wt.AUDIO;if(t==="main")return this.hls.audioTracks.length?Wt.VIDEO:Wt.MUXED}getTopBandwidth(e){let t=0,i,s=this.hls;if(e===Wt.AUDIO)i=s.audioTracks;else{let n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;i=s.levels.slice(0,a)}for(let n of i)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,i=e===Wt.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:qe.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(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,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(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=[],i=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(!i(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),i={},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=Fi.serialize(n[o]);l&&(i[`CMCD-${s[o]}`]=l)}return i}static toQuery(e){return`CMCD=${encodeURIComponent(Fi.serialize(e))}`}static appendQueryToUri(e,t){if(!t)return e;let i=e.includes("?")?"&":"?";return`${e}${i}${t}`}},V_=3e5,rh=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(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;!e||(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.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(i=>i!==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:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:i}=t;if((i==null?void 0:i.action)===Ft.SendAlternateToPenaltyBox&&i.flags===hi.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),i.resolved=this.pathwayId!==n)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}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,i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach(n=>{s-i[n]>V_&&delete i[n]});for(let n=0;n<e.length;n++){let a=e[n];if(i[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(y.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 i={},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=pt({},c);u.details=void 0,u.url=l0(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&&(i[h.AUDIO]=f,h.AUDIO=f),g&&(s[h.SUBTITLES]=g,h.SUBTITLES=g),u.attrs=h;let E=new Kr(u);return ll(E,"audio",f),ll(E,"text",g),E});t.push(...d),vg(this.audioTracks,i,l,a),vg(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){let t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(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 vg(r,e,t,i){!r||Object.keys(e).forEach(s=>{let n=r.filter(a=>a.groupId===s).map(a=>{let o=pt({},a);return o.details=void 0,o.attrs=new Qe(o.attrs),o.url=o.attrs.URI=l0(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=i,o});r.push(...n)})}function l0(r,e,t,i){let{HOST:s,PARAMS:n,[t]:a}=i,o;e&&(o=a==null?void 0:a[e],o&&(r=o));let l=new self.URL(r);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}var K_=/^age:\s*[\d.]+\s*$/im,bl=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 Ws,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,i){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=i,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e)return;let i=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(i,t.url)}).catch(a=>(i.open("GET",t.url,!0),n(i,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(a=>{this.callbacks.onError({code:i.status,text:a.message},t,i,s)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);let s=this.context.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.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),i.timeout=n&&ce(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:i}=this;if(!e||!t)return;let s=t.readyState,n=this.config;if(!i.aborted&&s>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.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-(i.loading.first-i.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)){i.loading.end=Math.max(self.performance.now(),i.loading.first);let l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(i.loaded=i.total=d,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;let c=this.callbacks.onProgress;if(c&&c(i,e,l,t),!this.callbacks)return;let u={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(u,i,e,t)}else{let l=n.loadPolicy.errorRetry,d=i.retry;ol(l,d,!1,a)?this.retry(l):(M.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,i))}}}loadtimeout(){var e;let t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,i=this.stats.retry;if(ol(t,i,!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:i}=this;this.retryDelay=dh(e,i.retry),i.retry++,M.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t.url}, retrying ${i.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&&K_.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 W_(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var q_=/(\d+)-(\d+)\/(\d+)/,Tl=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||X_,this.controller=new self.AbortController,this.stats=new Ws}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,i){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=Y_(e,this.controller.signal),a=i.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:c}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&ce(d)?d:c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.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(),i.onTimeout(s,e,this.response)},c-(h-s.loading.start)),!u.ok){let{status:f,statusText:g}=u;throw new sh(g||"fetch, bad network response",f,u)}return s.loading.first=h,s.total=z_(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),i.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;i.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,i,s=0,n){let a=new gl,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,i,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,i,a.flush(),e)):n(t,i,c,e),l()}).catch(()=>Promise.reject());return l()}};function Y_(r,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(pt({},r.headers))};return r.rangeEnd&&t.headers.set("Range","bytes="+r.rangeStart+"-"+String(r.rangeEnd-1)),t}function j_(r){let e=q_.exec(r);if(e)return parseInt(e[2])-parseInt(e[1])+1}function z_(r){let e=r.get("Content-Range");if(e){let i=j_(e);if(ce(i))return i}let t=r.get("Content-Length");if(t)return parseInt(t)}function X_(r,e){return new self.Request(r.url,e)}var sh=class extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}},Q_=/\s/,Z_={newCue(r,e,t,i){let s=[],n,a,o,l,d,c=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(n=i.rows[h],o=!0,l=0,d="",!n.isEmpty()){var u;for(let E=0;E<n.chars.length;E++)Q_.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=s0(d.trim()),g=gh(e,t,f);r!=null&&(u=r.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 r&&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=>Og(r,h))),s}},J_={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},eA=zt(zt({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:bl,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:$u,bufferController:Yu,capLevelController:jn,errorController:yu,fpsController:ih,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:Tg,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:J_},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},tA()),{},{subtitleStreamController:Vu,subtitleTrackController:Wu,timelineController:th,audioStreamController:Gu,audioTrackController:Hu,emeController:vr,cmcdController:Fi,contentSteeringController:rh});function tA(){return{cueHandler:Z_,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 iA(r,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=nh(r),i=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.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])}`)}),zt(zt({},t),e)}function nh(r){return r&&typeof r=="object"?Array.isArray(r)?r.map(nh):Object.keys(r).reduce((e,t)=>(e[t]=nh(r[t]),e),{}):r}function rA(r){let e=r.loader;e!==Tl&&e!==bl?(M.log("[config]: Custom loader detected, cannot enable progressive streaming"),r.progressive=!1):W_()&&(r.loader=Tl,r.progressive=!0,r.enableSoftwareAES=!0,M.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Ui=class{static get version(){return"1.4.8"}static isSupported(){return KT()}static get Events(){return y}static get ErrorTypes(){return pe}static get ErrorDetails(){return B}static get DefaultConfig(){return Ui.defaultConfig?Ui.defaultConfig:eA}static set DefaultConfig(e){Ui.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new mh,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,wb(e.debug||!1,"Hls instance");let t=this.config=iA(Ui.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&rA(t);let{abrController:i,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new i(this),c=this.bufferController=new s(this),u=this.capLevelController=new n(this),h=new o(this),f=new uu(this),g=new mu(this),E=t.contentSteeringController,T=E?new E(this):null,A=this.levelController=new bu(this,T),R=new Tu(this),x=new Au(this.config),N=this.streamController=new Uu(this,R,x);u.setStreamController(N),h.setStreamController(N);let w=[f,A,N];T&&w.splice(1,0,T),this.networkControllers=w;let $=[d,c,u,h,g,R];this.audioTrackController=this.createController(t.audioTrackController,w);let O=t.audioStreamController;O&&w.push(new O(this,R,x)),this.subtitleTrackController=this.createController(t.subtitleTrackController,w);let H=t.subtitleStreamController;H&&w.push(new H(this,R,x)),this.createController(t.timelineController,$),x.emeController=this.emeController=this.createController(t.emeController,$),this.cmcdController=this.createController(t.cmcdController,$),this.latencyController=this.createController(pu,$),this.coreComponents=$,w.push(l);let q=l.onErrorOut;typeof q=="function"&&this.on(y.ERROR,q,l)}createController(e,t){if(e){let i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,s){this._emitter.off(e,t,i,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){M.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(y.ERROR,{type:pe.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,fatal:!1,event:e,error:i})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){M.log("destroy"),this.trigger(y.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(y.MEDIA_ATTACHING,{media:e})}detachMedia(){M.log("detachMedia"),this.trigger(y.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,i=this.url,s=this.url=ah.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});M.log(`loadSource:${s}`),t&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(y.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){gu.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 i=e.length;for(let s=0;s<i;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this,s;if(t===-1&&e&&e.length?s=e.length-1:s=t,i)for(let n=s;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)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}};Ui.defaultConfig=void 0;var kt=Ui,zn=class extends Error{constructor(r,e=zn.MEDIA_ERR_CUSTOM,t,i){var s;super(r),this.name="MediaError",this.code=e,this.context=i,this.fatal=t!=null?t:e>=zn.MEDIA_ERR_NETWORK&&e<=zn.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(s=zn.defaultMessages[this.code])!=null?s:"")}},it=zn;it.MEDIA_ERR_ABORTED=1,it.MEDIA_ERR_NETWORK=2,it.MEDIA_ERR_DECODE=3,it.MEDIA_ERR_SRC_NOT_SUPPORTED=4,it.MEDIA_ERR_ENCRYPTED=5,it.MEDIA_ERR_CUSTOM=100,it.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 sA=r=>r==null,p0=(r,e)=>sA(e)?!1:r in e,Eh={ANY:"any",MUTED:"muted"},Ze={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},oi={MSE:"mse",NATIVE:"native"},yh={HEADER:"header",QUERY:"query",NONE:"none"},qs=Object.values(yh),Er={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},bh={HLS:Er.M3U8},gw=Object.keys(bh),vw=[...Object.values(Er),"hls","HLS"],gi=(r,e,t,i,s=r)=>{s.addEventListener(e,t,i),r.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function nA(r,e,t){e&&t>e&&(t=e);for(let i=0;i<r.length;i++)if(r.start(i)<=t&&r.end(i)>=t)return!0;return!1}var aA=r=>{let e=r.indexOf("?");if(e<0)return[r];let t=r.slice(0,e),i=r.slice(e);return[t,i]},xl=r=>{let e=r.type;if(e){let i=e.toUpperCase();return p0(i,bh)?bh[i]:e}let{src:t}=r;return t?oA(t):""},g0=r=>r==="VOD"?Ze.ON_DEMAND:Ze.LIVE,v0=r=>r==="EVENT"?Number.POSITIVE_INFINITY:r==="VOD"?Number.NaN:0,oA=r=>{let e="";try{e=new URL(r).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let i=e.slice(t+1).toUpperCase();return p0(i,Er)?Er[i]:""},lA=Object.values(Eh),d0=r=>typeof r=="boolean"||typeof r=="string"&&lA.includes(r),dA=({autoplay:r},e,t)=>{let i=!1,s=!1,n=d0(r)?r:!!r,a=()=>{i||gi(e,"playing",()=>{i=!0},{once:!0})};if(a(),gi(e,"loadstart",()=>{i=!1,a(),vh(e,n)},{once:!0}),gi(e,"loadstart",()=>{t||(s=!Number.isFinite(e.duration)),vh(e,n)},{once:!0}),t&&t.once(kt.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&&gi(e,"play",()=>{e.preload==="metadata"?t.once(kt.Events.LEVEL_UPDATED,o):o()},{once:!0})}return o=>{i||(n=d0(o)?o:!!o,vh(e,n))}},vh=(r,e)=>{if(!e)return;let t=r.muted,i=()=>r.muted=t;switch(e){case Eh.ANY:r.play().catch(()=>{r.muted=!0,r.play().catch(i)});break;case Eh.MUTED:r.muted=!0,r.play().catch(i);break;default:r.play().catch(()=>{});break}},cA=({preload:r,src:e},t,i)=>{let s=u=>{u!=null&&["","none","metadata","auto"].includes(u)?t.setAttribute("preload",u):t.removeAttribute("preload")};if(!i)return s(r),s;let n=!1,a=!1,o=i.config.maxBufferLength,l=i.config.maxBufferSize,d=u=>{s(u);let h=u!=null?u:t.preload;a||h==="none"||(h==="metadata"?(i.config.maxBufferLength=1,i.config.maxBufferSize=1):(i.config.maxBufferLength=o,i.config.maxBufferSize=l),c())},c=()=>{!n&&e&&(n=!0,i.loadSource(e))};return gi(t,"play",()=>{a=!0,i.config.maxBufferLength=o,i.config.maxBufferSize=l,c()},{once:!0}),d(r),d};function uA(r,e){if(!("videoTracks"in r))return;let t=new WeakMap;e.on(kt.Events.MANIFEST_PARSED,function(n,a){s();let o=r.addVideoTrack("main");o.selected=!0;for(let[l,d]of a.levels.entries()){let c=o.addRendition(d.url[0],d.width,d.height,d.videoCodec,d.bitrate);t.set(d,`${l}`),c.id=`${l}`}}),e.on(kt.Events.LEVELS_UPDATED,function(n,a){var o;let l=r.videoTracks[(o=r.videoTracks.selectedIndex)!=null?o:0];if(!l)return;let d=a.levels.map(c=>t.get(c));for(let c of r.videoRenditions)c.id&&!d.includes(c.id)&&l.removeRendition(c)});let i=n=>{let a=n.target.selectedIndex;a!=e.nextLevel&&(e.nextLevel=a)};r.videoRenditions.addEventListener("change",i);let s=()=>{for(let n of r.videoTracks)r.removeVideoTrack(n)};e.once(kt.Events.DESTROYING,()=>{s()})}function hA(r,e){e.on(kt.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);Il(r,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(r.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)})};r.textTracks.addEventListener("change",t),e.on(kt.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=r.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(kt.Events.DESTROYING,()=>{r.textTracks.removeEventListener("change",t),r.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let i=()=>{Array.from(r.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&s.label==="thumbnails"){if(!((n=s.cues)!=null&&n.length)){let o=r.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(kt.Events.MANIFEST_LOADED,i),e.once(kt.Events.MEDIA_ATTACHED,i)}function Il(r,e,t,i,s){let n=document.createElement("track");return n.kind=e,n.label=t,i&&(n.srclang=i),s&&(n.id=s),n.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),r.append(n),n.track}function E0(r,e){let t=Array.prototype.find.call(r.querySelectorAll("track"),i=>i.track===e);t==null||t.remove()}var Xn="cuepoints",_h=Object.freeze({label:Xn}),Ah=(r,{label:e=Xn}=_h)=>{var t;return(t=Array.from(r.querySelectorAll("track")).find(i=>i.track.label===e&&i.track.kind==="metadata"))==null?void 0:t.track};async function Sh(r,e,t=_h){let i=Ah(r,t);if(!i){let{label:s=Xn}=t;i=Il(r,"metadata",s),i.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))}return i.mode!=="hidden"&&(i.mode="hidden"),[...e].sort(({time:s},{time:n})=>n-s).forEach(({time:s,value:n})=>{var a,o;let l=Array.prototype.findIndex.call(i==null?void 0:i.cues,f=>f.startTime>=s),d=(a=i==null?void 0:i.cues)==null?void 0:a[l],c=d?d.startTime:Number.isFinite(r.duration)?r.duration:Number.MAX_SAFE_INTEGER,u=(o=i==null?void 0:i.cues)==null?void 0:o[l-1];u&&(u.endTime=s);let h=new VTTCue(s,c,JSON.stringify(n!=null?n:null));i.addCue(h)}),i}var y0=r=>({time:r.startTime,value:JSON.parse(r.text)});function b0(r,e={label:Xn}){let t=Ah(r,e);return t!=null&&t.cues?Array.from(t.cues,i=>y0(i)):[]}function xh(r,e={label:Xn}){var t,i;let s=Ah(r,e);if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;let{currentTime:n}=r,a=Array.prototype.find.call((i=s.activeCues)!=null?i:[],({startTime:o,endTime:l})=>o<=n&&l>n);return y0(a)}async function fA(r,e=_h){return new Promise(t=>{gi(r,"loadstart",async()=>{let i=await Sh(r,[],e);gi(r,"cuechange",()=>{let s=xh(r);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});r.dispatchEvent(n)}},{},i),t(i)})})}function T0(r,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-r.currentTime*1e3)}return typeof r.getStartDate=="function"?r.getStartDate():new Date(NaN)}function _0(r,e){if(e&&e.playingDate)return e.playingDate;if(typeof r.getStartDate=="function"){let t=r.getStartDate();return new Date(t.getTime()+r.currentTime*1e3)}return new Date(NaN)}var mA=async r=>fetch(r).then(e=>e.text()).then(e=>{let t=e.split(`
|
|
955
|
+
`),d=[],c=e?v_(e.baseTime,e.timescale):0,u="00:00.000",h=0,m=0,g,E=!0;o.oncue=function(T){let A=t[i],R=t.ccOffset,x=(h-c)/9e4;if(A!=null&&A.new&&(m!==void 0?R=t.ccOffset=A.start:U_(t,i,x)),x){if(!e){g=new Error("Missing initPTS for VTT MPEGTS");return}R=x-t.presentationOffset}let N=T.endTime-T.startTime,w=ai((T.startTime+R-m)*9e4,s*9e4)/9e4;T.startTime=Math.max(w,0),T.endTime=Math.max(w+N,0);let $=T.text.trim();T.text=decodeURIComponent(encodeURIComponent($)),T.id||(T.id=vh(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(iu(T,"X-TIMESTAMP-MAP=")){E=!1,T.slice(16).split(",").forEach(A=>{iu(A,"LOCAL:")?u=A.slice(6):iu(A,"MPEGTS:")&&(h=parseInt(A.slice(7)))});try{m=F_(u)/1e3}catch(A){g=A}return}else T===""&&(E=!1);o.parse(T+`
|
|
956
|
+
`)}),o.flush()}var su="stpp.ttml.im1t",l0=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,d0=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,$_={left:"start",center:"center",right:"end",start:"start",end:"end"};function gg(r,e,t,i){let s=Pe(new Uint8Array(r),["mdat"]);if(s.length===0){i(new Error("Could not parse IMSC1 mdat"));return}let n=s.map(o=>Bi(o)),a=g_(e.baseTime,1,e.timescale);try{n.forEach(o=>t(G_(o,a)))}catch(o){i(o)}}function G_(r,e){let s=new DOMParser().parseFromString(r,"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=vg(nu(s,"styling","style")),d=vg(nu(s,"layout","region")),c=nu(s,"body","[begin]");return[].map.call(c,u=>{let h=c0(u,o);if(!h||!u.hasAttribute("begin"))return null;let m=ou(u.getAttribute("begin"),a),g=ou(u.getAttribute("dur"),a),E=ou(u.getAttribute("end"),a);if(m===null)throw Eg(u);if(E===null){if(g===null)throw Eg(u);E=m+g}let T=new gh(m-e,E-e,h);T.id=vh(T.startTime,T.endTime,T.text);let A=d[u.getAttribute("region")],R=l[u.getAttribute("style")],x=H_(A,R,l),{textAlign:N}=x;if(N){let w=$_[N];w&&(T.lineAlign=w),T.align=N}return pt(T,x),T}).filter(u=>u!==null)}function nu(r,e,t){let i=r.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function vg(r){return r.reduce((e,t)=>{let i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function c0(r,e){return[].slice.call(r.childNodes).reduce((t,i,s)=>{var n;return i.nodeName==="br"&&s?t+`
|
|
957
|
+
`:(n=i.childNodes)!=null&&n.length?c0(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function H_(r,e,t){let i="http://www.w3.org/ns/ttml#styling",s=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=r!=null&&r.hasAttribute("style")?r.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{let d=au(e,i,l)||au(r,i,l)||au(s,i,l);return d&&(o[l]=d),o},{})}function au(r,e,t){return r&&r.hasAttributeNS(e,t)?r.getAttributeNS(e,t):null}function Eg(r){return new Error(`Could not parse ttml timestamp ${r}`)}function ou(r,e){if(!r)return null;let t=n0(r);return t===null&&(l0.test(r)?t=V_(r,e):d0.test(r)&&(t=K_(r,e))),t}function V_(r,e){let t=l0.exec(r),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function K_(r,e){let t=d0.exec(r),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}var ih=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=yg(),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 Ks(this,"textTrack1"),i=new Ks(this,"textTrack2"),s=new Ks(this,"textTrack3"),n=new Ks(this,"textTrack4");this.cea608Parser1=new yl(1,t,i),this.cea608Parser2=new yl(3,s,n)}e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,i,s,n){let a=!1;for(let o=n.length;o--;){let l=n[o],d=q_(l[0],l[1],t,i);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],i),a=!0,d/(i-t)>.5))return}if(a||n.push([t,i]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,i,s)}else{let o=this.Cues.newCue(null,t,i,s);this.hls.trigger(y.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:n}){let{unparsedVttFrags:a}=this;i==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(y.FRAG_LOADED,o)}))}getExistingTrack(e){let{media:t}=this;if(t)for(let i=0;i<t.textTracks.length;i++){let s=t.textTracks[i];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:i,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(e);if(o)i[e]=o,Vs(i[e]),Ng(i[e],s);else{let l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,i[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let i=t.label,s={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,i){let s=this.media;if(!!s)return s.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{Vs(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=yg(),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 i=0;i<t.length;i++)Vs(t[i])}onSubtitleTracksUpdated(e,t){let i=t.subtitleTracks||[],s=i.some(n=>n.textCodec===su);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(r0(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,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(W_(a[u],o)){c=a[u];break}c&&(d=c)}if(d)Vs(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(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){let t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&i)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{let s=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!s)return;let n=`textTrack${s[1]}`,a=this.captionsProperties[n];!a||(a.label=i.name,i.lang&&(a.languageCode=i.lang),a.media=i)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){let{cea608Parser1:i,cea608Parser2:s,lastSn:n,lastPartIndex:a}=this;if(!(!this.enabled||!(i&&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||(i.reset(),s.reset()),this.lastSn=d,this.lastPartIndex=c}}onFragLoaded(e,t){let{frag:i,payload:s}=t;if(i.type===ge.SUBTITLE)if(s.byteLength){let n=i.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[i.level],l=this.vttCCs;l[i.cc]||(l[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===su?this._parseIMSC1(i,s):this._parseVTTs(t)}}else this.hls.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){let i=this.hls;gg(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),i.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{M.log(`Failed to parse IMSC1: ${s}`),i.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;let{frag:i,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[i.cc]&&o===-1){a.push(e);return}let l=this.hls,d=(t=i.initSegment)!=null&&t.data?Hr(i.initSegment.data,new Uint8Array(s)):s;B_(d,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,c=>{this._appendCues(c,i.level),l.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},c=>{let u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(i,s),M.log(`Failed to parse VTT cue: ${c}`),!(u&&o>i.cc)&&l.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:c})})}_fallbackToIMSC1(e,t){let i=this.tracks[e.level];i.textCodec||gg(t,this.initPTS[e.cc],()=>{i.textCodec=su,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){let i=this.hls;if(this.config.renderTextTracksNatively){let s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>Fg(s,n))}else{let s=this.tracks[t];if(!s)return;let n=s.default?"default":"subtitles"+t;i.trigger(y.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){let{frag:i}=t;i.type===ge.SUBTITLE&&this.onFragLoaded(y.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){let{cea608Parser1:i,cea608Parser2:s}=this;if(!this.enabled||!(i&&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);i.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:s,type:n}){let{media:a}=this;if(!(!a||a.currentTime<i)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>fu(o[l],t,i))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>fu(o[l],t,s))}}}extractCea608Data(e){let t=[[],[]],i=e[0]&31,s=2;for(let n=0;n<i;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 W_(r,e){return!!r&&r.label===e.name&&!(r.textTrack1||r.textTrack2)}function q_(r,e,t,i){return Math.min(e,i)-Math.max(r,t)}function yg(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var jn=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(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){let i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.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 i=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,jn.getMaxLevelByMediaSize(i,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 i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.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(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){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>=i)&&s(o,e[a+1])){n=a;break}}return n}},rh=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(y.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let i=this.hls.config;if(i.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),i.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,i){let s=performance.now();if(t){if(this.lastTime){let n=s-this.lastTime,a=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(y.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:i}),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(y.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,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)}},Jo="[eme]",vr=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=vr.CDMCleanupPromise?[vr.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=M.debug.bind(M,Jo),this.log=M.log.bind(M,Jo),this.warn=M.warn.bind(M,Jo),this.error=M.error.bind(M,Jo),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(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(y.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(y.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:i}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===st.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){let{drmSystems:t}=this.config,i=t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,i=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(i),n=t.map(a=>a.videoCodec).filter(i);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 Yt?o(u):o(new Yt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_ACCESS,error:u,fatal:!0},u.message))})};l(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${i}`;return Sg===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return i(e,t)}getMediaKeysPromise(e,t,i){let s=Wb(e,t,i,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:i}){this.log(`Creating key-system session "${t}" keyId: ${Oi.hexDump(e.keyId||[])}`);let s=i.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let i=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,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 Oi.hexDump(e.keyId)}updateKeySession(e,t){var i;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Oi.hexDump(((i=e.decryptdata)==null?void 0:i.keyId)||[])}
|
|
958
|
+
} (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,i)=>{let s=Gc(this.config),n=e.map(Fp).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=Up(a);o?t(o):i(new Error(`Unable to find format for key-system "${a}"`))}).catch(i)})}loadKey(e){let t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),s=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[i];return n||(n=this.keyIdToKeySessionPromise[i]=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 Yt?this.hls.trigger(y.ERROR,e.data):this.hls.trigger(y.ERROR,{type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){let s=Fp(e.keyFormat),n=s?[s]:Gc(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=Gc(this.config)),e.length===0)throw new Yt({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:i}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),i===null)return;let s,n;if(t==="sinf"&&this.config.drmSystems[st.FAIRPLAY]){let c=Rt(new Uint8Array(i));try{let u=lh(JSON.parse(c).sinf),h=Cg(new Uint8Array(u));if(!h)return;s=h.subarray(8,24),n=st.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{let c=pT(i);if(c===null)return;c.version===0&&c.systemId===Ag.WIDEVINE&&c.data&&(s=c.data.subarray(8,24)),n=Kb(c.systemId)}if(!n||!s)return;let a=Oi.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 m=Oi.hexDump(h.keyId);if(a===m||h.uri.replace(/-/g,"").indexOf(a)!==-1){d=o[m],delete o[m],h.pssh=new Uint8Array(i),h.keyId=s,d=o[a]=d.then(()=>this.generateRequestWithPreferredKeySession(u,t,i,"encrypted-event-key-match"));break}}d||(d=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:c,mediaKeys:u})=>{var h;this.throwIfDestroyed();let m=new Vr("ISO-23001-7",a,(h=Up(c))!=null?h:"");return m.pssh=new Uint8Array(i),m.keyId=s,this.attemptSetMediaKeys(c,u).then(()=>{this.throwIfDestroyed();let g=this.createMediaKeySessionContext({decryptdata:m,keySystem:c,mediaKeys:u});return this.generateRequestWithPreferredKeySession(g,t,i,"encrypted-event-no-match")})})),d.catch(c=>this.handleError(c))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){let i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let s=Promise.all(i).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}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,i,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,i,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,i=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(i===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: ${i?i.byteLength:null})`);let c=new ph;e.mediaKeysSession.onmessage=h=>{let m=e.mediaKeysSession;if(!m){c.emit("error",new Error("invalid state"));return}let{messageType:g,message:E}=h;this.log(`"${g}" message event for session "${m.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===st.FAIRPLAY&&(this.updateKeySession(e,_g("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,m)=>{c.on("error",m),c.on("keyStatus",g=>{g.startsWith("usable")?h():g==="output-restricted"?m(new Yt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?m(new Yt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?m(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,i).then(()=>{var h;this.log(`Request generated for key-session "${(h=e.mediaKeysSession)==null?void 0:h.sessionId}" keyId: ${d}`)}).catch(h=>{throw new Yt({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,i)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Oi.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Oi.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,i=t.loader,s=new i(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,m,g,E)=>{a(h.data)},onError:(h,m,g,E)=>{o(new Yt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:zt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,m,g)=>{o(new Yt({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,m,g)=>{o(new Error("aborted"))}};s.load(l,c,u)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((s,n)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new Yt({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(i=>this.updateKeySession(e,new Uint8Array(i)).catch(s=>{throw new Yt({type:pe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}setupLicenseXHR(e,t,i,s){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,i,s)}).catch(a=>{if(!i.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,i,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 i=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=i.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new Yt({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 i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.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={},Vr.clearKeyUriToKeyIdMap();let i=t.length;vr.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(()=>{i&&(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 i=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:i}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),t.onmessage=null,t.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.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}`)})}}};vr.CDMCleanupPromise=void 0;var Yt=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}},Y_=1,Wt={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},j_="h",Fi=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:Wt.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===Wt.VIDEO||o===Wt.AUDIO||o==Wt.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:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||Fi.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){let e=this.hls;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHED,this.onMediaDetached,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHED,this.onMediaDetached,this),e.off(y.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 i,s;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:Y_,sf:j_,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){pt(t,this.createData());let i=t.ot===Wt.INIT||t.ot===Wt.VIDEO||t.ot===Wt.MUXED;if(this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){let s=Fi.toHeaders(t);if(!Object.keys(s).length)return;e.headers||(e.headers={}),pt(e.headers,s)}else{let s=Fi.toQuery(t);if(!s)return;e.url=Fi.appendQueryToUri(e.url,s)}}getObjectType(e){let{type:t}=e;if(t==="subtitle")return Wt.TIMED_TEXT;if(e.sn==="initSegment")return Wt.INIT;if(t==="audio")return Wt.AUDIO;if(t==="main")return this.hls.audioTracks.length?Wt.VIDEO:Wt.MUXED}getTopBandwidth(e){let t=0,i,s=this.hls;if(e===Wt.AUDIO)i=s.audioTracks;else{let n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;i=s.levels.slice(0,a)}for(let n of i)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,i=e===Wt.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:qe.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(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,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(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=[],i=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(!i(c)||d==="v"&&c===1||d=="pr"&&c===1)continue;let u=o[d];u&&(c=u(c));let h=typeof c,m;d==="ot"||d==="sf"||d==="st"?m=`${d}=${c}`:h==="boolean"?m=d:h==="number"?m=`${d}=${c}`:m=`${d}=${JSON.stringify(c)}`,t.push(m)}return t.join(",")}static toHeaders(e){let t=Object.keys(e),i={},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=Fi.serialize(n[o]);l&&(i[`CMCD-${s[o]}`]=l)}return i}static toQuery(e){return`CMCD=${encodeURIComponent(Fi.serialize(e))}`}static appendQueryToUri(e,t){if(!t)return e;let i=e.includes("?")?"&":"?";return`${e}${i}${t}`}},z_=3e5,sh=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(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;!e||(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.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(i=>i!==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:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:i}=t;if((i==null?void 0:i.action)===Ft.SendAlternateToPenaltyBox&&i.flags===hi.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),i.resolved=this.pathwayId!==n)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}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,i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach(n=>{s-i[n]>z_&&delete i[n]});for(let n=0;n<e.length;n++){let a=e[n];if(i[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(y.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 i={},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=pt({},c);u.details=void 0,u.url=u0(c.uri,c.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l);let h=new Qe(c.attrs);h["PATHWAY-ID"]=a;let m=h.AUDIO&&`${h.AUDIO}_clone_${a}`,g=h.SUBTITLES&&`${h.SUBTITLES}_clone_${a}`;m&&(i[h.AUDIO]=m,h.AUDIO=m),g&&(s[h.SUBTITLES]=g,h.SUBTITLES=g),u.attrs=h;let E=new Kr(u);return ll(E,"audio",m),ll(E,"text",g),E});t.push(...d),bg(this.audioTracks,i,l,a),bg(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){let t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(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,m)=>{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,m)=>{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 bg(r,e,t,i){!r||Object.keys(e).forEach(s=>{let n=r.filter(a=>a.groupId===s).map(a=>{let o=pt({},a);return o.details=void 0,o.attrs=new Qe(o.attrs),o.url=o.attrs.URI=u0(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=i,o});r.push(...n)})}function u0(r,e,t,i){let{HOST:s,PARAMS:n,[t]:a}=i,o;e&&(o=a==null?void 0:a[e],o&&(r=o));let l=new self.URL(r);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}var X_=/^age:\s*[\d.]+\s*$/im,bl=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 Ws,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,i){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=i,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e)return;let i=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(i,t.url)}).catch(a=>(i.open("GET",t.url,!0),n(i,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(a=>{this.callbacks.onError({code:i.status,text:a.message},t,i,s)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);let s=this.context.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.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),i.timeout=n&&ce(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:i}=this;if(!e||!t)return;let s=t.readyState,n=this.config;if(!i.aborted&&s>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.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-(i.loading.first-i.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)){i.loading.end=Math.max(self.performance.now(),i.loading.first);let l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(i.loaded=i.total=d,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;let c=this.callbacks.onProgress;if(c&&c(i,e,l,t),!this.callbacks)return;let u={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(u,i,e,t)}else{let l=n.loadPolicy.errorRetry,d=i.retry;ol(l,d,!1,a)?this.retry(l):(M.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,i))}}}loadtimeout(){var e;let t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,i=this.stats.retry;if(ol(t,i,!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:i}=this;this.retryDelay=ch(e,i.retry),i.retry++,M.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t.url}, retrying ${i.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&&X_.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 Q_(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var Z_=/(\d+)-(\d+)\/(\d+)/,Tl=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||iA,this.controller=new self.AbortController,this.stats=new Ws}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,i){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=J_(e,this.controller.signal),a=i.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:c}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&ce(d)?d:c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.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(),i.onTimeout(s,e,this.response)},c-(h-s.loading.start)),!u.ok){let{status:m,statusText:g}=u;throw new nh(g||"fetch, bad network response",m,u)}return s.loading.first=h,s.total=tA(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 m=u[l];m&&(s.loaded=s.total=m);let g={url:h.url,data:u,code:h.status};a&&!ce(t.highWaterMark)&&a(s,e,u,h),i.onSuccess(g,s,e,h)}).catch(u=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;let h=u&&u.code||0,m=u?u.message:null;i.onError({code:h,text:m},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,i,s=0,n){let a=new gl,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,i,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,i,a.flush(),e)):n(t,i,c,e),l()}).catch(()=>Promise.reject());return l()}};function J_(r,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(pt({},r.headers))};return r.rangeEnd&&t.headers.set("Range","bytes="+r.rangeStart+"-"+String(r.rangeEnd-1)),t}function eA(r){let e=Z_.exec(r);if(e)return parseInt(e[2])-parseInt(e[1])+1}function tA(r){let e=r.get("Content-Range");if(e){let i=eA(e);if(ce(i))return i}let t=r.get("Content-Length");if(t)return parseInt(t)}function iA(r,e){return new self.Request(r.url,e)}var nh=class extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}},rA=/\s/,sA={newCue(r,e,t,i){let s=[],n,a,o,l,d,c=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(n=i.rows[h],o=!0,l=0,d="",!n.isEmpty()){var u;for(let E=0;E<n.chars.length;E++)rA.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 m=o0(d.trim()),g=vh(e,t,m);r!=null&&(u=r.cues)!=null&&u.getCueById(g)||(a=new c(e,t,m),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 r&&s.length&&(s.sort((h,m)=>h.line==="auto"||m.line==="auto"?0:h.line>8&&m.line>8?m.line-h.line:h.line-m.line),s.forEach(h=>Fg(r,h))),s}},nA={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},aA=zt(zt({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:bl,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Gu,bufferController:ju,capLevelController:jn,errorController:bu,fpsController:rh,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:Sg,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:nA},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},oA()),{},{subtitleStreamController:Ku,subtitleTrackController:qu,timelineController:ih,audioStreamController:Hu,audioTrackController:Vu,emeController:vr,cmcdController:Fi,contentSteeringController:sh});function oA(){return{cueHandler:sA,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 lA(r,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=ah(r),i=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.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])}`)}),zt(zt({},t),e)}function ah(r){return r&&typeof r=="object"?Array.isArray(r)?r.map(ah):Object.keys(r).reduce((e,t)=>(e[t]=ah(r[t]),e),{}):r}function dA(r){let e=r.loader;e!==Tl&&e!==bl?(M.log("[config]: Custom loader detected, cannot enable progressive streaming"),r.progressive=!1):Q_()&&(r.loader=Tl,r.progressive=!0,r.enableSoftwareAES=!0,M.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Ui=class{static get version(){return"1.4.8"}static isSupported(){return XT()}static get Events(){return y}static get ErrorTypes(){return pe}static get ErrorDetails(){return B}static get DefaultConfig(){return Ui.defaultConfig?Ui.defaultConfig:aA}static set DefaultConfig(e){Ui.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new ph,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,Nb(e.debug||!1,"Hls instance");let t=this.config=lA(Ui.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&dA(t);let{abrController:i,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new i(this),c=this.bufferController=new s(this),u=this.capLevelController=new n(this),h=new o(this),m=new hu(this),g=new pu(this),E=t.contentSteeringController,T=E?new E(this):null,A=this.levelController=new Tu(this,T),R=new _u(this),x=new Su(this.config),N=this.streamController=new Bu(this,R,x);u.setStreamController(N),h.setStreamController(N);let w=[m,A,N];T&&w.splice(1,0,T),this.networkControllers=w;let $=[d,c,u,h,g,R];this.audioTrackController=this.createController(t.audioTrackController,w);let O=t.audioStreamController;O&&w.push(new O(this,R,x)),this.subtitleTrackController=this.createController(t.subtitleTrackController,w);let H=t.subtitleStreamController;H&&w.push(new H(this,R,x)),this.createController(t.timelineController,$),x.emeController=this.emeController=this.createController(t.emeController,$),this.cmcdController=this.createController(t.cmcdController,$),this.latencyController=this.createController(gu,$),this.coreComponents=$,w.push(l);let q=l.onErrorOut;typeof q=="function"&&this.on(y.ERROR,q,l)}createController(e,t){if(e){let i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,s){this._emitter.off(e,t,i,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){M.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(y.ERROR,{type:pe.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,fatal:!1,event:e,error:i})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){M.log("destroy"),this.trigger(y.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(y.MEDIA_ATTACHING,{media:e})}detachMedia(){M.log("detachMedia"),this.trigger(y.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,i=this.url,s=this.url=oh.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});M.log(`loadSource:${s}`),t&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(y.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){vu.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 i=e.length;for(let s=0;s<i;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this,s;if(t===-1&&e&&e.length?s=e.length-1:s=t,i)for(let n=s;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)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}};Ui.defaultConfig=void 0;var kt=Ui,zn=class extends Error{constructor(r,e=zn.MEDIA_ERR_CUSTOM,t,i){var s;super(r),this.name="MediaError",this.code=e,this.context=i,this.fatal=t!=null?t:e>=zn.MEDIA_ERR_NETWORK&&e<=zn.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(s=zn.defaultMessages[this.code])!=null?s:"")}},it=zn;it.MEDIA_ERR_ABORTED=1,it.MEDIA_ERR_NETWORK=2,it.MEDIA_ERR_DECODE=3,it.MEDIA_ERR_SRC_NOT_SUPPORTED=4,it.MEDIA_ERR_ENCRYPTED=5,it.MEDIA_ERR_CUSTOM=100,it.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 cA=r=>r==null,E0=(r,e)=>cA(e)?!1:r in e,yh={ANY:"any",MUTED:"muted"},Ze={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},oi={MSE:"mse",NATIVE:"native"},bh={HEADER:"header",QUERY:"query",NONE:"none"},qs=Object.values(bh),Er={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Th={HLS:Er.M3U8},Sw=Object.keys(Th),xw=[...Object.values(Er),"hls","HLS"],gi=(r,e,t,i,s=r)=>{s.addEventListener(e,t,i),r.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function uA(r,e,t){e&&t>e&&(t=e);for(let i=0;i<r.length;i++)if(r.start(i)<=t&&r.end(i)>=t)return!0;return!1}var hA=r=>{let e=r.indexOf("?");if(e<0)return[r];let t=r.slice(0,e),i=r.slice(e);return[t,i]},xl=r=>{let e=r.type;if(e){let i=e.toUpperCase();return E0(i,Th)?Th[i]:e}let{src:t}=r;return t?fA(t):""},y0=r=>r==="VOD"?Ze.ON_DEMAND:Ze.LIVE,b0=r=>r==="EVENT"?Number.POSITIVE_INFINITY:r==="VOD"?Number.NaN:0,fA=r=>{let e="";try{e=new URL(r).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let i=e.slice(t+1).toUpperCase();return E0(i,Er)?Er[i]:""},mA=Object.values(yh),h0=r=>typeof r=="boolean"||typeof r=="string"&&mA.includes(r),pA=({autoplay:r},e,t)=>{let i=!1,s=!1,n=h0(r)?r:!!r,a=()=>{i||gi(e,"playing",()=>{i=!0},{once:!0})};if(a(),gi(e,"loadstart",()=>{i=!1,a(),Eh(e,n)},{once:!0}),gi(e,"loadstart",()=>{t||(s=!Number.isFinite(e.duration)),Eh(e,n)},{once:!0}),t&&t.once(kt.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&&gi(e,"play",()=>{e.preload==="metadata"?t.once(kt.Events.LEVEL_UPDATED,o):o()},{once:!0})}return o=>{i||(n=h0(o)?o:!!o,Eh(e,n))}},Eh=(r,e)=>{if(!e)return;let t=r.muted,i=()=>r.muted=t;switch(e){case yh.ANY:r.play().catch(()=>{r.muted=!0,r.play().catch(i)});break;case yh.MUTED:r.muted=!0,r.play().catch(i);break;default:r.play().catch(()=>{});break}},gA=({preload:r,src:e},t,i)=>{let s=u=>{u!=null&&["","none","metadata","auto"].includes(u)?t.setAttribute("preload",u):t.removeAttribute("preload")};if(!i)return s(r),s;let n=!1,a=!1,o=i.config.maxBufferLength,l=i.config.maxBufferSize,d=u=>{s(u);let h=u!=null?u:t.preload;a||h==="none"||(h==="metadata"?(i.config.maxBufferLength=1,i.config.maxBufferSize=1):(i.config.maxBufferLength=o,i.config.maxBufferSize=l),c())},c=()=>{!n&&e&&(n=!0,i.loadSource(e))};return gi(t,"play",()=>{a=!0,i.config.maxBufferLength=o,i.config.maxBufferSize=l,c()},{once:!0}),d(r),d};function vA(r,e){if(!("videoTracks"in r))return;let t=new WeakMap;e.on(kt.Events.MANIFEST_PARSED,function(n,a){s();let o=r.addVideoTrack("main");o.selected=!0;for(let[l,d]of a.levels.entries()){let c=o.addRendition(d.url[0],d.width,d.height,d.videoCodec,d.bitrate);t.set(d,`${l}`),c.id=`${l}`}}),e.on(kt.Events.LEVELS_UPDATED,function(n,a){var o;let l=r.videoTracks[(o=r.videoTracks.selectedIndex)!=null?o:0];if(!l)return;let d=a.levels.map(c=>t.get(c));for(let c of r.videoRenditions)c.id&&!d.includes(c.id)&&l.removeRendition(c)});let i=n=>{let a=n.target.selectedIndex;a!=e.nextLevel&&(e.nextLevel=a)};r.videoRenditions.addEventListener("change",i);let s=()=>{for(let n of r.videoTracks)r.removeVideoTrack(n)};e.once(kt.Events.DESTROYING,()=>{s()})}function EA(r,e){e.on(kt.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);Il(r,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(r.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)})};r.textTracks.addEventListener("change",t),e.on(kt.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=r.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(kt.Events.DESTROYING,()=>{r.textTracks.removeEventListener("change",t),r.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let i=()=>{Array.from(r.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&s.label==="thumbnails"){if(!((n=s.cues)!=null&&n.length)){let o=r.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(kt.Events.MANIFEST_LOADED,i),e.once(kt.Events.MEDIA_ATTACHED,i)}function Il(r,e,t,i,s){let n=document.createElement("track");return n.kind=e,n.label=t,i&&(n.srclang=i),s&&(n.id=s),n.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),r.append(n),n.track}function T0(r,e){let t=Array.prototype.find.call(r.querySelectorAll("track"),i=>i.track===e);t==null||t.remove()}var Xn="cuepoints",Ah=Object.freeze({label:Xn}),Sh=(r,{label:e=Xn}=Ah)=>{var t;return(t=Array.from(r.querySelectorAll("track")).find(i=>i.track.label===e&&i.track.kind==="metadata"))==null?void 0:t.track};async function xh(r,e,t=Ah){let i=Sh(r,t);if(!i){let{label:s=Xn}=t;i=Il(r,"metadata",s),i.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))}return i.mode!=="hidden"&&(i.mode="hidden"),[...e].sort(({time:s},{time:n})=>n-s).forEach(({time:s,value:n})=>{var a,o;let l=Array.prototype.findIndex.call(i==null?void 0:i.cues,m=>m.startTime>=s),d=(a=i==null?void 0:i.cues)==null?void 0:a[l],c=d?d.startTime:Number.isFinite(r.duration)?r.duration:Number.MAX_SAFE_INTEGER,u=(o=i==null?void 0:i.cues)==null?void 0:o[l-1];u&&(u.endTime=s);let h=new VTTCue(s,c,JSON.stringify(n!=null?n:null));i.addCue(h)}),i}var _0=r=>({time:r.startTime,value:JSON.parse(r.text)});function A0(r,e={label:Xn}){let t=Sh(r,e);return t!=null&&t.cues?Array.from(t.cues,i=>_0(i)):[]}function Ih(r,e={label:Xn}){var t,i;let s=Sh(r,e);if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;let{currentTime:n}=r,a=Array.prototype.find.call((i=s.activeCues)!=null?i:[],({startTime:o,endTime:l})=>o<=n&&l>n);return _0(a)}async function yA(r,e=Ah){return new Promise(t=>{gi(r,"loadstart",async()=>{let i=await xh(r,[],e);gi(r,"cuechange",()=>{let s=Ih(r);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});r.dispatchEvent(n)}},{},i),t(i)})})}function S0(r,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-r.currentTime*1e3)}return typeof r.getStartDate=="function"?r.getStartDate():new Date(NaN)}function x0(r,e){if(e&&e.playingDate)return e.playingDate;if(typeof r.getStartDate=="function"){let t=r.getStartDate();return new Date(t.getTime()+r.currentTime*1e3)}return new Date(NaN)}var bA=async r=>fetch(r).then(e=>e.text()).then(e=>{let t=e.split(`
|
|
959
959
|
`).find((i,s,n)=>s&&n[s-1].startsWith("#EXT-X-STREAM-INF"));return fetch(t).then(i=>i.text()).then(i=>i.split(`
|
|
960
|
-
`))}),pA=r=>{var e,t;let i=(t=((e=r.find(o=>o.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),s=g0(i),n=v0(i),a;if(s===Ze.LIVE){let o=r.find(l=>l.startsWith("#EXT-X-PART-INF"));o?a=+o.split(":")[1].split("=")[1]*2:a=+r.find(l=>l.startsWith("#EXT-X-TARGETDURATION")).split(":")[1]*3}return{streamType:s,targetLiveWindow:n,liveEdgeStartOffset:a}},gA=async(r,e)=>{if(e===Er.MP4)return{streamType:Ze.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===Er.M3U8){let t=await mA(r);return pA(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${r}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},c0=async(r,e,t=xl({src:r}))=>{var i,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await gA(r,t);((i=wt.get(e))!=null?i:{}).liveEdgeStartOffset=l,((s=wt.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=wt.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},vA=r=>{var e;let t=r.type,i=g0(t),s=v0(t),n,a=!!((e=r.partList)!=null&&e.length);return i===Ze.LIVE&&(n=a?r.partTarget*2:r.targetduration*3),{streamType:i,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},EA=(r,e,t)=>{var i,s,n,a,o,l,d,c;let{streamType:u,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:g}=vA(r);if(u===Ze.LIVE){g?(t.config.backBufferLength=(i=t.userConfig.backBufferLength)!=null?i: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=wt.get(e))!=null?o:{}).seekable=E}((l=wt.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=wt.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((c=wt.get(e))!=null?c:{}).streamType=u,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},u0,h0,yA=(h0=(u0=globalThis==null?void 0:globalThis.navigator)==null?void 0:u0.userAgent)!=null?h0:"",bA=yA.toLowerCase().indexOf("android")!==-1,wt=new WeakMap,A0="mux.com",f0,m0,S0=(m0=(f0=kt).isSupported)==null?void 0:m0.call(f0),TA=bA,x0=()=>Sl.default.utils.now(),_A=Sl.default.utils.generateUUID,I0=(r,{domain:e=A0,maxResolution:t=""}={})=>{if(!r)return;let[i,s=""]=aA(r),n=new URL(`https://stream.${e}/${i}.m3u8${s}`);return t&&n.searchParams.set("max_resolution",t),n.toString()},AA=r=>{if(!r)return;let[e]=r.split("?");return e||void 0},SA=r=>{if(!r||!r.startsWith("https://stream."))return;let[e]=new URL(r).pathname.slice(1).split(".m3u8");return e||void 0},xA=r=>{var e,t,i;return(e=r==null?void 0:r.metadata)!=null&&e.video_id?r.metadata.video_id:O0(r)&&(i=(t=AA(r.playbackId))!=null?t:SA(r.src))!=null?i:r.src},L0=r=>{var e;return(e=wt.get(r))==null?void 0:e.error},R0=r=>{var e,t;return(t=(e=wt.get(r))==null?void 0:e.streamType)!=null?t:Ze.UNKNOWN},k0=r=>{var e,t;return(t=(e=wt.get(r))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},Ih=r=>{var e,t;return(t=(e=wt.get(r))==null?void 0:e.seekable)!=null?t:r.seekable},w0=r=>{var e;let t=(e=wt.get(r))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let i=Ih(r);return i.length?i.end(i.length-1)-t:Number.NaN},IA=(r,e,t=.001)=>Math.abs(r-e)<=t,D0=(r,e,t=.001)=>r>e||IA(r,e,t),LA=r=>r.paused&&D0(r.currentTime,r.duration),Lh=(r,e)=>r.loop||!!e?r.ended:r.ended||LA(r),C0=(r,e,t)=>{Rh(e,t);let{metadata:i={}}=r,{view_session_id:s=_A()}=i,n=xA(r);i.view_session_id=s,i.video_id=n,r.metadata=i,wt.set(e,{});let a=RA(r,e);wA(r,e,a),DA(r,e,a),fA(e);let o=dA(r,e,a),l=cA(r,e,a);return{engine:a,setAutoplay:o,setPreload:l}},Rh=(r,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),(r==null?void 0:r.mux)&&!r.mux.deleted&&(r.mux.destroy(),delete r.mux),r&&(r.removeAttribute("src"),r.load(),r.removeEventListener("error",N0),r.removeEventListener("error",Th),r.removeEventListener("durationchange",P0),wt.delete(r),r.dispatchEvent(new Event("teardown")))};function M0(r,e){var t;let i=xl(r);if(i!==Er.M3U8)return!0;let s=!i||((t=e.canPlayType(i))!=null?t:!0),{preferPlayback:n}=r,a=n===oi.MSE,o=n===oi.NATIVE;return s&&(o||!(S0&&(a||TA)))}var RA=(r,e)=>{let{debug:t,streamType:i,startTime:s=-1,metadata:n,preferCmcd:a}=r,o=xl(r)===Er.M3U8,l=M0(r,e);if(o&&!l&&S0){let d={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=kA(i),u=a!==yh.NONE?{useHeaders:a===yh.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new kt({debug:t,startPosition:s,cmcd:u,...d,...c})}},kA=r=>r===Ze.LIVE?{backBufferLength:8}:{},O0=({playbackId:r,src:e,customDomain:t})=>{if(r)return!0;if(typeof e!="string")return!1;let i=window==null?void 0:window.location.href,s=new URL(e,i).hostname.toLocaleLowerCase();return s.includes(A0)||!!t&&s.includes(t.toLocaleLowerCase())},wA=(r,e,t)=>{var i;let{envKey:s}=r,n=O0(r);if(s||n){let{playerInitTime:a,playerSoftwareName:o,playerSoftwareVersion:l,beaconCollectionDomain:d,debug:c,disableCookies:u}=r,h={...r.metadata,video_title:((i=r==null?void 0:r.metadata)==null?void 0:i.video_title)||void 0},f=g=>typeof g.player_error_code=="string"?!1:typeof r.errorTranslator=="function"?r.errorTranslator(g):g;Sl.default.monitor(e,{debug:c,beaconCollectionDomain:d,hlsjs:t,Hls:t?kt: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}})}},DA=(r,e,t)=>{var i;let s=M0(r,e),{src:n}=r;if(e&&s){let a=xl(r);typeof n=="string"?(e.preload==="none"?gi(e,"loadstart",()=>c0(n,e,a)):c0(n,e,a),e.setAttribute("src",n),r.startTime&&(((i=wt.get(e))!=null?i:{}).startTime=r.startTime,e.addEventListener("durationchange",P0,{once:!0}))):e.removeAttribute("src"),e.addEventListener("error",N0),e.addEventListener("error",Th),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(l=>{l.remove()})},{once:!0});let o=()=>{e.ended||!Lh(e)||e.dispatchEvent(new Event("ended"))};gi(e,"pause",o),gi(e,"seeked",o),gi(e,"play",()=>{e.ended||!D0(e.currentTime,e.duration)||(e.currentTime=e.seekable.start(0))})}else t&&n?(t.once(kt.Events.LEVEL_LOADED,(a,o)=>{EA(o.details,e,t)}),t.on(kt.Events.ERROR,(a,o)=>{let l={[kt.ErrorTypes.NETWORK_ERROR]:it.MEDIA_ERR_NETWORK,[kt.ErrorTypes.MEDIA_ERROR]:it.MEDIA_ERR_DECODE},d=new it("",l[o.type]);d.fatal=o.fatal,d.data=o,e.dispatchEvent(new CustomEvent("error",{detail:d}))}),e.addEventListener("error",Th),uA(r,t),hA(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 P0(r){var e;let t=r.target,i=(e=wt.get(t))==null?void 0:e.startTime;if(!!i&&nA(t.seekable,t.duration,i)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=i,s&&(t.preload="auto")}}async function N0(r){if(!r.isTrusted)return;r.stopImmediatePropagation();let e=r.target;if(!(e!=null&&e.error))return;let{message:t,code:i}=e.error,s=new it(t,i);if(e.src&&(i!==it.MEDIA_ERR_DECODE||i!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:s}))}function Th(r){var e,t;if(!(r instanceof CustomEvent)||!(r.detail instanceof it))return;let i=r.target,s=r.detail;!s||!s.fatal||(((e=wt.get(i))!=null?e:{}).error=s,(t=i.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var CA=Object.defineProperty,MA=(r,e,t)=>e in r?CA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Be=(r,e,t)=>(MA(r,typeof e!="symbol"?e+"":e,t),t),Hh=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},G=(r,e,t)=>(Hh(r,e,"read from private field"),t?t.call(r):e.get(r)),le=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},ue=(r,e,t,i)=>(Hh(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),nt=(r,e,t)=>(Hh(r,e,"access private method"),t),Pl=class{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}};if(typeof DocumentFragment=="undefined"){class r extends Pl{}globalThis.DocumentFragment=r}var Vh=class extends Pl{},OA=class extends Pl{},PA={get(r){},define(r,e,t){},upgrade(r){},whenDefined(r){return Promise.resolve(Vh)}},Ll,NA=class{constructor(r,e={}){le(this,Ll,void 0),ue(this,Ll,e==null?void 0:e.detail)}get detail(){return G(this,Ll)}initCustomEvent(){}};Ll=new WeakMap;function FA(r,e){return new Vh}var K0={document:{createElement:FA},DocumentFragment,customElements:PA,CustomEvent:NA,EventTarget:Pl,HTMLElement:Vh,HTMLVideoElement:OA},W0=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Rl=W0?K0:globalThis,bw=W0?K0.document:globalThis.document,UA=()=>{try{return"0.16.0"}catch{}return"UNKNOWN"},BA=UA(),$A=()=>BA,F0=r=>{var e,t,i,s,n,a,o,l,d,c,u,h,f,g,E,T,A,R,x,N,w,$,O,H,q,P,X,j,Ae,Ee,ye,we,Se,Z,ae,se,xe,Ie,$e,ht;return e=class extends r{constructor(){super(),le(this,X),le(this,Ae),le(this,ye),le(this,Se),le(this,ae),le(this,xe),le(this,$e),Be(this,"castEnabled",!1),le(this,w,{paused:!1}),le(this,$,void 0),le(this,O,{}),le(this,H,void 0),le(this,q,void 0),le(this,P,void 0),e.instances.add(this),nt(this,ae,se).call(this)}static get castElement(){return G(e,t)}static get castEnabled(){return G(e,i)}static get castState(){var V;return(V=G(e,d,c))==null?void 0:V.getCastState()}static async exitCast(){try{await G(e,d,c).endCurrentSession(!0)}catch(V){console.error(V);return}}get castPlayer(){if(e.castElement===this)return G(this,$)}attributeChangedCallback(V){if(this.castPlayer)switch(V){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(V={}){var J;nt(J=e,x,N).call(J,V),ue(e,t,this),Object.entries(G(this,O)).forEach(([Re,Je])=>{G(this,$).controller.addEventListener(Re,Je)});try{await G(e,d,c).requestSession()}catch{ue(e,t,void 0);return}G(this,w).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(Re){console.error(Re)}}async load(){var V,J;if(!this.castPlayer)return super.load();let Re=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),Je=[...this.querySelectorAll("track")].filter(({kind:Jt,src:yi})=>yi&&(Jt==="subtitles"||Jt==="captions")),_t=[],Xt=0;Je.length&&(Re.tracks=Je.map(Jt=>{let yi=++Xt;_t.length===0&&Jt.track.mode==="showing"&&_t.push(yi);let bi=new chrome.cast.media.Track(yi,chrome.cast.media.TrackType.TEXT);return bi.trackContentId=Jt.src,bi.trackContentType="text/vtt",bi.subtype=Jt.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,bi.name=Jt.label,bi.language=Jt.srclang,bi})),this.castStreamType==="live"?Re.streamType=chrome.cast.media.StreamType.LIVE:Re.streamType=chrome.cast.media.StreamType.BUFFERED,Re.metadata=new chrome.cast.media.GenericMediaMetadata,Re.metadata.title=this.title,Re.metadata.images=[{url:this.poster}];let sr=new chrome.cast.media.LoadRequest(Re);sr.currentTime=(V=super.currentTime)!=null?V:0,sr.autoplay=!G(this,w).paused,sr.activeTrackIds=_t,await((J=G(e,u,h))==null?void 0:J.loadMedia(sr)),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,J,Re;return(Re=(J=this.getAttribute("cast-src"))!=null?J:(V=this.querySelector("source"))==null?void 0:V.src)!=null?Re: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,J;return(J=(V=this.getAttribute("cast-stream-type"))!=null?V:this.streamType)!=null?J: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 J;if(this.castPlayer){(V&&!this.castPlayer.isMuted||!V&&this.castPlayer.isMuted)&&((J=this.castPlayer.controller)==null||J.muteOrUnmute());return}super.muted=V}get volume(){var V,J;return this.castPlayer?(J=(V=this.castPlayer)==null?void 0:V.volumeLevel)!=null?J:1:super.volume}set volume(V){var J;if(this.castPlayer){this.castPlayer.volumeLevel=V,(J=this.castPlayer.controller)==null||J.setVolumeLevel();return}super.volume=V}get duration(){var V,J;return this.castPlayer&&G(this,X,j)?(J=(V=this.castPlayer)==null?void 0:V.duration)!=null?J:NaN:super.duration}get currentTime(){var V,J;return this.castPlayer&&G(this,X,j)?(J=(V=this.castPlayer)==null?void 0:V.currentTime)!=null?J:0:super.currentTime}set currentTime(V){var J;if(this.castPlayer){this.castPlayer.currentTime=V,(J=this.castPlayer.controller)==null||J.seek();return}super.currentTime=V}get onentercast(){return G(this,H)}set onentercast(V){G(this,H)&&(this.removeEventListener("entercast",G(this,H)),ue(this,H,null)),typeof V=="function"&&(ue(this,H,V),this.addEventListener("entercast",V))}get onleavecast(){return G(this,q)}set onleavecast(V){G(this,q)&&(this.removeEventListener("leavecast",G(this,q)),ue(this,q,null)),typeof V=="function"&&(ue(this,q,V),this.addEventListener("leavecast",V))}get oncastchange(){return G(this,P)}set oncastchange(V){G(this,P)&&(this.removeEventListener("castchange",G(this,P)),ue(this,P,null)),typeof V=="function"&&(ue(this,P,V),this.addEventListener("castchange",V))}},t=new WeakMap,i=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(G(e,o,l))return cast.framework.CastContext.getInstance()},u=new WeakSet,h=function(){var V;return(V=G(e,d,c))==null?void 0:V.getCurrentSession()},f=new WeakSet,g=function(){var V;return(V=G(e,u,h))==null?void 0:V.getSessionObj().media[0]},E=new WeakSet,T=function(V){return new Promise((J,Re)=>{G(e,f,g).editTracksInfo(V,J,Re)})},A=new WeakSet,R=function(V){return new Promise((J,Re)=>{G(e,f,g).getStatus(V,J,Re)})},x=new WeakSet,N=function(V){return G(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})},w=new WeakMap,$=new WeakMap,O=new WeakMap,H=new WeakMap,q=new WeakMap,P=new WeakMap,X=new WeakSet,j=function(){var V;return(V=this.castPlayer)==null?void 0:V.isMediaLoaded},Ae=new WeakSet,Ee=function(){G(e,t)===this&&(Object.entries(G(this,O)).forEach(([V,J])=>{G(this,$).controller.removeEventListener(V,J)}),ue(e,t,void 0),this.muted=G(this,$).isMuted,this.currentTime=G(this,$).savedPlayerState.currentTime,G(this,$).savedPlayerState.isPaused===!1&&this.play())},ye=new WeakSet,we=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:G(e,d,c).getCastState()}))},Se=new WeakSet,Z=async function(){var V,J;let{SESSION_RESUMED:Re}=cast.framework.SessionState;if(G(e,d,c).getSessionState()===Re&&this.castSrc===((V=G(e,f,g))==null?void 0:V.media.contentId)){ue(e,t,this),Object.entries(G(this,O)).forEach(([Je,_t])=>{G(this,$).controller.addEventListener(Je,_t)});try{await nt(J=e,A,R).call(J,new chrome.cast.media.GetStatusRequest)}catch(Je){console.error(Je)}G(this,O)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),G(this,O)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},ae=new WeakSet,se=function(){var V;!G(e,o,l)||this.castEnabled||(this.castEnabled=!0,nt(V=e,x,N).call(V),this.textTracks.addEventListener("change",nt(this,$e,ht).bind(this)),nt(this,ye,we).call(this),ue(this,$,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(G(this,$)),ue(this,O,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:J})=>{J===!1&&nt(this,Ae,Ee).call(this),this.dispatchEvent(new Event(J?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!G(this,X,j)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var J,Re;((J=this.castPlayer)==null?void 0:J.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(Re=this.castPlayer)==null?void 0:Re.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!G(this,X,j)||(await Promise.resolve(),nt(this,xe,Ie).call(this))}}))},xe=new WeakSet,Ie=function(){nt(this,$e,ht).call(this)},$e=new WeakSet,ht=async function(){var V,J,Re,Je,_t,Xt;if(!this.castPlayer)return;let sr=((J=(V=G(this,$).mediaInfo)==null?void 0:V.tracks)!=null?J:[]).filter(({type:rt})=>rt===chrome.cast.media.TrackType.TEXT),Jt=[...this.textTracks].filter(({kind:rt})=>rt==="subtitles"||rt==="captions"),yi=sr.map(({language:rt,name:Rr,trackId:nn})=>{var an;let{mode:Ta}=(an=Jt.find(on=>on.language===rt&&on.label===Rr))!=null?an:{};return Ta?{mode:Ta,trackId:nn}:!1}).filter(Boolean),bi=yi.filter(({mode:rt})=>rt!=="showing").map(({trackId:rt})=>rt),fs=yi.find(({mode:rt})=>rt==="showing"),sn=(_t=(Je=(Re=G(e,u,h))==null?void 0:Re.getSessionObj().media[0])==null?void 0:Je.activeTrackIds)!=null?_t:[],li=sn;if(sn.length&&(li=li.filter(rt=>!bi.includes(rt))),fs!=null&&fs.trackId&&(li=[...li,fs.trackId]),li=[...new Set(li)],!((rt,Rr)=>rt.length===Rr.length&&rt.every(nn=>Rr.includes(nn)))(sn,li))try{let rt=new chrome.cast.media.EditTracksInfoRequest(li);await nt(Xt=e,E,T).call(Xt,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,x),Be(e,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Be(e,"instances",new Set),le(e,t,void 0),le(e,i,!1),Be(e,"initCast",()=>{var V;G(e,n,a)?G(e,o,l)?G(V=e,s).call(V,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var J;return G(J=e,s).call(J,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var J;return G(J=e,s).call(J,chrome.cast.isAvailable)})}}),le(e,s,V=>{if(V){ue(e,i,!0);let{CAST_STATE_CHANGED:J}=cast.framework.CastContextEventType;G(e,d,c).addEventListener(J,Je=>{e.instances.forEach(_t=>{var Xt;return nt(Xt=_t,ye,we).call(Xt,Je)})});let{SESSION_STATE_CHANGED:Re}=cast.framework.CastContextEventType;G(e,d,c).addEventListener(Re,Je=>{e.instances.forEach(_t=>{var Xt;return nt(Xt=_t,Se,Z).call(Xt,Je)})}),e.instances.forEach(Je=>{var _t;return nt(_t=Je,ae,se).call(_t)})}}),e},Ch=globalThis.HTMLVideoElement?F0(HTMLVideoElement):F0(Object);globalThis.customElements&&!globalThis.customElements.get("castable-video")&&(customElements.define("castable-video",Ch,{extends:"video"}),globalThis.CastableVideoElement=Ch);Ch.initCast();var Nl=["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"],U0,Mh=(U0=globalThis.document)==null?void 0:U0.createElement("template");Mh&&(Mh.innerHTML=`
|
|
960
|
+
`))}),TA=r=>{var e,t;let i=(t=((e=r.find(o=>o.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),s=y0(i),n=b0(i),a;if(s===Ze.LIVE){let o=r.find(l=>l.startsWith("#EXT-X-PART-INF"));o?a=+o.split(":")[1].split("=")[1]*2:a=+r.find(l=>l.startsWith("#EXT-X-TARGETDURATION")).split(":")[1]*3}return{streamType:s,targetLiveWindow:n,liveEdgeStartOffset:a}},_A=async(r,e)=>{if(e===Er.MP4)return{streamType:Ze.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===Er.M3U8){let t=await bA(r);return TA(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${r}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},f0=async(r,e,t=xl({src:r}))=>{var i,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await _A(r,t);((i=wt.get(e))!=null?i:{}).liveEdgeStartOffset=l,((s=wt.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=wt.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},AA=r=>{var e;let t=r.type,i=y0(t),s=b0(t),n,a=!!((e=r.partList)!=null&&e.length);return i===Ze.LIVE&&(n=a?r.partTarget*2:r.targetduration*3),{streamType:i,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},SA=(r,e,t)=>{var i,s,n,a,o,l,d,c;let{streamType:u,targetLiveWindow:h,liveEdgeStartOffset:m,lowLatency:g}=AA(r);if(u===Ze.LIVE){g?(t.config.backBufferLength=(i=t.userConfig.backBufferLength)!=null?i: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=wt.get(e))!=null?o:{}).seekable=E}((l=wt.get(e))!=null?l:{}).liveEdgeStartOffset=m,((d=wt.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((c=wt.get(e))!=null?c:{}).streamType=u,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},m0,p0,xA=(p0=(m0=globalThis==null?void 0:globalThis.navigator)==null?void 0:m0.userAgent)!=null?p0:"",IA=xA.toLowerCase().indexOf("android")!==-1,wt=new WeakMap,I0="mux.com",g0,v0,L0=(v0=(g0=kt).isSupported)==null?void 0:v0.call(g0),LA=IA,R0=()=>Sl.default.utils.now(),RA=Sl.default.utils.generateUUID,k0=(r,{domain:e=I0,maxResolution:t=""}={})=>{if(!r)return;let[i,s=""]=hA(r),n=new URL(`https://stream.${e}/${i}.m3u8${s}`);return t&&n.searchParams.set("max_resolution",t),n.toString()},kA=r=>{if(!r)return;let[e]=r.split("?");return e||void 0},wA=r=>{if(!r||!r.startsWith("https://stream."))return;let[e]=new URL(r).pathname.slice(1).split(".m3u8");return e||void 0},DA=r=>{var e,t,i;return(e=r==null?void 0:r.metadata)!=null&&e.video_id?r.metadata.video_id:F0(r)&&(i=(t=kA(r.playbackId))!=null?t:wA(r.src))!=null?i:r.src},w0=r=>{var e;return(e=wt.get(r))==null?void 0:e.error},D0=r=>{var e,t;return(t=(e=wt.get(r))==null?void 0:e.streamType)!=null?t:Ze.UNKNOWN},C0=r=>{var e,t;return(t=(e=wt.get(r))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},Lh=r=>{var e,t;return(t=(e=wt.get(r))==null?void 0:e.seekable)!=null?t:r.seekable},M0=r=>{var e;let t=(e=wt.get(r))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let i=Lh(r);return i.length?i.end(i.length-1)-t:Number.NaN},CA=(r,e,t=.001)=>Math.abs(r-e)<=t,O0=(r,e,t=.001)=>r>e||CA(r,e,t),MA=r=>r.paused&&O0(r.currentTime,r.duration),Rh=(r,e)=>r.loop||!!e?r.ended:r.ended||MA(r),P0=(r,e,t)=>{kh(e,t);let{metadata:i={}}=r,{view_session_id:s=RA()}=i,n=DA(r);i.view_session_id=s,i.video_id=n,r.metadata=i,wt.set(e,{});let a=OA(r,e);NA(r,e,a),FA(r,e,a),yA(e);let o=pA(r,e,a),l=gA(r,e,a);return{engine:a,setAutoplay:o,setPreload:l}},kh=(r,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),(r==null?void 0:r.mux)&&!r.mux.deleted&&(r.mux.destroy(),delete r.mux),r&&(r.removeAttribute("src"),r.load(),r.removeEventListener("error",B0),r.removeEventListener("error",_h),r.removeEventListener("durationchange",U0),wt.delete(r),r.dispatchEvent(new Event("teardown")))};function N0(r,e){var t;let i=xl(r);if(i!==Er.M3U8)return!0;let s=!i||((t=e.canPlayType(i))!=null?t:!0),{preferPlayback:n}=r,a=n===oi.MSE,o=n===oi.NATIVE;return s&&(o||!(L0&&(a||LA)))}var OA=(r,e)=>{let{debug:t,streamType:i,startTime:s=-1,metadata:n,preferCmcd:a}=r,o=xl(r)===Er.M3U8,l=N0(r,e);if(o&&!l&&L0){let d={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=PA(i),u=a!==bh.NONE?{useHeaders:a===bh.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new kt({debug:t,startPosition:s,cmcd:u,...d,...c})}},PA=r=>r===Ze.LIVE?{backBufferLength:8}:{},F0=({playbackId:r,src:e,customDomain:t})=>{if(r)return!0;if(typeof e!="string")return!1;let i=window==null?void 0:window.location.href,s=new URL(e,i).hostname.toLocaleLowerCase();return s.includes(I0)||!!t&&s.includes(t.toLocaleLowerCase())},NA=(r,e,t)=>{var i;let{envKey:s}=r,n=F0(r);if(s||n){let{playerInitTime:a,playerSoftwareName:o,playerSoftwareVersion:l,beaconCollectionDomain:d,debug:c,disableCookies:u}=r,h={...r.metadata,video_title:((i=r==null?void 0:r.metadata)==null?void 0:i.video_title)||void 0},m=g=>typeof g.player_error_code=="string"?!1:typeof r.errorTranslator=="function"?r.errorTranslator(g):g;Sl.default.monitor(e,{debug:c,beaconCollectionDomain:d,hlsjs:t,Hls:t?kt:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:u,data:{...s?{env_key:s}:{},player_software_name:o,player_software:o,player_software_version:l,player_init_time:a,...h}})}},FA=(r,e,t)=>{var i;let s=N0(r,e),{src:n}=r;if(e&&s){let a=xl(r);typeof n=="string"?(e.preload==="none"?gi(e,"loadstart",()=>f0(n,e,a)):f0(n,e,a),e.setAttribute("src",n),r.startTime&&(((i=wt.get(e))!=null?i:{}).startTime=r.startTime,e.addEventListener("durationchange",U0,{once:!0}))):e.removeAttribute("src"),e.addEventListener("error",B0),e.addEventListener("error",_h),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(l=>{l.remove()})},{once:!0});let o=()=>{e.ended||!Rh(e)||e.dispatchEvent(new Event("ended"))};gi(e,"pause",o),gi(e,"seeked",o),gi(e,"play",()=>{e.ended||!O0(e.currentTime,e.duration)||(e.currentTime=e.seekable.start(0))})}else t&&n?(t.once(kt.Events.LEVEL_LOADED,(a,o)=>{SA(o.details,e,t)}),t.on(kt.Events.ERROR,(a,o)=>{let l={[kt.ErrorTypes.NETWORK_ERROR]:it.MEDIA_ERR_NETWORK,[kt.ErrorTypes.MEDIA_ERROR]:it.MEDIA_ERR_DECODE},d=new it("",l[o.type]);d.fatal=o.fatal,d.data=o,e.dispatchEvent(new CustomEvent("error",{detail:d}))}),e.addEventListener("error",_h),vA(r,t),EA(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 U0(r){var e;let t=r.target,i=(e=wt.get(t))==null?void 0:e.startTime;if(!!i&&uA(t.seekable,t.duration,i)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=i,s&&(t.preload="auto")}}async function B0(r){if(!r.isTrusted)return;r.stopImmediatePropagation();let e=r.target;if(!(e!=null&&e.error))return;let{message:t,code:i}=e.error,s=new it(t,i);if(e.src&&(i!==it.MEDIA_ERR_DECODE||i!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:s}))}function _h(r){var e,t;if(!(r instanceof CustomEvent)||!(r.detail instanceof it))return;let i=r.target,s=r.detail;!s||!s.fatal||(((e=wt.get(i))!=null?e:{}).error=s,(t=i.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var UA=Object.defineProperty,BA=(r,e,t)=>e in r?UA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Be=(r,e,t)=>(BA(r,typeof e!="symbol"?e+"":e,t),t),Wh=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},G=(r,e,t)=>(Wh(r,e,"read from private field"),t?t.call(r):e.get(r)),le=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},ue=(r,e,t,i)=>(Wh(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),nt=(r,e,t)=>(Wh(r,e,"access private method"),t),Nl=class{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}};if(typeof DocumentFragment=="undefined"){class r extends Nl{}globalThis.DocumentFragment=r}var qh=class extends Nl{},$A=class extends Nl{},GA={get(r){},define(r,e,t){},upgrade(r){},whenDefined(r){return Promise.resolve(qh)}},Ll,HA=class{constructor(r,e={}){le(this,Ll,void 0),ue(this,Ll,e==null?void 0:e.detail)}get detail(){return G(this,Ll)}initCustomEvent(){}};Ll=new WeakMap;function VA(r,e){return new qh}var W0={document:{createElement:VA},DocumentFragment,customElements:GA,CustomEvent:HA,EventTarget:Nl,HTMLElement:qh,HTMLVideoElement:$A},q0=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Rl=q0?W0:globalThis,Rw=q0?W0.document:globalThis.document,KA=()=>{try{return"0.16.1"}catch{}return"UNKNOWN"},WA=KA(),qA=()=>WA,$0=r=>{var e,t,i,s,n,a,o,l,d,c,u,h,m,g,E,T,A,R,x,N,w,$,O,H,q,P,X,j,Ae,Ee,ye,we,Se,Z,ae,se,xe,Ie,$e,ht;return e=class extends r{constructor(){super(),le(this,X),le(this,Ae),le(this,ye),le(this,Se),le(this,ae),le(this,xe),le(this,$e),Be(this,"castEnabled",!1),le(this,w,{paused:!1}),le(this,$,void 0),le(this,O,{}),le(this,H,void 0),le(this,q,void 0),le(this,P,void 0),e.instances.add(this),nt(this,ae,se).call(this)}static get castElement(){return G(e,t)}static get castEnabled(){return G(e,i)}static get castState(){var V;return(V=G(e,d,c))==null?void 0:V.getCastState()}static async exitCast(){try{await G(e,d,c).endCurrentSession(!0)}catch(V){console.error(V);return}}get castPlayer(){if(e.castElement===this)return G(this,$)}attributeChangedCallback(V){if(this.castPlayer)switch(V){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(V={}){var J;nt(J=e,x,N).call(J,V),ue(e,t,this),Object.entries(G(this,O)).forEach(([Re,Je])=>{G(this,$).controller.addEventListener(Re,Je)});try{await G(e,d,c).requestSession()}catch{ue(e,t,void 0);return}G(this,w).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(Re){console.error(Re)}}async load(){var V,J;if(!this.castPlayer)return super.load();let Re=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),Je=[...this.querySelectorAll("track")].filter(({kind:Jt,src:yi})=>yi&&(Jt==="subtitles"||Jt==="captions")),_t=[],Xt=0;Je.length&&(Re.tracks=Je.map(Jt=>{let yi=++Xt;_t.length===0&&Jt.track.mode==="showing"&&_t.push(yi);let bi=new chrome.cast.media.Track(yi,chrome.cast.media.TrackType.TEXT);return bi.trackContentId=Jt.src,bi.trackContentType="text/vtt",bi.subtype=Jt.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,bi.name=Jt.label,bi.language=Jt.srclang,bi})),this.castStreamType==="live"?Re.streamType=chrome.cast.media.StreamType.LIVE:Re.streamType=chrome.cast.media.StreamType.BUFFERED,Re.metadata=new chrome.cast.media.GenericMediaMetadata,Re.metadata.title=this.title,Re.metadata.images=[{url:this.poster}];let sr=new chrome.cast.media.LoadRequest(Re);sr.currentTime=(V=super.currentTime)!=null?V:0,sr.autoplay=!G(this,w).paused,sr.activeTrackIds=_t,await((J=G(e,u,h))==null?void 0:J.loadMedia(sr)),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,J,Re;return(Re=(J=this.getAttribute("cast-src"))!=null?J:(V=this.querySelector("source"))==null?void 0:V.src)!=null?Re: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,J;return(J=(V=this.getAttribute("cast-stream-type"))!=null?V:this.streamType)!=null?J: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 J;if(this.castPlayer){(V&&!this.castPlayer.isMuted||!V&&this.castPlayer.isMuted)&&((J=this.castPlayer.controller)==null||J.muteOrUnmute());return}super.muted=V}get volume(){var V,J;return this.castPlayer?(J=(V=this.castPlayer)==null?void 0:V.volumeLevel)!=null?J:1:super.volume}set volume(V){var J;if(this.castPlayer){this.castPlayer.volumeLevel=V,(J=this.castPlayer.controller)==null||J.setVolumeLevel();return}super.volume=V}get duration(){var V,J;return this.castPlayer&&G(this,X,j)?(J=(V=this.castPlayer)==null?void 0:V.duration)!=null?J:NaN:super.duration}get currentTime(){var V,J;return this.castPlayer&&G(this,X,j)?(J=(V=this.castPlayer)==null?void 0:V.currentTime)!=null?J:0:super.currentTime}set currentTime(V){var J;if(this.castPlayer){this.castPlayer.currentTime=V,(J=this.castPlayer.controller)==null||J.seek();return}super.currentTime=V}get onentercast(){return G(this,H)}set onentercast(V){G(this,H)&&(this.removeEventListener("entercast",G(this,H)),ue(this,H,null)),typeof V=="function"&&(ue(this,H,V),this.addEventListener("entercast",V))}get onleavecast(){return G(this,q)}set onleavecast(V){G(this,q)&&(this.removeEventListener("leavecast",G(this,q)),ue(this,q,null)),typeof V=="function"&&(ue(this,q,V),this.addEventListener("leavecast",V))}get oncastchange(){return G(this,P)}set oncastchange(V){G(this,P)&&(this.removeEventListener("castchange",G(this,P)),ue(this,P,null)),typeof V=="function"&&(ue(this,P,V),this.addEventListener("castchange",V))}},t=new WeakMap,i=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(G(e,o,l))return cast.framework.CastContext.getInstance()},u=new WeakSet,h=function(){var V;return(V=G(e,d,c))==null?void 0:V.getCurrentSession()},m=new WeakSet,g=function(){var V;return(V=G(e,u,h))==null?void 0:V.getSessionObj().media[0]},E=new WeakSet,T=function(V){return new Promise((J,Re)=>{G(e,m,g).editTracksInfo(V,J,Re)})},A=new WeakSet,R=function(V){return new Promise((J,Re)=>{G(e,m,g).getStatus(V,J,Re)})},x=new WeakSet,N=function(V){return G(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})},w=new WeakMap,$=new WeakMap,O=new WeakMap,H=new WeakMap,q=new WeakMap,P=new WeakMap,X=new WeakSet,j=function(){var V;return(V=this.castPlayer)==null?void 0:V.isMediaLoaded},Ae=new WeakSet,Ee=function(){G(e,t)===this&&(Object.entries(G(this,O)).forEach(([V,J])=>{G(this,$).controller.removeEventListener(V,J)}),ue(e,t,void 0),this.muted=G(this,$).isMuted,this.currentTime=G(this,$).savedPlayerState.currentTime,G(this,$).savedPlayerState.isPaused===!1&&this.play())},ye=new WeakSet,we=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:G(e,d,c).getCastState()}))},Se=new WeakSet,Z=async function(){var V,J;let{SESSION_RESUMED:Re}=cast.framework.SessionState;if(G(e,d,c).getSessionState()===Re&&this.castSrc===((V=G(e,m,g))==null?void 0:V.media.contentId)){ue(e,t,this),Object.entries(G(this,O)).forEach(([Je,_t])=>{G(this,$).controller.addEventListener(Je,_t)});try{await nt(J=e,A,R).call(J,new chrome.cast.media.GetStatusRequest)}catch(Je){console.error(Je)}G(this,O)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),G(this,O)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},ae=new WeakSet,se=function(){var V;!G(e,o,l)||this.castEnabled||(this.castEnabled=!0,nt(V=e,x,N).call(V),this.textTracks.addEventListener("change",nt(this,$e,ht).bind(this)),nt(this,ye,we).call(this),ue(this,$,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(G(this,$)),ue(this,O,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:J})=>{J===!1&&nt(this,Ae,Ee).call(this),this.dispatchEvent(new Event(J?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!G(this,X,j)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var J,Re;((J=this.castPlayer)==null?void 0:J.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(Re=this.castPlayer)==null?void 0:Re.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!G(this,X,j)||(await Promise.resolve(),nt(this,xe,Ie).call(this))}}))},xe=new WeakSet,Ie=function(){nt(this,$e,ht).call(this)},$e=new WeakSet,ht=async function(){var V,J,Re,Je,_t,Xt;if(!this.castPlayer)return;let sr=((J=(V=G(this,$).mediaInfo)==null?void 0:V.tracks)!=null?J:[]).filter(({type:rt})=>rt===chrome.cast.media.TrackType.TEXT),Jt=[...this.textTracks].filter(({kind:rt})=>rt==="subtitles"||rt==="captions"),yi=sr.map(({language:rt,name:Rr,trackId:nn})=>{var an;let{mode:Ta}=(an=Jt.find(on=>on.language===rt&&on.label===Rr))!=null?an:{};return Ta?{mode:Ta,trackId:nn}:!1}).filter(Boolean),bi=yi.filter(({mode:rt})=>rt!=="showing").map(({trackId:rt})=>rt),fs=yi.find(({mode:rt})=>rt==="showing"),sn=(_t=(Je=(Re=G(e,u,h))==null?void 0:Re.getSessionObj().media[0])==null?void 0:Je.activeTrackIds)!=null?_t:[],li=sn;if(sn.length&&(li=li.filter(rt=>!bi.includes(rt))),fs!=null&&fs.trackId&&(li=[...li,fs.trackId]),li=[...new Set(li)],!((rt,Rr)=>rt.length===Rr.length&&rt.every(nn=>Rr.includes(nn)))(sn,li))try{let rt=new chrome.cast.media.EditTracksInfoRequest(li);await nt(Xt=e,E,T).call(Xt,rt)}catch(rt){console.error(rt)}},le(e,n),le(e,o),le(e,d),le(e,u),le(e,m),le(e,E),le(e,A),le(e,x),Be(e,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Be(e,"instances",new Set),le(e,t,void 0),le(e,i,!1),Be(e,"initCast",()=>{var V;G(e,n,a)?G(e,o,l)?G(V=e,s).call(V,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var J;return G(J=e,s).call(J,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var J;return G(J=e,s).call(J,chrome.cast.isAvailable)})}}),le(e,s,V=>{if(V){ue(e,i,!0);let{CAST_STATE_CHANGED:J}=cast.framework.CastContextEventType;G(e,d,c).addEventListener(J,Je=>{e.instances.forEach(_t=>{var Xt;return nt(Xt=_t,ye,we).call(Xt,Je)})});let{SESSION_STATE_CHANGED:Re}=cast.framework.CastContextEventType;G(e,d,c).addEventListener(Re,Je=>{e.instances.forEach(_t=>{var Xt;return nt(Xt=_t,Se,Z).call(Xt,Je)})}),e.instances.forEach(Je=>{var _t;return nt(_t=Je,ae,se).call(_t)})}}),e},Dh=globalThis.HTMLVideoElement?$0(HTMLVideoElement):$0(Object);globalThis.customElements&&!globalThis.customElements.get("castable-video")&&(customElements.define("castable-video",Dh,{extends:"video"}),globalThis.CastableVideoElement=Dh);Dh.initCast();var Fl=["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"],G0,Ch=(G0=globalThis.document)==null?void 0:G0.createElement("template");Ch&&(Ch.innerHTML=`
|
|
961
961
|
<style>
|
|
962
962
|
:host {
|
|
963
963
|
display: inline-block;
|
|
@@ -972,7 +972,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
|
|
|
972
972
|
}
|
|
973
973
|
</style>
|
|
974
974
|
<slot></slot>
|
|
975
|
-
`);var
|
|
975
|
+
`);var H0,Mh=(H0=globalThis.document)==null?void 0:H0.createElement("template");Mh&&(Mh.innerHTML=`
|
|
976
976
|
<style>
|
|
977
977
|
:host {
|
|
978
978
|
display: inline-block;
|
|
@@ -994,8 +994,8 @@ svg, img, ::slotted(svg), ::slotted(img) {
|
|
|
994
994
|
}
|
|
995
995
|
</style>
|
|
996
996
|
<slot></slot>
|
|
997
|
-
`);var Kh=(r,{tag:e,is:t})=>{var i,s,n,a,o,l,d,c,u,h,f,g,E;let T=(i=globalThis.document)==null?void 0:i.createElement(e,{is:t}),A=T?GA(T):[];return s=class extends r{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 R,x,N;return nt(R=s,a,o).call(R),[...(N=(x=T==null?void 0:T.constructor)==null?void 0:x.observedAttributes)!=null?N:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var R,x;return(x=(R=G(this,d))!=null?R:this.shadowRoot.querySelector(e))!=null?x:this.querySelector(e)}set nativeEl(R){ue(this,d,R)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(R){this.toggleAttribute("muted",Boolean(R))}get src(){return this.getAttribute("src")}set src(R){this.setAttribute("src",`${R}`)}get preload(){var R,x;return(x=this.getAttribute("preload"))!=null?x:(R=this.nativeEl)==null?void 0:R.preload}set preload(R){this.setAttribute("preload",`${R}`)}attributeChangedCallback(R,x,N){nt(this,c,u).call(this),nt(this,g,E).call(this,R,x,N)}connectedCallback(){nt(this,c,u).call(this)}},n=new WeakMap,a=new WeakSet,o=function(){if(G(this,n))return;ue(this,n,!0);let R=new Set(this.observedAttributes);R.delete("muted");for(let x of A)if(!(x in this.prototype))if(typeof T[x]=="function")this.prototype[x]=function(...N){return nt(this,c,u).call(this),(()=>this.call?this.call(x,...N):this.nativeEl[x].apply(this.nativeEl,N))()};else{let N={get(){var w,$,O;nt(this,c,u).call(this);let H=x.toLowerCase();if(R.has(H)){let q=this.getAttribute(H);return q===null?!1:q===""?!0:q}return(O=(w=this.get)==null?void 0:w.call(this,x))!=null?O:($=this.nativeEl)==null?void 0:$[x]}};x!==x.toUpperCase()&&(N.set=function(w){nt(this,c,u).call(this);let $=x.toLowerCase();if(R.has($)){w===!0||w===!1||w==null?this.toggleAttribute($,Boolean(w)):this.setAttribute($,w);return}if(this.set){this.set(x,w);return}this.nativeEl[x]=w}),Object.defineProperty(this.prototype,x,N)}},l=new WeakMap,d=new WeakMap,c=new WeakSet,u=function(){var R,x;if(G(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)nt(this,h,f).call(this,$);let N=new Map,w=this.shadowRoot.querySelector("slot:not([name])");w==null||w.addEventListener("slotchange",()=>{let $=new Map(N);w.assignedElements().filter(O=>["track","source"].includes(O.localName)).forEach(O=>{var H,q;$.delete(O);let P=N.get(O);P||(P=O.cloneNode(),N.set(O,P)),(q=(H=this.nativeEl).append)==null||q.call(H,P)}),$.forEach(O=>O.remove())});for(let $ of this.constructor.Events)(x=(R=this.shadowRoot).addEventListener)==null||x.call(R,$,O=>{O.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(O.type,{detail:O.detail}))},!0)},h=new WeakSet,f=function(R){if(Object.prototype.hasOwnProperty.call(this,R)){let x=this[R];delete this[R],this[R]=x}},g=new WeakSet,E=function(R,x,N){var w,$,O,H;["id","class"].includes(R)||(N===null?($=(w=this.nativeEl).removeAttribute)==null||$.call(w,R):(H=(O=this.nativeEl).setAttribute)==null||H.call(O,R,N))},le(s,a),Be(s,"Events",Nl),Be(s,"template",e.endsWith("audio")?Mh:Oh),le(s,n,void 0),s};function GA(r){let e=[];for(let t=Object.getPrototypeOf(r);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}var _w=globalThis.document?Kh(HTMLElement,{tag:"video"}):class{},Aw=globalThis.document?Kh(HTMLElement,{tag:"audio"}):class{},Fl=class extends Event{constructor(r,e){super(r),Be(this,"track"),this.track=e.track}},Ph=new WeakMap;function te(r){var e;return(e=Ph.get(r))!=null?e:HA(r,{})}function HA(r,e){let t=Ph.get(r);return t||Ph.set(r,t={}),Object.assign(t,e)}function kh(r,e){let t=r.videoTracks;te(e).media=r,te(e).renditionSet||(te(e).renditionSet=new Set);let i=te(t).trackSet;i.add(e);let s=i.size-1;s in Nh.prototype||Object.defineProperty(Nh.prototype,s,{get(){return[...te(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Fl("addtrack",{track:e}))})}function $0(r){let e=te(r).media.videoTracks;te(e).trackSet.delete(r),queueMicrotask(()=>{e.dispatchEvent(new Fl("removetrack",{track:r}))})}function VA(r){var e;let t=(e=te(r).media.videoTracks)!=null?e:[],i=!1;for(let s of t)s!==r&&(s.selected=!1,i=!0);if(i){if(te(t).changeRequested)return;te(t).changeRequested=!0,queueMicrotask(()=>{delete te(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var Wr,qr,Yr,Ys,Qn,Nh=class extends EventTarget{constructor(){super(),le(this,Ys),le(this,Wr,void 0),le(this,qr,void 0),le(this,Yr,void 0),te(this).trackSet=new Set}[Symbol.iterator](){return G(this,Ys,Qn).values()}get length(){return G(this,Ys,Qn).size}getTrackById(r){var e;return(e=[...G(this,Ys,Qn)].find(t=>t.id===r))!=null?e:null}get selectedIndex(){return[...G(this,Ys,Qn)].findIndex(r=>r.selected)}get onaddtrack(){return G(this,Wr)}set onaddtrack(r){G(this,Wr)&&(this.removeEventListener("addtrack",G(this,Wr)),ue(this,Wr,void 0)),typeof r=="function"&&(ue(this,Wr,r),this.addEventListener("addtrack",r))}get onremovetrack(){return G(this,qr)}set onremovetrack(r){G(this,qr)&&(this.removeEventListener("removetrack",G(this,qr)),ue(this,qr,void 0)),typeof r=="function"&&(ue(this,qr,r),this.addEventListener("removetrack",r))}get onchange(){return G(this,Yr)}set onchange(r){G(this,Yr)&&(this.removeEventListener("change",G(this,Yr)),ue(this,Yr,void 0)),typeof r=="function"&&(ue(this,Yr,r),this.addEventListener("change",r))}};Wr=new WeakMap,qr=new WeakMap,Yr=new WeakMap,Ys=new WeakSet,Qn=function(){return te(this).trackSet};var Ul=class extends Event{constructor(r,e){super(r),Be(this,"rendition"),this.rendition=e.rendition}};function KA(r,e){let t=te(r).media.videoRenditions;te(e).media=te(r).media,te(e).track=r;let i=te(r).renditionSet;i.add(e);let s=i.size-1;s in Fh.prototype||Object.defineProperty(Fh.prototype,s,{get(){return js(this)[s]}}),queueMicrotask(()=>{!r.selected||t.dispatchEvent(new Ul("addrendition",{rendition:e}))})}function WA(r){let e=te(r).media.videoRenditions,t=te(r).track;te(t).renditionSet.delete(r),queueMicrotask(()=>{!te(r).track.selected||e.dispatchEvent(new Ul("removerendition",{rendition:r}))})}function qA(r){let e=te(r).media.videoRenditions;!e||te(e).changeRequested||(te(e).changeRequested=!0,queueMicrotask(()=>{delete te(e).changeRequested,te(r).track.selected&&e.dispatchEvent(new Event("change"))}))}function js(r){return[...te(r).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...te(e).renditionSet])}var jr,zr,Xr,Fh=class extends EventTarget{constructor(){super(...arguments),le(this,jr,void 0),le(this,zr,void 0),le(this,Xr,void 0)}[Symbol.iterator](){return js(this).values()}get length(){return js(this).length}getRenditionById(r){var e;return(e=js(this).find(t=>`${t.id}`==`${r}`))!=null?e:null}get selectedIndex(){return js(this).findIndex(r=>r.selected)}set selectedIndex(r){for(let[e,t]of js(this).entries())t.selected=e===r}get onaddrendition(){return G(this,jr)}set onaddrendition(r){G(this,jr)&&(this.removeEventListener("addrendition",G(this,jr)),ue(this,jr,void 0)),typeof r=="function"&&(ue(this,jr,r),this.addEventListener("addrendition",r))}get onremoverendition(){return G(this,zr)}set onremoverendition(r){G(this,zr)&&(this.removeEventListener("removerendition",G(this,zr)),ue(this,zr,void 0)),typeof r=="function"&&(ue(this,zr,r),this.addEventListener("removerendition",r))}get onchange(){return G(this,Xr)}set onchange(r){G(this,Xr)&&(this.removeEventListener("change",G(this,Xr)),ue(this,Xr,void 0)),typeof r=="function"&&(ue(this,Xr,r),this.addEventListener("change",r))}};jr=new WeakMap,zr=new WeakMap,Xr=new WeakMap;var Zn,YA=class{constructor(){Be(this,"src"),Be(this,"id"),Be(this,"width"),Be(this,"height"),Be(this,"bitrate"),Be(this,"frameRate"),Be(this,"codec"),le(this,Zn,!1)}get selected(){return G(this,Zn)}set selected(r){G(this,Zn)!==r&&(ue(this,Zn,r),qA(this))}};Zn=new WeakMap;var Jn,G0=class{constructor(){Be(this,"id"),Be(this,"kind"),Be(this,"label",""),Be(this,"language",""),Be(this,"sourceBuffer"),le(this,Jn,!1)}addRendition(r,e,t,i,s,n){let a=new YA;return a.src=r,a.width=e,a.height=t,a.frameRate=n,a.bitrate=s,a.codec=i,KA(this,a),a}removeRendition(r){WA(r)}get selected(){return G(this,Jn)}set selected(r){G(this,Jn)!==r&&(ue(this,Jn,r),r===!0&&VA(this))}};Jn=new WeakMap;function jA(r,e){let t=te(r).media.audioRenditions;te(e).media=te(r).media,te(e).track=r;let i=te(r).renditionSet;i.add(e);let s=i.size-1;s in Uh.prototype||Object.defineProperty(Uh.prototype,s,{get(){return zs(this)[s]}}),queueMicrotask(()=>{!r.enabled||t.dispatchEvent(new Ul("addrendition",{rendition:e}))})}function zA(r){let e=te(r).media.audioRenditions,t=te(r).track;te(t).renditionSet.delete(r),queueMicrotask(()=>{!te(r).track.enabled||e.dispatchEvent(new Ul("removerendition",{rendition:r}))})}function XA(r){let e=te(r).media.audioRenditions;!e||te(e).changeRequested||(te(e).changeRequested=!0,queueMicrotask(()=>{delete te(e).changeRequested,te(r).track.enabled&&e.dispatchEvent(new Event("change"))}))}function zs(r){return[...te(r).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...te(e).renditionSet])}var Qr,Zr,Jr,Uh=class extends EventTarget{constructor(){super(...arguments),le(this,Qr,void 0),le(this,Zr,void 0),le(this,Jr,void 0)}[Symbol.iterator](){return zs(this).values()}get length(){return zs(this).length}getRenditionById(r){var e;return(e=zs(this).find(t=>`${t.id}`==`${r}`))!=null?e:null}get selectedIndex(){return zs(this).findIndex(r=>r.selected)}set selectedIndex(r){for(let[e,t]of zs(this).entries())t.selected=e===r}get onaddrendition(){return G(this,Qr)}set onaddrendition(r){G(this,Qr)&&(this.removeEventListener("addrendition",G(this,Qr)),ue(this,Qr,void 0)),typeof r=="function"&&(ue(this,Qr,r),this.addEventListener("addrendition",r))}get onremoverendition(){return G(this,Zr)}set onremoverendition(r){G(this,Zr)&&(this.removeEventListener("removerendition",G(this,Zr)),ue(this,Zr,void 0)),typeof r=="function"&&(ue(this,Zr,r),this.addEventListener("removerendition",r))}get onchange(){return G(this,Jr)}set onchange(r){G(this,Jr)&&(this.removeEventListener("change",G(this,Jr)),ue(this,Jr,void 0)),typeof r=="function"&&(ue(this,Jr,r),this.addEventListener("change",r))}};Qr=new WeakMap,Zr=new WeakMap,Jr=new WeakMap;var ea,QA=class{constructor(){Be(this,"src"),Be(this,"id"),Be(this,"bitrate"),Be(this,"codec"),le(this,ea,!1)}get selected(){return G(this,ea)}set selected(r){G(this,ea)!==r&&(ue(this,ea,r),XA(this))}};ea=new WeakMap;function wh(r,e){let t=r.audioTracks;te(e).media=r,te(e).renditionSet||(te(e).renditionSet=new Set);let i=te(t).trackSet;i.add(e);let s=i.size-1;s in Bh.prototype||Object.defineProperty(Bh.prototype,s,{get(){return[...te(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Fl("addtrack",{track:e}))})}function H0(r){let e=te(r).media.audioTracks;te(e).trackSet.delete(r),queueMicrotask(()=>{e.dispatchEvent(new Fl("removetrack",{track:r}))})}function ZA(r){let e=te(r).media.audioTracks;!e||te(e).changeRequested||(te(e).changeRequested=!0,queueMicrotask(()=>{delete te(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var es,ts,is,ta,kl,Bh=class extends EventTarget{constructor(){super(),le(this,ta),le(this,es,void 0),le(this,ts,void 0),le(this,is,void 0),te(this).trackSet=new Set}[Symbol.iterator](){return G(this,ta,kl).values()}get length(){return G(this,ta,kl).size}getTrackById(r){var e;return(e=[...G(this,ta,kl)].find(t=>t.id===r))!=null?e:null}get onaddtrack(){return G(this,es)}set onaddtrack(r){G(this,es)&&(this.removeEventListener("addtrack",G(this,es)),ue(this,es,void 0)),typeof r=="function"&&(ue(this,es,r),this.addEventListener("addtrack",r))}get onremovetrack(){return G(this,ts)}set onremovetrack(r){G(this,ts)&&(this.removeEventListener("removetrack",G(this,ts)),ue(this,ts,void 0)),typeof r=="function"&&(ue(this,ts,r),this.addEventListener("removetrack",r))}get onchange(){return G(this,is)}set onchange(r){G(this,is)&&(this.removeEventListener("change",G(this,is)),ue(this,is,void 0)),typeof r=="function"&&(ue(this,is,r),this.addEventListener("change",r))}};es=new WeakMap,ts=new WeakMap,is=new WeakMap,ta=new WeakSet,kl=function(){return te(this).trackSet};var ia,V0=class{constructor(){Be(this,"id"),Be(this,"kind"),Be(this,"label",""),Be(this,"language",""),Be(this,"sourceBuffer"),le(this,ia,!1)}addRendition(r,e,t){let i=new QA;return i.src=r,i.codec=e,i.bitrate=t,jA(this,i),i}removeRendition(r){zA(r)}get enabled(){return G(this,ia)}set enabled(r){G(this,ia)!==r&&(ue(this,ia,r),ZA(this))}};ia=new WeakMap;function JA(r){var e,t;if(!(r!=null&&r.prototype))return r;let i=(e=Object.getOwnPropertyDescriptor(r.prototype,"videoTracks"))==null?void 0:e.get,s=(t=Object.getOwnPropertyDescriptor(r.prototype,"audioTracks"))==null?void 0:t.get;if(i&&!`${i}`.includes("[native code]"))return r;Object.defineProperty(r.prototype,"videoTracks",{get(){return n(this)}}),Object.defineProperty(r.prototype,"audioTracks",{get(){return a(this)}}),"addVideoTrack"in r.prototype||(r.prototype.addVideoTrack=function(d,c="",u=""){let h=new G0;return h.kind=d,h.label=c,h.language=u,kh(this,h),h}),"removeVideoTrack"in r.prototype||(r.prototype.removeVideoTrack=$0),"addAudioTrack"in r.prototype||(r.prototype.addAudioTrack=function(d,c="",u=""){let h=new V0;return h.kind=d,h.label=c,h.language=u,wh(this,h),h}),"removeAudioTrack"in r.prototype||(r.prototype.removeAudioTrack=H0);let n=d=>{let c=te(d).videoTracks;if(!c&&(c=new Nh,te(d).videoTracks=c,i)){let u=i.call(d);for(let h of u)kh(d,h);u.addEventListener("change",()=>{c.dispatchEvent(new Event("change"))}),u.addEventListener("addtrack",h=>{[...c].some(f=>f instanceof G0)||kh(d,h.track)}),u.addEventListener("removetrack",h=>{$0(h.track)})}return c},a=d=>{let c=te(d).audioTracks;if(!c&&(c=new Bh,te(d).audioTracks=c,s)){let u=s.call(d);for(let h of u)wh(d,h);u.addEventListener("change",()=>{c.dispatchEvent(new Event("change"))}),u.addEventListener("addtrack",h=>{[...c].some(f=>f instanceof V0)||wh(d,h.track)}),u.addEventListener("removetrack",h=>{H0(h.track)})}return c};"videoRenditions"in r.prototype||Object.defineProperty(r.prototype,"videoRenditions",{get(){return o(this)}});let o=d=>{let c=te(d).videoRenditions;return c||(c=new Fh,te(c).media=d,te(d).videoRenditions=c),c};"audioRenditions"in r.prototype||Object.defineProperty(r.prototype,"audioRenditions",{get(){return l(this)}});let l=d=>{let c=te(d).audioRenditions;return c||(c=new Uh,te(c).media=d,te(d).audioRenditions=c),c};return r}Nl.push("castchange","entercast","leavecast");var Dh=JA(Kh(Rl.HTMLElement,{tag:"video",is:"castable-video"})),Y={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",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"},eS=Object.values(Y),tS=$A(),iS="mux-video",Xi,ra,wl,sa,Dl,Cl,Ml,Ol,$h,Gh=class extends Dh{constructor(){super(),le(this,Ol),le(this,Xi,void 0),le(this,ra,void 0),le(this,wl,void 0),le(this,sa,{}),le(this,Dl,void 0),le(this,Cl,void 0),le(this,Ml,void 0),ue(this,wl,x0())}static get observedAttributes(){var r;return[...eS,...(r=Dh.observedAttributes)!=null?r:[]]}get preferCmcd(){var r;return(r=this.getAttribute(Y.PREFER_CMCD))!=null?r:void 0}set preferCmcd(r){r!==this.preferCmcd&&(r?qs.includes(r)?this.setAttribute(Y.PREFER_CMCD,r):console.warn(`Invalid value for preferCmcd. Must be one of ${qs.join()}`):this.removeAttribute(Y.PREFER_CMCD))}get playerInitTime(){return G(this,wl)}get playerSoftwareName(){var r;return(r=G(this,Cl))!=null?r:iS}set playerSoftwareName(r){ue(this,Cl,r)}get playerSoftwareVersion(){var r;return(r=G(this,Dl))!=null?r:tS}set playerSoftwareVersion(r){ue(this,Dl,r)}get _hls(){var r;return(r=G(this,Xi))==null?void 0:r.engine}get mux(){return this.nativeEl.mux}get error(){var r;return(r=L0(this.nativeEl))!=null?r:null}get errorTranslator(){return G(this,Ml)}set errorTranslator(r){ue(this,Ml,r)}get src(){return this.getAttribute("src")}set src(r){r!==this.src&&(r==null?this.removeAttribute("src"):this.setAttribute("src",r))}get type(){var r;return(r=this.getAttribute(Y.TYPE))!=null?r:void 0}set type(r){r!==this.type&&(r?this.setAttribute(Y.TYPE,r):this.removeAttribute(Y.TYPE))}get autoplay(){let r=this.getAttribute("autoplay");return r===null?!1:r===""?!0:r}set autoplay(r){let e=this.autoplay;r!==e&&(r?this.setAttribute("autoplay",typeof r=="string"?r:""):this.removeAttribute("autoplay"))}get preload(){let r=this.getAttribute("preload");return r===""?"auto":["none","metadata","auto"].includes(r)?r:super.preload}set preload(r){r!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(r)?this.setAttribute("preload",r):this.removeAttribute("preload"))}get debug(){return this.getAttribute(Y.DEBUG)!=null}set debug(r){r!==this.debug&&(r?this.setAttribute(Y.DEBUG,""):this.removeAttribute(Y.DEBUG))}get disableCookies(){return this.hasAttribute(Y.DISABLE_COOKIES)}set disableCookies(r){r!==this.disableCookies&&(r?this.setAttribute(Y.DISABLE_COOKIES,""):this.removeAttribute(Y.DISABLE_COOKIES))}get startTime(){let r=this.getAttribute(Y.START_TIME);if(r==null)return;let e=+r;return Number.isNaN(e)?void 0:e}set startTime(r){r!==this.startTime&&(r==null?this.removeAttribute(Y.START_TIME):this.setAttribute(Y.START_TIME,`${r}`))}get playbackId(){var r;return(r=this.getAttribute(Y.PLAYBACK_ID))!=null?r:void 0}set playbackId(r){r!==this.playbackId&&(r?this.setAttribute(Y.PLAYBACK_ID,r):this.removeAttribute(Y.PLAYBACK_ID))}get maxResolution(){var r;return(r=this.getAttribute(Y.MAX_RESOLUTION))!=null?r:void 0}set maxResolution(r){r!==this.maxResolution&&(r?this.setAttribute(Y.MAX_RESOLUTION,r):this.removeAttribute(Y.MAX_RESOLUTION))}get customDomain(){var r;return(r=this.getAttribute(Y.CUSTOM_DOMAIN))!=null?r:void 0}set customDomain(r){r!==this.customDomain&&(r?this.setAttribute(Y.CUSTOM_DOMAIN,r):this.removeAttribute(Y.CUSTOM_DOMAIN))}get ended(){return Lh(this.nativeEl,this._hls)}get envKey(){var r;return(r=this.getAttribute(Y.ENV_KEY))!=null?r:void 0}set envKey(r){r!==this.envKey&&(r?this.setAttribute(Y.ENV_KEY,r):this.removeAttribute(Y.ENV_KEY))}get beaconCollectionDomain(){var r;return(r=this.getAttribute(Y.BEACON_COLLECTION_DOMAIN))!=null?r:void 0}set beaconCollectionDomain(r){r!==this.beaconCollectionDomain&&(r?this.setAttribute(Y.BEACON_COLLECTION_DOMAIN,r):this.removeAttribute(Y.BEACON_COLLECTION_DOMAIN))}get streamType(){var r;return(r=this.getAttribute(Y.STREAM_TYPE))!=null?r:R0(this.nativeEl)}set streamType(r){r!==this.streamType&&(r?this.setAttribute(Y.STREAM_TYPE,r):this.removeAttribute(Y.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(Y.TARGET_LIVE_WINDOW)?+this.getAttribute(Y.TARGET_LIVE_WINDOW):k0(this.nativeEl)}set targetLiveWindow(r){r!=this.targetLiveWindow&&(r==null?this.removeAttribute(Y.TARGET_LIVE_WINDOW):this.setAttribute(Y.TARGET_LIVE_WINDOW,`${+r}`))}get liveEdgeStart(){var r,e;if(this.hasAttribute(Y.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:t}=this,i=(r=this.nativeEl.seekable.end(0))!=null?r:0,s=(e=this.nativeEl.seekable.start(0))!=null?e:0;return Math.max(s,i-t)}return w0(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(Y.LIVE_EDGE_OFFSET))return+this.getAttribute(Y.LIVE_EDGE_OFFSET)}set liveEdgeOffset(r){r!=this.targetLiveWindow&&(r==null?this.removeAttribute(Y.LIVE_EDGE_OFFSET):this.setAttribute(Y.LIVE_EDGE_OFFSET,`${+r}`))}get seekable(){return Ih(this.nativeEl)}async addCuePoints(r){return Sh(this.nativeEl,r)}get activeCuePoint(){return xh(this.nativeEl)}get cuePoints(){return b0(this.nativeEl)}getStartDate(){return T0(this.nativeEl,this._hls)}get currentPdt(){return _0(this.nativeEl,this._hls)}get preferPlayback(){let r=this.getAttribute(Y.PREFER_PLAYBACK);if(r===oi.MSE||r===oi.NATIVE)return r}set preferPlayback(r){r!==this.preferPlayback&&(r===oi.MSE||r===oi.NATIVE?this.setAttribute(Y.PREFER_PLAYBACK,r):this.removeAttribute(Y.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(r=>r.startsWith("metadata-")&&![Y.METADATA_URL].includes(r)).reduce((r,e)=>{let t=this.getAttribute(e);return t!=null&&(r[e.replace(/^metadata-/,"").replace(/-/g,"_")]=t),r},{}),...G(this,sa)}}set metadata(r){ue(this,sa,r!=null?r:{}),this.mux&&this.mux.emit("hb",G(this,sa))}load(){ue(this,Xi,C0(this,this.nativeEl,G(this,Xi)))}unload(){Rh(this.nativeEl,G(this,Xi)),ue(this,Xi,void 0)}attributeChangedCallback(r,e,t){var i,s;switch(Dh.observedAttributes.includes(r)&&!["src","autoplay","preload"].includes(r)&&super.attributeChangedCallback(r,e,t),r){case Y.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case Y.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":{let n=!!e,a=!!t;!n&&a?nt(this,Ol,$h).call(this):n&&!a?this.unload():n&&a&&(this.unload(),nt(this,Ol,$h).call(this));break}case"autoplay":if(t===e)break;(i=G(this,Xi))==null||i.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=G(this,Xi))==null||s.setPreload(t);break;case Y.PLAYBACK_ID:this.src=I0(t!=null?t:void 0,{maxResolution:this.maxResolution,domain:this.customDomain});break;case Y.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 Y.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 Y.STREAM_TYPE:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case Y.TARGET_LIVE_WINDOW:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}disconnectedCallback(){this.unload()}};Xi=new WeakMap,ra=new WeakMap,wl=new WeakMap,sa=new WeakMap,Dl=new WeakMap,Cl=new WeakMap,Ml=new WeakMap,Ol=new WeakSet,$h=async function(){G(this,ra)||(await ue(this,ra,Promise.resolve()),ue(this,ra,null),this.load())};Rl.customElements.get("mux-video")||(Rl.customElements.define("mux-video",Gh),Rl.MuxVideoElement=Gh);var q0=Gh;var rS="en",rs={code:rS};var Y0="en";function ke(r,e=!0){var s,n;let t=e&&(n=(s=rs)==null?void 0:s[r])!=null?n:r,i=e?rs.code:Y0;return new Wh(t,i)}var Wh=class{constructor(e,t=(i=>(i=rs.code)!=null?i:Y0)()){this.message=e,this.locale=t}format(e){return this.message.replace(/\{(\w+)\}/g,(t,i)=>{var s;return(s=e[i])!=null?s:""})}toString(){return this.message}};function j0(r){let e="";return Object.entries(r).forEach(([t,i])=>{i!=null&&(e+=`${Bl(t)}: ${i}; `)}),e?e.trim():void 0}function Bl(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function $l(r){return r.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Qi(r){if(r==null)return;let e=+r;return Number.isNaN(e)?void 0:e}function Gl(r){let e=sS(r).toString();return e?"?"+e:""}function sS(r){let e={};for(let t in r)r[t]!=null&&(e[t]=r[t]);return new URLSearchParams(e)}function yr(r){let e=(r!=null?r:"").split(".")[1];if(!e)return{};let t=e.replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(i)}var qh=(r,e)=>!r||!e?!1:r.contains(e)?!0:qh(r,e.getRootNode().host);var Yh="mux.com",nS=()=>{try{return"1.12.0"}catch{}return"UNKNOWN"},aS=nS(),Vl=()=>aS,jh=(r,{maxResolution:e,token:t,domain:i=Yh}={})=>{let a=!!t?{token:t}:{redundant_streams:!0,...e?{max_resolution:e}:{}};return`https://stream.${i}/${r}.m3u8${Gl(a)}`},z0=(r,{token:e,thumbnailTime:t,domain:i=Yh}={})=>{let s=e==null?t:void 0,{aud:n}=yr(e);if(!(e&&n!=="t"))return`https://image.${i}/${r}/thumbnail.webp${Gl({token:e,time:s})}`},X0=(r,{token:e,domain:t=Yh}={})=>{let{aud:i}=yr(e);if(!(e&&i!=="s"))return`https://image.${t}/${r}/storyboard.vtt${Gl({token:e,format:"webp"})}`},na=r=>{if(!!r){if([Ze.LIVE,Ze.ON_DEMAND].includes(r))return r;if(r!=null&&r.includes("live"))return Ze.LIVE}};var oS={crossorigin:"crossOrigin",playsinline:"playsInline"};function Q0(r){var e;return(e=oS[r])!=null?e:$l(r)}var ss,ns,Ut,Hl=class{constructor(e,t){ut(this,ss,void 0);ut(this,ns,void 0);ut(this,Ut,[]);ii(this,ss,e),ii(this,ns,t)}[Symbol.iterator](){return Ne(this,Ut).values()}get length(){return Ne(this,Ut).length}get value(){var e;return(e=Ne(this,Ut).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(ii(this,Ut,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return Ne(this,Ut)[e]}values(){return Ne(this,Ut).values()}keys(){return Ne(this,Ut).keys()}forEach(e){Ne(this,Ut).forEach(e)}add(...e){var t,i;e.forEach(s=>{this.contains(s)||Ne(this,Ut).push(s)}),!(this.value===""&&!((t=Ne(this,ss))!=null&&t.hasAttribute(`${Ne(this,ns)}`)))&&((i=Ne(this,ss))==null||i.setAttribute(`${Ne(this,ns)}`,`${this.value}`))}remove(...e){var t;e.forEach(i=>{Ne(this,Ut).splice(Ne(this,Ut).indexOf(i),1)}),(t=Ne(this,ss))==null||t.setAttribute(`${Ne(this,ns)}`,`${this.value}`)}contains(e){return Ne(this,Ut).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)}};ss=new WeakMap,ns=new WeakMap,Ut=new WeakMap;var Z0=`[mux-player ${Vl()}]`;function br(...r){console.warn(Z0,...r)}function vi(...r){console.error(Z0,...r)}function zh(r){var t;let e=(t=r.message)!=null?t:"";if(r.context&&(e+=` ${r.context}`),r.file){let i="https://github.com/muxinc/elements/blob/main/errors/";e+=` ${ke("Read more: ")}
|
|
998
|
-
${i}${r.file}`}br(e)}var Pt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},as={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},ev=Object.freeze({length:0,start(r){let e=r>>>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(r){let e=r>>>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}}),lS=Nl.filter(r=>r!=="error"),dS=Object.values(Pt).filter(r=>![Pt.PLAYSINLINE].includes(r)),cS=Object.values(as);function tv(r){r.querySelectorAll(":scope > track").forEach(e=>{var t;(t=r.media)==null||t.append(e.cloneNode())}),lS.forEach(e=>{var t;(t=r.media)==null||t.addEventListener(e,i=>{r.dispatchEvent(new Event(i.type))})})}var Xh=class extends at.HTMLElement{static get observedAttributes(){return[...dS,...cS]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(i=>{var s;(s=this.media)==null||s.append(i.cloneNode())});let e=i=>{for(let s of i)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,i){var s,n;switch(e){case as.MUTED:{this.media&&(this.media.muted=i!=null,this.media.defaultMuted=i!=null);return}case as.VOLUME:{let a=(s=Qi(i))!=null?s:1;this.media&&(this.media.volume=a);return}case as.PLAYBACKRATE:{let a=(n=Qi(i))!=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:ev}get seekable(){var e,t;return(t=(e=this.media)==null?void 0:e.seekable)!=null?t:ev}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=Qi(this.getAttribute(as.PLAYBACKRATE)))!=null?e:1}set defaultPlaybackRate(e){e!=null?this.setAttribute(as.PLAYBACKRATE,`${e}`):this.removeAttribute(as.PLAYBACKRATE)}get crossOrigin(){return aa(this,Pt.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(Pt.CROSSORIGIN,`${e}`)}get autoplay(){return aa(this,Pt.AUTOPLAY)!=null}set autoplay(e){e?this.setAttribute(Pt.AUTOPLAY,typeof e=="string"?e:""):this.removeAttribute(Pt.AUTOPLAY)}get loop(){return aa(this,Pt.LOOP)!=null}set loop(e){e?this.setAttribute(Pt.LOOP,""):this.removeAttribute(Pt.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 aa(this,Pt.MUTED)!=null}set defaultMuted(e){e?this.setAttribute(Pt.MUTED,""):this.removeAttribute(Pt.MUTED)}get playsInline(){return aa(this,Pt.PLAYSINLINE)!=null}set playsInline(e){vi("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(Pt.PRELOAD,e):this.removeAttribute(Pt.PRELOAD)}};function aa(r,e){return r.media?r.media.getAttribute(e):r.getAttribute(e)}var Qh=Xh;var uS=Object.defineProperty,hS=(r,e,t)=>e in r?uS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,fS=(r,e,t)=>(hS(r,typeof e!="symbol"?e+"":e,t),t),av=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Le=(r,e,t)=>(av(r,e,"read from private field"),t?t.call(r):e.get(r)),$i=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Zi=(r,e,t,i)=>(av(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Xs,Kl,os,oa,Tr,_r,Ar,ls,Qs,Wl,Ei,iv=1,rv=0,mS=1,pS={processCallback(r,e,t){if(!!t){for(let[i,s]of e)if(i in t){let n=t[i];typeof n=="boolean"&&s instanceof Bt&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof Bt?s.element[s.attributeName]=n:s.value=n}}}},Ji=class extends D.DocumentFragment{constructor(e,t,i=pS){var s;super(),$i(this,Xs,void 0),$i(this,Kl,void 0),this.append(e.content.cloneNode(!0)),Zi(this,Xs,ov(this)),Zi(this,Kl,i),(s=i.createCallback)==null||s.call(i,this,Le(this,Xs),t),i.processCallback(this,Le(this,Xs),t)}update(e){Le(this,Kl).processCallback(this,Le(this,Xs),e)}};Xs=new WeakMap;Kl=new WeakMap;var ov=(r,e=[])=>{let t,i;for(let s of r.attributes||[])if(s.value.includes("{{")){let n=new Zh;for([t,i]of nv(s.value))if(!t)n.append(i);else{let a=new Bt(r,s.name,s.namespaceURI);n.append(a),e.push([i,a])}s.value=n.toString()}for(let s of r.childNodes)if(s.nodeType===iv&&!(s instanceof HTMLTemplateElement))ov(s,e);else if(s.nodeType===iv||s.data.includes("{{")){let n=[];if(s.data)for([t,i]of nv(s.data))if(!t)n.push(new Text(i));else{let a=new er(r);n.push(a),e.push([i,a])}else if(s instanceof HTMLTemplateElement){let a=new la(r,s);n.push(a),e.push([a.expression,a])}s.replaceWith(...n.flatMap(a=>a.replacementNodes||[a]))}return e},sv={},nv=r=>{let e="",t=0,i=sv[r],s=0,n;if(i)return i;for(i=[];n=r[s];s++)n==="{"&&r[s+1]==="{"&&r[s-1]!=="\\"&&r[s+2]&&++t==1?(e&&i.push([rv,e]),e="",s++):n==="}"&&r[s+1]==="}"&&r[s-1]!=="\\"&&!--t?(i.push([mS,e.trim()]),e="",s++):e+=n||"";return e&&i.push([rv,(t>0?"{{":"")+e]),sv[r]=i},gS=11,ql=class{get value(){return""}set value(e){}toString(){return this.value}},lv=new WeakMap,Zh=class{constructor(){$i(this,os,[])}[Symbol.iterator](){return Le(this,os).values()}get length(){return Le(this,os).length}item(e){return Le(this,os)[e]}append(...e){for(let t of e)t instanceof Bt&&lv.set(t,this),Le(this,os).push(t)}toString(){return Le(this,os).join("")}};os=new WeakMap;var Bt=class extends ql{constructor(e,t,i){super(),$i(this,ls),$i(this,oa,""),$i(this,Tr,void 0),$i(this,_r,void 0),$i(this,Ar,void 0),Zi(this,Tr,e),Zi(this,_r,t),Zi(this,Ar,i)}get attributeName(){return Le(this,_r)}get attributeNamespace(){return Le(this,Ar)}get element(){return Le(this,Tr)}get value(){return Le(this,oa)}set value(e){Le(this,oa)!==e&&(Zi(this,oa,e),!Le(this,ls,Qs)||Le(this,ls,Qs).length===1?e==null?Le(this,Tr).removeAttributeNS(Le(this,Ar),Le(this,_r)):Le(this,Tr).setAttributeNS(Le(this,Ar),Le(this,_r),e):Le(this,Tr).setAttributeNS(Le(this,Ar),Le(this,_r),Le(this,ls,Qs)))}get booleanValue(){return Le(this,Tr).hasAttributeNS(Le(this,Ar),Le(this,_r))}set booleanValue(e){if(!Le(this,ls,Qs)||Le(this,ls,Qs).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};oa=new WeakMap;Tr=new WeakMap;_r=new WeakMap;Ar=new WeakMap;ls=new WeakSet;Qs=function(){return lv.get(this)};var er=class extends ql{constructor(e,t){super(),$i(this,Wl,void 0),$i(this,Ei,void 0),Zi(this,Wl,e),Zi(this,Ei,t?[...t]:[new Text])}get replacementNodes(){return Le(this,Ei)}get parentNode(){return Le(this,Wl)}get nextSibling(){return Le(this,Ei)[Le(this,Ei).length-1].nextSibling}get previousSibling(){return Le(this,Ei)[0].previousSibling}get value(){return Le(this,Ei).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){let t=e.flat().flatMap(i=>i==null?[new Text]:i.forEach?[...i]:i.nodeType===gS?[...i.childNodes]:i.nodeType?[i]:[new Text(i)]);t.length||t.push(new Text),Zi(this,Ei,vS(Le(this,Ei)[0].parentNode,Le(this,Ei),t,this.nextSibling))}};Wl=new WeakMap;Ei=new WeakMap;var la=class extends er{constructor(e,t){let i=t.getAttribute("directive")||t.getAttribute("type"),s=t.getAttribute("expression")||t.getAttribute(i)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),fS(this,"directive"),this.expression=s,this.template=t,this.directive=i}};function vS(r,e,t,i=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];)i=t[--d,--l];if(s==d)for(;s<l;)r.insertBefore(t[s++],i);if(s==l)for(;s<d;)r.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:i,n==o?n=a:s<l&&t[s]==a?(r.replaceChild(o,n),n=a):r.insertBefore(o,n);for(;n!=i;)a=n.nextSibling,r.removeChild(n),n=a}return t}var dv={string:r=>String(r)},jl=class{constructor(e){this.template=e,this.state=void 0}},ds=new WeakMap,cs=new WeakMap,Jh={partial:(r,e)=>{e[r.expression]=new jl(r.template)},if:(r,e)=>{var t;if(uv(r.expression,e))if(ds.get(r)!==r.template){ds.set(r,r.template);let i=new Ji(r.template,e,zl);r.replace(i),cs.set(r,i)}else(t=cs.get(r))==null||t.update(e);else r.replace(""),ds.delete(r),cs.delete(r)}},ES=Object.keys(Jh),zl={processCallback(r,e,t){var i,s;if(!!t)for(let[n,a]of e){if(a instanceof la){if(!a.directive){let l=ES.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(i=Jh[a.directive])==null||i.call(Jh,a,t);continue}let o=uv(n,t);if(o instanceof jl){ds.get(a)!==o.template?(ds.set(a,o.template),o=new Ji(o.template,o.state,zl),a.value=o,cs.set(a,o)):(s=cs.get(a))==null||s.update(o.state);continue}o?(a instanceof Bt&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof Bt?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,ds.delete(a),cs.delete(a))):a instanceof Bt?a.value=void 0:(a.value=void 0,ds.delete(a),cs.delete(a))}}},cv={"!":r=>!r,"!!":r=>!!r,"==":(r,e)=>r==e,"!=":(r,e)=>r!=e,">":(r,e)=>r>e,">=":(r,e)=>r>=e,"<":(r,e)=>r<e,"<=":(r,e)=>r<=e,"??":(r,e)=>r!=null?r:e,"|":(r,e)=>{var t;return(t=dv[e])==null?void 0:t.call(dv,r)}};function yS(r){return bS(r,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function uv(r,e={}){var t,i,s,n,a,o,l;let d=yS(r);if(d.length===0||d.some(({type:c})=>!c))return da(r);if(((t=d[0])==null?void 0:t.token)===">"){let c=e[(i=d[1])==null?void 0:i.token];if(!c)return da(r);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]=ca(T,e))}return c}if(d.length===1)return Yl(d[0])?ca(d[0].token,e):da(r);if(d.length===2){let c=(o=d[0])==null?void 0:o.token,u=cv[c];if(!u||!Yl(d[1]))return da(r);let h=ca(d[1].token,e);return u(h)}if(d.length===3){let c=(l=d[1])==null?void 0:l.token,u=cv[c];if(!u||!Yl(d[0])||!Yl(d[2]))return da(r);let h=ca(d[0].token,e);if(c==="|")return u(h,d[2].token);let f=ca(d[2].token,e);return u(h,f)}}function da(r){return console.warn(`Warning: invalid expression \`${r}\``),!1}function Yl({type:r}){return["number","boolean","string","param"].includes(r)}function ca(r,e){let t=r[0],i=r.slice(-1);return r==="true"||r==="false"?r==="true":t===i&&["'",'"'].includes(t)?r.slice(1,-1):La(r)?parseFloat(r):e[r]}function bS(r,e){let t,i,s,n=[];for(;r;){s=null,t=r.length;for(let a in e)i=e[a].exec(r),i&&i.index<t&&(s={token:i[0],type:a,matches:i.slice(1)},t=i.index);t&&n.push({token:r.substr(0,t),type:void 0}),s&&n.push(s),r=r.substr(t+(s?s.token.length:0))}return n}var TS=Object.defineProperty,_S=(r,e,t)=>e in r?TS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ha=(r,e,t)=>(_S(r,typeof e!="symbol"?e+"":e,t),t),af=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},rf=(r,e,t)=>(af(r,e,"read from private field"),t?t.call(r):e.get(r)),ua=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},us=(r,e,t,i)=>(af(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),ef=(r,e,t)=>(af(r,e,"access private method"),t),Zs,Xl,Js,sf,hv,Ql,nf,tf={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},fv=z.createElement("template");fv.innerHTML=`
|
|
997
|
+
`);var Yh=(r,{tag:e,is:t})=>{var i,s,n,a,o,l,d,c,u,h,m,g,E;let T=(i=globalThis.document)==null?void 0:i.createElement(e,{is:t}),A=T?YA(T):[];return s=class extends r{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 R,x,N;return nt(R=s,a,o).call(R),[...(N=(x=T==null?void 0:T.constructor)==null?void 0:x.observedAttributes)!=null?N:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var R,x;return(x=(R=G(this,d))!=null?R:this.shadowRoot.querySelector(e))!=null?x:this.querySelector(e)}set nativeEl(R){ue(this,d,R)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(R){this.toggleAttribute("muted",Boolean(R))}get src(){return this.getAttribute("src")}set src(R){this.setAttribute("src",`${R}`)}get preload(){var R,x;return(x=this.getAttribute("preload"))!=null?x:(R=this.nativeEl)==null?void 0:R.preload}set preload(R){this.setAttribute("preload",`${R}`)}attributeChangedCallback(R,x,N){nt(this,c,u).call(this),nt(this,g,E).call(this,R,x,N)}connectedCallback(){nt(this,c,u).call(this)}},n=new WeakMap,a=new WeakSet,o=function(){if(G(this,n))return;ue(this,n,!0);let R=new Set(this.observedAttributes);R.delete("muted");for(let x of A)if(!(x in this.prototype))if(typeof T[x]=="function")this.prototype[x]=function(...N){return nt(this,c,u).call(this),(()=>this.call?this.call(x,...N):this.nativeEl[x].apply(this.nativeEl,N))()};else{let N={get(){var w,$,O;nt(this,c,u).call(this);let H=x.toLowerCase();if(R.has(H)){let q=this.getAttribute(H);return q===null?!1:q===""?!0:q}return(O=(w=this.get)==null?void 0:w.call(this,x))!=null?O:($=this.nativeEl)==null?void 0:$[x]}};x!==x.toUpperCase()&&(N.set=function(w){nt(this,c,u).call(this);let $=x.toLowerCase();if(R.has($)){w===!0||w===!1||w==null?this.toggleAttribute($,Boolean(w)):this.setAttribute($,w);return}if(this.set){this.set(x,w);return}this.nativeEl[x]=w}),Object.defineProperty(this.prototype,x,N)}},l=new WeakMap,d=new WeakMap,c=new WeakSet,u=function(){var R,x;if(G(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)nt(this,h,m).call(this,$);let N=new Map,w=this.shadowRoot.querySelector("slot:not([name])");w==null||w.addEventListener("slotchange",()=>{let $=new Map(N);w.assignedElements().filter(O=>["track","source"].includes(O.localName)).forEach(O=>{var H,q;$.delete(O);let P=N.get(O);P||(P=O.cloneNode(),N.set(O,P)),(q=(H=this.nativeEl).append)==null||q.call(H,P)}),$.forEach(O=>O.remove())});for(let $ of this.constructor.Events)(x=(R=this.shadowRoot).addEventListener)==null||x.call(R,$,O=>{O.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(O.type,{detail:O.detail}))},!0)},h=new WeakSet,m=function(R){if(Object.prototype.hasOwnProperty.call(this,R)){let x=this[R];delete this[R],this[R]=x}},g=new WeakSet,E=function(R,x,N){var w,$,O,H;["id","class"].includes(R)||(N===null?($=(w=this.nativeEl).removeAttribute)==null||$.call(w,R):(H=(O=this.nativeEl).setAttribute)==null||H.call(O,R,N))},le(s,a),Be(s,"Events",Fl),Be(s,"template",e.endsWith("audio")?Ch:Mh),le(s,n,void 0),s};function YA(r){let e=[];for(let t=Object.getPrototypeOf(r);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}var ww=globalThis.document?Yh(HTMLElement,{tag:"video"}):class{},Dw=globalThis.document?Yh(HTMLElement,{tag:"audio"}):class{},Ul=class extends Event{constructor(r,e){super(r),Be(this,"track"),this.track=e.track}},Oh=new WeakMap;function te(r){var e;return(e=Oh.get(r))!=null?e:jA(r,{})}function jA(r,e){let t=Oh.get(r);return t||Oh.set(r,t={}),Object.assign(t,e)}function Ph(r,e){let t=r.videoTracks;te(e).media=r,te(e).renditionSet||(te(e).renditionSet=new Set);let i=te(t).trackSet;i.add(e);let s=i.size-1;s in Fh.prototype||Object.defineProperty(Fh.prototype,s,{get(){return[...te(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Ul("addtrack",{track:e}))})}function Nh(r){var e;let t=(e=te(r).media)==null?void 0:e.videoTracks;!t||(te(t).trackSet.delete(r),queueMicrotask(()=>{t.dispatchEvent(new Ul("removetrack",{track:r}))}))}function zA(r){var e;let t=(e=te(r).media.videoTracks)!=null?e:[],i=!1;for(let s of t)s!==r&&(s.selected=!1,i=!0);if(i){if(te(t).changeRequested)return;te(t).changeRequested=!0,queueMicrotask(()=>{delete te(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var Wr,qr,Yr,Ys,Qn,Fh=class extends EventTarget{constructor(){super(),le(this,Ys),le(this,Wr,void 0),le(this,qr,void 0),le(this,Yr,void 0),te(this).trackSet=new Set}[Symbol.iterator](){return G(this,Ys,Qn).values()}get length(){return G(this,Ys,Qn).size}getTrackById(r){var e;return(e=[...G(this,Ys,Qn)].find(t=>t.id===r))!=null?e:null}get selectedIndex(){return[...G(this,Ys,Qn)].findIndex(r=>r.selected)}get onaddtrack(){return G(this,Wr)}set onaddtrack(r){G(this,Wr)&&(this.removeEventListener("addtrack",G(this,Wr)),ue(this,Wr,void 0)),typeof r=="function"&&(ue(this,Wr,r),this.addEventListener("addtrack",r))}get onremovetrack(){return G(this,qr)}set onremovetrack(r){G(this,qr)&&(this.removeEventListener("removetrack",G(this,qr)),ue(this,qr,void 0)),typeof r=="function"&&(ue(this,qr,r),this.addEventListener("removetrack",r))}get onchange(){return G(this,Yr)}set onchange(r){G(this,Yr)&&(this.removeEventListener("change",G(this,Yr)),ue(this,Yr,void 0)),typeof r=="function"&&(ue(this,Yr,r),this.addEventListener("change",r))}};Wr=new WeakMap,qr=new WeakMap,Yr=new WeakMap,Ys=new WeakSet,Qn=function(){return te(this).trackSet};var Bl=class extends Event{constructor(r,e){super(r),Be(this,"rendition"),this.rendition=e.rendition}};function XA(r,e){let t=te(r).media.videoRenditions;te(e).media=te(r).media,te(e).track=r;let i=te(r).renditionSet;i.add(e);let s=i.size-1;s in Uh.prototype||Object.defineProperty(Uh.prototype,s,{get(){return js(this)[s]}}),queueMicrotask(()=>{!r.selected||t.dispatchEvent(new Bl("addrendition",{rendition:e}))})}function QA(r){let e=te(r).media.videoRenditions,t=te(r).track;te(t).renditionSet.delete(r),queueMicrotask(()=>{!te(r).track.selected||e.dispatchEvent(new Bl("removerendition",{rendition:r}))})}function ZA(r){let e=te(r).media.videoRenditions;!e||te(e).changeRequested||(te(e).changeRequested=!0,queueMicrotask(()=>{delete te(e).changeRequested,te(r).track.selected&&e.dispatchEvent(new Event("change"))}))}function js(r){return[...te(r).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...te(e).renditionSet])}var jr,zr,Xr,Uh=class extends EventTarget{constructor(){super(...arguments),le(this,jr,void 0),le(this,zr,void 0),le(this,Xr,void 0)}[Symbol.iterator](){return js(this).values()}get length(){return js(this).length}getRenditionById(r){var e;return(e=js(this).find(t=>`${t.id}`==`${r}`))!=null?e:null}get selectedIndex(){return js(this).findIndex(r=>r.selected)}set selectedIndex(r){for(let[e,t]of js(this).entries())t.selected=e===r}get onaddrendition(){return G(this,jr)}set onaddrendition(r){G(this,jr)&&(this.removeEventListener("addrendition",G(this,jr)),ue(this,jr,void 0)),typeof r=="function"&&(ue(this,jr,r),this.addEventListener("addrendition",r))}get onremoverendition(){return G(this,zr)}set onremoverendition(r){G(this,zr)&&(this.removeEventListener("removerendition",G(this,zr)),ue(this,zr,void 0)),typeof r=="function"&&(ue(this,zr,r),this.addEventListener("removerendition",r))}get onchange(){return G(this,Xr)}set onchange(r){G(this,Xr)&&(this.removeEventListener("change",G(this,Xr)),ue(this,Xr,void 0)),typeof r=="function"&&(ue(this,Xr,r),this.addEventListener("change",r))}};jr=new WeakMap,zr=new WeakMap,Xr=new WeakMap;var Zn,JA=class{constructor(){Be(this,"src"),Be(this,"id"),Be(this,"width"),Be(this,"height"),Be(this,"bitrate"),Be(this,"frameRate"),Be(this,"codec"),le(this,Zn,!1)}get selected(){return G(this,Zn)}set selected(r){G(this,Zn)!==r&&(ue(this,Zn,r),ZA(this))}};Zn=new WeakMap;var Jn,Y0=class{constructor(){Be(this,"id"),Be(this,"kind"),Be(this,"label",""),Be(this,"language",""),Be(this,"sourceBuffer"),le(this,Jn,!1)}addRendition(r,e,t,i,s,n){let a=new JA;return a.src=r,a.width=e,a.height=t,a.frameRate=n,a.bitrate=s,a.codec=i,XA(this,a),a}removeRendition(r){QA(r)}get selected(){return G(this,Jn)}set selected(r){G(this,Jn)!==r&&(ue(this,Jn,r),r===!0&&zA(this))}};Jn=new WeakMap;function eS(r,e){let t=te(r).media.audioRenditions;te(e).media=te(r).media,te(e).track=r;let i=te(r).renditionSet;i.add(e);let s=i.size-1;s in Bh.prototype||Object.defineProperty(Bh.prototype,s,{get(){return zs(this)[s]}}),queueMicrotask(()=>{!r.enabled||t.dispatchEvent(new Bl("addrendition",{rendition:e}))})}function tS(r){let e=te(r).media.audioRenditions,t=te(r).track;te(t).renditionSet.delete(r),queueMicrotask(()=>{!te(r).track.enabled||e.dispatchEvent(new Bl("removerendition",{rendition:r}))})}function iS(r){let e=te(r).media.audioRenditions;!e||te(e).changeRequested||(te(e).changeRequested=!0,queueMicrotask(()=>{delete te(e).changeRequested,te(r).track.enabled&&e.dispatchEvent(new Event("change"))}))}function zs(r){return[...te(r).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...te(e).renditionSet])}var Qr,Zr,Jr,Bh=class extends EventTarget{constructor(){super(...arguments),le(this,Qr,void 0),le(this,Zr,void 0),le(this,Jr,void 0)}[Symbol.iterator](){return zs(this).values()}get length(){return zs(this).length}getRenditionById(r){var e;return(e=zs(this).find(t=>`${t.id}`==`${r}`))!=null?e:null}get selectedIndex(){return zs(this).findIndex(r=>r.selected)}set selectedIndex(r){for(let[e,t]of zs(this).entries())t.selected=e===r}get onaddrendition(){return G(this,Qr)}set onaddrendition(r){G(this,Qr)&&(this.removeEventListener("addrendition",G(this,Qr)),ue(this,Qr,void 0)),typeof r=="function"&&(ue(this,Qr,r),this.addEventListener("addrendition",r))}get onremoverendition(){return G(this,Zr)}set onremoverendition(r){G(this,Zr)&&(this.removeEventListener("removerendition",G(this,Zr)),ue(this,Zr,void 0)),typeof r=="function"&&(ue(this,Zr,r),this.addEventListener("removerendition",r))}get onchange(){return G(this,Jr)}set onchange(r){G(this,Jr)&&(this.removeEventListener("change",G(this,Jr)),ue(this,Jr,void 0)),typeof r=="function"&&(ue(this,Jr,r),this.addEventListener("change",r))}};Qr=new WeakMap,Zr=new WeakMap,Jr=new WeakMap;var ea,rS=class{constructor(){Be(this,"src"),Be(this,"id"),Be(this,"bitrate"),Be(this,"codec"),le(this,ea,!1)}get selected(){return G(this,ea)}set selected(r){G(this,ea)!==r&&(ue(this,ea,r),iS(this))}};ea=new WeakMap;function $h(r,e){let t=r.audioTracks;te(e).media=r,te(e).renditionSet||(te(e).renditionSet=new Set);let i=te(t).trackSet;i.add(e);let s=i.size-1;s in Hh.prototype||Object.defineProperty(Hh.prototype,s,{get(){return[...te(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Ul("addtrack",{track:e}))})}function Gh(r){var e;let t=(e=te(r).media)==null?void 0:e.audioTracks;!t||(te(t).trackSet.delete(r),queueMicrotask(()=>{t.dispatchEvent(new Ul("removetrack",{track:r}))}))}function sS(r){let e=te(r).media.audioTracks;!e||te(e).changeRequested||(te(e).changeRequested=!0,queueMicrotask(()=>{delete te(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var es,ts,is,ta,kl,Hh=class extends EventTarget{constructor(){super(),le(this,ta),le(this,es,void 0),le(this,ts,void 0),le(this,is,void 0),te(this).trackSet=new Set}[Symbol.iterator](){return G(this,ta,kl).values()}get length(){return G(this,ta,kl).size}getTrackById(r){var e;return(e=[...G(this,ta,kl)].find(t=>t.id===r))!=null?e:null}get onaddtrack(){return G(this,es)}set onaddtrack(r){G(this,es)&&(this.removeEventListener("addtrack",G(this,es)),ue(this,es,void 0)),typeof r=="function"&&(ue(this,es,r),this.addEventListener("addtrack",r))}get onremovetrack(){return G(this,ts)}set onremovetrack(r){G(this,ts)&&(this.removeEventListener("removetrack",G(this,ts)),ue(this,ts,void 0)),typeof r=="function"&&(ue(this,ts,r),this.addEventListener("removetrack",r))}get onchange(){return G(this,is)}set onchange(r){G(this,is)&&(this.removeEventListener("change",G(this,is)),ue(this,is,void 0)),typeof r=="function"&&(ue(this,is,r),this.addEventListener("change",r))}};es=new WeakMap,ts=new WeakMap,is=new WeakMap,ta=new WeakSet,kl=function(){return te(this).trackSet};var ia,j0=class{constructor(){Be(this,"id"),Be(this,"kind"),Be(this,"label",""),Be(this,"language",""),Be(this,"sourceBuffer"),le(this,ia,!1)}addRendition(r,e,t){let i=new rS;return i.src=r,i.codec=e,i.bitrate=t,eS(this,i),i}removeRendition(r){tS(r)}get enabled(){return G(this,ia)}set enabled(r){G(this,ia)!==r&&(ue(this,ia,r),sS(this))}};ia=new WeakMap;var V0=Pl(globalThis.HTMLMediaElement,"video"),K0=Pl(globalThis.HTMLMediaElement,"audio");function nS(r){if(!(r!=null&&r.prototype))return r;let e=Pl(r,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(r.prototype,"videoTracks",{get(){return aS(this)}});let t=Pl(r,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(r.prototype,"audioTracks",{get(){return oS(this)}}),"addVideoTrack"in r.prototype||(r.prototype.addVideoTrack=function(n,a="",o=""){let l=new Y0;return l.kind=n,l.label=a,l.language=o,Ph(this,l),l}),"removeVideoTrack"in r.prototype||(r.prototype.removeVideoTrack=Nh),"addAudioTrack"in r.prototype||(r.prototype.addAudioTrack=function(n,a="",o=""){let l=new j0;return l.kind=n,l.label=a,l.language=o,$h(this,l),l}),"removeAudioTrack"in r.prototype||(r.prototype.removeAudioTrack=Gh),"videoRenditions"in r.prototype||Object.defineProperty(r.prototype,"videoRenditions",{get(){return i(this)}});let i=n=>{let a=te(n).videoRenditions;return a||(a=new Uh,te(a).media=n,te(n).videoRenditions=a),a};"audioRenditions"in r.prototype||Object.defineProperty(r.prototype,"audioRenditions",{get(){return s(this)}});let s=n=>{let a=te(n).audioRenditions;return a||(a=new Bh,te(a).media=n,te(n).audioRenditions=a),a};return r}function Pl(r,e){var t;if(r!=null&&r.prototype)return(t=Object.getOwnPropertyDescriptor(r.prototype,`${e}Tracks`))==null?void 0:t.get}function aS(r){var e;let t=te(r).videoTracks;if(!t&&(t=new Fh,te(r).videoTracks=t,V0)){let i=V0.call((e=r.nativeEl)!=null?e:r);for(let s of i)Ph(r,s);i.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),i.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof Y0)){for(let n of i)Nh(n);return}Ph(r,s.track)}),i.addEventListener("removetrack",s=>{Nh(s.track)})}return t}function oS(r){var e;let t=te(r).audioTracks;if(!t&&(t=new Hh,te(r).audioTracks=t,K0)){let i=K0.call((e=r.nativeEl)!=null?e:r);for(let s of i)$h(r,s);i.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),i.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof j0)){for(let n of i)Gh(n);return}$h(r,s.track)}),i.addEventListener("removetrack",s=>{Gh(s.track)})}return t}Fl.push("castchange","entercast","leavecast");var wh=nS(Yh(Rl.HTMLElement,{tag:"video",is:"castable-video"})),Y={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",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"},lS=Object.values(Y),dS=qA(),cS="mux-video",Xi,ra,wl,sa,Dl,Cl,Ml,Ol,Vh,Kh=class extends wh{constructor(){super(),le(this,Ol),le(this,Xi,void 0),le(this,ra,void 0),le(this,wl,void 0),le(this,sa,{}),le(this,Dl,void 0),le(this,Cl,void 0),le(this,Ml,void 0),ue(this,wl,R0())}static get observedAttributes(){var r;return[...lS,...(r=wh.observedAttributes)!=null?r:[]]}get preferCmcd(){var r;return(r=this.getAttribute(Y.PREFER_CMCD))!=null?r:void 0}set preferCmcd(r){r!==this.preferCmcd&&(r?qs.includes(r)?this.setAttribute(Y.PREFER_CMCD,r):console.warn(`Invalid value for preferCmcd. Must be one of ${qs.join()}`):this.removeAttribute(Y.PREFER_CMCD))}get playerInitTime(){return G(this,wl)}get playerSoftwareName(){var r;return(r=G(this,Cl))!=null?r:cS}set playerSoftwareName(r){ue(this,Cl,r)}get playerSoftwareVersion(){var r;return(r=G(this,Dl))!=null?r:dS}set playerSoftwareVersion(r){ue(this,Dl,r)}get _hls(){var r;return(r=G(this,Xi))==null?void 0:r.engine}get mux(){return this.nativeEl.mux}get error(){var r;return(r=w0(this.nativeEl))!=null?r:null}get errorTranslator(){return G(this,Ml)}set errorTranslator(r){ue(this,Ml,r)}get src(){return this.getAttribute("src")}set src(r){r!==this.src&&(r==null?this.removeAttribute("src"):this.setAttribute("src",r))}get type(){var r;return(r=this.getAttribute(Y.TYPE))!=null?r:void 0}set type(r){r!==this.type&&(r?this.setAttribute(Y.TYPE,r):this.removeAttribute(Y.TYPE))}get autoplay(){let r=this.getAttribute("autoplay");return r===null?!1:r===""?!0:r}set autoplay(r){let e=this.autoplay;r!==e&&(r?this.setAttribute("autoplay",typeof r=="string"?r:""):this.removeAttribute("autoplay"))}get preload(){let r=this.getAttribute("preload");return r===""?"auto":["none","metadata","auto"].includes(r)?r:super.preload}set preload(r){r!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(r)?this.setAttribute("preload",r):this.removeAttribute("preload"))}get debug(){return this.getAttribute(Y.DEBUG)!=null}set debug(r){r!==this.debug&&(r?this.setAttribute(Y.DEBUG,""):this.removeAttribute(Y.DEBUG))}get disableCookies(){return this.hasAttribute(Y.DISABLE_COOKIES)}set disableCookies(r){r!==this.disableCookies&&(r?this.setAttribute(Y.DISABLE_COOKIES,""):this.removeAttribute(Y.DISABLE_COOKIES))}get startTime(){let r=this.getAttribute(Y.START_TIME);if(r==null)return;let e=+r;return Number.isNaN(e)?void 0:e}set startTime(r){r!==this.startTime&&(r==null?this.removeAttribute(Y.START_TIME):this.setAttribute(Y.START_TIME,`${r}`))}get playbackId(){var r;return(r=this.getAttribute(Y.PLAYBACK_ID))!=null?r:void 0}set playbackId(r){r!==this.playbackId&&(r?this.setAttribute(Y.PLAYBACK_ID,r):this.removeAttribute(Y.PLAYBACK_ID))}get maxResolution(){var r;return(r=this.getAttribute(Y.MAX_RESOLUTION))!=null?r:void 0}set maxResolution(r){r!==this.maxResolution&&(r?this.setAttribute(Y.MAX_RESOLUTION,r):this.removeAttribute(Y.MAX_RESOLUTION))}get customDomain(){var r;return(r=this.getAttribute(Y.CUSTOM_DOMAIN))!=null?r:void 0}set customDomain(r){r!==this.customDomain&&(r?this.setAttribute(Y.CUSTOM_DOMAIN,r):this.removeAttribute(Y.CUSTOM_DOMAIN))}get ended(){return Rh(this.nativeEl,this._hls)}get envKey(){var r;return(r=this.getAttribute(Y.ENV_KEY))!=null?r:void 0}set envKey(r){r!==this.envKey&&(r?this.setAttribute(Y.ENV_KEY,r):this.removeAttribute(Y.ENV_KEY))}get beaconCollectionDomain(){var r;return(r=this.getAttribute(Y.BEACON_COLLECTION_DOMAIN))!=null?r:void 0}set beaconCollectionDomain(r){r!==this.beaconCollectionDomain&&(r?this.setAttribute(Y.BEACON_COLLECTION_DOMAIN,r):this.removeAttribute(Y.BEACON_COLLECTION_DOMAIN))}get streamType(){var r;return(r=this.getAttribute(Y.STREAM_TYPE))!=null?r:D0(this.nativeEl)}set streamType(r){r!==this.streamType&&(r?this.setAttribute(Y.STREAM_TYPE,r):this.removeAttribute(Y.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(Y.TARGET_LIVE_WINDOW)?+this.getAttribute(Y.TARGET_LIVE_WINDOW):C0(this.nativeEl)}set targetLiveWindow(r){r!=this.targetLiveWindow&&(r==null?this.removeAttribute(Y.TARGET_LIVE_WINDOW):this.setAttribute(Y.TARGET_LIVE_WINDOW,`${+r}`))}get liveEdgeStart(){var r,e;if(this.hasAttribute(Y.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:t}=this,i=(r=this.nativeEl.seekable.end(0))!=null?r:0,s=(e=this.nativeEl.seekable.start(0))!=null?e:0;return Math.max(s,i-t)}return M0(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(Y.LIVE_EDGE_OFFSET))return+this.getAttribute(Y.LIVE_EDGE_OFFSET)}set liveEdgeOffset(r){r!=this.targetLiveWindow&&(r==null?this.removeAttribute(Y.LIVE_EDGE_OFFSET):this.setAttribute(Y.LIVE_EDGE_OFFSET,`${+r}`))}get seekable(){return Lh(this.nativeEl)}async addCuePoints(r){return xh(this.nativeEl,r)}get activeCuePoint(){return Ih(this.nativeEl)}get cuePoints(){return A0(this.nativeEl)}getStartDate(){return S0(this.nativeEl,this._hls)}get currentPdt(){return x0(this.nativeEl,this._hls)}get preferPlayback(){let r=this.getAttribute(Y.PREFER_PLAYBACK);if(r===oi.MSE||r===oi.NATIVE)return r}set preferPlayback(r){r!==this.preferPlayback&&(r===oi.MSE||r===oi.NATIVE?this.setAttribute(Y.PREFER_PLAYBACK,r):this.removeAttribute(Y.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(r=>r.startsWith("metadata-")&&![Y.METADATA_URL].includes(r)).reduce((r,e)=>{let t=this.getAttribute(e);return t!=null&&(r[e.replace(/^metadata-/,"").replace(/-/g,"_")]=t),r},{}),...G(this,sa)}}set metadata(r){ue(this,sa,r!=null?r:{}),this.mux&&this.mux.emit("hb",G(this,sa))}load(){ue(this,Xi,P0(this,this.nativeEl,G(this,Xi)))}unload(){kh(this.nativeEl,G(this,Xi)),ue(this,Xi,void 0)}attributeChangedCallback(r,e,t){var i,s;switch(wh.observedAttributes.includes(r)&&!["src","autoplay","preload"].includes(r)&&super.attributeChangedCallback(r,e,t),r){case Y.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case Y.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":{let n=!!e,a=!!t;!n&&a?nt(this,Ol,Vh).call(this):n&&!a?this.unload():n&&a&&(this.unload(),nt(this,Ol,Vh).call(this));break}case"autoplay":if(t===e)break;(i=G(this,Xi))==null||i.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=G(this,Xi))==null||s.setPreload(t);break;case Y.PLAYBACK_ID:this.src=k0(t!=null?t:void 0,{maxResolution:this.maxResolution,domain:this.customDomain});break;case Y.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 Y.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 Y.STREAM_TYPE:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case Y.TARGET_LIVE_WINDOW:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}disconnectedCallback(){this.unload()}};Xi=new WeakMap,ra=new WeakMap,wl=new WeakMap,sa=new WeakMap,Dl=new WeakMap,Cl=new WeakMap,Ml=new WeakMap,Ol=new WeakSet,Vh=async function(){G(this,ra)||(await ue(this,ra,Promise.resolve()),ue(this,ra,null),this.load())};Rl.customElements.get("mux-video")||(Rl.customElements.define("mux-video",Kh),Rl.MuxVideoElement=Kh);var z0=Kh;var uS="en",rs={code:uS};var X0="en";function ke(r,e=!0){var s,n;let t=e&&(n=(s=rs)==null?void 0:s[r])!=null?n:r,i=e?rs.code:X0;return new jh(t,i)}var jh=class{constructor(e,t=(i=>(i=rs.code)!=null?i:X0)()){this.message=e,this.locale=t}format(e){return this.message.replace(/\{(\w+)\}/g,(t,i)=>{var s;return(s=e[i])!=null?s:""})}toString(){return this.message}};function Q0(r){let e="";return Object.entries(r).forEach(([t,i])=>{i!=null&&(e+=`${$l(t)}: ${i}; `)}),e?e.trim():void 0}function $l(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Gl(r){return r.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Qi(r){if(r==null)return;let e=+r;return Number.isNaN(e)?void 0:e}function Hl(r){let e=hS(r).toString();return e?"?"+e:""}function hS(r){let e={};for(let t in r)r[t]!=null&&(e[t]=r[t]);return new URLSearchParams(e)}function yr(r){let e=(r!=null?r:"").split(".")[1];if(!e)return{};let t=e.replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(i)}var zh=(r,e)=>!r||!e?!1:r.contains(e)?!0:zh(r,e.getRootNode().host);var Xh="mux.com",fS=()=>{try{return"1.12.1"}catch{}return"UNKNOWN"},mS=fS(),Kl=()=>mS,Qh=(r,{maxResolution:e,token:t,domain:i=Xh}={})=>{let a=!!t?{token:t}:{redundant_streams:!0,...e?{max_resolution:e}:{}};return`https://stream.${i}/${r}.m3u8${Hl(a)}`},Z0=(r,{token:e,thumbnailTime:t,domain:i=Xh}={})=>{let s=e==null?t:void 0,{aud:n}=yr(e);if(!(e&&n!=="t"))return`https://image.${i}/${r}/thumbnail.webp${Hl({token:e,time:s})}`},J0=(r,{token:e,domain:t=Xh}={})=>{let{aud:i}=yr(e);if(!(e&&i!=="s"))return`https://image.${t}/${r}/storyboard.vtt${Hl({token:e,format:"webp"})}`},na=r=>{if(!!r){if([Ze.LIVE,Ze.ON_DEMAND].includes(r))return r;if(r!=null&&r.includes("live"))return Ze.LIVE}};var pS={crossorigin:"crossOrigin",playsinline:"playsInline"};function ev(r){var e;return(e=pS[r])!=null?e:Gl(r)}var ss,ns,Ut,Vl=class{constructor(e,t){ut(this,ss,void 0);ut(this,ns,void 0);ut(this,Ut,[]);ii(this,ss,e),ii(this,ns,t)}[Symbol.iterator](){return Ne(this,Ut).values()}get length(){return Ne(this,Ut).length}get value(){var e;return(e=Ne(this,Ut).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(ii(this,Ut,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return Ne(this,Ut)[e]}values(){return Ne(this,Ut).values()}keys(){return Ne(this,Ut).keys()}forEach(e){Ne(this,Ut).forEach(e)}add(...e){var t,i;e.forEach(s=>{this.contains(s)||Ne(this,Ut).push(s)}),!(this.value===""&&!((t=Ne(this,ss))!=null&&t.hasAttribute(`${Ne(this,ns)}`)))&&((i=Ne(this,ss))==null||i.setAttribute(`${Ne(this,ns)}`,`${this.value}`))}remove(...e){var t;e.forEach(i=>{Ne(this,Ut).splice(Ne(this,Ut).indexOf(i),1)}),(t=Ne(this,ss))==null||t.setAttribute(`${Ne(this,ns)}`,`${this.value}`)}contains(e){return Ne(this,Ut).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)}};ss=new WeakMap,ns=new WeakMap,Ut=new WeakMap;var tv=`[mux-player ${Kl()}]`;function br(...r){console.warn(tv,...r)}function vi(...r){console.error(tv,...r)}function Zh(r){var t;let e=(t=r.message)!=null?t:"";if(r.context&&(e+=` ${r.context}`),r.file){let i="https://github.com/muxinc/elements/blob/main/errors/";e+=` ${ke("Read more: ")}
|
|
998
|
+
${i}${r.file}`}br(e)}var Pt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},as={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},rv=Object.freeze({length:0,start(r){let e=r>>>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(r){let e=r>>>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}}),gS=Fl.filter(r=>r!=="error"),vS=Object.values(Pt).filter(r=>![Pt.PLAYSINLINE].includes(r)),ES=Object.values(as);function sv(r){r.querySelectorAll(":scope > track").forEach(e=>{var t;(t=r.media)==null||t.append(e.cloneNode())}),gS.forEach(e=>{var t;(t=r.media)==null||t.addEventListener(e,i=>{r.dispatchEvent(new Event(i.type))})})}var Jh=class extends at.HTMLElement{static get observedAttributes(){return[...vS,...ES]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(i=>{var s;(s=this.media)==null||s.append(i.cloneNode())});let e=i=>{for(let s of i)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,i){var s,n;switch(e){case as.MUTED:{this.media&&(this.media.muted=i!=null,this.media.defaultMuted=i!=null);return}case as.VOLUME:{let a=(s=Qi(i))!=null?s:1;this.media&&(this.media.volume=a);return}case as.PLAYBACKRATE:{let a=(n=Qi(i))!=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:rv}get seekable(){var e,t;return(t=(e=this.media)==null?void 0:e.seekable)!=null?t:rv}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=Qi(this.getAttribute(as.PLAYBACKRATE)))!=null?e:1}set defaultPlaybackRate(e){e!=null?this.setAttribute(as.PLAYBACKRATE,`${e}`):this.removeAttribute(as.PLAYBACKRATE)}get crossOrigin(){return aa(this,Pt.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(Pt.CROSSORIGIN,`${e}`)}get autoplay(){return aa(this,Pt.AUTOPLAY)!=null}set autoplay(e){e?this.setAttribute(Pt.AUTOPLAY,typeof e=="string"?e:""):this.removeAttribute(Pt.AUTOPLAY)}get loop(){return aa(this,Pt.LOOP)!=null}set loop(e){e?this.setAttribute(Pt.LOOP,""):this.removeAttribute(Pt.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 aa(this,Pt.MUTED)!=null}set defaultMuted(e){e?this.setAttribute(Pt.MUTED,""):this.removeAttribute(Pt.MUTED)}get playsInline(){return aa(this,Pt.PLAYSINLINE)!=null}set playsInline(e){vi("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(Pt.PRELOAD,e):this.removeAttribute(Pt.PRELOAD)}};function aa(r,e){return r.media?r.media.getAttribute(e):r.getAttribute(e)}var ef=Jh;var yS=Object.defineProperty,bS=(r,e,t)=>e in r?yS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,TS=(r,e,t)=>(bS(r,typeof e!="symbol"?e+"":e,t),t),dv=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Le=(r,e,t)=>(dv(r,e,"read from private field"),t?t.call(r):e.get(r)),$i=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},Zi=(r,e,t,i)=>(dv(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Xs,Wl,os,oa,Tr,_r,Ar,ls,Qs,ql,Ei,nv=1,av=0,_S=1,AS={processCallback(r,e,t){if(!!t){for(let[i,s]of e)if(i in t){let n=t[i];typeof n=="boolean"&&s instanceof Bt&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof Bt?s.element[s.attributeName]=n:s.value=n}}}},Ji=class extends D.DocumentFragment{constructor(e,t,i=AS){var s;super(),$i(this,Xs,void 0),$i(this,Wl,void 0),this.append(e.content.cloneNode(!0)),Zi(this,Xs,cv(this)),Zi(this,Wl,i),(s=i.createCallback)==null||s.call(i,this,Le(this,Xs),t),i.processCallback(this,Le(this,Xs),t)}update(e){Le(this,Wl).processCallback(this,Le(this,Xs),e)}};Xs=new WeakMap;Wl=new WeakMap;var cv=(r,e=[])=>{let t,i;for(let s of r.attributes||[])if(s.value.includes("{{")){let n=new tf;for([t,i]of lv(s.value))if(!t)n.append(i);else{let a=new Bt(r,s.name,s.namespaceURI);n.append(a),e.push([i,a])}s.value=n.toString()}for(let s of r.childNodes)if(s.nodeType===nv&&!(s instanceof HTMLTemplateElement))cv(s,e);else if(s.nodeType===nv||s.data.includes("{{")){let n=[];if(s.data)for([t,i]of lv(s.data))if(!t)n.push(new Text(i));else{let a=new er(r);n.push(a),e.push([i,a])}else if(s instanceof HTMLTemplateElement){let a=new la(r,s);n.push(a),e.push([a.expression,a])}s.replaceWith(...n.flatMap(a=>a.replacementNodes||[a]))}return e},ov={},lv=r=>{let e="",t=0,i=ov[r],s=0,n;if(i)return i;for(i=[];n=r[s];s++)n==="{"&&r[s+1]==="{"&&r[s-1]!=="\\"&&r[s+2]&&++t==1?(e&&i.push([av,e]),e="",s++):n==="}"&&r[s+1]==="}"&&r[s-1]!=="\\"&&!--t?(i.push([_S,e.trim()]),e="",s++):e+=n||"";return e&&i.push([av,(t>0?"{{":"")+e]),ov[r]=i},SS=11,Yl=class{get value(){return""}set value(e){}toString(){return this.value}},uv=new WeakMap,tf=class{constructor(){$i(this,os,[])}[Symbol.iterator](){return Le(this,os).values()}get length(){return Le(this,os).length}item(e){return Le(this,os)[e]}append(...e){for(let t of e)t instanceof Bt&&uv.set(t,this),Le(this,os).push(t)}toString(){return Le(this,os).join("")}};os=new WeakMap;var Bt=class extends Yl{constructor(e,t,i){super(),$i(this,ls),$i(this,oa,""),$i(this,Tr,void 0),$i(this,_r,void 0),$i(this,Ar,void 0),Zi(this,Tr,e),Zi(this,_r,t),Zi(this,Ar,i)}get attributeName(){return Le(this,_r)}get attributeNamespace(){return Le(this,Ar)}get element(){return Le(this,Tr)}get value(){return Le(this,oa)}set value(e){Le(this,oa)!==e&&(Zi(this,oa,e),!Le(this,ls,Qs)||Le(this,ls,Qs).length===1?e==null?Le(this,Tr).removeAttributeNS(Le(this,Ar),Le(this,_r)):Le(this,Tr).setAttributeNS(Le(this,Ar),Le(this,_r),e):Le(this,Tr).setAttributeNS(Le(this,Ar),Le(this,_r),Le(this,ls,Qs)))}get booleanValue(){return Le(this,Tr).hasAttributeNS(Le(this,Ar),Le(this,_r))}set booleanValue(e){if(!Le(this,ls,Qs)||Le(this,ls,Qs).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};oa=new WeakMap;Tr=new WeakMap;_r=new WeakMap;Ar=new WeakMap;ls=new WeakSet;Qs=function(){return uv.get(this)};var er=class extends Yl{constructor(e,t){super(),$i(this,ql,void 0),$i(this,Ei,void 0),Zi(this,ql,e),Zi(this,Ei,t?[...t]:[new Text])}get replacementNodes(){return Le(this,Ei)}get parentNode(){return Le(this,ql)}get nextSibling(){return Le(this,Ei)[Le(this,Ei).length-1].nextSibling}get previousSibling(){return Le(this,Ei)[0].previousSibling}get value(){return Le(this,Ei).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){let t=e.flat().flatMap(i=>i==null?[new Text]:i.forEach?[...i]:i.nodeType===SS?[...i.childNodes]:i.nodeType?[i]:[new Text(i)]);t.length||t.push(new Text),Zi(this,Ei,xS(Le(this,Ei)[0].parentNode,Le(this,Ei),t,this.nextSibling))}};ql=new WeakMap;Ei=new WeakMap;var la=class extends er{constructor(e,t){let i=t.getAttribute("directive")||t.getAttribute("type"),s=t.getAttribute("expression")||t.getAttribute(i)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),TS(this,"directive"),this.expression=s,this.template=t,this.directive=i}};function xS(r,e,t,i=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];)i=t[--d,--l];if(s==d)for(;s<l;)r.insertBefore(t[s++],i);if(s==l)for(;s<d;)r.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:i,n==o?n=a:s<l&&t[s]==a?(r.replaceChild(o,n),n=a):r.insertBefore(o,n);for(;n!=i;)a=n.nextSibling,r.removeChild(n),n=a}return t}var hv={string:r=>String(r)},zl=class{constructor(e){this.template=e,this.state=void 0}},ds=new WeakMap,cs=new WeakMap,rf={partial:(r,e)=>{e[r.expression]=new zl(r.template)},if:(r,e)=>{var t;if(mv(r.expression,e))if(ds.get(r)!==r.template){ds.set(r,r.template);let i=new Ji(r.template,e,Xl);r.replace(i),cs.set(r,i)}else(t=cs.get(r))==null||t.update(e);else r.replace(""),ds.delete(r),cs.delete(r)}},IS=Object.keys(rf),Xl={processCallback(r,e,t){var i,s;if(!!t)for(let[n,a]of e){if(a instanceof la){if(!a.directive){let l=IS.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(i=rf[a.directive])==null||i.call(rf,a,t);continue}let o=mv(n,t);if(o instanceof zl){ds.get(a)!==o.template?(ds.set(a,o.template),o=new Ji(o.template,o.state,Xl),a.value=o,cs.set(a,o)):(s=cs.get(a))==null||s.update(o.state);continue}o?(a instanceof Bt&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof Bt?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,ds.delete(a),cs.delete(a))):a instanceof Bt?a.value=void 0:(a.value=void 0,ds.delete(a),cs.delete(a))}}},fv={"!":r=>!r,"!!":r=>!!r,"==":(r,e)=>r==e,"!=":(r,e)=>r!=e,">":(r,e)=>r>e,">=":(r,e)=>r>=e,"<":(r,e)=>r<e,"<=":(r,e)=>r<=e,"??":(r,e)=>r!=null?r:e,"|":(r,e)=>{var t;return(t=hv[e])==null?void 0:t.call(hv,r)}};function LS(r){return RS(r,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function mv(r,e={}){var t,i,s,n,a,o,l;let d=LS(r);if(d.length===0||d.some(({type:c})=>!c))return da(r);if(((t=d[0])==null?void 0:t.token)===">"){let c=e[(i=d[1])==null?void 0:i.token];if(!c)return da(r);let u={...e};c.state=u;let h=d.slice(2);for(let m=0;m<h.length;m+=3){let g=(s=h[m])==null?void 0:s.token,E=(n=h[m+1])==null?void 0:n.token,T=(a=h[m+2])==null?void 0:a.token;g&&E==="="&&(u[g]=ca(T,e))}return c}if(d.length===1)return jl(d[0])?ca(d[0].token,e):da(r);if(d.length===2){let c=(o=d[0])==null?void 0:o.token,u=fv[c];if(!u||!jl(d[1]))return da(r);let h=ca(d[1].token,e);return u(h)}if(d.length===3){let c=(l=d[1])==null?void 0:l.token,u=fv[c];if(!u||!jl(d[0])||!jl(d[2]))return da(r);let h=ca(d[0].token,e);if(c==="|")return u(h,d[2].token);let m=ca(d[2].token,e);return u(h,m)}}function da(r){return console.warn(`Warning: invalid expression \`${r}\``),!1}function jl({type:r}){return["number","boolean","string","param"].includes(r)}function ca(r,e){let t=r[0],i=r.slice(-1);return r==="true"||r==="false"?r==="true":t===i&&["'",'"'].includes(t)?r.slice(1,-1):La(r)?parseFloat(r):e[r]}function RS(r,e){let t,i,s,n=[];for(;r;){s=null,t=r.length;for(let a in e)i=e[a].exec(r),i&&i.index<t&&(s={token:i[0],type:a,matches:i.slice(1)},t=i.index);t&&n.push({token:r.substr(0,t),type:void 0}),s&&n.push(s),r=r.substr(t+(s?s.token.length:0))}return n}var kS=Object.defineProperty,wS=(r,e,t)=>e in r?kS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ha=(r,e,t)=>(wS(r,typeof e!="symbol"?e+"":e,t),t),df=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},af=(r,e,t)=>(df(r,e,"read from private field"),t?t.call(r):e.get(r)),ua=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},us=(r,e,t,i)=>(df(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),sf=(r,e,t)=>(df(r,e,"access private method"),t),Zs,Ql,Js,of,pv,Zl,lf,nf={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},gv=z.createElement("template");gv.innerHTML=`
|
|
999
999
|
<style>
|
|
1000
1000
|
:host {
|
|
1001
1001
|
display: inline-block;
|
|
@@ -1018,7 +1018,7 @@ ${i}${r.file}`}br(e)}var Pt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:
|
|
|
1018
1018
|
display: none;
|
|
1019
1019
|
}
|
|
1020
1020
|
</style>
|
|
1021
|
-
`;var Sr=class extends D.HTMLElement{constructor(){super(),ua(this,
|
|
1021
|
+
`;var Sr=class extends D.HTMLElement{constructor(){super(),ua(this,of),ua(this,Zl),ha(this,"renderRoot"),ha(this,"renderer"),ua(this,Zs,void 0),ua(this,Ql,void 0),ua(this,Js,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());let e=new MutationObserver(t=>{var i;(i=this.mediaController)!=null&&i.breakpointsUncomputed||t.some(s=>{let n=s.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(nf[s.attributeName]||s.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),sf(this,of,pv).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=af(this,Zs))!=null?e:this.constructor.template}set template(e){us(this,Js,null),us(this,Zs,e),this.createRenderer()}get props(){var e,t,i;let s=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>nf[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(let a of s){let o=(i=nf[a.name])!=null?i:Zf(a.name),{value:l}=a;l!=null?(La(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,i){e==="template"&&t!=i&&sf(this,Zl,lf).call(this)}connectedCallback(){sf(this,Zl,lf).call(this)}createRenderer(){this.template&&this.template!==af(this,Ql)&&(us(this,Ql,this.template),this.renderer=new Ji(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(gv.content.cloneNode(!0),this.renderer))}render(){var e;(e=this.renderer)==null||e.update(this.props)}};Zs=new WeakMap;Ql=new WeakMap;Js=new WeakMap;of=new WeakSet;pv=function(r){if(Object.prototype.hasOwnProperty.call(this,r)){let e=this[r];delete this[r],this[r]=e}};Zl=new WeakSet;lf=function(){var r;let e=this.getAttribute("template");if(!e||e===af(this,Js))return;let t=this.getRootNode(),i=(r=t==null?void 0:t.getElementById)==null?void 0:r.call(t,e);if(i){us(this,Js,e),us(this,Zs,i),this.createRenderer();return}DS(e)&&(us(this,Js,e),CS(e).then(s=>{let n=z.createElement("template");n.innerHTML=s,us(this,Zs,n),this.createRenderer()}).catch(console.error))};ha(Sr,"template");ha(Sr,"observedAttributes",["template"]);ha(Sr,"processor",Xl);function DS(r){if(!/^(\/|\.\/|https?:\/\/)/.test(r))return!1;let e=/^https?:\/\//.test(r)?void 0:location.origin;try{new URL(r,e)}catch{return!1}return!0}async function CS(r){let e=await fetch(r);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}D.customElements.get("media-theme")||D.customElements.define("media-theme",Sr);var vv=`:host {
|
|
1022
1022
|
--media-control-display: var(--controls);
|
|
1023
1023
|
--media-loading-indicator-display: var(--loading-indicator);
|
|
1024
1024
|
--media-dialog-display: var(--dialog);
|
|
@@ -1138,7 +1138,7 @@ media-theme {
|
|
|
1138
1138
|
--media-duration-display-display: var(--duration-display, var(--bottom-duration-display));
|
|
1139
1139
|
--media-title-display-display: var(--title-display, var(--bottom-title-display));
|
|
1140
1140
|
}
|
|
1141
|
-
`;var
|
|
1141
|
+
`;var yv=`
|
|
1142
1142
|
:host {
|
|
1143
1143
|
z-index: 100;
|
|
1144
1144
|
display: var(--media-dialog-display, flex);
|
|
@@ -1190,17 +1190,17 @@ media-theme {
|
|
|
1190
1190
|
text-align: center;
|
|
1191
1191
|
line-height: 1.4;
|
|
1192
1192
|
}
|
|
1193
|
-
`,
|
|
1193
|
+
`,bv=Qt.createElement("template");bv.innerHTML=`
|
|
1194
1194
|
<style>
|
|
1195
|
-
${
|
|
1195
|
+
${yv}
|
|
1196
1196
|
</style>
|
|
1197
1197
|
|
|
1198
1198
|
<div class="dialog">
|
|
1199
1199
|
<slot></slot>
|
|
1200
1200
|
</div>
|
|
1201
|
-
`;var xr=class extends at.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})),
|
|
1201
|
+
`;var xr=class extends at.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})),Ev(this)}close(){!this.hasAttribute("open")||(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),OS(this))}attributeChangedCallback(t,i,s){t==="open"&&i!==s&&(s!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&Ev(this)}};xr.styles=yv,xr.template=bv,xr.observedAttributes=["open"];function Ev(r){let e=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(r.dispatchEvent(e),e.defaultPrevented)return;let t=r.querySelector("[autofocus]:not([disabled])");!t&&r.tabIndex>=0&&(t=r),t||(t=Tv(r.shadowRoot)),r._previouslyFocusedElement=Qt.activeElement,Qt.activeElement instanceof HTMLElement&&Qt.activeElement.blur(),r.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function Tv(r){let t=["button","input","keygen","select","textarea"].map(function(s){return s+":not([disabled])"});t.push('[tabindex]:not([disabled]):not([tabindex=""])');let i=r==null?void 0:r.querySelector(t.join(", "));if(!i&&"attachShadow"in Element.prototype){let s=(r==null?void 0:r.querySelectorAll("*"))||[];for(let n=0;n<s.length&&!(s[n].tagName&&s[n].shadowRoot&&(i=Tv(s[n].shadowRoot),i));n++);}return i}function OS(r){r._previouslyFocusedElement instanceof HTMLElement&&r._previouslyFocusedElement.focus()}at.customElements.get("media-dialog")||(at.customElements.define("media-dialog",xr),at.MediaDialog=xr);var cf=xr;var _v=Qt.createElement("template");_v.innerHTML=`
|
|
1202
1202
|
<style>
|
|
1203
|
-
${
|
|
1203
|
+
${cf.styles}
|
|
1204
1204
|
|
|
1205
1205
|
.close {
|
|
1206
1206
|
background: none;
|
|
@@ -1229,22 +1229,22 @@ media-theme {
|
|
|
1229
1229
|
</svg>
|
|
1230
1230
|
</button>
|
|
1231
1231
|
</slot>
|
|
1232
|
-
`;var fa=class extends
|
|
1232
|
+
`;var fa=class extends cf{constructor(){var e,t;super(),(t=(e=this.shadowRoot)==null?void 0:e.querySelector(".close"))==null||t.addEventListener("click",()=>{this.close()})}};fa.template=_v;at.customElements.get("mxp-dialog")||(at.customElements.define("mxp-dialog",fa),at.MxpDialog=fa);var ma=new WeakMap,pa=class{constructor(e,t){this.element=e;this.type=t;this.element.addEventListener(this.type,this);let i=ma.get(this.element);i&&i.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=ma.get(this.element);t&&t.delete(this.type)}}static for(e){ma.has(e.element)||ma.set(e.element,new Map);let t=e.attributeName.slice(2),i=ma.get(e.element);return i&&i.has(t)?i.get(t):new pa(e.element,t)}};function PS(r,e){return r instanceof Bt&&r.attributeName.startsWith("on")?(pa.for(r).set(e),r.element.removeAttributeNS(r.attributeNamespace,r.attributeName),!0):!1}function NS(r,e){return e instanceof Jl&&r instanceof er?(e.renderInto(r),!0):!1}function FS(r,e){return e instanceof DocumentFragment&&r instanceof er?(e.childNodes.length&&r.replace(...e.childNodes),!0):!1}function US(r,e){if(r instanceof Bt){let t=r.attributeNamespace,i=r.element.getAttributeNS(t,r.attributeName);return String(e)!==i&&(r.value=String(e)),!0}return r.value=String(e),!0}function BS(r,e){if(r instanceof Bt&&e instanceof Element){let t=r.element;return t[r.attributeName]!==e&&(r.element.removeAttributeNS(r.attributeNamespace,r.attributeName),t[r.attributeName]=e),!0}return!1}function $S(r,e){if(typeof e=="boolean"&&r instanceof Bt){let t=r.attributeNamespace,i=r.element.hasAttributeNS(t,r.attributeName);return e!==i&&(r.booleanValue=e),!0}return!1}function GS(r,e){return e===!1&&r instanceof er?(r.replace(""),!0):!1}function HS(r,e){BS(r,e)||$S(r,e)||PS(r,e)||GS(r,e)||NS(r,e)||FS(r,e)||US(r,e)}var uf=new Map,Av=new WeakMap,Sv=new WeakMap,Jl=class{constructor(e,t,i){this.strings=e;this.values=t;this.processor=i;this.stringsKey=this.strings.join("")}get template(){if(uf.has(this.stringsKey))return uf.get(this.stringsKey);{let e=Qt.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((i,s,n)=>i+s+(n<t?`{{ ${n} }}`:""),""),uf.set(this.stringsKey,e),e}}renderInto(e){var s;let t=this.template;if(Av.get(e)!==t){Av.set(e,t);let n=new Ji(t,this.values,this.processor);Sv.set(e,n),e instanceof er?e.replace(...n.children):e.appendChild(n);return}let i=Sv.get(e);(s=i==null?void 0:i.update)==null||s.call(i,this.values)}},VS={processCallback(r,e,t){var i;if(!!t){for(let[s,n]of e)if(s in t){let a=(i=t[s])!=null?i:"";HS(n,a)}}}};function tr(r,...e){return new Jl(r,e,VS)}function xv(r,e){r.renderInto(e)}var Iv=r=>tr`
|
|
1233
1233
|
<style>
|
|
1234
|
-
${
|
|
1234
|
+
${vv}
|
|
1235
1235
|
</style>
|
|
1236
|
-
${
|
|
1237
|
-
`,
|
|
1236
|
+
${WS(r)}
|
|
1237
|
+
`,KS=r=>{let e=r.hotKeys?`${r.hotKeys}`:"";return na(r.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},WS=r=>{var e,t,i,s,n,a,o,l,d,c,u,h,m,g,E,T,A,R,x,N,w,$,O,H,q,P,X,j,Ae,Ee,ye,we,Se,Z;return tr`
|
|
1238
1238
|
<media-theme
|
|
1239
1239
|
template="${r.themeTemplate||!1}"
|
|
1240
1240
|
defaultstreamtype="${(e=r.defaultStreamType)!=null?e:!1}"
|
|
1241
|
-
hotkeys="${
|
|
1241
|
+
hotkeys="${KS(r)||!1}"
|
|
1242
1242
|
nohotkeys="${r.noHotKeys||!r.hasSrc||r.isDialogOpen||!1}"
|
|
1243
1243
|
noautoseektolive="${!!((t=r.streamType)!=null&&t.includes(Ze.LIVE))&&r.targetLiveWindow!==0}"
|
|
1244
1244
|
novolumepref="${r.novolumepref||!1}"
|
|
1245
1245
|
disabled="${!r.hasSrc||r.isDialogOpen}"
|
|
1246
1246
|
audio="${(i=r.audio)!=null?i:!1}"
|
|
1247
|
-
style="${(s=
|
|
1247
|
+
style="${(s=Q0({"--media-primary-color":r.primaryColor,"--media-secondary-color":r.secondaryColor}))!=null?s:!1}"
|
|
1248
1248
|
defaultsubtitles="${!r.defaultHiddenCaptions}"
|
|
1249
1249
|
forwardseekoffset="${(n=r.forwardSeekOffset)!=null?n:!1}"
|
|
1250
1250
|
backwardseekoffset="${(a=r.backwardSeekOffset)!=null?a:!1}"
|
|
@@ -1258,7 +1258,7 @@ media-theme {
|
|
|
1258
1258
|
slot="media"
|
|
1259
1259
|
target-live-window="${(u=r.targetLiveWindow)!=null?u:!1}"
|
|
1260
1260
|
stream-type="${(h=na(r.streamType))!=null?h:!1}"
|
|
1261
|
-
crossorigin="${(
|
|
1261
|
+
crossorigin="${(m=r.crossOrigin)!=null?m:""}"
|
|
1262
1262
|
playsinline
|
|
1263
1263
|
autoplay="${(g=r.autoplay)!=null?g:!1}"
|
|
1264
1264
|
muted="${(E=r.muted)!=null?E:!1}"
|
|
@@ -1274,8 +1274,8 @@ media-theme {
|
|
|
1274
1274
|
player-software-version="${(H=r.playerSoftwareVersion)!=null?H:!1}"
|
|
1275
1275
|
env-key="${(q=r.envKey)!=null?q:!1}"
|
|
1276
1276
|
custom-domain="${(P=r.customDomain)!=null?P:!1}"
|
|
1277
|
-
src="${r.src?r.src:r.playbackId?
|
|
1278
|
-
cast-src="${r.src?r.src:r.playbackId?
|
|
1277
|
+
src="${r.src?r.src:r.playbackId?Qh(r.playbackId,{maxResolution:r.maxResolution,domain:r.customDomain,token:r.tokens.playback}):!1}"
|
|
1278
|
+
cast-src="${r.src?r.src:r.playbackId?Qh(r.playbackId,{maxResolution:r.maxResolution,domain:r.customDomain,token:r.tokens.playback}):!1}"
|
|
1279
1279
|
exportparts="video"
|
|
1280
1280
|
>
|
|
1281
1281
|
${r.storyboard?tr`<track label="thumbnails" default kind="metadata" src="${r.storyboard}" />`:tr``}
|
|
@@ -1306,7 +1306,7 @@ media-theme {
|
|
|
1306
1306
|
</p>
|
|
1307
1307
|
</mxp-dialog>
|
|
1308
1308
|
</media-theme>
|
|
1309
|
-
`};function
|
|
1309
|
+
`};function ed(r,e,t,i,s){var o,l,d;let n={},a={};switch(r.code){case it.MEDIA_ERR_NETWORK:{switch(n.title=ke("Network Error",s),n.message=r.message,(o=r.data)==null?void 0:o.response.code){case 412:{n.title=ke("Video is not currently available",s),n.message=ke("The live stream or video file are not yet ready.",s),a.message=ke("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=ke("Video does not exist",s),n.message="",a.message=ke("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=ke("Invalid playback URL",s),n.message=ke("The video URL or playback-token are formatted with incorrect or incomplete information.",s),a.message=ke("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",!i)break;let{exp:c,aud:u,sub:h}=yr(i),m=Date.now()>c*1e3,g=h!==t,E=u!=="v",T={timeStyle:"medium",dateStyle:"medium"};if(m){n.title=ke("Video URL has expired",s),n.message=ke("The video\u2019s secured playback-token has expired.",s),a.message=ke("The video\u2019s secured playback-token has expired.",s),a.context=ke("Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat(rs.code,T).format(c*1e3),currentDate:new Intl.DateTimeFormat(rs.code,T).format(Date.now())}),a.file="403-expired-token.md";break}if(g){n.title=ke("Video URL is formatted incorrectly",s),n.message=ke("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.message=ke("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.context=ke("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=ke("Video URL is formatted incorrectly",s),n.message=ke("The playback-token is formatted with incorrect information.",s),a.message=ke("The playback-token is formatted with incorrect information.",s),a.context=ke("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=ke("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 it.MEDIA_ERR_DECODE:{let{message:c}=r;n={title:ke("Media Error",s),message:c},a.file="media-decode-error.md";break}case it.MEDIA_ERR_SRC_NOT_SUPPORTED:{let c=(d=(l=r.data)==null?void 0:l.response)==null?void 0:d.code;if(c>=400&&c<500){r.code=it.MEDIA_ERR_NETWORK,r.data={response:{code:c}},{dialog:n,devlog:a}=ed(r,e,t,i);break}n={title:ke("Source Not Supported",s),message:r.message},a.file="media-src-not-supported.md";break}default:n={title:ke("Error",s),message:r.message};break}return e&&(n={title:ke("Your device appears to be offline",s),message:ke("Check your internet connection and try reloading this video.",s)}),{dialog:n,devlog:a}}var Lv=`<!-- prettier-ignore -->
|
|
1310
1310
|
<template id="media-theme-classic">
|
|
1311
1311
|
<style>
|
|
1312
1312
|
:host {
|
|
@@ -2076,8 +2076,8 @@ media-theme {
|
|
|
2076
2076
|
|
|
2077
2077
|
</media-controller>
|
|
2078
2078
|
</template>
|
|
2079
|
-
`;var df=Qt.createElement("template");"innerHTML"in df&&(df.innerHTML=Sv);var xv,Iv,ed=class extends Sr{};ed.template=(Iv=(xv=df.content)==null?void 0:xv.children)==null?void 0:Iv[0];at.customElements.get("media-theme-classic")||at.customElements.define("media-theme-classic",ed);var BS="classic";var ir={SRC:"src",POSTER:"poster"},re={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",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"},cf=["audio","backwardseekoffset","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function $S(r,e){var i;return{src:!r.playbackId&&r.src,playbackId:r.playbackId,hasSrc:!!r.playbackId||!!r.src,poster:r.poster,storyboard:r.storyboard,storyboardSrc:r.getAttribute(re.STORYBOARD_SRC),placeholder:r.getAttribute("placeholder"),themeTemplate:GS(r),thumbnailTime:!r.tokens.thumbnail&&r.thumbnailTime,autoplay:r.autoplay,crossOrigin:r.crossOrigin,loop:r.loop,noHotKeys:r.hasAttribute(re.NOHOTKEYS),hotKeys:r.getAttribute(re.HOTKEYS),muted:r.muted,paused:r.paused,preload:r.preload,envKey:r.envKey,preferCmcd:r.preferCmcd,debug:r.debug,disableCookies:r.disableCookies,tokens:r.tokens,beaconCollectionDomain:r.beaconCollectionDomain,maxResolution:r.maxResolution,metadata:r.metadata,playerSoftwareName:r.playerSoftwareName,playerSoftwareVersion:r.playerSoftwareVersion,startTime:r.startTime,preferPlayback:r.preferPlayback,audio:r.audio,defaultStreamType:r.defaultStreamType,targetLiveWindow:r.getAttribute(Y.TARGET_LIVE_WINDOW),streamType:na(r.getAttribute(Y.STREAM_TYPE)),primaryColor:r.primaryColor,secondaryColor:r.secondaryColor,forwardSeekOffset:r.forwardSeekOffset,backwardSeekOffset:r.backwardSeekOffset,defaultHiddenCaptions:r.defaultHiddenCaptions,defaultShowRemainingTime:r.defaultShowRemainingTime,hideDuration:HS(r),playbackRates:r.getAttribute(re.PLAYBACK_RATES),customDomain:(i=r.getAttribute(Y.CUSTOM_DOMAIN))!=null?i:void 0,title:r.getAttribute(re.TITLE),novolumepref:r.hasAttribute(re.NO_VOLUME_PREF),...e}}function GS(r){var t,i;let e=r.theme;if(e){let s=(i=(t=r.getRootNode())==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(s&&s instanceof HTMLTemplateElement)return s;e.startsWith("media-theme-")||(e=`media-theme-${e}`);let n=at.customElements.get(e);if(n!=null&&n.template)return n.template}}function HS(r){var t;let e=(t=r.mediaController)==null?void 0:t.querySelector("media-time-display");return e&&getComputedStyle(e).getPropertyValue("--media-duration-display-display").trim()==="none"}function Lv(r){return r.getAttributeNames().filter(e=>e.startsWith("metadata-")).reduce((e,t)=>{let i=r.getAttribute(t);return i!==null&&(e[t.replace(/^metadata-/,"").replace(/-/g,"_")]=i),e},{})}var VS=Object.values(Y),KS=Object.values(ir),WS=Object.values(re),qS=Vl(),YS="mux-player",Rv={dialog:void 0,isDialogOpen:!1},va,Ea,rr,ya,hs,Ir,tn,td,kv,ba,uf,Lr,rn,id,wv,rd,Dv,sd,Cv,nd,Mv,ga=class extends Qh{constructor(){super();ut(this,Ir);ut(this,td);ut(this,ba);ut(this,Lr);ut(this,id);ut(this,rd);ut(this,sd);ut(this,nd);ut(this,va,!1);ut(this,Ea,{});ut(this,rr,!0);ut(this,ya,new Hl(this,"hotkeys"));ut(this,hs,{...Rv,onCloseErrorDialog:()=>yt(this,ba,uf).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:t=>{qh(this,Qt.activeElement)||t.preventDefault()}});this.attachShadow({mode:"open"}),yt(this,td,kv).call(this),this.isConnected&&yt(this,Ir,tn).call(this)}static get observedAttributes(){var t;return[...(t=Qh.observedAttributes)!=null?t:[],...KS,...VS,...WS]}get mediaTheme(){var t;return(t=this.shadowRoot)==null?void 0:t.querySelector("media-theme")}get mediaController(){var t,i;return(i=(t=this.mediaTheme)==null?void 0:t.shadowRoot)==null?void 0:i.querySelector("media-controller")}connectedCallback(){var i;let t=(i=this.shadowRoot)==null?void 0:i.querySelector("mux-video");t&&(t.metadata=Lv(this))}attributeChangedCallback(t,i,s){switch(yt(this,Ir,tn).call(this),super.attributeChangedCallback(t,i,s),t){case re.HOTKEYS:Ne(this,ya).value=s;break;case re.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&br(ke("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case re.THUMBNAIL_TOKEN:{let{aud:a}=yr(s);s&&a!=="t"&&br(ke("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:a}));break}case re.STORYBOARD_TOKEN:{let{aud:a}=yr(s);s&&a!=="s"&&br(ke("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:a}));break}case Y.PLAYBACK_ID:{s!=null&&s.includes("?token")&&vi(ke("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:s}));break}case Y.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:zh({file:"invalid-stream-type.md",message:ke("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}[Y.PLAYBACK_ID,ir.SRC,re.PLAYBACK_TOKEN].includes(t)&&i!==s&&ii(this,hs,{...Ne(this,hs),...Rv}),yt(this,Lr,rn).call(this,{[Q0(t)]:s})}get preferCmcd(){var t;return(t=this.getAttribute(Y.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?qs.includes(t)?this.setAttribute(Y.PREFER_CMCD,t):br(`Invalid value for preferCmcd. Must be one of ${qs.join()}`):this.removeAttribute(Y.PREFER_CMCD))}get hasPlayed(){var t,i;return(i=(t=this.mediaController)==null?void 0:t.hasAttribute("media-has-played"))!=null?i:!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(re.THEME))!=null?t:BS}set theme(t){this.setAttribute(re.THEME,`${t}`)}get themeProps(){let t=this.mediaTheme;if(!t)return;let i={};for(let s of t.getAttributeNames()){if(cf.includes(s))continue;let n=t.getAttribute(s);i[$l(s)]=n===""?!0:n}return i}set themeProps(t){var s,n;yt(this,Ir,tn).call(this);let i={...this.themeProps,...t};for(let a in i){if(cf.includes(a))continue;let o=t==null?void 0:t[a];typeof o=="boolean"||o==null?(s=this.mediaTheme)==null||s.toggleAttribute(Bl(a),Boolean(o)):(n=this.mediaTheme)==null||n.setAttribute(Bl(a),o)}}get playbackId(){var t;return(t=this.getAttribute(Y.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t?this.setAttribute(Y.PLAYBACK_ID,t):this.removeAttribute(Y.PLAYBACK_ID)}get src(){var t,i;return this.playbackId?(t=en(this,ir.SRC))!=null?t:void 0:(i=this.getAttribute(ir.SRC))!=null?i:void 0}set src(t){t?this.setAttribute(ir.SRC,t):this.removeAttribute(ir.SRC)}get poster(){var i;let t=this.getAttribute(ir.POSTER);if(t!=null)return t;if(this.playbackId&&!this.audio)return z0(this.playbackId,{domain:this.customDomain,thumbnailTime:(i=this.thumbnailTime)!=null?i: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(re.STORYBOARD_SRC))!=null?t:void 0}set storyboardSrc(t){t?this.setAttribute(re.STORYBOARD_SRC,t):this.removeAttribute(re.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 X0(this.playbackId,{domain:this.customDomain,token:this.tokens.storyboard})}get audio(){return this.hasAttribute(re.AUDIO)}set audio(t){if(!t){this.removeAttribute(re.AUDIO);return}this.setAttribute(re.AUDIO,"")}get hotkeys(){return Ne(this,ya)}get nohotkeys(){return this.hasAttribute(re.NOHOTKEYS)}set nohotkeys(t){if(!t){this.removeAttribute(re.NOHOTKEYS);return}this.setAttribute(re.NOHOTKEYS,"")}get thumbnailTime(){return Qi(this.getAttribute(re.THUMBNAIL_TIME))}set thumbnailTime(t){this.setAttribute(re.THUMBNAIL_TIME,`${t}`)}get title(){var t;return(t=this.getAttribute(re.TITLE))!=null?t:""}set title(t){t!==this.title&&(t?this.setAttribute(re.TITLE,t):this.removeAttribute("title"),super.title=t)}get placeholder(){var t;return(t=en(this,re.PLACEHOLDER))!=null?t:""}set placeholder(t){this.setAttribute(re.PLACEHOLDER,`${t}`)}get primaryColor(){var i,s;let t=this.getAttribute(re.PRIMARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(i=at.getComputedStyle(this.mediaTheme))==null?void 0:i.getPropertyValue("--_primary-color"))==null?void 0:s.trim(),t))return t}set primaryColor(t){this.setAttribute(re.PRIMARY_COLOR,`${t}`)}get secondaryColor(){var i,s;let t=this.getAttribute(re.SECONDARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(i=at.getComputedStyle(this.mediaTheme))==null?void 0:i.getPropertyValue("--_secondary-color"))==null?void 0:s.trim(),t))return t}set secondaryColor(t){this.setAttribute(re.SECONDARY_COLOR,`${t}`)}get defaultShowRemainingTime(){return this.hasAttribute(re.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(t){t?this.setAttribute(re.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(re.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(!!this.hasAttribute(re.PLAYBACK_RATES))return this.getAttribute(re.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(t=>Number(t)).filter(t=>!Number.isNaN(t)).sort((t,i)=>t-i)}set playbackRates(t){if(!t){this.removeAttribute(re.PLAYBACK_RATES);return}this.setAttribute(re.PLAYBACK_RATES,t.join(" "))}get forwardSeekOffset(){var t;return(t=Qi(this.getAttribute(re.FORWARD_SEEK_OFFSET)))!=null?t:10}set forwardSeekOffset(t){this.setAttribute(re.FORWARD_SEEK_OFFSET,`${t}`)}get backwardSeekOffset(){var t;return(t=Qi(this.getAttribute(re.BACKWARD_SEEK_OFFSET)))!=null?t:10}set backwardSeekOffset(t){this.setAttribute(re.BACKWARD_SEEK_OFFSET,`${t}`)}get defaultHiddenCaptions(){return this.hasAttribute(re.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(t){t?this.setAttribute(re.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(re.DEFAULT_HIDDEN_CAPTIONS)}get playerSoftwareName(){var t;return(t=this.getAttribute(Y.PLAYER_SOFTWARE_NAME))!=null?t:YS}get playerSoftwareVersion(){var t;return(t=this.getAttribute(Y.PLAYER_SOFTWARE_VERSION))!=null?t:qS}get beaconCollectionDomain(){var t;return(t=this.getAttribute(Y.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(Y.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(Y.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var t;return(t=this.getAttribute(Y.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(Y.MAX_RESOLUTION,t):this.removeAttribute(Y.MAX_RESOLUTION))}get customDomain(){var t;return(t=this.getAttribute(Y.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(Y.CUSTOM_DOMAIN,t):this.removeAttribute(Y.CUSTOM_DOMAIN))}get envKey(){var t;return(t=en(this,Y.ENV_KEY))!=null?t:void 0}set envKey(t){this.setAttribute(Y.ENV_KEY,`${t}`)}get noVolumePref(){return this.hasAttribute(re.NO_VOLUME_PREF)}set noVolumePref(t){t?this.setAttribute(re.NO_VOLUME_PREF,""):this.removeAttribute(re.NO_VOLUME_PREF)}get debug(){return en(this,Y.DEBUG)!=null}set debug(t){t?this.setAttribute(Y.DEBUG,""):this.removeAttribute(Y.DEBUG)}get disableCookies(){return en(this,Y.DISABLE_COOKIES)!=null}set disableCookies(t){t?this.setAttribute(Y.DISABLE_COOKIES,""):this.removeAttribute(Y.DISABLE_COOKIES)}get streamType(){var t,i,s;return(s=(i=this.getAttribute(Y.STREAM_TYPE))!=null?i:(t=this.media)==null?void 0:t.streamType)!=null?s:Ze.UNKNOWN}set streamType(t){this.setAttribute(Y.STREAM_TYPE,`${t}`)}get defaultStreamType(){var t,i,s;return(s=(i=this.getAttribute(re.DEFAULT_STREAM_TYPE))!=null?i:(t=this.mediaController)==null?void 0:t.getAttribute(re.DEFAULT_STREAM_TYPE))!=null?s:Ze.ON_DEMAND}set defaultStreamType(t){t?this.setAttribute(re.DEFAULT_STREAM_TYPE,t):this.removeAttribute(re.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var t,i;return this.hasAttribute(re.TARGET_LIVE_WINDOW)?+this.getAttribute(re.TARGET_LIVE_WINDOW):(i=(t=this.media)==null?void 0:t.targetLiveWindow)!=null?i:Number.NaN}set targetLiveWindow(t){t!=this.targetLiveWindow&&(t==null?this.removeAttribute(re.TARGET_LIVE_WINDOW):this.setAttribute(re.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t;return(t=this.media)==null?void 0:t.liveEdgeStart}get startTime(){return Qi(en(this,Y.START_TIME))}set startTime(t){this.setAttribute(Y.START_TIME,`${t}`)}get preferPlayback(){let t=this.getAttribute(Y.PREFER_PLAYBACK);if(t===oi.MSE||t===oi.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===oi.MSE||t===oi.NATIVE?this.setAttribute(Y.PREFER_PLAYBACK,t):this.removeAttribute(Y.PREFER_PLAYBACK))}get metadata(){var t;return(t=this.media)==null?void 0:t.metadata}set metadata(t){if(yt(this,Ir,tn).call(this),!this.media){vi("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...Lv(this),...t}}async addCuePoints(t){var i;if(yt(this,Ir,tn).call(this),!this.media){vi("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(i=this.media)==null?void 0:i.addCuePoints(t)}get activeCuePoint(){var t;return(t=this.media)==null?void 0:t.activeCuePoint}get cuePoints(){var t,i;return(i=(t=this.media)==null?void 0:t.cuePoints)!=null?i:[]}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(re.PLAYBACK_TOKEN),i=this.getAttribute(re.THUMBNAIL_TOKEN),s=this.getAttribute(re.STORYBOARD_TOKEN);return{...Ne(this,Ea),...t!=null?{playback:t}:{},...i!=null?{thumbnail:i}:{},...s!=null?{storyboard:s}:{}}}set tokens(t){ii(this,Ea,t!=null?t:{})}get playbackToken(){var t;return(t=this.getAttribute(re.PLAYBACK_TOKEN))!=null?t:void 0}set playbackToken(t){this.setAttribute(re.PLAYBACK_TOKEN,`${t}`)}get thumbnailToken(){var t;return(t=this.getAttribute(re.THUMBNAIL_TOKEN))!=null?t:void 0}set thumbnailToken(t){this.setAttribute(re.THUMBNAIL_TOKEN,`${t}`)}get storyboardToken(){var t;return(t=this.getAttribute(re.STORYBOARD_TOKEN))!=null?t:void 0}set storyboardToken(t){this.setAttribute(re.STORYBOARD_TOKEN,`${t}`)}addTextTrack(t,i,s,n){var o;let a=(o=this.media)==null?void 0:o.nativeEl;if(!!a)return Il(a,t,i,s,n)}removeTextTrack(t){var s;let i=(s=this.media)==null?void 0:s.nativeEl;if(!!i)return E0(i,t)}get textTracks(){var t;return(t=this.media)==null?void 0:t.textTracks}};va=new WeakMap,Ea=new WeakMap,rr=new WeakMap,ya=new WeakMap,hs=new WeakMap,Ir=new WeakSet,tn=function(){var t,i,s;if(!Ne(this,va)){ii(this,va,!0),yt(this,Lr,rn).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof at.HTMLElement))throw""}catch{vi("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof q0))throw""}catch{vi("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof wd))throw""}catch{vi("<media-controller> failed to upgrade!")}tv(this),yt(this,id,wv).call(this),yt(this,rd,Dv).call(this),yt(this,sd,Cv).call(this),ii(this,rr,(i=(t=this.mediaController)==null?void 0:t.hasAttribute("userinactive"))!=null?i:!0),yt(this,nd,Mv).call(this),(s=this.media)==null||s.addEventListener("streamtypechange",()=>{yt(this,Lr,rn).call(this)})}},td=new WeakSet,kv=function(){var t,i;try{(t=window==null?void 0:window.CSS)==null||t.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(i=window==null?void 0:window.CSS)==null||i.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},ba=new WeakSet,uf=function(t){Object.assign(Ne(this,hs),t),yt(this,Lr,rn).call(this)},Lr=new WeakSet,rn=function(t={}){_v(Av($S(this,{...Ne(this,hs),...t})),this.shadowRoot)},id=new WeakSet,wv=function(){let t=s=>{var o,l;if(!(s!=null&&s.startsWith("theme-")))return;let n=s.replace(/^theme-/,"");if(cf.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)},rd=new WeakSet,Dv=function(){var i;let t=s=>{let{detail:n}=s;if(n instanceof it||(n=new it(n.message,n.code,n.fatal)),!(n!=null&&n.fatal)){br(n),n.data&&br(`${n.name} data:`,n.data);return}let{dialog:a,devlog:o}=Jl(n,!window.navigator.onLine,this.playbackId,this.playbackToken);o.message&&zh(o),vi(n),n.data&&vi(`${n.name} data:`,n.data),yt(this,ba,uf).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 it))return s;let{devlog:n}=Jl((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}}),(i=this.media)==null||i.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 it(l,d)}!(n!=null&&n.fatal)||this.dispatchEvent(new CustomEvent("error",{detail:n}))})},sd=new WeakSet,Cv=function(){var i,s,n,a;let t=()=>yt(this,Lr,rn).call(this);(s=(i=this.media)==null?void 0:i.textTracks)==null||s.addEventListener("addtrack",t),(a=(n=this.media)==null?void 0:n.textTracks)==null||a.addEventListener("removetrack",t)},nd=new WeakSet,Mv=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(`
|
|
2080
|
-
`).length,R=t?-2:-3;this.streamType===Ze.LIVE&&(R=t?-1:-2);let x=R-A;if(T.line===x&&!g)return;n.has(T)||n.set(T,T.line),T.line=x-1,T.line=x}else setTimeout(()=>{T.line=n.get(T)||"auto"},500)})},l=()=>{var h,
|
|
2079
|
+
`;var hf=Qt.createElement("template");"innerHTML"in hf&&(hf.innerHTML=Lv);var Rv,kv,td=class extends Sr{};td.template=(kv=(Rv=hf.content)==null?void 0:Rv.children)==null?void 0:kv[0];at.customElements.get("media-theme-classic")||at.customElements.define("media-theme-classic",td);var YS="classic";var ir={SRC:"src",POSTER:"poster"},re={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",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"},ff=["audio","backwardseekoffset","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function jS(r,e){var i;return{src:!r.playbackId&&r.src,playbackId:r.playbackId,hasSrc:!!r.playbackId||!!r.src,poster:r.poster,storyboard:r.storyboard,storyboardSrc:r.getAttribute(re.STORYBOARD_SRC),placeholder:r.getAttribute("placeholder"),themeTemplate:zS(r),thumbnailTime:!r.tokens.thumbnail&&r.thumbnailTime,autoplay:r.autoplay,crossOrigin:r.crossOrigin,loop:r.loop,noHotKeys:r.hasAttribute(re.NOHOTKEYS),hotKeys:r.getAttribute(re.HOTKEYS),muted:r.muted,paused:r.paused,preload:r.preload,envKey:r.envKey,preferCmcd:r.preferCmcd,debug:r.debug,disableCookies:r.disableCookies,tokens:r.tokens,beaconCollectionDomain:r.beaconCollectionDomain,maxResolution:r.maxResolution,metadata:r.metadata,playerSoftwareName:r.playerSoftwareName,playerSoftwareVersion:r.playerSoftwareVersion,startTime:r.startTime,preferPlayback:r.preferPlayback,audio:r.audio,defaultStreamType:r.defaultStreamType,targetLiveWindow:r.getAttribute(Y.TARGET_LIVE_WINDOW),streamType:na(r.getAttribute(Y.STREAM_TYPE)),primaryColor:r.primaryColor,secondaryColor:r.secondaryColor,forwardSeekOffset:r.forwardSeekOffset,backwardSeekOffset:r.backwardSeekOffset,defaultHiddenCaptions:r.defaultHiddenCaptions,defaultShowRemainingTime:r.defaultShowRemainingTime,hideDuration:XS(r),playbackRates:r.getAttribute(re.PLAYBACK_RATES),customDomain:(i=r.getAttribute(Y.CUSTOM_DOMAIN))!=null?i:void 0,title:r.getAttribute(re.TITLE),novolumepref:r.hasAttribute(re.NO_VOLUME_PREF),...e}}function zS(r){var t,i;let e=r.theme;if(e){let s=(i=(t=r.getRootNode())==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(s&&s instanceof HTMLTemplateElement)return s;e.startsWith("media-theme-")||(e=`media-theme-${e}`);let n=at.customElements.get(e);if(n!=null&&n.template)return n.template}}function XS(r){var t;let e=(t=r.mediaController)==null?void 0:t.querySelector("media-time-display");return e&&getComputedStyle(e).getPropertyValue("--media-duration-display-display").trim()==="none"}function wv(r){return r.getAttributeNames().filter(e=>e.startsWith("metadata-")).reduce((e,t)=>{let i=r.getAttribute(t);return i!==null&&(e[t.replace(/^metadata-/,"").replace(/-/g,"_")]=i),e},{})}var QS=Object.values(Y),ZS=Object.values(ir),JS=Object.values(re),ex=Kl(),tx="mux-player",Dv={dialog:void 0,isDialogOpen:!1},va,Ea,rr,ya,hs,Ir,tn,id,Cv,ba,mf,Lr,rn,rd,Mv,sd,Ov,nd,Pv,ad,Nv,ga=class extends ef{constructor(){super();ut(this,Ir);ut(this,id);ut(this,ba);ut(this,Lr);ut(this,rd);ut(this,sd);ut(this,nd);ut(this,ad);ut(this,va,!1);ut(this,Ea,{});ut(this,rr,!0);ut(this,ya,new Vl(this,"hotkeys"));ut(this,hs,{...Dv,onCloseErrorDialog:()=>yt(this,ba,mf).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:t=>{zh(this,Qt.activeElement)||t.preventDefault()}});this.attachShadow({mode:"open"}),yt(this,id,Cv).call(this),this.isConnected&&yt(this,Ir,tn).call(this)}static get observedAttributes(){var t;return[...(t=ef.observedAttributes)!=null?t:[],...ZS,...QS,...JS]}get mediaTheme(){var t;return(t=this.shadowRoot)==null?void 0:t.querySelector("media-theme")}get mediaController(){var t,i;return(i=(t=this.mediaTheme)==null?void 0:t.shadowRoot)==null?void 0:i.querySelector("media-controller")}connectedCallback(){var i;let t=(i=this.shadowRoot)==null?void 0:i.querySelector("mux-video");t&&(t.metadata=wv(this))}attributeChangedCallback(t,i,s){switch(yt(this,Ir,tn).call(this),super.attributeChangedCallback(t,i,s),t){case re.HOTKEYS:Ne(this,ya).value=s;break;case re.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&br(ke("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case re.THUMBNAIL_TOKEN:{let{aud:a}=yr(s);s&&a!=="t"&&br(ke("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:a}));break}case re.STORYBOARD_TOKEN:{let{aud:a}=yr(s);s&&a!=="s"&&br(ke("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:a}));break}case Y.PLAYBACK_ID:{s!=null&&s.includes("?token")&&vi(ke("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:s}));break}case Y.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:Zh({file:"invalid-stream-type.md",message:ke("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}[Y.PLAYBACK_ID,ir.SRC,re.PLAYBACK_TOKEN].includes(t)&&i!==s&&ii(this,hs,{...Ne(this,hs),...Dv}),yt(this,Lr,rn).call(this,{[ev(t)]:s})}get preferCmcd(){var t;return(t=this.getAttribute(Y.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?qs.includes(t)?this.setAttribute(Y.PREFER_CMCD,t):br(`Invalid value for preferCmcd. Must be one of ${qs.join()}`):this.removeAttribute(Y.PREFER_CMCD))}get hasPlayed(){var t,i;return(i=(t=this.mediaController)==null?void 0:t.hasAttribute("media-has-played"))!=null?i:!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(re.THEME))!=null?t:YS}set theme(t){this.setAttribute(re.THEME,`${t}`)}get themeProps(){let t=this.mediaTheme;if(!t)return;let i={};for(let s of t.getAttributeNames()){if(ff.includes(s))continue;let n=t.getAttribute(s);i[Gl(s)]=n===""?!0:n}return i}set themeProps(t){var s,n;yt(this,Ir,tn).call(this);let i={...this.themeProps,...t};for(let a in i){if(ff.includes(a))continue;let o=t==null?void 0:t[a];typeof o=="boolean"||o==null?(s=this.mediaTheme)==null||s.toggleAttribute($l(a),Boolean(o)):(n=this.mediaTheme)==null||n.setAttribute($l(a),o)}}get playbackId(){var t;return(t=this.getAttribute(Y.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t?this.setAttribute(Y.PLAYBACK_ID,t):this.removeAttribute(Y.PLAYBACK_ID)}get src(){var t,i;return this.playbackId?(t=en(this,ir.SRC))!=null?t:void 0:(i=this.getAttribute(ir.SRC))!=null?i:void 0}set src(t){t?this.setAttribute(ir.SRC,t):this.removeAttribute(ir.SRC)}get poster(){var i;let t=this.getAttribute(ir.POSTER);if(t!=null)return t;if(this.playbackId&&!this.audio)return Z0(this.playbackId,{domain:this.customDomain,thumbnailTime:(i=this.thumbnailTime)!=null?i: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(re.STORYBOARD_SRC))!=null?t:void 0}set storyboardSrc(t){t?this.setAttribute(re.STORYBOARD_SRC,t):this.removeAttribute(re.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 J0(this.playbackId,{domain:this.customDomain,token:this.tokens.storyboard})}get audio(){return this.hasAttribute(re.AUDIO)}set audio(t){if(!t){this.removeAttribute(re.AUDIO);return}this.setAttribute(re.AUDIO,"")}get hotkeys(){return Ne(this,ya)}get nohotkeys(){return this.hasAttribute(re.NOHOTKEYS)}set nohotkeys(t){if(!t){this.removeAttribute(re.NOHOTKEYS);return}this.setAttribute(re.NOHOTKEYS,"")}get thumbnailTime(){return Qi(this.getAttribute(re.THUMBNAIL_TIME))}set thumbnailTime(t){this.setAttribute(re.THUMBNAIL_TIME,`${t}`)}get title(){var t;return(t=this.getAttribute(re.TITLE))!=null?t:""}set title(t){t!==this.title&&(t?this.setAttribute(re.TITLE,t):this.removeAttribute("title"),super.title=t)}get placeholder(){var t;return(t=en(this,re.PLACEHOLDER))!=null?t:""}set placeholder(t){this.setAttribute(re.PLACEHOLDER,`${t}`)}get primaryColor(){var i,s;let t=this.getAttribute(re.PRIMARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(i=at.getComputedStyle(this.mediaTheme))==null?void 0:i.getPropertyValue("--_primary-color"))==null?void 0:s.trim(),t))return t}set primaryColor(t){this.setAttribute(re.PRIMARY_COLOR,`${t}`)}get secondaryColor(){var i,s;let t=this.getAttribute(re.SECONDARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(i=at.getComputedStyle(this.mediaTheme))==null?void 0:i.getPropertyValue("--_secondary-color"))==null?void 0:s.trim(),t))return t}set secondaryColor(t){this.setAttribute(re.SECONDARY_COLOR,`${t}`)}get defaultShowRemainingTime(){return this.hasAttribute(re.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(t){t?this.setAttribute(re.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(re.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(!!this.hasAttribute(re.PLAYBACK_RATES))return this.getAttribute(re.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(t=>Number(t)).filter(t=>!Number.isNaN(t)).sort((t,i)=>t-i)}set playbackRates(t){if(!t){this.removeAttribute(re.PLAYBACK_RATES);return}this.setAttribute(re.PLAYBACK_RATES,t.join(" "))}get forwardSeekOffset(){var t;return(t=Qi(this.getAttribute(re.FORWARD_SEEK_OFFSET)))!=null?t:10}set forwardSeekOffset(t){this.setAttribute(re.FORWARD_SEEK_OFFSET,`${t}`)}get backwardSeekOffset(){var t;return(t=Qi(this.getAttribute(re.BACKWARD_SEEK_OFFSET)))!=null?t:10}set backwardSeekOffset(t){this.setAttribute(re.BACKWARD_SEEK_OFFSET,`${t}`)}get defaultHiddenCaptions(){return this.hasAttribute(re.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(t){t?this.setAttribute(re.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(re.DEFAULT_HIDDEN_CAPTIONS)}get playerSoftwareName(){var t;return(t=this.getAttribute(Y.PLAYER_SOFTWARE_NAME))!=null?t:tx}get playerSoftwareVersion(){var t;return(t=this.getAttribute(Y.PLAYER_SOFTWARE_VERSION))!=null?t:ex}get beaconCollectionDomain(){var t;return(t=this.getAttribute(Y.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(Y.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(Y.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var t;return(t=this.getAttribute(Y.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(Y.MAX_RESOLUTION,t):this.removeAttribute(Y.MAX_RESOLUTION))}get customDomain(){var t;return(t=this.getAttribute(Y.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(Y.CUSTOM_DOMAIN,t):this.removeAttribute(Y.CUSTOM_DOMAIN))}get envKey(){var t;return(t=en(this,Y.ENV_KEY))!=null?t:void 0}set envKey(t){this.setAttribute(Y.ENV_KEY,`${t}`)}get noVolumePref(){return this.hasAttribute(re.NO_VOLUME_PREF)}set noVolumePref(t){t?this.setAttribute(re.NO_VOLUME_PREF,""):this.removeAttribute(re.NO_VOLUME_PREF)}get debug(){return en(this,Y.DEBUG)!=null}set debug(t){t?this.setAttribute(Y.DEBUG,""):this.removeAttribute(Y.DEBUG)}get disableCookies(){return en(this,Y.DISABLE_COOKIES)!=null}set disableCookies(t){t?this.setAttribute(Y.DISABLE_COOKIES,""):this.removeAttribute(Y.DISABLE_COOKIES)}get streamType(){var t,i,s;return(s=(i=this.getAttribute(Y.STREAM_TYPE))!=null?i:(t=this.media)==null?void 0:t.streamType)!=null?s:Ze.UNKNOWN}set streamType(t){this.setAttribute(Y.STREAM_TYPE,`${t}`)}get defaultStreamType(){var t,i,s;return(s=(i=this.getAttribute(re.DEFAULT_STREAM_TYPE))!=null?i:(t=this.mediaController)==null?void 0:t.getAttribute(re.DEFAULT_STREAM_TYPE))!=null?s:Ze.ON_DEMAND}set defaultStreamType(t){t?this.setAttribute(re.DEFAULT_STREAM_TYPE,t):this.removeAttribute(re.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var t,i;return this.hasAttribute(re.TARGET_LIVE_WINDOW)?+this.getAttribute(re.TARGET_LIVE_WINDOW):(i=(t=this.media)==null?void 0:t.targetLiveWindow)!=null?i:Number.NaN}set targetLiveWindow(t){t!=this.targetLiveWindow&&(t==null?this.removeAttribute(re.TARGET_LIVE_WINDOW):this.setAttribute(re.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t;return(t=this.media)==null?void 0:t.liveEdgeStart}get startTime(){return Qi(en(this,Y.START_TIME))}set startTime(t){this.setAttribute(Y.START_TIME,`${t}`)}get preferPlayback(){let t=this.getAttribute(Y.PREFER_PLAYBACK);if(t===oi.MSE||t===oi.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===oi.MSE||t===oi.NATIVE?this.setAttribute(Y.PREFER_PLAYBACK,t):this.removeAttribute(Y.PREFER_PLAYBACK))}get metadata(){var t;return(t=this.media)==null?void 0:t.metadata}set metadata(t){if(yt(this,Ir,tn).call(this),!this.media){vi("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...wv(this),...t}}async addCuePoints(t){var i;if(yt(this,Ir,tn).call(this),!this.media){vi("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(i=this.media)==null?void 0:i.addCuePoints(t)}get activeCuePoint(){var t;return(t=this.media)==null?void 0:t.activeCuePoint}get cuePoints(){var t,i;return(i=(t=this.media)==null?void 0:t.cuePoints)!=null?i:[]}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(re.PLAYBACK_TOKEN),i=this.getAttribute(re.THUMBNAIL_TOKEN),s=this.getAttribute(re.STORYBOARD_TOKEN);return{...Ne(this,Ea),...t!=null?{playback:t}:{},...i!=null?{thumbnail:i}:{},...s!=null?{storyboard:s}:{}}}set tokens(t){ii(this,Ea,t!=null?t:{})}get playbackToken(){var t;return(t=this.getAttribute(re.PLAYBACK_TOKEN))!=null?t:void 0}set playbackToken(t){this.setAttribute(re.PLAYBACK_TOKEN,`${t}`)}get thumbnailToken(){var t;return(t=this.getAttribute(re.THUMBNAIL_TOKEN))!=null?t:void 0}set thumbnailToken(t){this.setAttribute(re.THUMBNAIL_TOKEN,`${t}`)}get storyboardToken(){var t;return(t=this.getAttribute(re.STORYBOARD_TOKEN))!=null?t:void 0}set storyboardToken(t){this.setAttribute(re.STORYBOARD_TOKEN,`${t}`)}addTextTrack(t,i,s,n){var o;let a=(o=this.media)==null?void 0:o.nativeEl;if(!!a)return Il(a,t,i,s,n)}removeTextTrack(t){var s;let i=(s=this.media)==null?void 0:s.nativeEl;if(!!i)return T0(i,t)}get textTracks(){var t;return(t=this.media)==null?void 0:t.textTracks}};va=new WeakMap,Ea=new WeakMap,rr=new WeakMap,ya=new WeakMap,hs=new WeakMap,Ir=new WeakSet,tn=function(){var t,i,s;if(!Ne(this,va)){ii(this,va,!0),yt(this,Lr,rn).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof at.HTMLElement))throw""}catch{vi("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof z0))throw""}catch{vi("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof Dd))throw""}catch{vi("<media-controller> failed to upgrade!")}sv(this),yt(this,rd,Mv).call(this),yt(this,sd,Ov).call(this),yt(this,nd,Pv).call(this),ii(this,rr,(i=(t=this.mediaController)==null?void 0:t.hasAttribute("userinactive"))!=null?i:!0),yt(this,ad,Nv).call(this),(s=this.media)==null||s.addEventListener("streamtypechange",()=>{yt(this,Lr,rn).call(this)})}},id=new WeakSet,Cv=function(){var t,i;try{(t=window==null?void 0:window.CSS)==null||t.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(i=window==null?void 0:window.CSS)==null||i.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},ba=new WeakSet,mf=function(t){Object.assign(Ne(this,hs),t),yt(this,Lr,rn).call(this)},Lr=new WeakSet,rn=function(t={}){xv(Iv(jS(this,{...Ne(this,hs),...t})),this.shadowRoot)},rd=new WeakSet,Mv=function(){let t=s=>{var o,l;if(!(s!=null&&s.startsWith("theme-")))return;let n=s.replace(/^theme-/,"");if(ff.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)},sd=new WeakSet,Ov=function(){var i;let t=s=>{let{detail:n}=s;if(n instanceof it||(n=new it(n.message,n.code,n.fatal)),!(n!=null&&n.fatal)){br(n),n.data&&br(`${n.name} data:`,n.data);return}let{dialog:a,devlog:o}=ed(n,!window.navigator.onLine,this.playbackId,this.playbackToken);o.message&&Zh(o),vi(n),n.data&&vi(`${n.name} data:`,n.data),yt(this,ba,mf).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 it))return s;let{devlog:n}=ed((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}}),(i=this.media)==null||i.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 it(l,d)}!(n!=null&&n.fatal)||this.dispatchEvent(new CustomEvent("error",{detail:n}))})},nd=new WeakSet,Pv=function(){var i,s,n,a;let t=()=>yt(this,Lr,rn).call(this);(s=(i=this.media)==null?void 0:i.textTracks)==null||s.addEventListener("addtrack",t),(a=(n=this.media)==null?void 0:n.textTracks)==null||a.addEventListener("removetrack",t)},ad=new WeakSet,Nv=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,m,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(!m||this.paused){let A=T.text.split(`
|
|
2080
|
+
`).length,R=t?-2:-3;this.streamType===Ze.LIVE&&(R=t?-1:-2);let x=R-A;if(T.line===x&&!g)return;n.has(T)||n.set(T,T.line),T.line=x-1,T.line=x}else setTimeout(()=>{T.line=n.get(T)||"auto"},500)})},l=()=>{var h,m;o(s,(m=(h=this.mediaController)==null?void 0:h.hasAttribute("userinactive"))!=null?m:!1)},d=()=>{var g,E;let m=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];m!==s&&(s==null||s.removeEventListener("cuechange",l)),s=m,s==null||s.addEventListener("cuechange",l),o(s,Ne(this,rr))};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,rr),!0),this.paused||window.requestAnimationFrame(h)};this.addEventListener("playing",()=>{h()})}this.addEventListener("userinactivechange",()=>{var m,g;let h=(g=(m=this.mediaController)==null?void 0:m.hasAttribute("userinactive"))!=null?g:!0;Ne(this,rr)!==h&&(ii(this,rr,h),o(s,Ne(this,rr)))})};function en(r,e){return r.media?r.media.getAttribute(e):r.getAttribute(e)}at.customElements.get("mux-player")||(at.customElements.define("mux-player",ga),at.MuxPlayerElement=ga);var uD=ga;export{it as MediaError,uD as default,en as getVideoAttribute};
|
|
2081
2081
|
/*!
|
|
2082
2082
|
* JavaScript Cookie v2.1.3
|
|
2083
2083
|
* https://github.com/js-cookie/js-cookie
|