@mux/mux-player 1.11.3 → 1.11.4
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 +2 -2
- package/dist/index.mjs +1 -1
- package/dist/mux-player.js +218 -219
- package/dist/mux-player.mjs +218 -219
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
package/dist/mux-player.js
CHANGED
|
@@ -1,48 +1,22 @@
|
|
|
1
|
-
"use strict";(()=>{var tE=Object.create;var If=Object.defineProperty;var iE=Object.getOwnPropertyDescriptor;var rE=Object.getOwnPropertyNames;var aE=Object.getPrototypeOf,nE=Object.prototype.hasOwnProperty;var Rf=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports);var sE=(n,r,o,m)=>{if(r&&typeof r=="object"||typeof r=="function")for(let v of rE(r))!nE.call(n,v)&&v!==o&&If(n,v,{get:()=>r[v],enumerable:!(m=iE(r,v))||m.enumerable});return n};var Df=(n,r,o)=>(o=n!=null?tE(aE(n)):{},sE(r||!n||!n.__esModule?If(o,"default",{value:n,enumerable:!0}):o,n));var Ld=(n,r,o)=>{if(!r.has(n))throw TypeError("Cannot "+o)};var ot=(n,r,o)=>(Ld(n,r,"read from private field"),o?o.call(n):r.get(n)),Ht=(n,r,o)=>{if(r.has(n))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(n):r.set(n,o)},Gi=(n,r,o,m)=>(Ld(n,r,"write to private field"),m?m.call(n,o):r.set(n,o),o);var Qt=(n,r,o)=>(Ld(n,r,"access private method"),o);var Ep=Rf((nu,Vc)=>{(function(){var n,r;n=this,r=function(){return function(){var o={80:function(y,I,M){y.exports=M(728).default},728:function(y,I,M){"use strict";M.d(I,{default:function(){return qo}});var U=M(48),H=M.n(U),z=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(_){var g=16*Math.random()|0;return(_==="x"?g:3&g|8).toString(16)})},J=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},Z=function(_){return _&&_.nodeName!==void 0?(_.muxId||(_.muxId=_.id||J()),_.muxId):_},se=function(_){var g;_&&_.nodeName!==void 0?_=Z(g=_):g=document.querySelector(_);var T=g&&g.nodeName?g.nodeName.toLowerCase():"";return[g,_,T]},me=M(640),Te=M.n(me),ge=Te().methodFactory;Te().methodFactory=function(_,g,T){var R=ge(_,g,T);return function(){for(var C=["[mux]"],O=0;O<arguments.length;O++)C.push(arguments[O]);R.apply(void 0,C)}},Te().setLevel(Te().getLevel());var ye=Te();function Ee(){return(H().doNotTrack||H().navigator&&H().navigator.doNotTrack)==="1"}var de={now:function(){var _=H().performance,g=_&&_.timing,T=g&&g.navigationStart,R=typeof T=="number"&&typeof _.now=="function"?T+_.now():Date.now();return Math.round(R)}},Be=function(_){return Ge(_)[0]},Ge=function(_){if(typeof _!="string"||_==="")return["localhost"];var g,T=(_.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return T&&(g=(T.match(/[^\.]+\.[^\.]+$/)||[])[0]),[T,g]},re={exists:function(){var _=H().performance;return(_&&_.timing)!==void 0},domContentLoadedEventEnd:function(){var _=H().performance,g=_&&_.timing;return g&&g.domContentLoadedEventEnd},navigationStart:function(){var _=H().performance,g=_&&_.timing;return g&&g.navigationStart}};function k(_,g,T){T=T===void 0?1:T,_[g]=_[g]||0,_[g]+=T}var oe=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],q=["x-cdn","content-type"].concat(oe);function Se(_){var g={};return(_=_||"").trim().split(/[\r\n]+/).forEach(function(T){if(T){var R=T.split(": "),C=R.shift();C&&(q.indexOf(C.toLowerCase())>=0||C.toLowerCase().indexOf("x-litix-")===0)&&(g[C]=R.join(": "))}}),g}function Xe(_){if(_){var g=oe.find(function(T){return _[T]!==void 0});return g?_[g]:void 0}}var at=function(_){var g={};for(var T in _){var R=_[T];R["DATA-ID"].search("io.litix.data.")!==-1&&(g[R["DATA-ID"].replace("io.litix.data.","")]=R.VALUE)}return g};function jt(_,g){var T=Object.keys(_);if(Object.getOwnPropertySymbols){var R=Object.getOwnPropertySymbols(_);g&&(R=R.filter(function(C){return Object.getOwnPropertyDescriptor(_,C).enumerable})),T.push.apply(T,R)}return T}function it(_){for(var g=1;g<arguments.length;g++){var T=arguments[g]!=null?arguments[g]:{};g%2?jt(Object(T),!0).forEach(function(R){B(_,R,T[R])}):Object.getOwnPropertyDescriptors?Object.defineProperties(_,Object.getOwnPropertyDescriptors(T)):jt(Object(T)).forEach(function(R){Object.defineProperty(_,R,Object.getOwnPropertyDescriptor(T,R))})}return _}function B(_,g,T){return g in _?Object.defineProperty(_,g,{value:T,enumerable:!0,configurable:!0,writable:!0}):_[g]=T,_}var di=function(_){if(!_)return{};var g=re.navigationStart(),T=_.loading,R=T?T.start:_.trequest,C=T?T.first:_.tfirst,O=T?T.end:_.tload;return{bytesLoaded:_.total,requestStart:Math.round(g+R),responseStart:Math.round(g+C),responseEnd:Math.round(g+O)}},zt=function(_){if(_&&typeof _.getAllResponseHeaders=="function")return Se(_.getAllResponseHeaders())};function nt(_,g){var T=Object.keys(_);if(Object.getOwnPropertySymbols){var R=Object.getOwnPropertySymbols(_);g&&(R=R.filter(function(C){return Object.getOwnPropertyDescriptor(_,C).enumerable})),T.push.apply(T,R)}return T}function ri(_){for(var g=1;g<arguments.length;g++){var T=arguments[g]!=null?arguments[g]:{};g%2?nt(Object(T),!0).forEach(function(R){$e(_,R,T[R])}):Object.getOwnPropertyDescriptors?Object.defineProperties(_,Object.getOwnPropertyDescriptors(T)):nt(Object(T)).forEach(function(R){Object.defineProperty(_,R,Object.getOwnPropertyDescriptor(T,R))})}return _}function $e(_,g,T){return g in _?Object.defineProperty(_,g,{value:T,enumerable:!0,configurable:!0,writable:!0}):_[g]=T,_}var Vt=function(_,g){if(!_||typeof _.getRequests!="function")return{};var T=_.getRequests({state:"executed"});if(T.length===0)return{};var R,C=T[T.length-1],O=Be(C.url),x=C.url,G=C.bytesLoaded,$=new Date(C.requestStartDate).getTime(),K=new Date(C.firstByteDate).getTime(),ee=new Date(C.requestEndDate).getTime(),Fe=isNaN(C.duration)?0:C.duration,_e=typeof g.getMetricsFor=="function"?g.getMetricsFor(C.mediaType).HttpList:g.getDashMetrics().getHttpRequests(C.mediaType);return _e.length>0&&(R=Se(_e[_e.length-1]._responseHeaders||"")),{requestStart:$,requestResponseStart:K,requestResponseEnd:ee,requestBytesLoaded:G,requestResponseHeaders:R,requestMediaDuration:Fe,requestHostname:O,requestUrl:x,requestId:R?Xe(R):void 0}},Et=function(_,g){var T=g.getQualityFor(_),R=g.getCurrentTrackFor(_).bitrateList;return R?{currentLevel:T,renditionWidth:R[T].width||null,renditionHeight:R[T].height||null,renditionBitrate:R[T].bandwidth}:{}},Mt=function(_){var g;return(g=_.match(/.*codecs\*?="(.*)"/))===null||g===void 0?void 0:g[1]};function rr(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}var te=0,ke=function(){function _(){(function(C,O){if(!(C instanceof O))throw new TypeError("Cannot call a class as a function")})(this,_)}var g,T,R;return g=_,T=[{key:"on",value:function(C,O,x){return O._eventEmitterGuid=O._eventEmitterGuid||++te,this._listeners=this._listeners||{},this._listeners[C]=this._listeners[C]||[],x&&(O=O.bind(x)),this._listeners[C].push(O),O}},{key:"off",value:function(C,O){var x=this._listeners&&this._listeners[C];x&&x.forEach(function(G,$){G._eventEmitterGuid===O._eventEmitterGuid&&x.splice($,1)})}},{key:"one",value:function(C,O,x){var G=this;O._eventEmitterGuid=O._eventEmitterGuid||++te;var $=function K(){G.off(C,K),O.apply(x||this,arguments)};$._eventEmitterGuid=O._eventEmitterGuid,this.on(C,$)}},{key:"emit",value:function(C,O){var x=this;if(this._listeners){O=O||{};var G=this._listeners["before*"]||[],$=this._listeners[C]||[],K=this._listeners["after"+C]||[],ee=function(Fe,_e){(Fe=Fe.slice()).forEach(function(Re){Re.call(x,{type:C},_e)})};ee(G,O),ee($,O),ee(K,O)}}}],T&&rr(g.prototype,T),R&&rr(g,R),Object.defineProperty(g,"prototype",{writable:!1}),_}(),st=ke;function Lt(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}var Rt=function(){function _(C){var O=this;(function(x,G){if(!(x instanceof G))throw new TypeError("Cannot call a class as a function")})(this,_),this.pm=C,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,C.on("playing",function(){O._playheadShouldBeProgressing=!0}),C.on("play",this._startPlaybackHeartbeatInterval.bind(this)),C.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),C.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),C.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),C.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),C.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),C.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),C.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),C.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),C.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),C.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),C.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),C.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),C.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),C.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),C.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),C.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),C.on("seeked",function(){C.data.player_is_paused?O._stopPlaybackHeartbeatInterval():O._startPlaybackHeartbeatInterval()}),C.on("timeupdate",function(){O._playbackHeartbeatInterval!==null&&C.emit("playbackheartbeat")}),C.on("devicesleep",function(x,G){O._playbackHeartbeatInterval!==null&&(H().clearInterval(O._playbackHeartbeatInterval),C.emit("playbackheartbeatend",{viewer_time:G.viewer_time}),O._playbackHeartbeatInterval=null)})}var g,T,R;return g=_,(T=[{key:"_startPlaybackHeartbeatInterval",value:function(){var C=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=H().setInterval(function(){C.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(H().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Lt(g.prototype,T),R&&Lt(g,R),Object.defineProperty(g,"prototype",{writable:!1}),_}();function ci(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}function $i(_,g,T){return g&&ci(_.prototype,g),T&&ci(_,T),Object.defineProperty(_,"prototype",{writable:!1}),_}var Ze=$i(function _(g){var T=this;(function(R,C){if(!(R instanceof C))throw new TypeError("Cannot call a class as a function")})(this,_),g.on("viewinit",function(){T.viewErrored=!1}),g.on("error",function(R,C){try{var O=g.errorTranslator({player_error_code:C.player_error_code,player_error_message:C.player_error_message,player_error_context:C.player_error_context});O?(g.data.player_error_code=O.player_error_code||C.player_error_code,g.data.player_error_message=O.player_error_message||C.player_error_message,g.data.player_error_context=O.player_error_context||C.player_error_context,T.viewErrored=!0):(delete g.data.player_error_code,delete g.data.player_error_message,delete g.data.player_error_context)}catch(x){g.mux.log.warn("Exception in error translator callback.",x),T.viewErrored=!0}})});function vi(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}var gi=function(){function _(C){(function(O,x){if(!(O instanceof x))throw new TypeError("Cannot call a class as a function")})(this,_),this.pm=C,this._watchTimeTrackerLastCheckedTime=null,C.on("playbackheartbeat",this._updateWatchTime.bind(this)),C.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var g,T,R;return g=_,(T=[{key:"_updateWatchTime",value:function(C,O){var x=O.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=x),k(this.pm.data,"view_watch_time",x-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=x}},{key:"_clearWatchTimeState",value:function(C,O){this._updateWatchTime(C,O),this._watchTimeTrackerLastCheckedTime=null}}])&&vi(g.prototype,T),R&&vi(g,R),Object.defineProperty(g,"prototype",{writable:!1}),_}();function ji(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}var ar=function(){function _(C){(function(O,x){if(!(O instanceof x))throw new TypeError("Cannot call a class as a function")})(this,_),this.pm=C,this._playbackTimeTrackerLastPlayheadPosition=-1,C.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),C.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),C.on("seeking",this._clearPlaybackTimeState.bind(this))}var g,T,R;return g=_,(T=[{key:"_updatePlaybackTime",value:function(){var C=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&C>this._playbackTimeTrackerLastPlayheadPosition){var O=C-this._playbackTimeTrackerLastPlayheadPosition;O<=1e3&&k(this.pm.data,"view_content_playback_time",O)}this._playbackTimeTrackerLastPlayheadPosition=C}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&ji(g.prototype,T),R&&ji(g,R),Object.defineProperty(g,"prototype",{writable:!1}),_}();function Ei(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}var ft=function(){function _(C){(function(x,G){if(!(x instanceof G))throw new TypeError("Cannot call a class as a function")})(this,_),this.pm=C;var O=this._updatePlayheadTime.bind(this);C.on("playbackheartbeat",O),C.on("playbackheartbeatend",O),C.on("timeupdate",O),C.on("destroy",function(){C.off("timeupdate",O)})}var g,T,R;return g=_,(T=[{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(C,O){var x=this,G=function(){x.pm.currentFragmentPDT&&x.pm.currentFragmentStart&&(x.pm.data.player_program_time=x.pm.currentFragmentPDT+x.pm.data.player_playhead_time-x.pm.currentFragmentStart)};if(O&&O.player_playhead_time)this.pm.data.player_playhead_time=O.player_playhead_time,G(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var $=this.pm.getPlayheadTime();$!==void 0&&(this.pm.data.player_playhead_time=$,G(),this._updateMaxPlayheadPosition())}}}])&&Ei(g.prototype,T),R&&Ei(g,R),Object.defineProperty(g,"prototype",{writable:!1}),_}();function nr(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}function yr(_,g,T){return g&&nr(_.prototype,g),T&&nr(_,T),Object.defineProperty(_,"prototype",{writable:!1}),_}var $r=3e5,xi=yr(function _(g){if(function(O,x){if(!(O instanceof x))throw new TypeError("Cannot call a class as a function")}(this,_),!g.disableRebufferTracking){var T,R=function(O,x){C(x),T=void 0},C=function(O){if(T){var x=O.viewer_time-T;k(g.data,"view_rebuffer_duration",x),T=O.viewer_time,g.data.view_rebuffer_duration>$r&&(g.emit("viewend"),g.send("viewend"),g.mux.log.warn("Ending view after rebuffering for longer than ".concat($r,"ms, future events will be ignored unless a programchange or videochange occurs.")))}g.data.view_watch_time>=0&&g.data.view_rebuffer_count>0&&(g.data.view_rebuffer_frequency=g.data.view_rebuffer_count/g.data.view_watch_time,g.data.view_rebuffer_percentage=g.data.view_rebuffer_duration/g.data.view_watch_time)};g.on("playbackheartbeat",function(O,x){return C(x)}),g.on("rebufferstart",function(O,x){T||(k(g.data,"view_rebuffer_count",1),T=x.viewer_time,g.one("rebufferend",R))}),g.on("viewinit",function(){T=void 0,g.off("rebufferend",R)})}});function br(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}var ts=function(){function _(C){var O=this;(function(x,G){if(!(x instanceof G))throw new TypeError("Cannot call a class as a function")})(this,_),this.pm=C,C.disableRebufferTracking||C.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,C.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),C.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),C.on("seeking",function(){O._cleanupRebufferTracker(null,{viewer_time:de.now()})}))}var g,T,R;return g=_,T=[{key:"_checkIfRebuffering",value:function(C,O){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(C,O);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var x=O.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&x>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=O.viewer_time}else this._cleanupRebufferTracker(C,O,!0);else this._prepareRebufferTrackerState(O.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(C){this._lastCheckedTime=C,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=C}},{key:"_cleanupRebufferTracker",value:function(C,O){var x=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:O.viewer_time});else{if(this._lastCheckedTime===null)return;var G=this.pm.data.player_playhead_time-this._lastPlayheadTime,$=O.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&G>0&&$-G>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+$-G}))}x?this._prepareRebufferTrackerState(O.viewer_time):this._clearRebufferTrackerState()}}],T&&br(g.prototype,T),R&&br(g,R),Object.defineProperty(g,"prototype",{writable:!1}),_}(),vo=ts;function ga(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}var nn=function(){function _(C){var O=this;(function(x,G){if(!(x instanceof G))throw new TypeError("Cannot call a class as a function")})(this,_),this.pm=C,C.on("viewinit",function(){var x=C.data,G=x.view_id;if(!x.view_program_changed){var $=function(K,ee){var Fe=ee.viewer_time;K.type==="playing"&&C.data.view_time_to_first_frame===void 0?O.calculateTimeToFirstFrame(Fe||de.now(),G):K.type!=="adplaying"||C.data.view_time_to_first_frame!==void 0&&!O._inPrerollPosition()||O.calculateTimeToFirstFrame(Fe||de.now(),G)};C.one("playing",$),C.one("adplaying",$),C.one("viewend",function(){C.off("playing",$),C.off("adplaying",$)})}})}var g,T,R;return g=_,(T=[{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(C,O){O===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:C}),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))}}])&&ga(g.prototype,T),R&&ga(g,R),Object.defineProperty(g,"prototype",{writable:!1}),_}();function go(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}function Eo(_,g,T){return g&&go(_.prototype,g),T&&go(_,T),Object.defineProperty(_,"prototype",{writable:!1}),_}var Uu=Eo(function _(g){var T=this;(function(R,C){if(!(R instanceof C))throw new TypeError("Cannot call a class as a function")})(this,_),g.on("viewinit",function(){T._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(R){g.on(R,function(){if(T._lastPlayheadPosition>=0&&g.data.player_playhead_time>=0&&T._lastPlayerWidth>=0&&T._lastSourceWidth>0&&T._lastPlayerHeight>=0&&T._lastSourceHeight>0){var C=g.data.player_playhead_time-T._lastPlayheadPosition;if(C<0)return void(T._lastPlayheadPosition=-1);var O=Math.min(T._lastPlayerWidth/T._lastSourceWidth,T._lastPlayerHeight/T._lastSourceHeight),x=Math.max(0,O-1),G=Math.max(0,1-O);g.data.view_max_upscale_percentage=Math.max(g.data.view_max_upscale_percentage||0,x),g.data.view_max_downscale_percentage=Math.max(g.data.view_max_downscale_percentage||0,G),k(g.data,"view_total_content_playback_time",C),k(g.data,"view_total_upscaling",x*C),k(g.data,"view_total_downscaling",G*C)}T._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(R){g.on(R,function(){T._lastPlayheadPosition=g.data.player_playhead_time,T._lastPlayerWidth=g.data.player_width,T._lastPlayerHeight=g.data.player_height,T._lastSourceWidth=g.data.video_source_width,T._lastSourceHeight=g.data.video_source_height})})});function is(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}function Bu(_,g,T){return g&&is(_.prototype,g),T&&is(_,T),Object.defineProperty(_,"prototype",{writable:!1}),_}var Hu=Bu(function _(g){var T=this;(function(R,C){if(!(R instanceof C))throw new TypeError("Cannot call a class as a function")})(this,_),this.isSeeking=!1,g.on("seeking",function(R,C){Object.assign(g.data,C),T._lastSeekingTime=de.now(),T.isSeeking===!1&&(T.isSeeking=!0,g.send("seeking"))}),g.on("seeked",function(){T.isSeeking=!1;var R=T._lastSeekingTime||de.now(),C=de.now()-R;k(g.data,"view_seek_count",1),k(g.data,"view_seek_duration",C);var O=g.data.view_max_seek_time||0;g.data.view_max_seek_time=Math.max(O,C)}),g.on("viewend",function(){T.isSeeking=!1})});function yo(_,g){return function(T){if(Array.isArray(T))return T}(_)||function(T,R){var C=T==null?null:typeof Symbol!="undefined"&&T[Symbol.iterator]||T["@@iterator"];if(C!=null){var O,x,G=[],$=!0,K=!1;try{for(C=C.call(T);!($=(O=C.next()).done)&&(G.push(O.value),!R||G.length!==R);$=!0);}catch(ee){K=!0,x=ee}finally{try{$||C.return==null||C.return()}finally{if(K)throw x}}return G}}(_,g)||function(T,R){if(T){if(typeof T=="string")return bo(T,R);var C=Object.prototype.toString.call(T).slice(8,-1);return C==="Object"&&T.constructor&&(C=T.constructor.name),C==="Map"||C==="Set"?Array.from(T):C==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(C)?bo(T,R):void 0}}(_,g)||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 bo(_,g){(g==null||g>_.length)&&(g=_.length);for(var T=0,R=new Array(g);T<g;T++)R[T]=_[T];return R}function To(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}var Ii=function(_,g){_.push(g),_.sort(function(T,R){return T.viewer_time-R.viewer_time})},Gu=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Pi=function(){function _(C){var O=this;(function(G,$){if(!(G instanceof $))throw new TypeError("Cannot call a class as a function")})(this,_),this.pm=C,C.on("viewinit",function(){O.isAdBreak=!1,O._currentAdRequestNumber=0,O._currentAdResponseNumber=0,O._adRequests=[],O._adResponses=[],O._adHasPlayed=!1,O._wouldBeNewAdPlay=!0,O._prerollPlayTime=void 0}),Gu.forEach(function(G){return C.on(G,O._updateAdData.bind(O))});var x=function(){O.isAdBreak=!1};C.on("adbreakstart",function(){O.isAdBreak=!0}),C.on("play",x),C.on("playing",x),C.on("viewend",x),C.on("adrequest",function(G,$){$=Object.assign({ad_request_id:"generatedAdRequestId"+O._currentAdRequestNumber++},$),Ii(O._adRequests,$),k(C.data,"view_ad_request_count"),O.inPrerollPosition()&&(C.data.view_preroll_requested=!0,O._adHasPlayed||k(C.data,"view_preroll_request_count"))}),C.on("adresponse",function(G,$){$=Object.assign({ad_request_id:"generatedAdRequestId"+O._currentAdResponseNumber++},$),Ii(O._adResponses,$);var K=O.findAdRequest($.ad_request_id);K&&k(C.data,"view_ad_request_time",Math.max(0,$.viewer_time-K.viewer_time))}),C.on("adplay",function(G,$){O._adHasPlayed=!0,O._wouldBeNewAdPlay&&(O._wouldBeNewAdPlay=!1,k(C.data,"view_ad_played_count")),O.inPrerollPosition()&&!C.data.view_preroll_played&&(C.data.view_preroll_played=!0,O._adRequests.length>0&&(C.data.view_preroll_request_time=Math.max(0,$.viewer_time-O._adRequests[0].viewer_time)),C.data.view_start&&(C.data.view_startup_preroll_request_time=Math.max(0,$.viewer_time-C.data.view_start)),O._prerollPlayTime=$.viewer_time)}),C.on("adplaying",function(G,$){O.inPrerollPosition()&&C.data.view_preroll_load_time===void 0&&O._prerollPlayTime!==void 0&&(C.data.view_preroll_load_time=$.viewer_time-O._prerollPlayTime,C.data.view_startup_preroll_load_time=$.viewer_time-O._prerollPlayTime)}),C.on("adended",function(){O._wouldBeNewAdPlay=!0}),C.on("aderror",function(){O._wouldBeNewAdPlay=!0})}var g,T,R;return g=_,(T=[{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(C){for(var O=0;O<this._adRequests.length;O++)if(this._adRequests[O].ad_request_id===C)return this._adRequests[O]}},{key:"_updateAdData",value:function(C,O){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&O.ad_tag_url){var x=yo(Ge(O.ad_tag_url),2),G=x[0],$=x[1];this.pm.data.view_preroll_ad_tag_domain=$,this.pm.data.view_preroll_ad_tag_hostname=G}if(!this.pm.data.view_preroll_ad_asset_hostname&&O.ad_asset_url){var K=yo(Ge(O.ad_asset_url),2),ee=K[0],Fe=K[1];this.pm.data.view_preroll_ad_asset_domain=Fe,this.pm.data.view_preroll_ad_asset_hostname=ee}}this.pm.data.ad_asset_url=O==null?void 0:O.ad_asset_url,this.pm.data.ad_tag_url=O==null?void 0:O.ad_tag_url,this.pm.data.ad_creative_id=O==null?void 0:O.ad_creative_id,this.pm.data.ad_id=O==null?void 0:O.ad_id,this.pm.data.ad_universal_id=O==null?void 0:O.ad_universal_id}}])&&To(g.prototype,T),R&&To(g,R),Object.defineProperty(g,"prototype",{writable:!1}),_}();function Ea(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}function Vu(_,g,T){return g&&Ea(_.prototype,g),T&&Ea(_,T),Object.defineProperty(_,"prototype",{writable:!1}),_}var _o=Vu(function _(g){var T,R;(function(G,$){if(!(G instanceof $))throw new TypeError("Cannot call a class as a function")})(this,_);var C=function(){g.disableRebufferTracking||T&&(k(g.data,"view_waiting_rebuffer_duration",de.now()-T),T=!1,H().clearInterval(R))},O=!1,x=function(){O=!1,C()};g.on("waiting",function(){O&&(g.disableRebufferTracking||(k(g.data,"view_waiting_rebuffer_count",1),T=de.now(),R=H().setInterval(function(){if(T){var G=de.now();k(g.data,"view_waiting_rebuffer_duration",G-T),T=G}},250)))}),g.on("playing",function(){C(),O=!0}),g.on("pause",x),g.on("seeking",x)});function xt(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}function Ao(_,g,T){return g&&xt(_.prototype,g),T&&xt(_,T),Object.defineProperty(_,"prototype",{writable:!1}),_}var He=Ao(function _(g){var T=this;(function(O,x){if(!(O instanceof x))throw new TypeError("Cannot call a class as a function")})(this,_);var R=function(){T.lastWallClockTime=de.now(),g.on("before*",C)},C=function(O){var x=de.now(),G=T.lastWallClockTime;T.lastWallClockTime=x,x-G>3e4&&(g.emit("devicesleep",{viewer_time:G}),Object.assign(g.data,{viewer_time:G}),g.send("devicesleep"),g.emit("devicewake",{viewer_time:x}),Object.assign(g.data,{viewer_time:x}),g.send("devicewake"))};g.one("playbackheartbeat",R),g.on("playbackheartbeatend",function(){g.off("before*",C),g.one("playbackheartbeat",R)})}),rs=M(375),as=M(655),Je=M.n(as),So="muxData",ns=function(){var _;try{_=rs.parse(Je().get(So)||"")}catch{_={}}return _},ss=function(_){try{Je().set(So,rs.stringify(_),{expires:7300})}catch{}},Ku=function(){var _=ns();return _.mux_viewer_id=_.mux_viewer_id||z(),_.msn=_.msn||Math.random(),ss(_),{mux_viewer_id:_.mux_viewer_id,mux_sample_number:_.msn}};function Tr(_,g){var T=g.beaconCollectionDomain,R=g.beaconDomain;if(T)return"https://"+T;var C=R||"litix.io";return(_=_||"inferred").match(/^[a-z0-9]+$/)?"https://"+_+"."+C:"https://img.litix.io/a.gif"}var os=function(){var _;switch(ko()){case"cellular":_="cellular";break;case"ethernet":_="wired";break;case"wifi":_="wifi";break;case void 0:break;default:_="other"}return _},ko=function(){var _=H().navigator,g=_&&(_.connection||_.mozConnection||_.webkitConnection);return g&&g.type};os.getConnectionFromAPI=ko;var wo=os,Lo=ya({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"}),Io=ya({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 ya(_){var g={};for(var T in _)_.hasOwnProperty(T)&&(g[_[T]]=T);return g}function ba(_){var g={},T={};return Object.keys(_).forEach(function(R){var C=!1;if(_.hasOwnProperty(R)&&_[R]!==void 0){var O=R.split("_"),x=O[0],G=Lo[x];G||(ye.info("Data key word `"+O[0]+"` not expected in "+R),G=x+"_"),O.splice(1).forEach(function($){$==="url"&&(C=!0),Io[$]?G+=Io[$]:Number($)&&Math.floor(Number($))===Number($)?G+=$:(ye.info("Data key word `"+$+"` not expected in "+R),G+="_"+$+"_")}),C?T[G]=_[R]:g[G]=_[R]}}),Object.assign(g,T)}var Ro={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Do=["hb","requestcompleted","requestfailed","requestcanceled"],ai="https://img.litix.io",Ri=function(_){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=_||ai,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},Ro,g)};Ri.prototype.queueEvent=function(_,g){var T=Object.assign({},g);return(this._eventQueue.length<=this._options.maxQueueLength||_==="eventrateexceeded")&&(this._eventQueue.push(T),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},Ri.prototype.flushEvents=function(){var _=arguments.length>0&&arguments[0]!==void 0&&arguments[0];_&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},Ri.prototype.destroy=function(){var _=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,_?this._clearBeaconQueue():this.flushEvents(),H().clearTimeout(this._sendTimeout)},Ri.prototype._clearBeaconQueue=function(){var _=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,g=this._eventQueue.slice(_);_>0&&Object.assign(g[g.length-1],ba({mux_view_message:"event queue truncated"}));var T=this._createPayload(g);Mo(this._beaconUrl,T,!0,function(){})},Ri.prototype._sendBeaconQueue=function(){var _=this;if(!this._postInFlight){var g=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var T=this._createPayload(g),R=de.now();Mo(this._beaconUrl,T,!1,function(C,O){O?(_._eventQueue=g.concat(_._eventQueue),_._failureCount+=1,ye.info("Error sending beacon: "+O)):_._failureCount=0,_._roundTripTime=de.now()-R,_._postInFlight=!1})}},Ri.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var _=Math.pow(2,this._failureCount-1);return(1+(_*=Math.random()))*this._options.baseTimeBetweenBeacons},Ri.prototype._startBeaconSending=function(){var _=this;H().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=H().setTimeout(function(){_._eventQueue.length&&_._sendBeaconQueue(),_._startBeaconSending()},this._getNextBeaconTime()))},Ri.prototype._createPayload=function(_){var g,T,R,C=this,O={transmission_timestamp:Math.round(de.now())};this._roundTripTime&&(O.rtt_ms=Math.round(this._roundTripTime));var x=function(){g=JSON.stringify({metadata:O,events:T||_}),R=g.length/1024},G=function(){return R<=C._options.maxPayloadKBSize};return x(),G()||(ye.info("Payload size is too big ("+R+" kb). Removing unnecessary events."),T=_.filter(function($){return Do.indexOf($.e)===-1}),x()),G()||(ye.info("Payload size still too big ("+R+" kb). Cropping fields.."),T.forEach(function($){for(var K in $){var ee=$[K];typeof ee=="string"&&ee.length>51200&&($[K]=ee.substring(0,51200))}}),x()),g};var Co=function(_){return _.length<=57344},Mo=function(_,g,T,R){if(T&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(_,g))R();else if(H().fetch)H().fetch(_,{method:"POST",body:g,headers:{"Content-Type":"text/plain"},keepalive:Co(g)}).then(function(O){return R(null,O.ok?null:"Error")}).catch(function(O){return R(null,O)});else{if(H().XMLHttpRequest){var C=new(H()).XMLHttpRequest;return C.onreadystatechange=function(){if(C.readyState===4)return R(null,C.status!==200?"error":void 0)},C.open("POST",_),C.setRequestHeader("Content-Type","text/plain"),void C.send(g)}R()}},sn=Ri;function Wu(_,g){return function(T){if(Array.isArray(T))return T}(_)||function(T,R){var C=T==null?null:typeof Symbol!="undefined"&&T[Symbol.iterator]||T["@@iterator"];if(C!=null){var O,x,G=[],$=!0,K=!1;try{for(C=C.call(T);!($=(O=C.next()).done)&&(G.push(O.value),!R||G.length!==R);$=!0);}catch(ee){K=!0,x=ee}finally{try{$||C.return==null||C.return()}finally{if(K)throw x}}return G}}(_,g)||function(T,R){if(T){if(typeof T=="string")return ls(T,R);var C=Object.prototype.toString.call(T).slice(8,-1);return C==="Object"&&T.constructor&&(C=T.constructor.name),C==="Map"||C==="Set"?Array.from(T):C==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(C)?ls(T,R):void 0}}(_,g)||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 rt(_,g){(g==null||g>_.length)&&(g=_.length);for(var T=0,R=new Array(g);T<g;T++)R[T]=_[T];return R}function Di(_,g){for(var T=0;T<g.length;T++){var R=g[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(_,R.key,R)}}function Oi(_,g){return Oi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,R){return T.__proto__=R,T},Oi(_,g)}function Fo(_){var g=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 T,R=_a(_);if(g){var C=_a(this).constructor;T=Reflect.construct(R,arguments,C)}else T=R.apply(this,arguments);return hs(this,T)}}function hs(_,g){if(g&&(yi(g)==="object"||typeof g=="function"))return g;if(g!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Pt(_)}function Pt(_){if(_===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return _}function _a(_){return _a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(g){return g.__proto__||Object.getPrototypeOf(g)},_a(_)}var Uo=["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"],Qr=function(_){(function(x,G){if(typeof G!="function"&&G!==null)throw new TypeError("Super expression must either be null or a function");x.prototype=Object.create(G&&G.prototype,{constructor:{value:x,writable:!0,configurable:!0}}),Object.defineProperty(x,"prototype",{writable:!1}),G&&Oi(x,G)})(O,_);var g,T,R,C=Fo(O);function O(x,G,$){var K;(function(we,Ce){if(!(we instanceof Ce))throw new TypeError("Cannot call a class as a function")})(this,O),(K=C.call(this)).DOM_CONTENT_LOADED_EVENT_END=re.domContentLoadedEventEnd(),K.NAVIGATION_START=re.navigationStart(),K.mux=x,K.id=G,($=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(we){return we}},$)).data=$.data||{},$.data.property_key&&($.data.env_key=$.data.property_key,delete $.data.property_key),ye.setLevel($.debug?"debug":"warn"),K.getPlayheadTime=$.getPlayheadTime,K.getStateData=$.getStateData||function(){return{}},K.getAdData=$.getAdData||function(){},K.minimumRebufferDuration=$.minimumRebufferDuration,K.sustainedRebufferThreshold=$.sustainedRebufferThreshold,K.playbackHeartbeatTime=$.playbackHeartbeatTime,K.disableRebufferTracking=$.disableRebufferTracking,K.disableRebufferTracking&&K.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."),K.disablePlayheadRebufferTracking=$.disablePlayheadRebufferTracking,K.errorTranslator=$.errorTranslator,K.playbackEventDispatcher=new Yu(x,$.data.env_key,$),K.data={player_instance_id:z(),mux_sample_rate:$.sampleRate,beacon_domain:$.beaconCollectionDomain?$.beaconCollectionDomain:$.beaconDomain},K.data.view_sequence_number=1,K.data.player_sequence_number=1,K.oldEmit=K.emit,K.emit=function(we,Ce){Ce=Object.assign({viewer_time:this.mux.utils.now()},Ce),this.oldEmit(we,Ce)};var ee=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Pt(K));K.on("viewinit",function(we,Ce){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,Ce),this._initializeViewData(),this.one("play",ee),this.one("adbreakstart",ee)});var Fe=function(we){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",we)}.bind(Pt(K));if(K.on("videochange",function(we,Ce){Fe(Ce)}),K.on("programchange",function(we,Ce){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."),Fe(Object.assign(Ce,{view_program_changed:!0})),ee(),this.emit("play"),this.emit("playing")}),K.on("fragmentchange",function(we,Ce){this.currentFragmentPDT=Ce.currentFragmentPDT,this.currentFragmentStart=Ce.currentFragmentStart}),K.on("destroy",K.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var _e=function(){var we=K.data.view_start!==void 0;K.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",we&&K.mux.WINDOW_HIDDEN&&(K.data.player_is_paused||K.emit("hb"))};window.addEventListener("visibilitychange",_e,!1);var Re=function(we){we.persisted||K.destroy()};window.addEventListener("pagehide",Re,!1),K.on("destroy",function(){window.removeEventListener("visibilitychange",_e),window.removeEventListener("pagehide",Re)})}return K.on("playerready",function(we,Ce){Object.assign(this.data,Ce)}),Uo.forEach(function(we){K.on(we,function(Ce,We){we.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,We),this._sanitizeData()}),K.on("after"+we,function(){(we!=="error"||this.errorTracker.viewErrored)&&this.send(we)})}),K.on("viewend",function(we,Ce){Object.assign(K.data,Ce)}),K.one("playerready",function(we){var Ce=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=Ce-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}),K.longResumeTracker=new Ar(Pt(K)),K.errorTracker=new Ze(Pt(K)),new He(Pt(K)),K.seekingTracker=new Hu(Pt(K)),K.playheadTime=new ft(Pt(K)),K.playbackHeartbeat=new Rt(Pt(K)),new Uu(Pt(K)),K.watchTimeTracker=new gi(Pt(K)),new ar(Pt(K)),K.adTracker=new Pi(Pt(K)),new vo(Pt(K)),new xi(Pt(K)),new nn(Pt(K)),new _o(Pt(K)),new No(Pt(K)),$.hlsjs&&K.addHLSJS($),$.dashjs&&K.addDashJS($),K.emit("viewinit",$.data),K}return g=O,T=[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(x){if(this.data.view_id){var G=Object.assign({},this.data);if(G.video_source_is_live===void 0&&(G.player_source_duration===1/0||G.video_source_duration===1/0?G.video_source_is_live=!0:(G.player_source_duration>0||G.video_source_duration>0)&&(G.video_source_is_live=!1)),G.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(Fe){G[Fe]=void 0}),G.video_source_url=G.video_source_url||G.player_source_url,G.video_source_url){var $=zi(Ge(G.video_source_url),2),K=$[0],ee=$[1];G.video_source_domain=ee,G.video_source_hostname=K}delete G.ad_request_id,this.playbackEventDispatcher.send(x,G),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),x==="viewend"&&delete this.data.view_id}}},{key:"_updateStateData",value:function(){Object.assign(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var x=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(G){var $=parseInt(x.data[G],10);x.data[G]=isNaN($)?void 0:$}),["player_source_url","video_source_url"].forEach(function(G){if(x.data[G]){var $=x.data[G].toLowerCase();$.indexOf("data:")!==0&&$.indexOf("blob:")!==0||(x.data[G]="MSE style URL")}})}},{key:"_resetVideoData",value:function(x,G){var $=this;Object.keys(this.data).forEach(function(K){K.indexOf("video_")===0&&delete $.data[K]})}},{key:"_resetViewData",value:function(){var x=this;Object.keys(this.data).forEach(function(G){G.indexOf("view_")===0&&delete x.data[G]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(x,G){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var x=this,G=this.data.view_id=z(),$=function(){G===x.data.view_id&&k(x.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",$):$()}},{key:"_restartHeartBeat",value:function(){var x=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){x.data.player_is_paused||x.emit("hb")},1e4))}},{key:"addHLSJS",value:function(x){x.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=x.hlsjs,function(G,$,K){var ee=arguments.length>4?arguments[4]:void 0,Fe=G.log,_e=G.utils.secondsToMs,Re=function(tt){var ue,he=parseInt(ee.version);return he===1&&tt.programDateTime!==null&&(ue=tt.programDateTime),he===0&&tt.pdt!==null&&(ue=tt.pdt),ue};if(re.exists()){var we=function(tt,ue){return G.emit($,tt,ue)},Ce=function(tt,ue){var he=ue.levels,fe=ue.audioTracks,Ue=ue.url,qe=ue.stats,yt=ue.networkDetails,ni=ue.sessionData,Nt={},Jt={};he.forEach(function(De,wr){Nt[wr]={width:De.width,height:De.height,bitrate:De.bitrate,attrs:De.attrs}}),fe.forEach(function(De,wr){Jt[wr]={name:De.name,language:De.lang,bitrate:De.bitrate}});var Ft=di(qe),Ut=Ft.bytesLoaded,Ni=Ft.requestStart,Da=Ft.responseStart,Bt=Ft.responseEnd;we("requestcompleted",it(it({},at(ni)),{},{request_event_type:tt,request_bytes_loaded:Ut,request_start:Ni,request_response_start:Da,request_response_end:Bt,request_type:"manifest",request_hostname:Be(Ue),request_response_headers:zt(yt),request_rendition_lists:{media:Nt,audio:Jt,video:{}}}))};K.on(ee.Events.MANIFEST_LOADED,Ce);var We=function(tt,ue){var he=ue.details,fe=ue.level,Ue=ue.networkDetails,qe=ue.stats,yt=di(qe),ni=yt.bytesLoaded,Nt=yt.requestStart,Jt=yt.responseStart,Ft=yt.responseEnd,Ut=he.fragments[he.fragments.length-1],Ni=Re(Ut)+_e(Ut.duration);we("requestcompleted",{request_event_type:tt,request_bytes_loaded:ni,request_start:Nt,request_response_start:Jt,request_response_end:Ft,request_current_level:fe,request_type:"manifest",request_hostname:Be(he.url),request_response_headers:zt(Ue),video_holdback:he.holdBack&&_e(he.holdBack),video_part_holdback:he.partHoldBack&&_e(he.partHoldBack),video_part_target_duration:he.partTarget&&_e(he.partTarget),video_target_duration:he.targetduration&&_e(he.targetduration),video_source_is_live:he.live,player_manifest_newest_program_time:isNaN(Ni)?void 0:Ni})};K.on(ee.Events.LEVEL_LOADED,We);var Ot=function(tt,ue){var he=ue.details,fe=ue.networkDetails,Ue=ue.stats,qe=di(Ue),yt=qe.bytesLoaded,ni=qe.requestStart,Nt=qe.responseStart,Jt=qe.responseEnd;we("requestcompleted",{request_event_type:tt,request_bytes_loaded:yt,request_start:ni,request_response_start:Nt,request_response_end:Jt,request_type:"manifest",request_hostname:Be(he.url),request_response_headers:zt(fe)})};K.on(ee.Events.AUDIO_TRACK_LOADED,Ot);var Kt=function(tt,ue){var he=ue.stats,fe=ue.networkDetails,Ue=ue.frag;he=he||Ue.stats;var qe=di(he),yt=qe.bytesLoaded,ni=qe.requestStart,Nt=qe.responseStart,Jt=qe.responseEnd,Ft=fe?zt(fe):void 0,Ut={request_event_type:tt,request_bytes_loaded:yt,request_start:ni,request_response_start:Nt,request_response_end:Jt,request_hostname:fe?Be(fe.responseURL):void 0,request_id:Ft?Xe(Ft):void 0,request_response_headers:Ft,request_media_duration:Ue.duration,request_url:fe==null?void 0:fe.responseURL};Ue.type==="main"?(Ut.request_type="media",Ut.request_current_level=Ue.level,Ut.request_video_width=(K.levels[Ue.level]||{}).width,Ut.request_video_height=(K.levels[Ue.level]||{}).height,Ut.request_labeled_bitrate=(K.levels[Ue.level]||{}).bitrate):Ut.request_type=Ue.type,we("requestcompleted",Ut)};K.on(ee.Events.FRAG_LOADED,Kt);var Zt=function(tt,ue){var he=ue.frag,fe=he.start,Ue={currentFragmentPDT:Re(he),currentFragmentStart:_e(fe)};we("fragmentchange",Ue)};K.on(ee.Events.FRAG_CHANGED,Zt);var hi=function(tt,ue){var he=ue.type,fe=ue.details,Ue=ue.response,qe=ue.fatal,yt=ue.frag,ni=ue.networkDetails,Nt=(yt==null?void 0:yt.url)||ue.url||"",Jt=ni?zt(ni):void 0;if(fe!==ee.ErrorDetails.MANIFEST_LOAD_ERROR&&fe!==ee.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&fe!==ee.ErrorDetails.FRAG_LOAD_ERROR&&fe!==ee.ErrorDetails.FRAG_LOAD_TIMEOUT&&fe!==ee.ErrorDetails.LEVEL_LOAD_ERROR&&fe!==ee.ErrorDetails.LEVEL_LOAD_TIMEOUT&&fe!==ee.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&fe!==ee.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&fe!==ee.ErrorDetails.SUBTITLE_LOAD_ERROR&&fe!==ee.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&fe!==ee.ErrorDetails.KEY_LOAD_ERROR&&fe!==ee.ErrorDetails.KEY_LOAD_TIMEOUT||we("requestfailed",{request_error:fe,request_url:Nt,request_hostname:Be(Nt),request_id:Jt?Xe(Jt):void 0,request_type:fe===ee.ErrorDetails.FRAG_LOAD_ERROR||fe===ee.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":fe===ee.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||fe===ee.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":fe===ee.ErrorDetails.SUBTITLE_LOAD_ERROR||fe===ee.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":fe===ee.ErrorDetails.KEY_LOAD_ERROR||fe===ee.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:Ue==null?void 0:Ue.code,request_error_text:Ue==null?void 0:Ue.text}),qe){var Ft,Ut="".concat(Nt?"url: ".concat(Nt,`
|
|
5
|
-
`):"")+"".concat(
|
|
6
|
-
`):"")+"".concat(
|
|
7
|
-
`):"")+"".concat(
|
|
8
|
-
`):"")+"".concat(
|
|
9
|
-
`):"")+"".concat(
|
|
10
|
-
`):"")+"".concat(
|
|
11
|
-
`):"")+"".concat(
|
|
12
|
-
`):"")+"".concat(
|
|
13
|
-
`):"");
|
|
14
|
-
`):"")+"".concat(
|
|
15
|
-
`):"");
|
|
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 hn(_,g){(g==null||g>_.length)&&(g=_.length);for(var T=0,R=new Array(g);T<g;T++)R[T]=_[T];return R}var bi={},kr=function _(g){var T=arguments;typeof g=="string"?_.hasOwnProperty(g)?H().setTimeout(function(){T=Array.prototype.splice.call(T,1),_[g].apply(null,T)},0):ye.warn("`"+g+"` is an unknown task"):typeof g=="function"?H().setTimeout(function(){g(_)},0):ye.warn("`"+g+"` is invalid.")},Xu={loaded:de.now(),NAME:"mux-embed",VERSION:"4.24.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(_,g){return function(T,R,C){var O=un(se(R),3),x=O[0],G=O[1],$=O[2],K=T.log,ee=T.utils.getComputedStyle,Fe=T.utils.secondsToMs;if(!x)return K.error("No element was found with the `"+G+"` query selector.");if($!=="video"&&$!=="audio")return K.error("The element of `"+G+"` was not a media element.");x.mux&&(x.mux.destroy(),delete x.mux,K.warn("Already monitoring this video element, replacing existing event listeners")),(C=Object.assign({automaticErrorTracking:!0},C)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:T.VERSION},C.data),C.getPlayheadTime=function(){return Fe(x.currentTime)},C.getStateData=function(){var Re,we,Ce=this.hlsjs&&this.hlsjs.url,We=this.dashjs&&Sr(this.dashjs.getSource==="function")&&this.dashjs.getSource(),Ot={player_is_paused:x.paused,player_playhead_time:Fe(x.currentTime),player_width:parseInt(ee(x,"width")),player_height:parseInt(ee(x,"height")),player_autoplay_on:x.autoplay,player_preload_on:x.preload,player_language_code:x.lang,player_is_fullscreen:Sa()&&!!(Sa().fullscreenElement||Sa().webkitFullscreenElement||Sa().mozFullScreenElement||Sa().msFullscreenElement),video_poster_url:x.poster,video_source_url:Ce||We||x.currentSrc,video_source_duration:Fe(x.duration),video_source_height:x.videoHeight,video_source_width:x.videoWidth,view_dropped_frame_count:(Re=x)===null||Re===void 0||(we=Re.getVideoPlaybackQuality)===null||we===void 0?void 0:we.call(Re).droppedVideoFrames},Kt=C.getPlayheadTime();if(x.getStartDate&&Kt>0){var Zt=x.getStartDate();if(Zt&&typeof Zt.getTime=="function"&&Zt.getTime()){var hi=Zt.getTime();if(Ot.player_program_time=hi+Kt,x.seekable.length>0){var Ve=hi+x.seekable.end(x.seekable.length-1);Ot.player_live_edge_program_time=Ve}}}return Ot},x.mux=x.mux||{},x.mux.deleted=!1,x.mux.emit=function(Re,we){T.emit(G,Re,we)};var _e=function(){K.error("The monitor for this video element has already been destroyed.")};x.mux.destroy=function(){Object.keys(x.mux.listeners).forEach(function(Re){x.removeEventListener(Re,x.mux.listeners[Re],!1)}),delete x.mux.listeners,x.mux.destroy=_e,x.mux.swapElement=_e,x.mux.emit=_e,x.mux.addHLSJS=_e,x.mux.addDashJS=_e,x.mux.removeHLSJS=_e,x.mux.removeDashJS=_e,x.mux.deleted=!0,T.emit(G,"destroy")},x.mux.swapElement=function(Re){var we=un(se(Re),3),Ce=we[0],We=we[1],Ot=we[2];return Ce?Ot!=="video"&&Ot!=="audio"?T.log.error("The element of `"+We+"` was not a media element."):(Ce.muxId=x.muxId,delete x.muxId,Ce.mux=Ce.mux||{},Ce.mux.listeners=Object.assign({},x.mux.listeners),delete x.mux.listeners,Object.keys(Ce.mux.listeners).forEach(function(Kt){x.removeEventListener(Kt,Ce.mux.listeners[Kt],!1),Ce.addEventListener(Kt,Ce.mux.listeners[Kt],!1)}),Ce.mux.swapElement=x.mux.swapElement,Ce.mux.destroy=x.mux.destroy,delete x.mux,void(x=Ce)):T.log.error("No element was found with the `"+We+"` query selector.")},x.mux.addHLSJS=function(Re){T.addHLSJS(G,Re)},x.mux.addDashJS=function(Re){T.addDashJS(G,Re)},x.mux.removeHLSJS=function(){T.removeHLSJS(G)},x.mux.removeDashJS=function(){T.removeDashJS(G)},T.init(G,C),T.emit(G,"playerready"),x.paused||(T.emit(G,"play"),x.readyState>2&&T.emit(G,"playing")),x.mux.listeners={},$u.forEach(function(Re){(Re!=="error"||C.automaticErrorTracking)&&(x.mux.listeners[Re]=function(){var we={};if(Re==="error"){if(!x.error||x.error.code===1)return;we.player_error_code=x.error.code,we.player_error_message=ju[x.error.code]||x.error.message}T.emit(G,Re,we)},x.addEventListener(Re,x.mux.listeners[Re],!1))})}(kr,_,g)},destroyMonitor:function(_){var g=Ra(se(_),1)[0];g&&g.mux&&typeof g.mux.destroy=="function"?g.mux.destroy():ye.error("A video element monitor for `"+_+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(_,g){var T=Z(_);bi[T]?bi[T].addHLSJS(g):ye.error("A monitor for `"+T+"` has not been initialized.")},addDashJS:function(_,g){var T=Z(_);bi[T]?bi[T].addDashJS(g):ye.error("A monitor for `"+T+"` has not been initialized.")},removeHLSJS:function(_){var g=Z(_);bi[g]?bi[g].removeHLSJS():ye.error("A monitor for `"+g+"` has not been initialized.")},removeDashJS:function(_){var g=Z(_);bi[g]?bi[g].removeDashJS():ye.error("A monitor for `"+g+"` has not been initialized.")},init:function(_,g){Ee()&&g&&g.respectDoNotTrack&&ye.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var T=Z(_);bi[T]=new fs(kr,T,g)},emit:function(_,g,T){var R=Z(_);bi[R]?(bi[R].emit(g,T),g==="destroy"&&delete bi[R]):ye.error("A monitor for `"+R+"` has not been initialized.")},checkDoNotTrack:Ee,log:ye,utils:cn,events:Wo,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(kr,Xu),H()!==void 0&&typeof H().addEventListener=="function"&&H().addEventListener("pagehide",function(_){_.persisted||(kr.WINDOW_UNLOADING=!0)},!1);var qo=kr},655:function(y,I,M){var U,H;function z(J){return z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Z){return typeof Z}:function(Z){return Z&&typeof Symbol=="function"&&Z.constructor===Symbol&&Z!==Symbol.prototype?"symbol":typeof Z},z(J);}(function(J){var Z=!1;if((H=typeof(U=J)=="function"?U.call(I,M,I,y):U)===void 0||(y.exports=H),Z=!0,z(I)==="object"&&(y.exports=J(),Z=!0),!Z){var se=window.Cookies,me=window.Cookies=J();me.noConflict=function(){return window.Cookies=se,me}}})(function(){var J=function(){for(var Z=0,se={};Z<arguments.length;Z++){var me=arguments[Z];for(var Te in me)se[Te]=me[Te]}return se};return function Z(se){function me(Te,ge,ye){var Ee;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(ye=J({path:"/"},me.defaults,ye)).expires=="number"){var de=new Date;de.setMilliseconds(de.getMilliseconds()+864e5*ye.expires),ye.expires=de}try{Ee=JSON.stringify(ge),/^[\{\[]/.test(Ee)&&(ge=Ee)}catch{}return ge=se.write?se.write(ge,Te):encodeURIComponent(String(ge)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),Te=(Te=(Te=encodeURIComponent(String(Te))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[Te,"=",ge,ye.expires?"; expires="+ye.expires.toUTCString():"",ye.path?"; path="+ye.path:"",ye.domain?"; domain="+ye.domain:"",ye.secure?"; secure":""].join("")}Te||(Ee={});for(var Be=document.cookie?document.cookie.split("; "):[],Ge=/(%[0-9A-Z]{2})+/g,re=0;re<Be.length;re++){var k=Be[re].split("="),oe=k.slice(1).join("=");oe.charAt(0)==='"'&&(oe=oe.slice(1,-1));try{var q=k[0].replace(Ge,decodeURIComponent);if(oe=se.read?se.read(oe,q):se(oe,q)||oe.replace(Ge,decodeURIComponent),this.json)try{oe=JSON.parse(oe)}catch{}if(Te===q){Ee=oe;break}Te||(Ee[q]=oe)}catch{}}return Ee}}return me.set=me,me.get=function(Te){return me.call(me,Te)},me.getJSON=function(){return me.apply({json:!0},[].slice.call(arguments))},me.defaults={},me.remove=function(Te,ge){me(Te,"",J(ge,{expires:-1}))},me.withConverter=Z,me}(function(){})})},153:function(y,I,M){var U,H=M.g!==void 0?M.g:typeof window!="undefined"?window:{},z=M(558);typeof document!="undefined"?U=document:(U=H["__GLOBAL_DOCUMENT_CACHE@4"])||(U=H["__GLOBAL_DOCUMENT_CACHE@4"]=z),y.exports=U},48:function(y,I,M){var U;U=typeof window!="undefined"?window:M.g!==void 0?M.g:typeof self!="undefined"?self:{},y.exports=U},640:function(y,I,M){var U,H;(function(z,J){"use strict";U=function(){var Z=function(){},se="undefined",me=typeof window!==se&&typeof window.navigator!==se&&/Trident\/|MSIE /.test(window.navigator.userAgent),Te=["trace","debug","info","warn","error"];function ge(Se,Xe){var at=Se[Xe];if(typeof at.bind=="function")return at.bind(Se);try{return Function.prototype.bind.call(at,Se)}catch{return function(){return Function.prototype.apply.apply(at,[Se,arguments])}}}function ye(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function Ee(Se){return Se==="debug"&&(Se="log"),typeof console!==se&&(Se==="trace"&&me?ye:console[Se]!==void 0?ge(console,Se):console.log!==void 0?ge(console,"log"):Z)}function de(Se,Xe){for(var at=0;at<Te.length;at++){var jt=Te[at];this[jt]=at<Se?Z:this.methodFactory(jt,Se,Xe)}this.log=this.debug}function Be(Se,Xe,at){return function(){typeof console!==se&&(de.call(this,Xe,at),this[Se].apply(this,arguments))}}function Ge(Se,Xe,at){return Ee(Se)||Be.apply(this,arguments)}function re(Se,Xe,at){var jt,it=this;Xe=Xe==null?"WARN":Xe;var B="loglevel";function di($e){var Vt=(Te[$e]||"silent").toUpperCase();if(typeof window!==se&&B){try{return void(window.localStorage[B]=Vt)}catch{}try{window.document.cookie=encodeURIComponent(B)+"="+Vt+";"}catch{}}}function zt(){var $e;if(typeof window!==se&&B){try{$e=window.localStorage[B]}catch{}if(typeof $e===se)try{var Vt=window.document.cookie,Et=Vt.indexOf(encodeURIComponent(B)+"=");Et!==-1&&($e=/^([^;]+)/.exec(Vt.slice(Et))[1])}catch{}return it.levels[$e]===void 0&&($e=void 0),$e}}function nt(){if(typeof window!==se&&B){try{return void window.localStorage.removeItem(B)}catch{}try{window.document.cookie=encodeURIComponent(B)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof Se=="string"?B+=":"+Se:typeof Se=="symbol"&&(B=void 0),it.name=Se,it.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},it.methodFactory=at||Ge,it.getLevel=function(){return jt},it.setLevel=function($e,Vt){if(typeof $e=="string"&&it.levels[$e.toUpperCase()]!==void 0&&($e=it.levels[$e.toUpperCase()]),!(typeof $e=="number"&&$e>=0&&$e<=it.levels.SILENT))throw"log.setLevel() called with invalid level: "+$e;if(jt=$e,Vt!==!1&&di($e),de.call(it,$e,Se),typeof console===se&&$e<it.levels.SILENT)return"No console available for logging"},it.setDefaultLevel=function($e){Xe=$e,zt()||it.setLevel($e,!1)},it.resetLevel=function(){it.setLevel(Xe,!1),nt()},it.enableAll=function($e){it.setLevel(it.levels.TRACE,$e)},it.disableAll=function($e){it.setLevel(it.levels.SILENT,$e)};var ri=zt();ri==null&&(ri=Xe),it.setLevel(ri,!1)}var k=new re,oe={};k.getLogger=function(Se){if(typeof Se!="symbol"&&typeof Se!="string"||Se==="")throw new TypeError("You must supply a name when creating a logger.");var Xe=oe[Se];return Xe||(Xe=oe[Se]=new re(Se,k.getLevel(),k.methodFactory)),Xe};var q=typeof window!==se?window.log:void 0;return k.noConflict=function(){return typeof window!==se&&window.log===k&&(window.log=q),k},k.getLoggers=function(){return oe},k.default=k,k},(H=typeof U=="function"?U.call(I,M,I,y):U)===void 0||(y.exports=H)})()},375:function(y,I){"use strict";var M=Object.prototype.hasOwnProperty;function U(z){try{return decodeURIComponent(z.replace(/\+/g," "))}catch{return null}}function H(z){try{return encodeURIComponent(z)}catch{return null}}I.stringify=function(z,J){J=J||"";var Z,se,me=[];for(se in typeof J!="string"&&(J="?"),z)if(M.call(z,se)){if((Z=z[se])||Z!=null&&!isNaN(Z)||(Z=""),se=H(se),Z=H(Z),se===null||Z===null)continue;me.push(se+"="+Z)}return me.length?J+me.join("&"):""},I.parse=function(z){for(var J,Z=/([^=?#&]+)=?([^&]*)/g,se={};J=Z.exec(z);){var me=U(J[1]),Te=U(J[2]);me===null||Te===null||me in se||(se[me]=Te)}return se}},558:function(){}},m={};function v(y){var I=m[y];if(I!==void 0)return I.exports;var M=m[y]={exports:{}};return o[y].call(M.exports,M,M.exports,v),M.exports}return v.n=function(y){var I=y&&y.__esModule?function(){return y.default}:function(){return y};return v.d(I,{a:I}),I},v.d=function(y,I){for(var M in I)v.o(I,M)&&!v.o(y,M)&&Object.defineProperty(y,M,{enumerable:!0,get:I[M]})},v.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),v.o=function(y,I){return Object.prototype.hasOwnProperty.call(y,I)},v(80)}()},typeof nu=="object"&&typeof Vc=="object"?Vc.exports=r():typeof nu=="object"?nu.mux=r():n.mux=r()})()});var bp=Rf((yp,Kc)=>{(function n(r){var o,m;o=this,m=function(){"use strict";function v(u,s){var e=Object.keys(u);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(u);s&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(u,i).enumerable})),e.push.apply(e,t)}return e}function y(u){for(var s=1;s<arguments.length;s++){var e=arguments[s]!=null?arguments[s]:{};s%2?v(Object(e),!0).forEach(function(t){U(u,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(e)):v(Object(e)).forEach(function(t){Object.defineProperty(u,t,Object.getOwnPropertyDescriptor(e,t))})}return u}function I(u,s){for(var e=0;e<s.length;e++){var t=s[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(u,Ee(t.key),t)}}function M(u,s,e){return s&&I(u.prototype,s),e&&I(u,e),Object.defineProperty(u,"prototype",{writable:!1}),u}function U(u,s,e){return(s=Ee(s))in u?Object.defineProperty(u,s,{value:e,enumerable:!0,configurable:!0,writable:!0}):u[s]=e,u}function H(){return H=Object.assign?Object.assign.bind():function(u){for(var s=1;s<arguments.length;s++){var e=arguments[s];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(u[t]=e[t])}return u},H.apply(this,arguments)}function z(u,s){u.prototype=Object.create(s.prototype),u.prototype.constructor=u,Z(u,s)}function J(u){return J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},J(u)}function Z(u,s){return Z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Z(u,s)}function se(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function me(u,s,e){return me=se()?Reflect.construct.bind():function(t,i,a){var l=[null];l.push.apply(l,i);var d=new(Function.bind.apply(t,l));return a&&Z(d,a.prototype),d},me.apply(null,arguments)}function Te(u){var s=typeof Map=="function"?new Map:void 0;return Te=function(e){if(e===null||(t=e,Function.toString.call(t).indexOf("[native code]")===-1))return e;var t;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(s!==void 0){if(s.has(e))return s.get(e);s.set(e,i)}function i(){return me(e,arguments,J(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Z(i,e)},Te(u)}function ge(u,s){(s==null||s>u.length)&&(s=u.length);for(var e=0,t=new Array(s);e<s;e++)t[e]=u[e];return t}function ye(u,s){var e=typeof Symbol!="undefined"&&u[Symbol.iterator]||u["@@iterator"];if(e)return(e=e.call(u)).next.bind(e);if(Array.isArray(u)||(e=function(i,a){if(i){if(typeof i=="string")return ge(i,a);var l=Object.prototype.toString.call(i).slice(8,-1);return l==="Object"&&i.constructor&&(l=i.constructor.name),l==="Map"||l==="Set"?Array.from(i):l==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?ge(i,a):void 0}}(u))||s&&u&&typeof u.length=="number"){e&&(u=e);var t=0;return function(){return t>=u.length?{done:!0}:{done:!1,value:u[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
20
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ee(u){var s=function(e,t){if(typeof e!="object"||e===null)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var a=i.call(e,t||"default");if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}(u,"string");return typeof s=="symbol"?s:String(s)}function de(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}var Be={exports:{}};(function(u,s){var e,t,i,a,l;e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,l={buildAbsoluteURL:function(d,c,h){if(h=h||{},d=d.trim(),!(c=c.trim())){if(!h.alwaysNormalize)return d;var f=l.parseURL(d);if(!f)throw new Error("Error trying to parse base URL.");return f.path=l.normalizePath(f.path),l.buildURLFromParts(f)}var p=l.parseURL(c);if(!p)throw new Error("Error trying to parse relative URL.");if(p.scheme)return h.alwaysNormalize?(p.path=l.normalizePath(p.path),l.buildURLFromParts(p)):c;var E=l.parseURL(d);if(!E)throw new Error("Error trying to parse base URL.");if(!E.netLoc&&E.path&&E.path[0]!=="/"){var b=t.exec(E.path);E.netLoc=b[1],E.path=b[2]}E.netLoc&&!E.path&&(E.path="/");var A={scheme:E.scheme,netLoc:p.netLoc,path:null,params:p.params,query:p.query,fragment:p.fragment};if(!p.netLoc&&(A.netLoc=E.netLoc,p.path[0]!=="/"))if(p.path){var w=E.path,D=w.substring(0,w.lastIndexOf("/")+1)+p.path;A.path=l.normalizePath(D)}else A.path=E.path,p.params||(A.params=E.params,p.query||(A.query=E.query));return A.path===null&&(A.path=h.alwaysNormalize?l.normalizePath(p.path):p.path),l.buildURLFromParts(A)},parseURL:function(d){var c=e.exec(d);return c?{scheme:c[1]||"",netLoc:c[2]||"",path:c[3]||"",params:c[4]||"",query:c[5]||"",fragment:c[6]||""}:null},normalizePath:function(d){for(d=d.split("").reverse().join("").replace(i,"");d.length!==(d=d.replace(a,"")).length;);return d.split("").reverse().join("")},buildURLFromParts:function(d){return d.scheme+d.netLoc+d.path+d.params+d.query+d.fragment}},u.exports=l})(Be);var Ge=Be.exports,re=Number.isFinite||function(u){return typeof u=="number"&&isFinite(u)},k=function(u){return u.MEDIA_ATTACHING="hlsMediaAttaching",u.MEDIA_ATTACHED="hlsMediaAttached",u.MEDIA_DETACHING="hlsMediaDetaching",u.MEDIA_DETACHED="hlsMediaDetached",u.BUFFER_RESET="hlsBufferReset",u.BUFFER_CODECS="hlsBufferCodecs",u.BUFFER_CREATED="hlsBufferCreated",u.BUFFER_APPENDING="hlsBufferAppending",u.BUFFER_APPENDED="hlsBufferAppended",u.BUFFER_EOS="hlsBufferEos",u.BUFFER_FLUSHING="hlsBufferFlushing",u.BUFFER_FLUSHED="hlsBufferFlushed",u.MANIFEST_LOADING="hlsManifestLoading",u.MANIFEST_LOADED="hlsManifestLoaded",u.MANIFEST_PARSED="hlsManifestParsed",u.LEVEL_SWITCHING="hlsLevelSwitching",u.LEVEL_SWITCHED="hlsLevelSwitched",u.LEVEL_LOADING="hlsLevelLoading",u.LEVEL_LOADED="hlsLevelLoaded",u.LEVEL_UPDATED="hlsLevelUpdated",u.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",u.LEVELS_UPDATED="hlsLevelsUpdated",u.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",u.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",u.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",u.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",u.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",u.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",u.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",u.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",u.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",u.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",u.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",u.CUES_PARSED="hlsCuesParsed",u.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",u.INIT_PTS_FOUND="hlsInitPtsFound",u.FRAG_LOADING="hlsFragLoading",u.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",u.FRAG_LOADED="hlsFragLoaded",u.FRAG_DECRYPTED="hlsFragDecrypted",u.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",u.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",u.FRAG_PARSING_METADATA="hlsFragParsingMetadata",u.FRAG_PARSED="hlsFragParsed",u.FRAG_BUFFERED="hlsFragBuffered",u.FRAG_CHANGED="hlsFragChanged",u.FPS_DROP="hlsFpsDrop",u.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",u.ERROR="hlsError",u.DESTROYING="hlsDestroying",u.KEY_LOADING="hlsKeyLoading",u.KEY_LOADED="hlsKeyLoaded",u.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",u.BACK_BUFFER_REACHED="hlsBackBufferReached",u}({}),oe=function(u){return u.NETWORK_ERROR="networkError",u.MEDIA_ERROR="mediaError",u.KEY_SYSTEM_ERROR="keySystemError",u.MUX_ERROR="muxError",u.OTHER_ERROR="otherError",u}({}),q=function(u){return u.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",u.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",u.KEY_SYSTEM_NO_SESSION="keySystemNoSession",u.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",u.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",u.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",u.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",u.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",u.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",u.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",u.MANIFEST_LOAD_ERROR="manifestLoadError",u.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",u.MANIFEST_PARSING_ERROR="manifestParsingError",u.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",u.LEVEL_EMPTY_ERROR="levelEmptyError",u.LEVEL_LOAD_ERROR="levelLoadError",u.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",u.LEVEL_PARSING_ERROR="levelParsingError",u.LEVEL_SWITCH_ERROR="levelSwitchError",u.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",u.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",u.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",u.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",u.FRAG_LOAD_ERROR="fragLoadError",u.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",u.FRAG_DECRYPT_ERROR="fragDecryptError",u.FRAG_PARSING_ERROR="fragParsingError",u.FRAG_GAP="fragGap",u.REMUX_ALLOC_ERROR="remuxAllocError",u.KEY_LOAD_ERROR="keyLoadError",u.KEY_LOAD_TIMEOUT="keyLoadTimeOut",u.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",u.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",u.BUFFER_APPEND_ERROR="bufferAppendError",u.BUFFER_APPENDING_ERROR="bufferAppendingError",u.BUFFER_STALLED_ERROR="bufferStalledError",u.BUFFER_FULL_ERROR="bufferFullError",u.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",u.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",u.INTERNAL_EXCEPTION="internalException",u.INTERNAL_ABORTED="aborted",u.UNKNOWN="unknown",u}({}),Se=function(){},Xe={trace:Se,debug:Se,log:Se,warn:Se,info:Se,error:Se},at=Xe;function jt(u){var s=self.console[u];return s?s.bind(self.console,"["+u+"] >"):Se}function it(u,s){if(self.console&&u===!0||typeof u=="object"){(function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),a=1;a<t;a++)i[a-1]=arguments[a];i.forEach(function(l){at[l]=e[l]?e[l].bind(e):jt(l)})})(u,"debug","log","info","warn","error");try{at.log('Debug logs enabled for "'+s+'" in hls.js version 1.4.5')}catch{at=Xe}}else at=Xe}var B=at,di=/^(\d+)x(\d+)$/,zt=/(.+?)=(".*?"|.*?)(?:,|$)/g,nt=function(){function u(e){for(var t in typeof e=="string"&&(e=u.parseAttrList(e)),e)e.hasOwnProperty(t)&&(t.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}var s=u.prototype;return s.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},s.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var i=new Uint8Array(t.length/2),a=0;a<t.length/2;a++)i[a]=parseInt(t.slice(2*a,2*a+2),16);return i}return null},s.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},s.decimalFloatingPoint=function(e){return parseFloat(this[e])},s.optionalFloat=function(e,t){var i=this[e];return i?parseFloat(i):t},s.enumeratedString=function(e){return this[e]},s.bool=function(e){return this[e]==="YES"},s.decimalResolution=function(e){var t=di.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},u.parseAttrList=function(e){var t,i={};for(zt.lastIndex=0;(t=zt.exec(e))!==null;){var a=t[2];a.indexOf('"')===0&&a.lastIndexOf('"')===a.length-1&&(a=a.slice(1,-1)),i[t[1].trim()]=a}return i},u}();function ri(u){return u==="SCTE35-OUT"||u==="SCTE35-IN"}var $e=function(){function u(s,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var t=e.attr;for(var i in t)if(Object.prototype.hasOwnProperty.call(s,i)&&s[i]!==t[i]){B.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+s.ID+'"'),this._badValueForSameId=i;break}s=H(new nt({}),t,s)}if(this.attr=s,this._startDate=new Date(s["START-DATE"]),"END-DATE"in this.attr){var a=new Date(this.attr["END-DATE"]);re(a.getTime())&&(this._endDate=a)}}return M(u,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var s=this.duration;return s!==null?new Date(this._startDate.getTime()+1e3*s):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var s=this.attr.decimalFloatingPoint("DURATION");if(re(s))return s}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&re(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),u}(),Vt=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},Et="audio",Mt="video",rr="audiovideo",te=function(){function u(s){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[Et]=null,e[Mt]=null,e[rr]=null,e),this.baseurl=s}return u.prototype.setByteRange=function(s,e){var t=s.split("@",2),i=[];t.length===1?i[0]=e?e.byteRangeEndOffset:0:i[0]=parseInt(t[1]),i[1]=parseInt(t[0])+i[0],this._byteRange=i},M(u,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Ge.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(s){this._url=s}}]),u}(),ke=function(u){function s(t,i){var a;return(a=u.call(this,i)||this)._decryptdata=null,a.rawProgramDateTime=null,a.programDateTime=null,a.tagList=[],a.duration=0,a.sn=0,a.levelkeys=void 0,a.type=void 0,a.loader=null,a.keyLoader=null,a.level=-1,a.cc=0,a.startPTS=void 0,a.endPTS=void 0,a.startDTS=void 0,a.endDTS=void 0,a.start=0,a.deltaPTS=void 0,a.maxStartPTS=void 0,a.minEndPTS=void 0,a.stats=new Vt,a.urlId=0,a.data=void 0,a.bitrateTest=!1,a.title=null,a.initSegment=null,a.endList=void 0,a.gap=void 0,a.type=t,a}z(s,u);var e=s.prototype;return e.setKeyFormat=function(t){if(this.levelkeys){var i=this.levelkeys[t];i&&!this._decryptdata&&(this._decryptdata=i.getDecryptData(this.sn))}},e.abortRequests=function(){var t,i;(t=this.loader)==null||t.abort(),(i=this.keyLoader)==null||i.abort()},e.setElementaryStreamInfo=function(t,i,a,l,d,c){c===void 0&&(c=!1);var h=this.elementaryStreams,f=h[t];f?(f.startPTS=Math.min(f.startPTS,i),f.endPTS=Math.max(f.endPTS,a),f.startDTS=Math.min(f.startDTS,l),f.endDTS=Math.max(f.endDTS,d)):h[t]={startPTS:i,endPTS:a,startDTS:l,endDTS:d,partial:c}},e.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[Et]=null,t[Mt]=null,t[rr]=null},M(s,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{var i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!re(this.programDateTime))return null;var t=re(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){var i=Object.keys(this.levelkeys),a=i.length;if(a>1||a===1&&this.levelkeys[i[0]].encrypted)return!0}return!1}}]),s}(te),st=function(u){function s(e,t,i,a,l){var d;(d=u.call(this,i)||this).fragOffset=0,d.duration=0,d.gap=!1,d.independent=!1,d.relurl=void 0,d.fragment=void 0,d.index=void 0,d.stats=new Vt,d.duration=e.decimalFloatingPoint("DURATION"),d.gap=e.bool("GAP"),d.independent=e.bool("INDEPENDENT"),d.relurl=e.enumeratedString("URI"),d.fragment=t,d.index=a;var c=e.enumeratedString("BYTERANGE");return c&&d.setByteRange(c,l),l&&(d.fragOffset=l.fragOffset+l.duration),d}return z(s,u),M(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),s}(te),Lt=function(){function u(s){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=s}return u.prototype.reloaded=function(s){if(!s)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-s.lastPartSn,t=this.lastPartIndex-s.lastPartIndex;this.updated=this.endSN!==s.endSN||!!t||!!e,this.advanced=this.endSN>s.endSN||e>0||e===0&&t>0,this.updated||this.advanced?this.misses=Math.floor(.6*s.misses):this.misses=s.misses+1,this.availabilityDelay=s.availabilityDelay},M(u,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&re(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var s=this.driftEndTime-this.driftStartTime;return s>0?1e3*(this.driftEnd-this.driftStart)/s:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var s;return(s=this.partList)!=null&&s.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var s;return(s=this.fragments)!=null&&s.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var s;return(s=this.partList)!=null&&s.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var s;return(s=this.partList)!=null&&s.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),u}();function Rt(u){return Uint8Array.from(atob(u),function(s){return s.charCodeAt(0)})}function ci(u){var s,e,t=u.split(":"),i=null;if(t[0]==="data"&&t.length===2){var a=t[1].split(";"),l=a[a.length-1].split(",");if(l.length===2){var d=l[0]==="base64",c=l[1];d?(a.splice(-1,1),i=Rt(c)):(s=$i(c).subarray(0,16),(e=new Uint8Array(16)).set(s,16-s.length),i=e)}}return i}function $i(u){return Uint8Array.from(unescape(encodeURIComponent(u)),function(s){return s.charCodeAt(0)})}var Ze={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},vi="org.w3.clearkey",gi="com.apple.streamingkeydelivery",ji="com.microsoft.playready",ar="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function Ei(u){switch(u){case gi:return Ze.FAIRPLAY;case ji:return Ze.PLAYREADY;case ar:return Ze.WIDEVINE;case vi:return Ze.CLEARKEY}}var ft="edef8ba979d64acea3c827dcd51d21ed";function nr(u){switch(u){case Ze.FAIRPLAY:return gi;case Ze.PLAYREADY:return ji;case Ze.WIDEVINE:return ar;case Ze.CLEARKEY:return vi}}function yr(u){var s=u.drmSystems,e=u.widevineLicenseUrl,t=s?[Ze.FAIRPLAY,Ze.WIDEVINE,Ze.PLAYREADY,Ze.CLEARKEY].filter(function(i){return!!s[i]}):[];return!t[Ze.WIDEVINE]&&e&&t.push(Ze.WIDEVINE),t}var $r=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function xi(u,s,e){return Uint8Array.prototype.slice?u.slice(s,e):new Uint8Array(Array.prototype.slice.call(u,s,e))}var br,ts=function(u,s){return s+10<=u.length&&u[s]===73&&u[s+1]===68&&u[s+2]===51&&u[s+3]<255&&u[s+4]<255&&u[s+6]<128&&u[s+7]<128&&u[s+8]<128&&u[s+9]<128},vo=function(u,s){return s+10<=u.length&&u[s]===51&&u[s+1]===68&&u[s+2]===73&&u[s+3]<255&&u[s+4]<255&&u[s+6]<128&&u[s+7]<128&&u[s+8]<128&&u[s+9]<128},ga=function(u,s){for(var e=s,t=0;ts(u,s);)t+=10,t+=nn(u,s+6),vo(u,s+10)&&(t+=10),s+=t;if(t>0)return u.subarray(e,e+t)},nn=function(u,s){var e=0;return e=(127&u[s])<<21,e|=(127&u[s+1])<<14,e|=(127&u[s+2])<<7,e|=127&u[s+3]},go=function(u,s){return ts(u,s)&&nn(u,s+6)+10<=u.length-s},Eo=function(u){return u&&u.key==="PRIV"&&u.info==="com.apple.streaming.transportStreamTimestamp"},Uu=function(u){var s=String.fromCharCode(u[0],u[1],u[2],u[3]),e=nn(u,4);return{type:s,size:e,data:u.subarray(10,10+e)}},is=function(u){for(var s=0,e=[];ts(u,s);){for(var t=nn(u,s+6),i=(s+=10)+t;s+8<i;){var a=Uu(u.subarray(s)),l=Bu(a);l&&e.push(l),s+=a.size+10}vo(u,s)&&(s+=10)}return e},Bu=function(u){return u.type==="PRIV"?Hu(u):u.type[0]==="W"?bo(u):yo(u)},Hu=function(u){if(!(u.size<2)){var s=Ii(u.data,!0),e=new Uint8Array(u.data.subarray(s.length+1));return{key:u.type,info:s,data:e.buffer}}},yo=function(u){if(!(u.size<2)){if(u.type==="TXXX"){var s=1,e=Ii(u.data.subarray(s),!0);s+=e.length+1;var t=Ii(u.data.subarray(s));return{key:u.type,info:e,data:t}}var i=Ii(u.data.subarray(1));return{key:u.type,data:i}}},bo=function(u){if(u.type==="WXXX"){if(u.size<2)return;var s=1,e=Ii(u.data.subarray(s),!0);s+=e.length+1;var t=Ii(u.data.subarray(s));return{key:u.type,info:e,data:t}}var i=Ii(u.data);return{key:u.type,data:i}},To=function(u){if(u.data.byteLength===8){var s=new Uint8Array(u.data),e=1&s[3],t=(s[4]<<23)+(s[5]<<15)+(s[6]<<7)+s[7];return t/=45,e&&(t+=4772185884e-2),Math.round(t)}},Ii=function(u,s){s===void 0&&(s=!1);var e=Gu();if(e){var t=e.decode(u);if(s){var i=t.indexOf("\0");return i!==-1?t.substring(0,i):t}return t.replace(/\0/g,"")}for(var a,l,d,c=u.length,h="",f=0;f<c;){if((a=u[f++])===0&&s)return h;if(a!==0&&a!==3)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:h+=String.fromCharCode(a);break;case 12:case 13:l=u[f++],h+=String.fromCharCode((31&a)<<6|63&l);break;case 14:l=u[f++],d=u[f++],h+=String.fromCharCode((15&a)<<12|(63&l)<<6|(63&d)<<0)}}return h};function Gu(){return br||self.TextDecoder===void 0||(br=new self.TextDecoder("utf-8")),br}var Pi=function(u){for(var s="",e=0;e<u.length;e++){var t=u[e].toString(16);t.length<2&&(t="0"+t),s+=t}return s},Ea=Math.pow(2,32)-1,Vu=[].push,_o={video:1,audio:2,id3:3,text:4};function xt(u){return String.fromCharCode.apply(null,u)}function Ao(u,s){var e=u[s]<<8|u[s+1];return e<0?65536+e:e}function He(u,s){var e=rs(u,s);return e<0?4294967296+e:e}function rs(u,s){return u[s]<<24|u[s+1]<<16|u[s+2]<<8|u[s+3]}function as(u,s,e){u[s]=e>>24,u[s+1]=e>>16&255,u[s+2]=e>>8&255,u[s+3]=255&e}function Je(u,s){var e=[];if(!s.length)return e;for(var t=u.byteLength,i=0;i<t;){var a=He(u,i),l=a>1?i+a:t;if(xt(u.subarray(i+4,i+8))===s[0])if(s.length===1)e.push(u.subarray(i+8,l));else{var d=Je(u.subarray(i+8,l),s.slice(1));d.length&&Vu.apply(e,d)}i=l}return e}function So(u){var s=[],e=u[0],t=8,i=He(u,t);t+=4,t+=e===0?8:16,t+=2;var a=u.length+0,l=Ao(u,t);t+=2;for(var d=0;d<l;d++){var c=t,h=He(u,c);c+=4;var f=2147483647&h;if((2147483648&h)>>>31==1)return B.warn("SIDX has hierarchical references (not supported)"),null;var p=He(u,c);c+=4,s.push({referenceSize:f,subsegmentDuration:p,info:{duration:p/i,start:a,end:a+f-1}}),a+=f,t=c+=4}return{earliestPresentationTime:0,timescale:i,version:e,referencesCount:l,references:s}}function ns(u){for(var s=[],e=Je(u,["moov","trak"]),t=0;t<e.length;t++){var i=e[t],a=Je(i,["tkhd"])[0];if(a){var l=a[0],d=l===0?12:20,c=He(a,d),h=Je(i,["mdia","mdhd"])[0];if(h){var f=He(h,d=(l=h[0])===0?12:20),p=Je(i,["mdia","hdlr"])[0];if(p){var E=xt(p.subarray(8,12)),b={soun:Et,vide:Mt}[E];if(b){var A=Je(i,["mdia","minf","stbl","stsd"])[0],w=void 0;A&&(w=xt(A.subarray(12,16))),s[c]={timescale:f,type:b},s[b]={timescale:f,id:c,codec:w}}}}}}return Je(u,["moov","mvex","trex"]).forEach(function(D){var S=He(D,4),L=s[S];L&&(L.default={duration:He(D,12),flags:He(D,20)})}),s}function ss(u){var s=Je(u,["schm"])[0];if(s){var e=xt(s.subarray(4,8));if(e==="cbcs"||e==="cenc")return Je(u,["schi","tenc"])[0]}return B.error("[eme] missing 'schm' box"),null}function Ku(u){var s=He(u,0),e=8;1&s&&(e+=4),4&s&&(e+=4);for(var t=0,i=He(u,4),a=0;a<i;a++)256&s&&(t+=He(u,e),e+=4),512&s&&(e+=4),1024&s&&(e+=4),2048&s&&(e+=4);return t}function Tr(u,s){var e=new Uint8Array(u.length+s.length);return e.set(u),e.set(s,u.length),e}function os(u,s){var e=[],t=s.samples,i=s.timescale,a=s.id,l=!1;return Je(t,["moof"]).map(function(d){var c=d.byteOffset-8;Je(d,["traf"]).map(function(h){var f=Je(h,["tfdt"]).map(function(p){var E=p[0],b=He(p,4);return E===1&&(b*=Math.pow(2,32),b+=He(p,8)),b/i})[0];return f!==void 0&&(u=f),Je(h,["tfhd"]).map(function(p){var E=He(p,4),b=16777215&He(p,0),A=0,w=(16&b)!=0,D=0,S=(32&b)!=0,L=8;E===a&&((1&b)!=0&&(L+=8),(2&b)!=0&&(L+=4),(8&b)!=0&&(A=He(p,L),L+=4),w&&(D=He(p,L),L+=4),S&&(L+=4),s.type==="video"&&(l=function(N){if(!N)return!1;var P=N.indexOf("."),V=P<0?N:N.substring(0,P);return V==="hvc1"||V==="hev1"||V==="dvh1"||V==="dvhe"}(s.codec)),Je(h,["trun"]).map(function(N){var P=N[0],V=16777215&He(N,0),Y=(1&V)!=0,j=0,ie=(4&V)!=0,Q=(256&V)!=0,X=0,ce=(512&V)!=0,le=0,Ae=(1024&V)!=0,xe=(2048&V)!=0,Le=0,Me=He(N,4),Oe=8;Y&&(j=He(N,Oe),Oe+=4),ie&&(Oe+=4);for(var Pe=j+c,Ke=0;Ke<Me;Ke++){if(Q?(X=He(N,Oe),Oe+=4):X=A,ce?(le=He(N,Oe),Oe+=4):le=D,Ae&&(Oe+=4),xe&&(Le=P===0?He(N,Oe):rs(N,Oe),Oe+=4),s.type===Mt)for(var je=0;je<le;){var et=He(t,Pe);ko(l,t[Pe+=4])&&wo(t.subarray(Pe,Pe+et),l?2:1,u+Le/i,e),Pe+=et,je+=et+4}u+=X/i}}))})})}),e}function ko(u,s){if(u){var e=s>>1&63;return e===39||e===40}return(31&s)==6}function wo(u,s,e,t){var i=Lo(u),a=0;a+=s;for(var l=0,d=0,c=!1,h=0;a<i.length;){l=0;do{if(a>=i.length)break;l+=h=i[a++]}while(h===255);d=0;do{if(a>=i.length)break;d+=h=i[a++]}while(h===255);var f=i.length-a;if(!c&&l===4&&a<i.length){if(c=!0,i[a++]===181){var p=Ao(i,a);if(a+=2,p===49){var E=He(i,a);if(a+=4,E===1195456820){var b=i[a++];if(b===3){var A=i[a++],w=64&A,D=w?2+3*(31&A):0,S=new Uint8Array(D);if(w){S[0]=A;for(var L=1;L<D;L++)S[L]=i[a++]}t.push({type:b,payloadType:l,pts:e,bytes:S})}}}}}else if(l===5&&d<f){if(c=!0,d>16){for(var N=[],P=0;P<16;P++){var V=i[a++].toString(16);N.push(V.length==1?"0"+V:V),P!==3&&P!==5&&P!==7&&P!==9||N.push("-")}for(var Y=d-16,j=new Uint8Array(Y),ie=0;ie<Y;ie++)j[ie]=i[a++];t.push({payloadType:l,pts:e,uuid:N.join(""),userData:Ii(j),userDataBytes:j})}}else if(d<f)a+=d;else if(d>f)break}}function Lo(u){for(var s=u.byteLength,e=[],t=1;t<s-2;)u[t]===0&&u[t+1]===0&&u[t+2]===3?(e.push(t+2),t+=2):t++;if(e.length===0)return u;var i=s-e.length,a=new Uint8Array(i),l=0;for(t=0;t<i;l++,t++)l===e[0]&&(l++,e.shift()),a[t]=u[l];return a}function Io(u,s,e){if(u.byteLength!==16)throw new RangeError("Invalid system id");var t,i,a;if(s){t=1,i=new Uint8Array(16*s.length);for(var l=0;l<s.length;l++){var d=s[l];if(d.byteLength!==16)throw new RangeError("Invalid key");i.set(d,16*l)}}else t=0,i=new Uint8Array;t>0?(a=new Uint8Array(4),s.length>0&&new DataView(a.buffer).setUint32(0,s.length,!1)):a=new Uint8Array;var c=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(c.buffer).setUint32(0,e.byteLength,!1),function(h){for(var f=arguments.length,p=new Array(f>1?f-1:0),E=1;E<f;E++)p[E-1]=arguments[E];for(var b=p.length,A=8,w=b;w--;)A+=p[w].byteLength;var D=new Uint8Array(A);for(D[0]=A>>24&255,D[1]=A>>16&255,D[2]=A>>8&255,D[3]=255&A,D.set(h,4),w=0,A=8;w<b;w++)D.set(p[w],A),A+=p[w].byteLength;return D}([112,115,115,104],new Uint8Array([t,0,0,0]),u,a,i,c,e||new Uint8Array)}var ya={},ba=function(){function u(e,t,i,a,l){a===void 0&&(a=[1]),l===void 0&&(l=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=a,this.iv=l,this.encrypted=!!e&&e!=="NONE",this.isCommonEncryption=this.encrypted&&e!=="AES-128"}u.clearKeyUriToKeyIdMap=function(){ya={}};var s=u.prototype;return s.isSupported=function(){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 gi:case ar:case ji:case vi:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},s.getDecryptData=function(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||B.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=function(D){for(var S=new Uint8Array(16),L=12;L<16;L++)S[L]=D>>8*(15-L)&255;return S}(e);return new u(this.method,this.uri,"identity",this.keyFormatVersions,t)}var i=ci(this.uri);if(i)switch(this.keyFormat){case ar:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case ji:var a=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Io(a,null,i);var l=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2),d=String.fromCharCode.apply(null,Array.from(l)),c=d.substring(d.indexOf("<"),d.length),h=new DOMParser().parseFromString(c,"text/xml").getElementsByTagName("KID")[0];if(h){var f=h.childNodes[0]?h.childNodes[0].nodeValue:h.getAttribute("VALUE");if(f){var p=Rt(f).subarray(0,16);(function(D){var S=function(L,N,P){var V=L[N];L[N]=L[P],L[P]=V};S(D,0,3),S(D,1,2),S(D,4,5),S(D,6,7)})(p),this.keyId=p}}break;default:var E=i.subarray(0,16);if(E.length!==16){var b=new Uint8Array(16);b.set(E,16-E.length),E=b}this.keyId=E}if(!this.keyId||this.keyId.byteLength!==16){var A=ya[this.uri];if(!A){var w=Object.keys(ya).length%Number.MAX_SAFE_INTEGER;A=new Uint8Array(16),new DataView(A.buffer,12,4).setUint32(0,w),ya[this.uri]=A}this.keyId=A}return this},u}(),Ro=/\{\$([a-zA-Z0-9-_]+)\}/g;function Do(u){return Ro.test(u)}function ai(u,s,e){if(u.variableList!==null||u.hasVariableRefs)for(var t=e.length;t--;){var i=e[t],a=s[i];a&&(s[i]=Ri(u,a))}}function Ri(u,s){if(u.variableList!==null||u.hasVariableRefs){var e=u.variableList;return s.replace(Ro,function(t){var i=t.substring(2,t.length-1),a=e==null?void 0:e[i];return a===void 0?(u.playlistParsingError||(u.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+i+'"')),t):a})}return s}function Co(u,s,e){var t,i,a=u.variableList;if(a||(u.variableList=a={}),"QUERYPARAM"in s){t=s.QUERYPARAM;try{var l=new self.URL(e).searchParams;if(!l.has(t))throw new Error('"'+t+'" does not match any query parameter in URI: "'+e+'"');i=l.get(t)}catch(d){u.playlistParsingError||(u.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+d.message))}}else t=s.NAME,i=s.VALUE;t in a?u.playlistParsingError||(u.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+t+'"')):a[t]=i||""}function Mo(u,s,e){var t=s.IMPORT;if(e&&t in e){var i=u.variableList;i||(u.variableList=i={}),i[t]=e[t]}else u.playlistParsingError||(u.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+t+'"'))}function sn(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}var Wu={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}},ls=sn();function on(u,s){var e;return(e=ls==null?void 0:ls.isTypeSupported((s||"video")+'/mp4;codecs="'+u+'"'))!=null&&e}var _r=/#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,jr=/#EXT-X-MEDIA:(.*)/g,qu=/^#EXT(?:INF|-X-TARGETDURATION):/m,us=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ln=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("|")),Ta=function(){function u(){}return u.findGroup=function(s,e){for(var t=0;t<s.length;t++){var i=s[t];if(i.id===e)return i}},u.convertAVC1ToAVCOTI=function(s){var e=s.split(".");if(e.length>2){var t=e.shift()+".";return t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4)}return s},u.resolve=function(s,e){return Ge.buildAbsoluteURL(e,s,{alwaysNormalize:!0})},u.isMediaPlaylist=function(s){return qu.test(s)},u.parseMasterPlaylist=function(s,e){var t,i={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Do(s)},a=[];for(_r.lastIndex=0;(t=_r.exec(s))!=null;)if(t[1]){var l,d=new nt(t[1]);ai(i,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var c=Ri(i,t[2]),h={attrs:d,bitrate:d.decimalInteger("AVERAGE-BANDWIDTH")||d.decimalInteger("BANDWIDTH"),name:d.NAME,url:u.resolve(c,e)},f=d.decimalResolution("RESOLUTION");f&&(h.width=f.width,h.height=f.height),Yu((d.CODECS||"").split(/[ ,]+/).filter(function(N){return N}),h),h.videoCodec&&h.videoCodec.indexOf("avc1")!==-1&&(h.videoCodec=u.convertAVC1ToAVCOTI(h.videoCodec)),(l=h.unknownCodecs)!=null&&l.length||a.push(h),i.levels.push(h)}else if(t[3]){var p=t[3],E=t[4];switch(p){case"SESSION-DATA":var b=new nt(E);ai(i,b,["DATA-ID","LANGUAGE","VALUE","URI"]);var A=b["DATA-ID"];A&&(i.sessionData===null&&(i.sessionData={}),i.sessionData[A]=b);break;case"SESSION-KEY":var w=xo(E,e,i);w.encrypted&&w.isSupported()?(i.sessionKeys===null&&(i.sessionKeys=[]),i.sessionKeys.push(w)):B.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+E+'"');break;case"DEFINE":var D=new nt(E);ai(i,D,["NAME","VALUE","QUERYPARAM"]),Co(i,D,e);break;case"CONTENT-STEERING":var S=new nt(E);ai(i,S,["SERVER-URI","PATHWAY-ID"]),i.contentSteering={uri:u.resolve(S["SERVER-URI"],e),pathwayId:S["PATHWAY-ID"]||"."};break;case"START":i.startTimeOffset=Po(E)}}var L=a.length>0&&a.length<i.levels.length;return i.levels=L?a:i.levels,i.levels.length===0&&(i.playlistParsingError=new Error("no levels found in manifest")),i},u.parseMasterPlaylistMedia=function(s,e,t){var i,a={},l=t.levels,d={AUDIO:l.map(function(w){return{id:w.attrs.AUDIO,audioCodec:w.audioCodec}}),SUBTITLES:l.map(function(w){return{id:w.attrs.SUBTITLES,textCodec:w.textCodec}}),"CLOSED-CAPTIONS":[]},c=0;for(jr.lastIndex=0;(i=jr.exec(s))!==null;){var h=new nt(i[1]),f=h.TYPE;if(f){var p=d[f],E=a[f]||[];a[f]=E,ai(t,h,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var b={attrs:h,bitrate:0,id:c++,groupId:h["GROUP-ID"]||"",instreamId:h["INSTREAM-ID"],name:h.NAME||h.LANGUAGE||"",type:f,default:h.bool("DEFAULT"),autoselect:h.bool("AUTOSELECT"),forced:h.bool("FORCED"),lang:h.LANGUAGE,url:h.URI?u.resolve(h.URI,e):""};if(p!=null&&p.length){var A=u.findGroup(p,b.groupId)||p[0];ds(b,A,"audioCodec"),ds(b,A,"textCodec")}E.push(b)}}return a},u.parseLevelPlaylist=function(s,e,t,i,a,l){var d,c,h,f=new Lt(e),p=f.fragments,E=null,b=0,A=0,w=0,D=0,S=null,L=new ke(i,e),N=-1,P=!1;for(us.lastIndex=0,f.m3u8=s,f.hasVariableRefs=Do(s);(d=us.exec(s))!==null;){P&&(P=!1,(L=new ke(i,e)).start=w,L.sn=b,L.cc=D,L.level=t,E&&(L.initSegment=E,L.rawProgramDateTime=E.rawProgramDateTime,E.rawProgramDateTime=null));var V=d[1];if(V){L.duration=parseFloat(V);var Y=(" "+d[2]).slice(1);L.title=Y||null,L.tagList.push(Y?["INF",V,Y]:["INF",V])}else if(d[3]){if(re(L.duration)){L.start=w,h&&cs(L,h,f),L.sn=b,L.level=t,L.cc=D,L.urlId=a,p.push(L);var j=(" "+d[3]).slice(1);L.relurl=Ri(f,j),Oo(L,S),S=L,w+=L.duration,b++,A=0,P=!0}}else if(d[4]){var ie=(" "+d[4]).slice(1);S?L.setByteRange(ie,S):L.setByteRange(ie)}else if(d[5])L.rawProgramDateTime=(" "+d[5]).slice(1),L.tagList.push(["PROGRAM-DATE-TIME",L.rawProgramDateTime]),N===-1&&(N=p.length);else{if(!(d=d[0].match(ln))){B.warn("No matches on slow regex match for level playlist!");continue}for(c=1;c<d.length&&d[c]===void 0;c++);var Q=(" "+d[c]).slice(1),X=(" "+d[c+1]).slice(1),ce=d[c+2]?(" "+d[c+2]).slice(1):"";switch(Q){case"PLAYLIST-TYPE":f.type=X.toUpperCase();break;case"MEDIA-SEQUENCE":b=f.startSN=parseInt(X);break;case"SKIP":var le=new nt(X);ai(f,le,["RECENTLY-REMOVED-DATERANGES"]);var Ae=le.decimalInteger("SKIPPED-SEGMENTS");if(re(Ae)){f.skippedSegments=Ae;for(var xe=Ae;xe--;)p.unshift(null);b+=Ae}var Le=le.enumeratedString("RECENTLY-REMOVED-DATERANGES");Le&&(f.recentlyRemovedDateranges=Le.split(" "));break;case"TARGETDURATION":f.targetduration=Math.max(parseInt(X),1);break;case"VERSION":f.version=parseInt(X);break;case"EXTM3U":break;case"ENDLIST":f.live=!1;break;case"#":(X||ce)&&L.tagList.push(ce?[X,ce]:[X]);break;case"DISCONTINUITY":D++,L.tagList.push(["DIS"]);break;case"GAP":L.gap=!0,L.tagList.push([Q]);break;case"BITRATE":L.tagList.push([Q,X]);break;case"DATERANGE":var Me=new nt(X);ai(f,Me,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),ai(f,Me,Me.clientAttrs);var Oe=new $e(Me,f.dateRanges[Me.ID]);Oe.isValid||f.skippedSegments?f.dateRanges[Oe.id]=Oe:B.warn('Ignoring invalid DATERANGE tag: "'+X+'"'),L.tagList.push(["EXT-X-DATERANGE",X]);break;case"DEFINE":var Pe=new nt(X);ai(f,Pe,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in Pe?Mo(f,Pe,l):Co(f,Pe,e);break;case"DISCONTINUITY-SEQUENCE":D=parseInt(X);break;case"KEY":var Ke=xo(X,e,f);if(Ke.isSupported()){if(Ke.method==="NONE"){h=void 0;break}h||(h={}),h[Ke.keyFormat]&&(h=H({},h)),h[Ke.keyFormat]=Ke}else B.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+X+'"');break;case"START":f.startTimeOffset=Po(X);break;case"MAP":var je=new nt(X);if(ai(f,je,["BYTERANGE","URI"]),L.duration){var et=new ke(i,e);No(et,je,t,h),E=et,L.initSegment=E,E.rawProgramDateTime&&!L.rawProgramDateTime&&(L.rawProgramDateTime=E.rawProgramDateTime)}else No(L,je,t,h),E=L,P=!0;break;case"SERVER-CONTROL":var lt=new nt(X);f.canBlockReload=lt.bool("CAN-BLOCK-RELOAD"),f.canSkipUntil=lt.optionalFloat("CAN-SKIP-UNTIL",0),f.canSkipDateRanges=f.canSkipUntil>0&<.bool("CAN-SKIP-DATERANGES"),f.partHoldBack=lt.optionalFloat("PART-HOLD-BACK",0),f.holdBack=lt.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var _i=new nt(X);f.partTarget=_i.decimalFloatingPoint("PART-TARGET");break;case"PART":var Wt=f.partList;Wt||(Wt=f.partList=[]);var Qi=A>0?Wt[Wt.length-1]:void 0,Bi=A++,Hi=new nt(X);ai(f,Hi,["BYTERANGE","URI"]);var qt=new st(Hi,L,e,Bi,Qi);Wt.push(qt),L.duration+=qt.duration;break;case"PRELOAD-HINT":var ti=new nt(X);ai(f,ti,["URI"]),f.preloadHint=ti;break;case"RENDITION-REPORT":var lr=new nt(X);ai(f,lr,["URI"]),f.renditionReports=f.renditionReports||[],f.renditionReports.push(lr);break;default:B.warn("line parsed but not handled: "+d)}}}S&&!S.relurl?(p.pop(),w-=S.duration,f.partList&&(f.fragmentHint=S)):f.partList&&(Oo(L,S),L.cc=D,f.fragmentHint=L,h&&cs(L,h,f));var ea=p.length,Ci=p[0],As=p[ea-1];if((w+=f.skippedSegments*f.targetduration)>0&&ea&&As){f.averagetargetduration=w/ea;var Ss=As.sn;f.endSN=Ss!=="initSegment"?Ss:0,f.live||(As.endList=!0),Ci&&(f.startCC=Ci.cc)}else f.endSN=0,f.startCC=0;return f.fragmentHint&&(w+=f.fragmentHint.duration),f.totalduration=w,f.endCC=D,N>0&&function(il,En){for(var Oa=il[En],ks=En;ks--;){var Dr=il[ks];if(!Dr)return;Dr.programDateTime=Oa.programDateTime-1e3*Dr.duration,Oa=Dr}}(p,N),f},u}();function xo(u,s,e){var t,i,a=new nt(u);ai(e,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var l=(t=a.METHOD)!=null?t:"",d=a.URI,c=a.hexadecimalInteger("IV"),h=a.KEYFORMATVERSIONS,f=(i=a.KEYFORMAT)!=null?i:"identity";d&&a.IV&&!c&&B.error("Invalid IV: "+a.IV);var p=d?Ta.resolve(d,s):"",E=(h||"1").split("/").map(Number).filter(Number.isFinite);return new ba(l,p,f,E,c)}function Po(u){var s=new nt(u).decimalFloatingPoint("TIME-OFFSET");return re(s)?s:null}function Yu(u,s){["video","audio","text"].forEach(function(e){var t=u.filter(function(a){return function(l,d){var c=Wu[d];return!!c&&c[l.slice(0,4)]===!0}(a,e)});if(t.length){var i=t.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});s[e+"Codec"]=i.length>0?i[0]:t[0],u=u.filter(function(a){return t.indexOf(a)===-1})}}),s.unknownCodecs=u}function ds(u,s,e){var t=s[e];t&&(u[e]=t)}function Oo(u,s){u.rawProgramDateTime?u.programDateTime=Date.parse(u.rawProgramDateTime):s!=null&&s.programDateTime&&(u.programDateTime=s.endProgramDateTime),re(u.programDateTime)||(u.programDateTime=null,u.rawProgramDateTime=null)}function No(u,s,e,t){u.relurl=s.URI,s.BYTERANGE&&u.setByteRange(s.BYTERANGE),u.level=e,u.sn="initSegment",t&&(u.levelkeys=t),u.initSegment=null}function cs(u,s,e){u.levelkeys=s;var t=e.encryptedFragments;t.length&&t[t.length-1].levelkeys===s||!Object.keys(s).some(function(i){return s[i].isCommonEncryption})||t.push(u)}var zr="manifest",Ar="level",yi="audioTrack",zi="subtitleTrack",rt="main",Di="audio",Oi="subtitle";function Fo(u){switch(u.type){case yi:return Di;case zi:return Oi;default:return rt}}function hs(u,s){var e=u.url;return e!==void 0&&e.indexOf("data:")!==0||(e=s.url),e}var Pt=function(){function u(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}var s=u.prototype;return s.startLoad=function(e){},s.stopLoad=function(){this.destroyInternalLoaders()},s.registerListeners=function(){var e=this.hls;e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.LEVEL_LOADING,this.onLevelLoading,this),e.on(k.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(k.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},s.unregisterListeners=function(){var e=this.hls;e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.LEVEL_LOADING,this.onLevelLoading,this),e.off(k.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(k.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},s.createInternalLoader=function(e){var t=this.hls.config,i=t.pLoader,a=t.loader,l=new(i||a)(t);return this.loaders[e.type]=l,l},s.getInternalLoader=function(e){return this.loaders[e.type]},s.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},s.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},s.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},s.onManifestLoading=function(e,t){var i=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:zr,url:i,deliveryDirectives:null})},s.onLevelLoading=function(e,t){var i=t.id,a=t.level,l=t.url,d=t.deliveryDirectives;this.load({id:i,level:a,responseType:"text",type:Ar,url:l,deliveryDirectives:d})},s.onAudioTrackLoading=function(e,t){var i=t.id,a=t.groupId,l=t.url,d=t.deliveryDirectives;this.load({id:i,groupId:a,level:null,responseType:"text",type:yi,url:l,deliveryDirectives:d})},s.onSubtitleTrackLoading=function(e,t){var i=t.id,a=t.groupId,l=t.url,d=t.deliveryDirectives;this.load({id:i,groupId:a,level:null,responseType:"text",type:zi,url:l,deliveryDirectives:d})},s.load=function(e){var t,i,a,l=this,d=this.hls.config,c=this.getInternalLoader(e);if(c){var h=c.context;if(h&&h.url===e.url)return void B.trace("[playlist-loader]: playlist request ongoing");B.log("[playlist-loader]: aborting previous loader for type: "+e.type),c.abort()}if(i=e.type===zr?d.manifestLoadPolicy.default:H({},d.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),c=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part&&(e.type===Ar&&e.level!==null?a=this.hls.levels[e.level].details:e.type===yi&&e.id!==null?a=this.hls.audioTracks[e.id].details:e.type===zi&&e.id!==null&&(a=this.hls.subtitleTracks[e.id].details),a)){var f=a.partTarget,p=a.targetduration;if(f&&p){var E=1e3*Math.max(3*f,.8*p);i=H({},i,{maxTimeToFirstByteMs:Math.min(E,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(E,i.maxTimeToFirstByteMs)})}}var b=i.errorRetry||i.timeoutRetry||{},A={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:b.maxNumRetry||0,retryDelay:b.retryDelayMs||0,maxRetryDelay:b.maxRetryDelayMs||0},w={onSuccess:function(D,S,L,N){var P=l.getInternalLoader(L);l.resetInternalLoader(L.type);var V=D.data;V.indexOf("#EXTM3U")===0?(S.parsing.start=performance.now(),Ta.isMediaPlaylist(V)?l.handleTrackOrLevelPlaylist(D,S,L,N||null,P):l.handleMasterPlaylist(D,S,L,N)):l.handleManifestParsingError(D,L,new Error("no EXTM3U delimiter"),N||null,S)},onError:function(D,S,L,N){l.handleNetworkError(S,L,!1,D,N)},onTimeout:function(D,S,L){l.handleNetworkError(S,L,!0,void 0,D)}};c.load(e,A,w)},s.handleMasterPlaylist=function(e,t,i,a){var l=this.hls,d=e.data,c=hs(e,i),h=Ta.parseMasterPlaylist(d,c);if(h.playlistParsingError)this.handleManifestParsingError(e,i,h.playlistParsingError,a,t);else{var f=h.contentSteering,p=h.levels,E=h.sessionData,b=h.sessionKeys,A=h.startTimeOffset,w=h.variableList;this.variableList=w;var D=Ta.parseMasterPlaylistMedia(d,c,h),S=D.AUDIO,L=S===void 0?[]:S,N=D.SUBTITLES,P=D["CLOSED-CAPTIONS"];L.length&&(L.some(function(V){return!V.url})||!p[0].audioCodec||p[0].attrs.AUDIO||(B.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),L.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new nt({}),bitrate:0,url:""}))),l.trigger(k.MANIFEST_LOADED,{levels:p,audioTracks:L,subtitles:N,captions:P,contentSteering:f,url:c,stats:t,networkDetails:a,sessionData:E,sessionKeys:b,startTimeOffset:A,variableList:w})}},s.handleTrackOrLevelPlaylist=function(e,t,i,a,l){var d=this.hls,c=i.id,h=i.level,f=i.type,p=hs(e,i),E=re(c)?c:0,b=re(h)?h:E,A=Fo(i),w=Ta.parseLevelPlaylist(e.data,p,b,A,E,this.variableList);if(f===zr){var D={attrs:new nt({}),bitrate:0,details:w,name:"",url:p};d.trigger(k.MANIFEST_LOADED,{levels:[D],audioTracks:[],url:p,stats:t,networkDetails:a,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=w,this.handlePlaylistLoaded(w,e,t,i,a,l)},s.handleManifestParsingError=function(e,t,i,a,l){this.hls.trigger(k.ERROR,{type:oe.NETWORK_ERROR,details:q.MANIFEST_PARSING_ERROR,fatal:t.type===zr,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:a,stats:l})},s.handleNetworkError=function(e,t,i,a,l){i===void 0&&(i=!1);var d="A network "+(i?"timeout":"error"+(a?" (status "+a.code+")":""))+" occurred while loading "+e.type;e.type===Ar?d+=": "+e.level+" id: "+e.id:e.type!==yi&&e.type!==zi||(d+=" id: "+e.id+' group-id: "'+e.groupId+'"');var c=new Error(d);B.warn("[playlist-loader]: "+d);var h=q.UNKNOWN,f=!1,p=this.getInternalLoader(e);switch(e.type){case zr:h=i?q.MANIFEST_LOAD_TIMEOUT:q.MANIFEST_LOAD_ERROR,f=!0;break;case Ar:h=i?q.LEVEL_LOAD_TIMEOUT:q.LEVEL_LOAD_ERROR,f=!1;break;case yi:h=i?q.AUDIO_TRACK_LOAD_TIMEOUT:q.AUDIO_TRACK_LOAD_ERROR,f=!1;break;case zi:h=i?q.SUBTITLE_TRACK_LOAD_TIMEOUT:q.SUBTITLE_LOAD_ERROR,f=!1}p&&this.resetInternalLoader(e.type);var E={type:oe.NETWORK_ERROR,details:h,fatal:f,url:e.url,loader:p,context:e,error:c,networkDetails:t,stats:l};if(a){var b=(t==null?void 0:t.url)||e.url;E.response=y({url:b,data:void 0},a)}this.hls.trigger(k.ERROR,E)},s.handlePlaylistLoaded=function(e,t,i,a,l,d){var c=this.hls,h=a.type,f=a.level,p=a.id,E=a.groupId,b=a.deliveryDirectives,A=hs(t,a),w=Fo(a),D=typeof a.level=="number"&&w===rt?f:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var S=e.playlistParsingError;if(S)c.trigger(k.ERROR,{type:oe.NETWORK_ERROR,details:q.LEVEL_PARSING_ERROR,fatal:!1,url:A,error:S,reason:S.message,response:t,context:a,level:D,parent:w,networkDetails:l,stats:i});else switch(e.live&&d&&(d.getCacheAge&&(e.ageHeader=d.getCacheAge()||0),d.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),h){case zr:case Ar:c.trigger(k.LEVEL_LOADED,{details:e,level:D||0,id:p||0,stats:i,networkDetails:l,deliveryDirectives:b});break;case yi:c.trigger(k.AUDIO_TRACK_LOADED,{details:e,id:p||0,groupId:E||"",stats:i,networkDetails:l,deliveryDirectives:b});break;case zi:c.trigger(k.SUBTITLE_TRACK_LOADED,{details:e,id:p||0,groupId:E||"",stats:i,networkDetails:l,deliveryDirectives:b})}}else{var L=new Error("No Segments found in Playlist");c.trigger(k.ERROR,{type:oe.NETWORK_ERROR,details:q.LEVEL_EMPTY_ERROR,fatal:!1,url:A,error:L,reason:L.message,response:t,context:a,level:D,parent:w,networkDetails:l,stats:i})}},u}();function _a(u,s){var e;try{e=new Event("addtrack")}catch{(e=document.createEvent("Event")).initEvent("addtrack",!1,!1)}e.track=u,s.dispatchEvent(e)}function Uo(u,s){var e=u.mode;if(e==="disabled"&&(u.mode="hidden"),u.cues&&!u.cues.getCueById(s.id))try{if(u.addCue(s),!u.cues.getCueById(s.id))throw new Error("addCue is failed for: "+s)}catch(i){B.debug("[texttrack-utils]: "+i);var t=new self.TextTrackCue(s.startTime,s.endTime,s.text);t.id=s.id,u.addCue(t)}e==="disabled"&&(u.mode=e)}function Qr(u){var s=u.mode;if(s==="disabled"&&(u.mode="hidden"),u.cues)for(var e=u.cues.length;e--;)u.removeCue(u.cues[e]);s==="disabled"&&(u.mode=s)}function fs(u,s,e,t){var i=u.mode;if(i==="disabled"&&(u.mode="hidden"),u.cues&&u.cues.length>0)for(var a=function(d,c,h){var f=[],p=function(w,D){if(D<w[0].startTime)return 0;var S=w.length-1;if(D>w[S].endTime)return-1;for(var L=0,N=S;L<=N;){var P=Math.floor((N+L)/2);if(D<w[P].startTime)N=P-1;else{if(!(D>w[P].startTime&&L<S))return P;L=P+1}}return w[L].startTime-D<D-w[N].startTime?L:N}(d,c);if(p>-1)for(var E=p,b=d.length;E<b;E++){var A=d[E];if(A.startTime>=c&&A.endTime<=h)f.push(A);else if(A.startTime>h)return f}return f}(u.cues,s,e),l=0;l<a.length;l++)t&&!t(a[l])||u.removeCue(a[l]);i==="disabled"&&(u.mode=i)}var Aa="org.id3",Sa="com.apple.quicktime.HLS",Sr="https://aomedia.org/emsg/ID3";function un(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var ka=function(){var u=un();try{new u(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function sr(u,s){return u.getTime()/1e3-s}var $u=function(){function u(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var s=u.prototype;return s.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},s._registerListeners=function(){var e=this.hls;e.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(k.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(k.LEVEL_UPDATED,this.onLevelUpdated,this)},s._unregisterListeners=function(){var e=this.hls;e.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(k.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(k.LEVEL_UPDATED,this.onLevelUpdated,this)},s.onMediaAttached=function(e,t){this.media=t.media},s.onMediaDetaching=function(){this.id3Track&&(Qr(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},s.onManifestLoading=function(){this.dateRangeCuesAppended={}},s.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},s.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var i=e[t];if(i.kind==="metadata"&&i.label==="id3")return _a(i,this.media),i}return this.media.addTextTrack("metadata","id3")}},s.onFragParsingMetadata=function(e,t){if(this.media){var i=this.hls.config,a=i.enableEmsgMetadataCues,l=i.enableID3MetadataCues;if(a||l){var d=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var c=un(),h=0;h<d.length;h++){var f=d[h].type;if((f!==Sr||a)&&l){var p=is(d[h].data);if(p){var E=d[h].pts,b=E+d[h].duration;b>ka&&(b=ka),b-E<=0&&(b=E+.25);for(var A=0;A<p.length;A++){var w=p[A];if(!Eo(w)){this.updateId3CueEnds(E,f);var D=new c(E,b,"");D.value=w,f&&(D.type=f),this.id3Track.addCue(D)}}}}}}}},s.updateId3CueEnds=function(e,t){var i,a=(i=this.id3Track)==null?void 0:i.cues;if(a)for(var l=a.length;l--;){var d=a[l];d.type===t&&d.startTime<e&&d.endTime===ka&&(d.endTime=e)}},s.onBufferFlushing=function(e,t){var i=t.startOffset,a=t.endOffset,l=t.type,d=this.id3Track,c=this.hls;if(c){var h=c.config,f=h.enableEmsgMetadataCues,p=h.enableID3MetadataCues;d&&(f||p)&&fs(d,i,a,l==="audio"?function(E){return E.type===Aa&&p}:l==="video"?function(E){return E.type===Sr&&f}:function(E){return E.type===Aa&&p||E.type===Sr&&f})}},s.onLevelUpdated=function(e,t){var i=this,a=t.details;if(this.media&&a.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var l=this.dateRangeCuesAppended,d=this.id3Track,c=a.dateRanges,h=Object.keys(c);if(d)for(var f=Object.keys(l).filter(function(L){return!h.includes(L)}),p=function(){var L=f[E];Object.keys(l[L].cues).forEach(function(N){d.removeCue(l[L].cues[N])}),delete l[L]},E=f.length;E--;)p();var b=a.fragments[a.fragments.length-1];if(h.length!==0&&re(b==null?void 0:b.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var A=b.programDateTime/1e3-b.start,w=un(),D=function(){var L=h[S],N=c[L],P=l[L],V=(P==null?void 0:P.cues)||{},Y=(P==null?void 0:P.durationKnown)||!1,j=sr(N.startDate,A),ie=ka,Q=N.endDate;if(Q)ie=sr(Q,A),Y=!0;else if(N.endOnNext&&!Y){var X=h.reduce(function(Pe,Ke){var je=c[Ke];return je.class===N.class&&je.id!==Ke&&je.startDate>N.startDate&&Pe.push(je),Pe},[]).sort(function(Pe,Ke){return Pe.startDate.getTime()-Ke.startDate.getTime()})[0];X&&(ie=sr(X.startDate,A),Y=!0)}for(var ce,le,Ae=Object.keys(N.attr),xe=0;xe<Ae.length;xe++){var Le=Ae[xe];if((le=Le)!=="ID"&&le!=="CLASS"&&le!=="START-DATE"&&le!=="DURATION"&&le!=="END-DATE"&&le!=="END-ON-NEXT"){var Me=V[Le];if(Me)Y&&!P.durationKnown&&(Me.endTime=ie);else{var Oe=N.attr[Le];Me=new w(j,ie,""),ri(Le)&&(ce=Oe,Oe=Uint8Array.from(ce.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),Me.value={key:Le,data:Oe},Me.type=Sa,Me.id=L,i.id3Track.addCue(Me),V[Le]=Me}}}l[L]={cues:V,dateRange:N,durationKnown:Y}},S=0;S<h.length;S++)D()}}},u}(),ju=function(){function u(e){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}var s=u.prototype;return s.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},s.registerListeners=function(){this.hls.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(k.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(k.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(k.ERROR,this.onError,this)},s.unregisterListeners=function(){this.hls.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(k.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(k.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(k.ERROR,this.onError,this)},s.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},s.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},s.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},s.onLevelUpdated=function(e,t){var i=t.details;this.levelDetails=i,i.advanced&&this.timeupdate(),!i.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},s.onError=function(e,t){var i;t.details===q.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&B.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},s.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var i=this.computeLatency();if(i!==null){this._latency=i;var a=this.config,l=a.lowLatencyMode,d=a.maxLiveSyncPlaybackRate;if(l&&d!==1){var c=this.targetLatency;if(c!==null){var h=i-c,f=h<Math.min(this.maxLatency,c+t.targetduration);if(t.live&&f&&h>.05&&this.forwardBufferLength>1){var p=Math.min(2,Math.max(1,d)),E=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;e.playbackRate=Math.min(p,Math.max(1,E))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}}}}},s.estimateLiveEdge=function(){var e=this.levelDetails;return e===null?null:e.edge+e.age},s.computeLatency=function(){var e=this.estimateLiveEdge();return e===null?null:e-this.currentTime},M(u,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(e===null)return null;var t=e.holdBack,i=e.partHoldBack,a=e.targetduration,l=this.config,d=l.liveSyncDuration,c=l.liveSyncDurationCount,h=l.lowLatencyMode,f=this.hls.userConfig,p=h&&i||t;(f.liveSyncDuration||f.liveSyncDurationCount||p===0)&&(p=d!==void 0?d:c*a);var E=a;return p+Math.min(1*this.stallCount,E)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,i=this.levelDetails;if(e===null||t===null||i===null)return null;var a=i.edge,l=e-t-this.edgeStalled,d=a-i.totalduration,c=a-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(d,l),c)}},{key:"drift",get:function(){var e=this.levelDetails;return e===null?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(e===null)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}}]),u}(),ms=["NONE","TYPE-0","TYPE-1",null],ps="",zu="YES",Qu="v2",Bo=function(){function u(s,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=s,this.part=e,this.skip=t}return u.prototype.addDirectives=function(s){var e=new self.URL(s);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href},u}(),wa=function(){function u(s){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=[s.url],this._attrs=[s.attrs],this.bitrate=s.bitrate,s.details&&(this.details=s.details),this.id=s.id||0,this.name=s.name,this.width=s.width||0,this.height=s.height||0,this.audioCodec=s.audioCodec,this.videoCodec=s.videoCodec,this.unknownCodecs=s.unknownCodecs,this.codecSet=[s.videoCodec,s.audioCodec].filter(function(e){return e}).join(",").replace(/\.[^.,]+/g,"")}return u.prototype.addFallback=function(s){this.url.push(s.url),this._attrs.push(s.attrs)},M(u,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"attrs",get:function(){return this._attrs[this._urlId]}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(s){var e=s%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}},{key:"audioGroupId",get:function(){var s;return(s=this.audioGroupIds)==null?void 0:s[this.urlId]}},{key:"textGroupId",get:function(){var s;return(s=this.textGroupIds)==null?void 0:s[this.urlId]}}]),u}();function vs(u,s){var e=s.startPTS;if(re(e)){var t,i=0;s.sn>u.sn?(i=e-u.start,t=u):(i=u.start-e,t=s),t.duration!==i&&(t.duration=i)}else s.sn>u.sn?u.cc===s.cc&&u.minEndPTS?s.start=u.start+(u.minEndPTS-u.start):s.start=u.start+u.duration:s.start=Math.max(u.start-s.duration,0)}function La(u,s,e,t,i,a){t-e<=0&&(B.warn("Fragment should have a positive duration",s),t=e+s.duration,a=i+s.duration);var l=e,d=t,c=s.startPTS,h=s.endPTS;if(re(c)){var f=Math.abs(c-e);re(s.deltaPTS)?s.deltaPTS=Math.max(f,s.deltaPTS):s.deltaPTS=f,l=Math.max(e,c),e=Math.min(e,c),i=Math.min(i,s.startDTS),d=Math.min(t,h),t=Math.max(t,h),a=Math.max(a,s.endDTS)}var p=e-s.start;s.start!==0&&(s.start=e),s.duration=t-s.start,s.startPTS=e,s.maxStartPTS=l,s.startDTS=i,s.endPTS=t,s.minEndPTS=d,s.endDTS=a;var E,b=s.sn;if(!u||b<u.startSN||b>u.endSN)return 0;var A=b-u.startSN,w=u.fragments;for(w[A]=s,E=A;E>0;E--)vs(w[E],w[E-1]);for(E=A;E<w.length-1;E++)vs(w[E],w[E+1]);return u.fragmentHint&&vs(w[w.length-1],u.fragmentHint),u.PTSKnown=u.alignedSliding=!0,p}function gs(u,s){for(var e=null,t=u.fragments,i=t.length-1;i>=0;i--){var a=t[i].initSegment;if(a){e=a;break}}u.fragmentHint&&delete u.fragmentHint.endPTS;var l,d,c,h,f,p=0;if(function(S,L,N){for(var P=L.skippedSegments,V=Math.max(S.startSN,L.startSN)-L.startSN,Y=(S.fragmentHint?1:0)+(P?L.endSN:Math.min(S.endSN,L.endSN))-L.startSN,j=L.startSN-S.startSN,ie=L.fragmentHint?L.fragments.concat(L.fragmentHint):L.fragments,Q=S.fragmentHint?S.fragments.concat(S.fragmentHint):S.fragments,X=V;X<=Y;X++){var ce=Q[j+X],le=ie[X];P&&!le&&X<P&&(le=L.fragments[X]=ce),ce&&le&&N(ce,le)}}(u,s,function(S,L){S.relurl&&(p=S.cc-L.cc),re(S.startPTS)&&re(S.endPTS)&&(L.start=L.startPTS=S.startPTS,L.startDTS=S.startDTS,L.maxStartPTS=S.maxStartPTS,L.endPTS=S.endPTS,L.endDTS=S.endDTS,L.minEndPTS=S.minEndPTS,L.duration=S.endPTS-S.startPTS,L.duration&&(l=L),s.PTSKnown=s.alignedSliding=!0),L.elementaryStreams=S.elementaryStreams,L.loader=S.loader,L.stats=S.stats,L.urlId=S.urlId,S.initSegment&&(L.initSegment=S.initSegment,e=S.initSegment)}),e&&(s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments).forEach(function(S){var L;S.initSegment&&S.initSegment.relurl!==((L=e)==null?void 0:L.relurl)||(S.initSegment=e)}),s.skippedSegments)if(s.deltaUpdateFailed=s.fragments.some(function(S){return!S}),s.deltaUpdateFailed){B.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var E=s.skippedSegments;E--;)s.fragments.shift();s.startSN=s.fragments[0].sn,s.startCC=s.fragments[0].cc}else s.canSkipDateRanges&&(s.dateRanges=(d=u.dateRanges,c=s.dateRanges,h=s.recentlyRemovedDateranges,f=H({},d),h&&h.forEach(function(S){delete f[S]}),Object.keys(c).forEach(function(S){var L=new $e(c[S].attr,f[S]);L.isValid?f[S]=L:B.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(c[S].attr)+'"')}),f));var b=s.fragments;if(p){B.warn("discontinuity sliding from playlist, take drift into account");for(var A=0;A<b.length;A++)b[A].cc+=p}s.skippedSegments&&(s.startCC=s.fragments[0].cc),function(S,L,N){if(S&&L)for(var P=0,V=0,Y=S.length;V<=Y;V++){var j=S[V],ie=L[V+P];j&&ie&&j.index===ie.index&&j.fragment.sn===ie.fragment.sn?N(j,ie):P--}}(u.partList,s.partList,function(S,L){L.elementaryStreams=S.elementaryStreams,L.stats=S.stats}),l?La(s,l,l.startPTS,l.endPTS,l.startDTS,l.endDTS):Es(u,s),b.length&&(s.totalduration=s.edge-b[0].start),s.driftStartTime=u.driftStartTime,s.driftStart=u.driftStart;var w=s.advancedDateTime;if(s.advanced&&w){var D=s.edge;s.driftStart||(s.driftStartTime=w,s.driftStart=D),s.driftEndTime=w,s.driftEnd=D}else s.driftEndTime=u.driftEndTime,s.driftEnd=u.driftEnd,s.advancedDateTime=u.advancedDateTime}function Es(u,s){var e=s.startSN+s.skippedSegments-u.startSN,t=u.fragments;e<0||e>=t.length||Ia(s,t[e].start)}function Ia(u,s){if(s){for(var e=u.fragments,t=u.skippedSegments;t<e.length;t++)e[t].start+=s;u.fragmentHint&&(u.fragmentHint.start+=s)}}function Ho(u,s,e){var t;return u!=null&&u.details?Go((t=u.details)==null?void 0:t.partList,s,e):null}function Go(u,s,e){if(u)for(var t=u.length;t--;){var i=u[t];if(i.index===e&&i.fragment.sn===s)return i}return null}function dn(u){switch(u.details){case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_TIMEOUT:case q.LEVEL_LOAD_TIMEOUT:case q.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Vo(u,s){var e=dn(s);return u.default[(e?"timeout":"error")+"Retry"]}function ys(u,s){var e=u.backoff==="linear"?1:Math.pow(2,s);return Math.min(e*u.retryDelayMs,u.maxRetryDelayMs)}function Ko(u){return y(y({},u),{errorRetry:null,timeoutRetry:null})}function cn(u,s,e,t){return!!u&&s<u.maxNumRetry&&(function(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}(t)||!!e)}var Wo=function(u,s){for(var e=0,t=u.length-1,i=null,a=null;e<=t;){var l=s(a=u[i=(e+t)/2|0]);if(l>0)e=i+1;else{if(!(l<0))return a;t=i-1}}return null};function Ra(u,s,e,t){e===void 0&&(e=0),t===void 0&&(t=0);var i=null;if(u?i=s[u.sn-s[0].sn+1]||null:e===0&&s[0].start===0&&(i=s[0]),i&&hn(e,t,i)===0)return i;var a=Wo(s,hn.bind(null,e,t));return!a||a===u&&i?i:a}function hn(u,s,e){if(u===void 0&&(u=0),s===void 0&&(s=0),e.start<=u&&e.start+e.duration>u)return 0;var t=Math.min(s,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-t<=u?1:e.start-t>u&&e.start?-1:0}function bi(u,s,e){var t=1e3*Math.min(s,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>u}var kr,Xu=3e5,qo=0,_=2,g=5,T=0,R=1,C=2,O=function(){function u(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=B.log.bind(B,"[info]:"),this.warn=B.warn.bind(B,"[warning]:"),this.error=B.error.bind(B,"[error]:"),this.registerListeners()}var s=u.prototype;return s.registerListeners=function(){var e=this.hls;e.on(k.ERROR,this.onError,this),e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.LEVEL_UPDATED,this.onLevelUpdated,this)},s.unregisterListeners=function(){var e=this.hls;e&&(e.off(k.ERROR,this.onError,this),e.off(k.ERROR,this.onErrorOut,this),e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.LEVEL_UPDATED,this.onLevelUpdated,this))},s.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},s.startLoad=function(e){this.playlistError=0},s.stopLoad=function(){},s.getVariantLevelIndex=function(e){return(e==null?void 0:e.type)===rt?e.level:this.hls.loadLevel},s.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},s.onLevelUpdated=function(){this.playlistError=0},s.onError=function(e,t){var i;if(!t.fatal){var a=this.hls,l=t.context;switch(t.details){case q.FRAG_LOAD_ERROR:case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_ERROR:case q.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case q.FRAG_GAP:case q.FRAG_PARSING_ERROR:case q.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=_);case q.LEVEL_EMPTY_ERROR:case q.LEVEL_PARSING_ERROR:var d,c,h=t.parent===rt?t.level:a.loadLevel;return void(t.details===q.LEVEL_EMPTY_ERROR&&(d=t.context)!=null&&(c=d.levelDetails)!=null&&c.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,h):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,h)));case q.LEVEL_LOAD_ERROR:case q.LEVEL_LOAD_TIMEOUT:return void(typeof(l==null?void 0:l.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l.level)));case q.AUDIO_TRACK_LOAD_ERROR:case q.AUDIO_TRACK_LOAD_TIMEOUT:case q.SUBTITLE_LOAD_ERROR:case q.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){var f=a.levels[a.loadLevel];if(f&&(l.type===yi&&l.groupId===f.audioGroupId||l.type===zi&&l.groupId===f.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.loadLevel),t.errorAction.action=_,void(t.errorAction.flags=R)}return;case q.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var p=a.levels[a.loadLevel],E=p==null?void 0:p.attrs["HDCP-LEVEL"];return void(E&&(t.errorAction={action:_,flags:C,hdcpLevel:E}));case q.BUFFER_ADD_CODEC_ERROR:case q.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,(i=t.level)!=null?i:a.loadLevel));case q.INTERNAL_EXCEPTION:case q.BUFFER_APPENDING_ERROR:case q.BUFFER_APPEND_ERROR:case q.BUFFER_FULL_ERROR:case q.LEVEL_SWITCH_ERROR:case q.BUFFER_STALLED_ERROR:case q.BUFFER_SEEK_OVER_HOLE:case q.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:qo,flags:T})}if(t.type===oe.KEY_SYSTEM_ERROR){var b=this.getVariantLevelIndex(t.frag);return t.levelRetry=!1,void(t.errorAction=this.getLevelSwitchAction(t,b))}}},s.getPlaylistRetryOrSwitchAction=function(e,t){var i,a=Vo(this.hls.config.playlistLoadPolicy,e),l=this.playlistError++,d=(i=e.response)==null?void 0:i.code;if(cn(a,l,dn(e),d))return{action:g,flags:T,retryConfig:a,retryCount:l};var c=this.getLevelSwitchAction(e,t);return a&&(c.retryConfig=a,c.retryCount=l),c},s.getFragRetryOrSwitchAction=function(e){var t=this.hls,i=this.getVariantLevelIndex(e.frag),a=t.levels[i],l=t.config,d=l.fragLoadPolicy,c=l.keyLoadPolicy,h=Vo(e.details.startsWith("key")?c:d,e),f=t.levels.reduce(function(A,w){return A+w.fragmentError},0);if(a){var p;e.details!==q.FRAG_GAP&&a.fragmentError++;var E=(p=e.response)==null?void 0:p.code;if(cn(h,f,dn(e),E))return{action:g,flags:T,retryConfig:h,retryCount:f}}var b=this.getLevelSwitchAction(e,i);return h&&(b.retryConfig=h,b.retryCount=f),b},s.getLevelSwitchAction=function(e,t){var i=this.hls;t==null&&(t=i.loadLevel);var a=this.hls.levels[t];if(a&&(a.loadError++,i.autoLevelEnabled)){for(var l,d,c=-1,h=i.levels,f=(l=e.frag)==null?void 0:l.type,p=(d=e.context)!=null?d:{},E=p.type,b=p.groupId,A=h.length;A--;){var w=(A+i.loadLevel)%h.length;if(w!==i.loadLevel&&h[w].loadError===0){var D=h[w];if(e.details===q.FRAG_GAP&&e.frag){var S=h[w].details;if(S){var L=Ra(e.frag,S.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else if(E===yi&&b===D.audioGroupId||E===zi&&b===D.textGroupId||f===Di&&a.audioGroupId===D.audioGroupId||f===Oi&&a.textGroupId===D.textGroupId)continue;c=w;break}}if(c>-1&&i.loadLevel!==c)return e.levelRetry=!0,this.playlistError=0,{action:_,flags:T,nextAutoLevel:c}}return{action:_,flags:R}},s.onErrorOut=function(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case qo:break;case _:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===q.FRAG_GAP||(t.fatal=!0)}t.fatal&&this.hls.stopLoad()},s.sendAlternateToPenaltyBox=function(e){var t=this.hls,i=e.errorAction;if(i){var a=i.flags,l=i.hdcpLevel,d=i.nextAutoLevel;switch(a){case T:this.switchLevel(e,d);break;case R:i.resolved||(i.resolved=this.redundantFailover(e));break;case C:l&&(t.maxHdcpLevel=ms[ms.indexOf(l)-1],i.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')}i.resolved||this.switchLevel(e,d)}},s.switchLevel=function(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)},s.redundantFailover=function(e){var t=this,i=this.hls,a=this.penalizedRenditions,l=e.parent===rt?e.level:i.loadLevel,d=i.levels[l],c=d.url.length,h=e.frag?e.frag.urlId:d.urlId;d.urlId!==h||e.frag&&!d.details||this.penalizeRendition(d,e);for(var f=function(){var b=(h+p)%c,A=a[b];if(!A||function(w,D,S){if(performance.now()-w.lastErrorPerfMs>Xu)return!0;var L=w.details;if(D.details===q.FRAG_GAP&&L&&D.frag){var N=D.frag.start,P=Ra(null,L.fragments,N);if(P&&!P.gap)return!0}if(S&&w.errors.length<S.errors.length){var V=w.errors[w.errors.length-1];if(L&&V.frag&&D.frag&&Math.abs(V.frag.start-D.frag.start)>3*L.targetduration)return!0}return!1}(A,e,a[h]))return t.warn("Switching to Redundant Stream "+(b+1)+"/"+c+': "'+d.url[b]+'" after '+e.details),t.playlistError=0,i.levels.forEach(function(w){w.urlId=b}),i.nextLoadLevel=l,{v:!0}},p=1;p<c;p++){var E=f();if(typeof E=="object")return E.v}return!1},s.penalizeRendition=function(e,t){var i=this.penalizedRenditions,a=i[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};a.lastErrorPerfMs=performance.now(),a.errors.push(t),a.details=e.details,i[e.urlId]=a},u}(),x=function(){function u(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=B.log.bind(B,t+":"),this.warn=B.warn.bind(B,t+":"),this.hls=e}var s=u.prototype;return s.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},s.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},s.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},s.stopLoad=function(){this.canLoad=!1,this.clearTimer()},s.switchParams=function(e,t){var i=t==null?void 0:t.renditionReports;if(i){for(var a=-1,l=0;l<i.length;l++){var d=i[l],c=void 0;try{c=new self.URL(d.URI,t.url).href}catch(b){B.warn("Could not construct new URL for Rendition Report: "+b),c=d.URI||""}if(c===e){a=l;break}c===e.substring(0,c.length)&&(a=l)}if(a!==-1){var h=i[a],f=parseInt(h["LAST-MSN"])||(t==null?void 0:t.lastPartSn),p=parseInt(h["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var E=Math.min(t.age-t.partTarget,t.targetduration);p>=0&&E>t.partTarget&&(p+=1)}return new Bo(f,p>=0?p:void 0,ps)}}},s.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},s.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},s.shouldReloadPlaylist=function(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)},s.playlistLoaded=function(e,t,i){var a=this,l=t.details,d=t.stats,c=self.performance.now(),h=d.loading.first?Math.max(0,c-d.loading.first):0;if(l.advancedDateTime=Date.now()-h,l.live||i!=null&&i.live){if(l.reloaded(i),i&&this.log("live playlist "+e+" "+(l.advanced?"REFRESHED "+l.lastPartSn+"-"+l.lastPartIndex:"MISSED")),i&&l.fragments.length>0&&gs(i,l),!this.canLoad||!l.live)return;var f,p=void 0,E=void 0;if(l.canBlockReload&&l.endSN&&l.advanced){var b=this.hls.config.lowLatencyMode,A=l.lastPartSn,w=l.endSN,D=l.lastPartIndex,S=A===w;D!==-1?(p=S?w+1:A,E=S?b?0:D:D+1):p=w+1;var L=l.age,N=L+l.ageHeader,P=Math.min(N-l.partTarget,1.5*l.targetduration);if(P>0){if(i&&P>i.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+P+" with playlist age: "+l.age),P=0;else{var V=Math.floor(P/l.targetduration);p+=V,E!==void 0&&(E+=Math.round(P%l.targetduration/l.partTarget)),this.log("CDN Tune-in age: "+l.ageHeader+"s last advanced "+L.toFixed(2)+"s goal: "+P+" skip sn "+V+" to part "+E)}l.tuneInGoal=P}if(f=this.getDeliveryDirectives(l,t.deliveryDirectives,p,E),b||!S)return void this.loadPlaylist(f)}else l.canBlockReload&&(f=this.getDeliveryDirectives(l,t.deliveryDirectives,p,E));var Y=this.hls.mainForwardBufferInfo,j=Y?Y.end-Y.len:0,ie=function(X,ce){ce===void 0&&(ce=1/0);var le=1e3*X.targetduration;if(X.updated){var Ae=X.fragments;if(Ae.length&&4*le>ce){var xe=1e3*Ae[Ae.length-1].duration;xe<le&&(le=xe)}}else le/=2;return Math.round(le)}(l,1e3*(l.edge-j));l.updated&&c>this.requestScheduled+ie&&(this.requestScheduled=d.loading.start),p!==void 0&&l.canBlockReload?this.requestScheduled=d.loading.first+ie-(1e3*l.partTarget||1e3):this.requestScheduled===-1||this.requestScheduled+ie<c?this.requestScheduled=c:this.requestScheduled-c<=0&&(this.requestScheduled+=ie);var Q=this.requestScheduled-c;Q=Math.max(0,Q),this.log("reload live playlist "+e+" in "+Math.round(Q)+" ms"),this.timer=self.setTimeout(function(){return a.loadPlaylist(f)},Q)}else this.clearTimer()},s.getDeliveryDirectives=function(e,t,i,a){var l=function(d,c){var h=d.canSkipUntil,f=d.canSkipDateRanges,p=d.endSN;return h&&(c!==void 0?c-p:0)<h?f?Qu:zu:ps}(e,i);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,a=t.part,l=ps),new Bo(i,a,l)},s.checkRetry=function(e){var t=this,i=e.details,a=dn(e),l=e.errorAction,d=l||{},c=d.action,h=d.retryCount,f=h===void 0?0:h,p=d.retryConfig,E=!!l&&!!p&&(c===g||!l.resolved&&c===_);if(E){var b;if(this.requestScheduled=-1,f>=p.maxNumRetry)return!1;if(a&&(b=e.context)!=null&&b.deliveryDirectives)this.warn("Retrying playlist loading "+(f+1)+"/"+p.maxNumRetry+' after "'+i+'" without delivery-directives'),this.loadPlaylist();else{var A=ys(p,f);this.timer=self.setTimeout(function(){return t.loadPlaylist()},A),this.warn("Retrying playlist loading "+(f+1)+"/"+p.maxNumRetry+' after "'+i+'" in '+A+"ms")}e.levelRetry=!0,l.resolved=!0}return E},u}(),G=function(u){function s(t,i){var a;return(a=u.call(this,t,"[level-controller]")||this)._levels=[],a._firstLevel=-1,a._startLevel=void 0,a.currentLevel=null,a.currentLevelIndex=-1,a.manualLevelIndex=-1,a.steering=void 0,a.onParsedComplete=void 0,a.steering=i,a._registerListeners(),a}z(s,u);var e=s.prototype;return e._registerListeners=function(){var t=this.hls;t.on(k.MANIFEST_LOADING,this.onManifestLoading,this),t.on(k.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(k.LEVEL_LOADED,this.onLevelLoaded,this),t.on(k.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(k.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(k.FRAG_LOADED,this.onFragLoaded,this),t.on(k.ERROR,this.onError,this)},e._unregisterListeners=function(){var t=this.hls;t.off(k.MANIFEST_LOADING,this.onManifestLoading,this),t.off(k.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(k.LEVEL_LOADED,this.onLevelLoaded,this),t.off(k.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(k.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(k.FRAG_LOADED,this.onFragLoaded,this),t.off(k.ERROR,this.onError,this)},e.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),u.prototype.destroy.call(this)},e.startLoad=function(){this._levels.forEach(function(t){t.loadError=0,t.fragmentError=0}),u.prototype.startLoad.call(this)},e.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]},e.onManifestLoading=function(t,i){this.resetLevels()},e.onManifestLoaded=function(t,i){var a,l=[],d={};i.levels.forEach(function(c){var h,f=c.attrs;((h=c.audioCodec)==null?void 0:h.indexOf("mp4a.40.34"))!==-1&&(kr||(kr=/chrome|firefox/i.test(navigator.userAgent)),kr&&(c.audioCodec=void 0));var p=f.AUDIO,E=f.CODECS,b=f["FRAME-RATE"],A=f["PATHWAY-ID"],w=f.RESOLUTION,D=f.SUBTITLES,S=(A||".")+"-"+c.bitrate+"-"+w+"-"+b+"-"+E;(a=d[S])?a.addFallback(c):(a=new wa(c),d[S]=a,l.push(a)),$(a,"audio",p),$(a,"text",D)}),this.filterAndSortMediaOptions(l,i)},e.filterAndSortMediaOptions=function(t,i){var a=this,l=[],d=[],c=!1,h=!1,f=!1,p=t.filter(function(L){var N=L.audioCodec,P=L.videoCodec,V=L.width,Y=L.height,j=L.unknownCodecs;return c||(c=!(!V||!Y)),h||(h=!!P),f||(f=!!N),!(j!=null&&j.length)&&(!N||on(N,"audio"))&&(!P||on(P,"video"))});if((c||h)&&f&&(p=p.filter(function(L){var N=L.videoCodec,P=L.width,V=L.height;return!!N||!(!P||!V)})),p.length!==0){i.audioTracks&&K(l=i.audioTracks.filter(function(L){return!L.audioCodec||on(L.audioCodec,"audio")})),i.subtitles&&K(d=i.subtitles);var E=p.slice(0);p.sort(function(L,N){return L.attrs["HDCP-LEVEL"]!==N.attrs["HDCP-LEVEL"]?(L.attrs["HDCP-LEVEL"]||"")>(N.attrs["HDCP-LEVEL"]||"")?1:-1:L.bitrate!==N.bitrate?L.bitrate-N.bitrate:L.attrs["FRAME-RATE"]!==N.attrs["FRAME-RATE"]?L.attrs.decimalFloatingPoint("FRAME-RATE")-N.attrs.decimalFloatingPoint("FRAME-RATE"):L.attrs.SCORE!==N.attrs.SCORE?L.attrs.decimalFloatingPoint("SCORE")-N.attrs.decimalFloatingPoint("SCORE"):c&&L.height!==N.height?L.height-N.height:0});var b=E[0];if(this.steering&&(p=this.steering.filterParsedLevels(p)).length!==E.length){for(var A=0;A<E.length;A++)if(E[A].pathwayId===p[0].pathwayId){b=E[A];break}}this._levels=p;for(var w=0;w<p.length;w++)if(p[w]===b){this._firstLevel=w,this.log("manifest loaded, "+p.length+" level(s) found, first bitrate: "+b.bitrate);break}var D=f&&!h,S={levels:p,audioTracks:l,subtitleTracks:d,sessionData:i.sessionData,sessionKeys:i.sessionKeys,firstLevel:this._firstLevel,stats:i.stats,audio:f,video:h,altAudio:!D&&l.some(function(L){return!!L.url})};this.hls.trigger(k.MANIFEST_PARSED,S),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then(function(){if(a.hls){var L=new Error("no level with compatible codecs found in manifest");a.hls.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:i.url,error:L,reason:L.message})}})},e.onError=function(t,i){!i.fatal&&i.context&&i.context.type===Ar&&i.context.level===this.level&&this.checkRetry(i)},e.onFragLoaded=function(t,i){var a=i.frag;if(a!==void 0&&a.type===rt){var l=this._levels[a.level];l!==void 0&&(l.loadError=0)}},e.onLevelLoaded=function(t,i){var a,l,d=i.level,c=i.details,h=this._levels[d];if(!h)return this.warn("Invalid level index "+d),void((l=i.deliveryDirectives)!=null&&l.skip&&(c.deltaUpdateFailed=!0));d===this.currentLevelIndex?(h.fragmentError===0&&(h.loadError=0),this.playlistLoaded(d,i,h.details)):(a=i.deliveryDirectives)!=null&&a.skip&&(c.deltaUpdateFailed=!0)},e.onAudioTrackSwitched=function(t,i){var a=this.currentLevel;if(a){var l=this.hls.audioTracks[i.id].groupId;if(a.audioGroupIds&&a.audioGroupId!==l){for(var d=-1,c=0;c<a.audioGroupIds.length;c++)if(a.audioGroupIds[c]===l){d=c;break}d!==-1&&d!==a.urlId&&(a.urlId=d,this.canLoad&&this.startLoad())}}},e.loadPlaylist=function(t){u.prototype.loadPlaylist.call(this);var i=this.currentLevelIndex,a=this.currentLevel;if(a&&this.shouldLoadPlaylist(a)){var l=a.urlId,d=a.uri;if(t)try{d=t.addDirectives(d)}catch(h){this.warn("Could not construct new URL with HLS Delivery Directives: "+h)}var c=a.attrs["PATHWAY-ID"];this.log("Loading level index "+i+((t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:"")+" with"+(c?" Pathway "+c:"")+" URI "+(l+1)+"/"+a.url.length+" "+d),this.clearTimer(),this.hls.trigger(k.LEVEL_LOADING,{url:d,level:i,id:l,deliveryDirectives:t||null})}},e.removeLevel=function(t,i){var a=this,l=function(c,h){return h!==i},d=this._levels.filter(function(c,h){return h!==t||(c.url.length>1&&i!==void 0?(c.url=c.url.filter(l),c.audioGroupIds&&(c.audioGroupIds=c.audioGroupIds.filter(l)),c.textGroupIds&&(c.textGroupIds=c.textGroupIds.filter(l)),c.urlId=0,!0):(a.steering&&a.steering.removeLevel(c),!1))});this.hls.trigger(k.LEVELS_UPDATED,{levels:d})},e.onLevelsUpdated=function(t,i){var a=i.levels;a.forEach(function(l,d){var c=l.details;c!=null&&c.fragments&&c.fragments.forEach(function(h){h.level=d})}),this._levels=a},M(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var i=this._levels;if(i.length!==0){if(t<0||t>=i.length){var a=new Error("invalid level idx"),l=t<0;if(this.hls.trigger(k.ERROR,{type:oe.OTHER_ERROR,details:q.LEVEL_SWITCH_ERROR,level:t,fatal:l,error:a,reason:a.message}),l)return;t=Math.min(t,i.length-1)}var d=this.currentLevelIndex,c=this.currentLevel,h=c?c.attrs["PATHWAY-ID"]:void 0,f=i[t],p=f.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=f,d!==t||!f.details||!c||h!==p){this.log("Switching to level "+t+(p?" with Pathway "+p:"")+" from level "+d+(h?" with Pathway "+h:""));var E=H({},f,{level:t,maxBitrate:f.maxBitrate,attrs:f.attrs,uri:f.uri,urlId:f.urlId});delete E._attrs,delete E._urlId,this.hls.trigger(k.LEVEL_SWITCHING,E);var b=f.details;if(!b||b.live){var A=this.switchParams(f.uri,c==null?void 0:c.details);this.loadPlaylist(A)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}}]),s}(x);function $(u,s,e){e&&(s==="audio"?(u.audioGroupIds||(u.audioGroupIds=[]),u.audioGroupIds[u.url.length-1]=e):s==="text"&&(u.textGroupIds||(u.textGroupIds=[]),u.textGroupIds[u.url.length-1]=e))}function K(u){var s={};u.forEach(function(e){var t=e.groupId||"";e.id=s[t]=s[t]||0,s[t]++})}var ee="NOT_LOADED",Fe="APPENDING",_e="PARTIAL",Re="OK",we=function(){function u(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()}var s=u.prototype;return s._registerListeners=function(){var e=this.hls;e.on(k.BUFFER_APPENDED,this.onBufferAppended,this),e.on(k.FRAG_BUFFERED,this.onFragBuffered,this),e.on(k.FRAG_LOADED,this.onFragLoaded,this)},s._unregisterListeners=function(){var e=this.hls;e.off(k.BUFFER_APPENDED,this.onBufferAppended,this),e.off(k.FRAG_BUFFERED,this.onFragBuffered,this),e.off(k.FRAG_LOADED,this.onFragLoaded,this)},s.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},s.getAppendedFrag=function(e,t){var i=this.activePartLists[t];if(i)for(var a=i.length;a--;){var l=i[a];if(!l)break;var d=l.end;if(l.start<=e&&d!==null&&e<=d)return l}return this.getBufferedFrag(e,t)},s.getBufferedFrag=function(e,t){for(var i=this.fragments,a=Object.keys(i),l=a.length;l--;){var d=i[a[l]];if((d==null?void 0:d.body.type)===t&&d.buffered){var c=d.body;if(c.start<=e&&e<=c.end)return c}}return null},s.detectEvictedFragments=function(e,t,i,a){var l=this;this.timeRanges&&(this.timeRanges[e]=t);var d=(a==null?void 0:a.fragment.sn)||-1;Object.keys(this.fragments).forEach(function(c){var h=l.fragments[c];if(h&&!(d>=h.body.sn))if(h.buffered||h.loaded){var f=h.range[e];f&&f.time.some(function(p){var E=!l.isTimeBuffered(p.startPTS,p.endPTS,t);return E&&l.removeFragment(h.body),E})}else h.body.type===i&&l.removeFragment(h.body)})},s.detectPartialFragments=function(e){var t=this,i=this.timeRanges,a=e.frag,l=e.part;if(i&&a.sn!=="initSegment"){var d=We(a),c=this.fragments[d];if(c){var h=!a.relurl;Object.keys(i).forEach(function(f){var p=a.elementaryStreams[f];if(p){var E=i[f],b=h||p.partial===!0;c.range[f]=t.getBufferedTimes(a,l,b,E)}}),c.loaded=null,Object.keys(c.range).length?(c.buffered=!0,c.body.endList&&(this.endListFragments[c.body.type]=c),Ce(c)||this.removeParts(a.sn-1,a.type)):this.removeFragment(c.body)}}},s.removeParts=function(e,t){var i=this.activePartLists[t];i&&(this.activePartLists[t]=i.filter(function(a){return a.fragment.sn>=e}))},s.fragBuffered=function(e,t){var i=We(e),a=this.fragments[i];!a&&t&&(a=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),a&&(a.loaded=null,a.buffered=!0)},s.getBufferedTimes=function(e,t,i,a){for(var l={time:[],partial:i},d=e.start,c=e.end,h=e.minEndPTS||c,f=e.maxStartPTS||d,p=0;p<a.length;p++){var E=a.start(p)-this.bufferPadding,b=a.end(p)+this.bufferPadding;if(f>=E&&h<=b){l.time.push({startPTS:Math.max(d,a.start(p)),endPTS:Math.min(c,a.end(p))});break}if(d<b&&c>E)l.partial=!0,l.time.push({startPTS:Math.max(d,a.start(p)),endPTS:Math.min(c,a.end(p))});else if(c<=E)break}return l},s.getPartialFragment=function(e){var t,i,a,l=null,d=0,c=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(f){var p=h[f];p&&Ce(p)&&(i=p.body.start-c,a=p.body.end+c,e>=i&&e<=a&&(t=Math.min(e-i,a-e),d<=t&&(l=p.body,d=t)))}),l},s.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||Ce(t))},s.getState=function(e){var t=We(e),i=this.fragments[t];return i?i.buffered?Ce(i)?_e:Re:Fe:ee},s.isTimeBuffered=function(e,t,i){for(var a,l,d=0;d<i.length;d++){if(a=i.start(d)-this.bufferPadding,l=i.end(d)+this.bufferPadding,e>=a&&t<=l)return!0;if(t<=a)return!1}return!1},s.onFragLoaded=function(e,t){var i=t.frag,a=t.part;if(i.sn!=="initSegment"&&!i.bitrateTest){var l=a?null:t,d=We(i);this.fragments[d]={body:i,appendedPTS:null,loaded:l,buffered:!1,range:Object.create(null)}}},s.onBufferAppended=function(e,t){var i=this,a=t.frag,l=t.part,d=t.timeRanges;if(a.sn!=="initSegment"){var c=a.type;if(l){var h=this.activePartLists[c];h||(this.activePartLists[c]=h=[]),h.push(l)}this.timeRanges=d,Object.keys(d).forEach(function(f){var p=d[f];i.detectEvictedFragments(f,p,c,l)})}},s.onFragBuffered=function(e,t){this.detectPartialFragments(t)},s.hasFragment=function(e){var t=We(e);return!!this.fragments[t]},s.hasParts=function(e){var t;return!((t=this.activePartLists[e])==null||!t.length)},s.removeFragmentsInRange=function(e,t,i,a,l){var d=this;a&&!this.hasGaps||Object.keys(this.fragments).forEach(function(c){var h=d.fragments[c];if(h){var f=h.body;f.type!==i||a&&!f.gap||f.start<t&&f.end>e&&(h.buffered||l)&&d.removeFragment(f)}})},s.removeFragment=function(e){var t=We(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var i=this.activePartLists[e.type];if(i){var a=e.sn;this.activePartLists[e.type]=i.filter(function(l){return l.fragment.sn!==a})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},s.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},u}();function Ce(u){var s,e,t;return u.buffered&&(u.body.gap||((s=u.range.video)==null?void 0:s.partial)||((e=u.range.audio)==null?void 0:e.partial)||((t=u.range.audiovideo)==null?void 0:t.partial))}function We(u){return u.type+"_"+u.level+"_"+u.urlId+"_"+u.sn}var Ot=Math.pow(2,17),Kt=function(){function u(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var s=u.prototype;return s.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},s.abort=function(){this.loader&&this.loader.abort()},s.load=function(e,t){var i=this,a=e.url;if(!a)return Promise.reject(new Ve({type:oe.NETWORK_ERROR,details:q.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(a?"part list":"url")),networkDetails:null}));this.abort();var l=this.config,d=l.fLoader,c=l.loader;return new Promise(function(h,f){if(i.loader&&i.loader.destroy(),e.gap)f(hi(e));else{var p=i.loader=e.loader=d?new d(l):new c(l),E=Zt(e),b=Ko(l.fragLoadPolicy.default),A={loadPolicy:b,timeout:b.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Ot};e.stats=p.stats,p.load(E,A,{onSuccess:function(w,D,S,L){i.resetLoader(e,p);var N=w.data;S.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(N.slice(0,16)),N=N.slice(16)),h({frag:e,part:null,payload:N,networkDetails:L})},onError:function(w,D,S,L){i.resetLoader(e,p),f(new Ve({type:oe.NETWORK_ERROR,details:q.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:y({url:a,data:void 0},w),error:new Error("HTTP Error "+w.code+" "+w.text),networkDetails:S,stats:L}))},onAbort:function(w,D,S){i.resetLoader(e,p),f(new Ve({type:oe.NETWORK_ERROR,details:q.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:S,stats:w}))},onTimeout:function(w,D,S){i.resetLoader(e,p),f(new Ve({type:oe.NETWORK_ERROR,details:q.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+A.timeout+"ms"),networkDetails:S,stats:w}))},onProgress:function(w,D,S,L){t&&t({frag:e,part:null,payload:S,networkDetails:L})}})}})},s.loadPart=function(e,t,i){var a=this;this.abort();var l=this.config,d=l.fLoader,c=l.loader;return new Promise(function(h,f){if(a.loader&&a.loader.destroy(),e.gap||t.gap)f(hi(e,t));else{var p=a.loader=e.loader=d?new d(l):new c(l),E=Zt(e,t),b=Ko(l.fragLoadPolicy.default),A={loadPolicy:b,timeout:b.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Ot};t.stats=p.stats,p.load(E,A,{onSuccess:function(w,D,S,L){a.resetLoader(e,p),a.updateStatsFromPart(e,t);var N={frag:e,part:t,payload:w.data,networkDetails:L};i(N),h(N)},onError:function(w,D,S,L){a.resetLoader(e,p),f(new Ve({type:oe.NETWORK_ERROR,details:q.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:y({url:E.url,data:void 0},w),error:new Error("HTTP Error "+w.code+" "+w.text),networkDetails:S,stats:L}))},onAbort:function(w,D,S){e.stats.aborted=t.stats.aborted,a.resetLoader(e,p),f(new Ve({type:oe.NETWORK_ERROR,details:q.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:S,stats:w}))},onTimeout:function(w,D,S){a.resetLoader(e,p),f(new Ve({type:oe.NETWORK_ERROR,details:q.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+A.timeout+"ms"),networkDetails:S,stats:w}))}})}})},s.updateStatsFromPart=function(e,t){var i=e.stats,a=t.stats,l=a.total;if(i.loaded+=a.loaded,l){var d=Math.round(e.duration/t.duration),c=Math.min(Math.round(i.loaded/l),d),h=(d-c)*Math.round(i.loaded/c);i.total=i.loaded+h}else i.total=Math.max(i.loaded,i.total);var f=i.loading,p=a.loading;f.start?f.first+=p.first-p.start:(f.start=p.start,f.first=p.first),f.end=p.end},s.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},u}();function Zt(u,s){s===void 0&&(s=null);var e=s||u,t={frag:u,part:s,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},i=e.byteRangeStartOffset,a=e.byteRangeEndOffset;if(re(i)&&re(a)){var l,d=i,c=a;if(u.sn==="initSegment"&&((l=u.decryptdata)==null?void 0:l.method)==="AES-128"){var h=a-i;h%16&&(c=a+(16-h%16)),i!==0&&(t.resetIV=!0,d=i-16)}t.rangeStart=d,t.rangeEnd=c}return t}function hi(u,s){var e=new Error("GAP "+(u.gap?"tag":"attribute")+" found"),t={type:oe.MEDIA_ERROR,details:q.FRAG_GAP,fatal:!1,frag:u,error:e,networkDetails:null};return s&&(t.part=s),(s||u).stats.aborted=!0,new Ve(t)}var Ve=function(u){function s(e){var t;return(t=u.call(this,e.error.message)||this).data=void 0,t.data=e,t}return z(s,u),s}(Te(Error)),St=function(){function u(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var s=u.prototype;return s.abort=function(e){for(var t in this.keyUriToKeyInfo){var i=this.keyUriToKeyInfo[t].loader;if(i){if(e&&e!==i.context.frag.type)return;i.abort()}}},s.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},s.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},s.createKeyLoadError=function(e,t,i,a,l){return t===void 0&&(t=q.KEY_LOAD_ERROR),new Ve({type:oe.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:l,error:i,networkDetails:a})},s.loadClear=function(e,t){var i=this;if(this.emeController&&this.config.emeEnabled)for(var a=e.sn,l=e.cc,d=function(){var h=t[c];if(l<=h.cc&&(a==="initSegment"||h.sn==="initSegment"||a<h.sn))return i.emeController.selectKeySystemFormat(h).then(function(f){h.setKeyFormat(f)}),"break"},c=0;c<t.length&&d()!=="break";c++);},s.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(i){return t.loadInternal(e,i)}):this.loadInternal(e)},s.loadInternal=function(e,t){var i,a;t&&e.setKeyFormat(t);var l=e.decryptdata;if(!l){var 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,q.KEY_LOAD_ERROR,d))}var c=l.uri;if(!c)return Promise.reject(this.createKeyLoadError(e,q.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+c+'"')));var h,f=this.keyUriToKeyInfo[c];if((i=f)!=null&&i.decryptdata.key)return l.key=f.decryptdata.key,Promise.resolve({frag:e,keyInfo:f});if((a=f)!=null&&a.keyLoadPromise)switch((h=f.mediaKeySessionContext)==null?void 0:h.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return f.keyLoadPromise.then(function(p){return l.key=p.keyInfo.decryptdata.key,{frag:e,keyInfo:f}})}switch(f=this.keyUriToKeyInfo[c]={decryptdata:l,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},l.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return l.keyFormat==="identity"?this.loadKeyHTTP(f,e):this.loadKeyEME(f,e);case"AES-128":return this.loadKeyHTTP(f,e);default:return Promise.reject(this.createKeyLoadError(e,q.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+l.method+'"')))}},s.loadKeyEME=function(e,t){var i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var a=this.emeController.loadKey(i);if(a)return(e.keyLoadPromise=a.then(function(l){return e.mediaKeySessionContext=l,i})).catch(function(l){throw e.keyLoadPromise=null,l})}return Promise.resolve(i)},s.loadKeyHTTP=function(e,t){var i=this,a=this.config,l=new a.loader(a);return t.keyLoader=e.loader=l,e.keyLoadPromise=new Promise(function(d,c){var h={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},f=a.keyLoadPolicy.default,p={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},E={onSuccess:function(b,A,w,D){var S=w.frag,L=w.keyInfo,N=w.url;if(!S.decryptdata||L!==i.keyUriToKeyInfo[N])return c(i.createKeyLoadError(S,q.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),D));L.decryptdata.key=S.decryptdata.key=new Uint8Array(b.data),S.keyLoader=null,L.loader=null,d({frag:S,keyInfo:L})},onError:function(b,A,w,D){i.resetLoader(A),c(i.createKeyLoadError(t,q.KEY_LOAD_ERROR,new Error("HTTP Error "+b.code+" loading key "+b.text),w,y({url:h.url,data:void 0},b)))},onTimeout:function(b,A,w){i.resetLoader(A),c(i.createKeyLoadError(t,q.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),w))},onAbort:function(b,A,w){i.resetLoader(A),c(i.createKeyLoadError(t,q.INTERNAL_ABORTED,new Error("key loading aborted"),w))}};l.load(h,p,E)})},s.resetLoader=function(e){var t=e.frag,i=e.keyInfo,a=e.url,l=i.loader;t.keyLoader===l&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[a],l&&l.destroy()},u}(),tt=function(){function u(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var s=u.prototype;return s.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},s.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},s.onHandlerDestroyed=function(){},s.hasInterval=function(){return!!this._tickInterval},s.hasNextTick=function(){return!!this._tickTimer},s.setInterval=function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},s.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},s.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},s.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},s.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},s.doTick=function(){},u}(),ue={length:0,start:function(){return 0},end:function(){return 0}},he=function(){function u(){}return u.isBuffered=function(s,e){try{if(s){for(var t=u.getBuffered(s),i=0;i<t.length;i++)if(e>=t.start(i)&&e<=t.end(i))return!0}}catch{}return!1},u.bufferInfo=function(s,e,t){try{if(s){var i,a=u.getBuffered(s),l=[];for(i=0;i<a.length;i++)l.push({start:a.start(i),end:a.end(i)});return this.bufferedInfo(l,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},u.bufferedInfo=function(s,e,t){e=Math.max(0,e),s.sort(function(w,D){var S=w.start-D.start;return S||D.end-w.end});var i=[];if(t)for(var a=0;a<s.length;a++){var l=i.length;if(l){var d=i[l-1].end;s[a].start-d<t?s[a].end>d&&(i[l-1].end=s[a].end):i.push(s[a])}else i.push(s[a])}else i=s;for(var c,h=0,f=e,p=e,E=0;E<i.length;E++){var b=i[E].start,A=i[E].end;if(e+t>=b&&e<A)f=b,h=(p=A)-e;else if(e+t<b){c=b;break}}return{len:h,start:f||0,end:p||0,nextStart:c}},u.getBuffered=function(s){try{return s.buffered}catch(e){return B.log("failed to get media.buffered",e),ue}},u}(),fe=function(u,s,e,t,i,a){t===void 0&&(t=0),i===void 0&&(i=-1),a===void 0&&(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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=u,this.sn=s,this.id=e,this.size=t,this.part=i,this.partial=a};function Ue(u,s){for(var e=null,t=0,i=u.length;t<i;t++){var a=u[t];if(a&&a.cc===s){e=a;break}}return e}function qe(u,s){if(u){var e=u.start+s;u.start=u.startPTS=e,u.endPTS=e+u.duration}}function yt(u,s){for(var e=s.fragments,t=0,i=e.length;t<i;t++)qe(e[t],u);s.fragmentHint&&qe(s.fragmentHint,u),s.alignedSliding=!0}function ni(u,s,e){s&&(function(t,i,a){if(function(d,c,h){return!(!c.details||!(h.endCC>h.startCC||d&&d.cc<h.startCC))}(t,a,i)){var l=function(d,c,h){var f=d.fragments,p=c.fragments;if(p.length&&f.length){var E=Ue(f,p[0].cc);if(E&&(!E||E.startPTS))return E;B.log("No frag in previous level to align on")}else B.log("No fragments to align")}(a.details,i);l&&re(l.start)&&(B.log("Adjusting PTS using last level due to CC increase within current level "+i.url),yt(l.start,i))}}(u,e,s),!e.alignedSliding&&s.details&&function(t,i){if(i.fragments.length&&t.hasProgramDateTime&&i.hasProgramDateTime){var a=i.fragments[0].programDateTime,l=t.fragments[0].programDateTime,d=(l-a)/1e3+i.fragments[0].start;d&&re(d)&&(B.log("Adjusting PTS using programDateTime delta "+(l-a)+"ms, sliding:"+d.toFixed(3)+" "+t.url+" "),yt(d,t))}}(e,s.details),e.alignedSliding||!s.details||e.skippedSegments||Es(s.details,e))}function Nt(u,s){if(u.hasProgramDateTime&&s.hasProgramDateTime){var e=u.fragments,t=s.fragments;if(e.length&&t.length){var i=t[Math.round(t.length/2)-1],a=Ue(e,i.cc)||e[Math.round(e.length/2)-1],l=i.programDateTime,d=a.programDateTime;l!==null&&d!==null&&yt((d-l)/1e3-(a.start-i.start),u)}}}var Jt=function(){function u(s,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=s,this.aesIV=e}return u.prototype.decrypt=function(s,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,s)},u}(),Ft=function(){function u(s,e){this.subtle=void 0,this.key=void 0,this.subtle=s,this.key=e}return u.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},u}(),Ut=function(){function u(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var s=u.prototype;return s.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),i=new Uint32Array(4),a=0;a<4;a++)i[a]=t.getUint32(4*a);return i},s.initTable=function(){var e=this.sBox,t=this.invSBox,i=this.subMix,a=i[0],l=i[1],d=i[2],c=i[3],h=this.invSubMix,f=h[0],p=h[1],E=h[2],b=h[3],A=new Uint32Array(256),w=0,D=0,S=0;for(S=0;S<256;S++)A[S]=S<128?S<<1:S<<1^283;for(S=0;S<256;S++){var L=D^D<<1^D<<2^D<<3^D<<4;L=L>>>8^255&L^99,e[w]=L,t[L]=w;var N=A[w],P=A[N],V=A[P],Y=257*A[L]^16843008*L;a[w]=Y<<24|Y>>>8,l[w]=Y<<16|Y>>>16,d[w]=Y<<8|Y>>>24,c[w]=Y,Y=16843009*V^65537*P^257*N^16843008*w,f[L]=Y<<24|Y>>>8,p[L]=Y<<16|Y>>>16,E[L]=Y<<8|Y>>>24,b[L]=Y,w?(w=N^A[A[A[V^N]]],D^=A[A[D]]):w=D=1}},s.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),i=!0,a=0;a<t.length&&i;)i=t[a]===this.key[a],a++;if(!i){this.key=t;var l=this.keySize=t.length;if(l!==4&&l!==6&&l!==8)throw new Error("Invalid aes key size="+l);var d,c,h,f,p=this.ksRows=4*(l+6+1),E=this.keySchedule=new Uint32Array(p),b=this.invKeySchedule=new Uint32Array(p),A=this.sBox,w=this.rcon,D=this.invSubMix,S=D[0],L=D[1],N=D[2],P=D[3];for(d=0;d<p;d++)d<l?h=E[d]=t[d]:(f=h,d%l==0?(f=A[(f=f<<8|f>>>24)>>>24]<<24|A[f>>>16&255]<<16|A[f>>>8&255]<<8|A[255&f],f^=w[d/l|0]<<24):l>6&&d%l==4&&(f=A[f>>>24]<<24|A[f>>>16&255]<<16|A[f>>>8&255]<<8|A[255&f]),E[d]=h=(E[d-l]^f)>>>0);for(c=0;c<p;c++)d=p-c,f=3&c?E[d]:E[d-4],b[c]=c<4||d<=4?f:S[A[f>>>24]]^L[A[f>>>16&255]]^N[A[f>>>8&255]]^P[A[255&f]],b[c]=b[c]>>>0}},s.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},s.decrypt=function(e,t,i){for(var a,l,d,c,h,f,p,E,b,A,w,D,S,L,N=this.keySize+6,P=this.invKeySchedule,V=this.invSBox,Y=this.invSubMix,j=Y[0],ie=Y[1],Q=Y[2],X=Y[3],ce=this.uint8ArrayToUint32Array_(i),le=ce[0],Ae=ce[1],xe=ce[2],Le=ce[3],Me=new Int32Array(e),Oe=new Int32Array(Me.length),Pe=this.networkToHostOrderSwap;t<Me.length;){for(b=Pe(Me[t]),A=Pe(Me[t+1]),w=Pe(Me[t+2]),D=Pe(Me[t+3]),h=b^P[0],f=D^P[1],p=w^P[2],E=A^P[3],S=4,L=1;L<N;L++)a=j[h>>>24]^ie[f>>16&255]^Q[p>>8&255]^X[255&E]^P[S],l=j[f>>>24]^ie[p>>16&255]^Q[E>>8&255]^X[255&h]^P[S+1],d=j[p>>>24]^ie[E>>16&255]^Q[h>>8&255]^X[255&f]^P[S+2],c=j[E>>>24]^ie[h>>16&255]^Q[f>>8&255]^X[255&p]^P[S+3],h=a,f=l,p=d,E=c,S+=4;a=V[h>>>24]<<24^V[f>>16&255]<<16^V[p>>8&255]<<8^V[255&E]^P[S],l=V[f>>>24]<<24^V[p>>16&255]<<16^V[E>>8&255]<<8^V[255&h]^P[S+1],d=V[p>>>24]<<24^V[E>>16&255]<<16^V[h>>8&255]<<8^V[255&f]^P[S+2],c=V[E>>>24]<<24^V[h>>16&255]<<16^V[f>>8&255]<<8^V[255&p]^P[S+3],Oe[t]=Pe(a^le),Oe[t+1]=Pe(c^Ae),Oe[t+2]=Pe(d^xe),Oe[t+3]=Pe(l^Le),le=b,Ae=A,xe=w,Le=D,t+=4}return Oe.buffer},u}(),Ni=function(){function u(e,t){var i=(t===void 0?{}:t).removePKCS7Padding,a=i===void 0||i;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=a,a)try{var l=self.crypto;l&&(this.subtle=l.subtle||l.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var s=u.prototype;return s.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},s.isSync=function(){return this.useSoftware},s.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var i,a,l,d=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(a=(i=d).byteLength,(l=a&&new DataView(i.buffer).getUint8(a-1))?xi(i,0,a-l):i):d},s.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},s.decrypt=function(e,t,i){var a=this;return this.useSoftware?new Promise(function(l,d){a.softwareDecrypt(new Uint8Array(e),t,i);var c=a.flush();c?l(c.buffer):d(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i)},s.softwareDecrypt=function(e,t,i){var a=this.currentIV,l=this.currentResult,d=this.remainderData;this.logOnce("JS AES decrypt"),d&&(e=Tr(d,e),this.remainderData=null);var c=this.getValidChunk(e);if(!c.length)return null;a&&(i=a);var h=this.softwareDecrypter;h||(h=this.softwareDecrypter=new Ut),h.expandKey(t);var f=l;return this.currentResult=h.decrypt(c.buffer,0,i),this.currentIV=xi(c,-16).buffer,f||null},s.webCryptoDecrypt=function(e,t,i){var a=this,l=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new Ft(l,t)),this.fastAesKey.expandKey().then(function(d){return l?(a.logOnce("WebCrypto AES decrypt"),new Jt(l,new Uint8Array(i)).decrypt(e.buffer,d)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(d){return B.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+d.name+": "+d.message),a.onWebCryptoError(e,t,i)})},s.onWebCryptoError=function(e,t,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i);var a=this.flush();if(a)return a.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},s.getValidChunk=function(e){var t=e,i=e.length-e.length%16;return i!==e.length&&(t=xi(e,0,i),this.remainderData=xi(e,i)),t},s.logOnce=function(e){this.logEnabled&&(B.log("[decrypter]: "+e),this.logEnabled=!1)},u}(),Da=function(u){for(var s="",e=u.length,t=0;t<e;t++)s+="["+u.start(t).toFixed(3)+"-"+u.end(t).toFixed(3)+"]";return s},Bt="STOPPED",De="IDLE",wr="KEY_LOADING",Xr="FRAG_LOADING",Zr="FRAG_LOADING_WAITING_RETRY",Ca="WAITING_TRACK",Lr="PARSING",Yo="PARSED",bs="ENDED",fn="ERROR",Ts="WAITING_INIT_PTS",mn="WAITING_LEVEL",Zu=function(u){function s(t,i,a,l,d){var c;return(c=u.call(this)||this).hls=void 0,c.fragPrevious=null,c.fragCurrent=null,c.fragmentTracker=void 0,c.transmuxer=null,c._state=Bt,c.playlistType=void 0,c.media=null,c.mediaBuffer=null,c.config=void 0,c.bitrateTest=!1,c.lastCurrentTime=0,c.nextLoadPosition=0,c.startPosition=0,c.startTimeOffset=null,c.loadedmetadata=!1,c.retryDate=0,c.levels=null,c.fragmentLoader=void 0,c.keyLoader=void 0,c.levelLastLoaded=null,c.startFragRequested=!1,c.decrypter=void 0,c.initPTS=[],c.onvseeking=null,c.onvended=null,c.logPrefix="",c.log=void 0,c.warn=void 0,c.playlistType=d,c.logPrefix=l,c.log=B.log.bind(B,l+":"),c.warn=B.warn.bind(B,l+":"),c.hls=t,c.fragmentLoader=new Kt(t.config),c.keyLoader=a,c.fragmentTracker=i,c.config=t.config,c.decrypter=new Ni(t.config),t.on(k.MANIFEST_LOADED,c.onManifestLoaded,function(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}(c)),c}z(s,u);var e=s.prototype;return e.doTick=function(){this.onTickEnd()},e.onTickEnd=function(){},e.startLoad=function(t){},e.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Bt},e._streamEnded=function(t,i){if(i.live||t.nextStart||!t.end||!this.media)return!1;var a=i.partList;if(a!=null&&a.length){var l=a[a.length-1];return he.isBuffered(this.media,l.start+l.duration/2)}var d=i.fragments[i.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(d)},e.getLevelDetails=function(){var t;if(this.levels&&this.levelLastLoaded!==null)return(t=this.levels[this.levelLastLoaded])==null?void 0:t.details},e.onMediaAttached=function(t,i){var a=this.media=this.mediaBuffer=i.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),a.addEventListener("seeking",this.onvseeking),a.addEventListener("ended",this.onvended);var l=this.config;this.levels&&l.autoStartLoad&&this.state===Bt&&this.startLoad(l.startPosition)},e.onMediaDetaching=function(){var t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.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()},e.onMediaSeeking=function(){var t=this.config,i=this.fragCurrent,a=this.media,l=this.mediaBuffer,d=this.state,c=a?a.currentTime:0,h=he.bufferInfo(l||a,c,t.maxBufferHole);if(this.log("media seeking to "+(re(c)?c.toFixed(3):c)+", state: "+d),this.state===bs)this.resetLoadingState();else if(i){var f=t.maxFragLookUpTolerance,p=i.start-f,E=i.start+i.duration+f;if(!h.len||E<h.start||p>h.end){var b=c>E;(c<p||b)&&(b&&i.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),i.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}a&&(this.fragmentTracker.removeFragmentsInRange(c,1/0,this.playlistType,!0),this.lastCurrentTime=c),this.loadedmetadata||h.len||(this.nextLoadPosition=this.startPosition=c),this.tickImmediate()},e.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},e.onManifestLoaded=function(t,i){this.startTimeOffset=i.startTimeOffset,this.initPTS=[]},e.onHandlerDestroying=function(){this.stopLoad(),u.prototype.onHandlerDestroying.call(this)},e.onHandlerDestroyed=function(){this.state=Bt,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,u.prototype.onHandlerDestroyed.call(this)},e.loadFragment=function(t,i,a){this._loadFragForPlayback(t,i,a)},e._loadFragForPlayback=function(t,i,a){var l=this;this._doFragLoad(t,i,a,function(d){if(l.fragContextChanged(t))return l.warn("Fragment "+t.sn+(d.part?" p: "+d.part.index:"")+" of level "+t.level+" was dropped during download."),void l.fragmentTracker.removeFragment(t);t.stats.chunkCount++,l._handleFragmentLoadProgress(d)}).then(function(d){if(d){var c=l.state;l.fragContextChanged(t)?(c===Xr||!l.fragCurrent&&c===Lr)&&(l.fragmentTracker.removeFragment(t),l.state=De):("payload"in d&&(l.log("Loaded fragment "+t.sn+" of level "+t.level),l.hls.trigger(k.FRAG_LOADED,d)),l._handleFragmentLoadComplete(d))}}).catch(function(d){l.state!==Bt&&l.state!==fn&&(l.warn(d),l.resetFragmentLoading(t))})},e.clearTrackerIfNeeded=function(t){var i,a=this.fragmentTracker;if(a.getState(t)===Fe){var l=t.type,d=this.getFwdBufferInfo(this.mediaBuffer,l),c=Math.max(t.duration,d?d.len:this.config.maxBufferLength);this.reduceMaxBufferLength(c)&&a.removeFragment(t)}else((i=this.mediaBuffer)==null?void 0:i.buffered.length)===0?a.removeAllFragments():a.hasParts(t.type)&&(a.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),a.getState(t)===_e&&a.removeFragment(t))},e.flushMainBuffer=function(t,i,a){if(a===void 0&&(a=null),t-i){var l={startOffset:t,endOffset:i,type:a};this.hls.trigger(k.BUFFER_FLUSHING,l)}},e._loadInitSegment=function(t,i){var a=this;this._doFragLoad(t,i).then(function(l){if(!l||a.fragContextChanged(t)||!a.levels)throw new Error("init load aborted");return l}).then(function(l){var d=a.hls,c=l.payload,h=t.decryptdata;if(c&&c.byteLength>0&&h&&h.key&&h.iv&&h.method==="AES-128"){var f=self.performance.now();return a.decrypter.decrypt(new Uint8Array(c),h.key.buffer,h.iv.buffer).catch(function(p){throw d.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.FRAG_DECRYPT_ERROR,fatal:!1,error:p,reason:p.message,frag:t}),p}).then(function(p){var E=self.performance.now();return d.trigger(k.FRAG_DECRYPTED,{frag:t,payload:p,stats:{tstart:f,tdecrypt:E}}),l.payload=p,l})}return l}).then(function(l){var d=a.fragCurrent,c=a.hls;if(!a.levels)throw new Error("init load aborted, missing levels");var h=t.stats;a.state=De,i.fragmentError=0,t.data=new Uint8Array(l.payload),h.parsing.start=h.buffering.start=self.performance.now(),h.parsing.end=h.buffering.end=self.performance.now(),l.frag===d&&c.trigger(k.FRAG_BUFFERED,{stats:h,frag:d,part:null,id:t.type}),a.tick()}).catch(function(l){a.state!==Bt&&a.state!==fn&&(a.warn(l),a.resetFragmentLoading(t))})},e.fragContextChanged=function(t){var i=this.fragCurrent;return!t||!i||t.level!==i.level||t.sn!==i.sn||t.urlId!==i.urlId},e.fragBufferedComplete=function(t,i){var a,l,d,c,h=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(i?" part: "+i.index:"")+" of "+(this.playlistType===rt?"level":"track")+" "+t.level+" (frag:["+((a=t.startPTS)!=null?a:NaN).toFixed(3)+"-"+((l=t.endPTS)!=null?l:NaN).toFixed(3)+"] > buffer:"+(h?Da(he.getBuffered(h)):"(detached)")+")"),this.state=De,h&&(!this.loadedmetadata&&t.type==rt&&h.buffered.length&&((d=this.fragCurrent)==null?void 0:d.sn)===((c=this.fragPrevious)==null?void 0:c.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},e.seekToStartPos=function(){},e._handleFragmentLoadComplete=function(t){var i=this.transmuxer;if(i){var a=t.frag,l=t.part,d=t.partsLoaded,c=!d||d.length===0||d.some(function(f){return!f}),h=new fe(a.level,a.sn,a.stats.chunkCount+1,0,l?l.index:-1,!c);i.flush(h)}},e._handleFragmentLoadProgress=function(t){},e._doFragLoad=function(t,i,a,l){var d,c=this;a===void 0&&(a=null);var h=i==null?void 0:i.details;if(!this.levels||!h)throw new Error("frag load aborted, missing level"+(h?"":" detail")+"s");var f=null;if(!t.encrypted||(d=t.decryptdata)!=null&&d.key?!t.encrypted&&h.encryptedFragments.length&&this.keyLoader.loadClear(t,h.encryptedFragments):(this.log("Loading key for "+t.sn+" of ["+h.startSN+"-"+h.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level),this.state=wr,this.fragCurrent=t,f=this.keyLoader.load(t).then(function(S){if(!c.fragContextChanged(S.frag))return c.hls.trigger(k.KEY_LOADED,S),c.state===wr&&(c.state=De),S}),this.hls.trigger(k.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(f=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),a=Math.max(t.start,a||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){var p=h.partList;if(p&&l){a>t.end&&h.fragmentHint&&(t=h.fragmentHint);var E=this.getNextPart(p,t,a);if(E>-1){var b,A=p[E];return this.log("Loading part sn: "+t.sn+" p: "+A.index+" cc: "+t.cc+" of playlist ["+h.startSN+"-"+h.endSN+"] parts [0-"+E+"-"+(p.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(a.toFixed(3))),this.nextLoadPosition=A.start+A.duration,this.state=Xr,b=f?f.then(function(S){return!S||c.fragContextChanged(S.frag)?null:c.doFragPartsLoad(t,A,i,l)}).catch(function(S){return c.handleFragLoadError(S)}):this.doFragPartsLoad(t,A,i,l).catch(function(S){return c.handleFragLoadError(S)}),this.hls.trigger(k.FRAG_LOADING,{frag:t,part:A,targetBufferTime:a}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):b}if(!t.url||this.loadedEndOfParts(p,a))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(h?"of ["+h.startSN+"-"+h.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(a.toFixed(3))),re(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Xr;var w,D=this.config.progressive;return w=D&&f?f.then(function(S){return!S||c.fragContextChanged(S==null?void 0:S.frag)?null:c.fragmentLoader.load(t,l)}).catch(function(S){return c.handleFragLoadError(S)}):Promise.all([this.fragmentLoader.load(t,D?l:void 0),f]).then(function(S){var L=S[0];return!D&&L&&l&&l(L),L}).catch(function(S){return c.handleFragLoadError(S)}),this.hls.trigger(k.FRAG_LOADING,{frag:t,targetBufferTime:a}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):w},e.doFragPartsLoad=function(t,i,a,l){var d=this;return new Promise(function(c,h){var f,p=[],E=(f=a.details)==null?void 0:f.partList;(function b(A){d.fragmentLoader.loadPart(t,A,l).then(function(w){p[A.index]=w;var D=w.part;d.hls.trigger(k.FRAG_LOADED,w);var S=Ho(a,t.sn,A.index+1)||Go(E,t.sn,A.index+1);if(!S)return c({frag:t,part:D,partsLoaded:p});b(S)}).catch(h)})(i)})},e.handleFragLoadError=function(t){if("data"in t){var i=t.data;t.data&&i.details===q.INTERNAL_ABORTED?this.handleFragLoadAborted(i.frag,i.part):this.hls.trigger(k.ERROR,i)}else this.hls.trigger(k.ERROR,{type:oe.OTHER_ERROR,details:q.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},e._handleTransmuxerFlush=function(t){var i=this.getCurrentContext(t);if(i&&this.state===Lr){var a=i.frag,l=i.part,d=i.level,c=self.performance.now();a.stats.parsing.end=c,l&&(l.stats.parsing.end=c),this.updateLevelTiming(a,l,d,t.partial)}else this.fragCurrent||this.state===Bt||this.state===fn||(this.state=De)},e.getCurrentContext=function(t){var i=this.levels,a=this.fragCurrent,l=t.level,d=t.sn,c=t.part;if(i==null||!i[l])return this.warn("Levels object was unset while buffering fragment "+d+" of level "+l+". The current chunk will not be buffered."),null;var h=i[l],f=c>-1?Ho(h,d,c):null,p=f?f.fragment:function(E,b,A){if(E==null||!E.details)return null;var w=E.details,D=w.fragments[b-w.startSN];return D||((D=w.fragmentHint)&&D.sn===b?D:b<w.startSN&&A&&A.sn===b?A:null)}(h,d,a);return p?(a&&a!==p&&(p.stats=a.stats),{frag:p,part:f,level:h}):null},e.bufferFragmentData=function(t,i,a,l){var d;if(t&&this.state===Lr){var c=t.data1,h=t.data2,f=c;if(c&&h&&(f=Tr(c,h)),(d=f)!=null&&d.length){var p={type:t.type,frag:i,part:a,chunkMeta:l,parent:i.type,data:f};this.hls.trigger(k.BUFFER_APPENDING,p),t.dropped&&t.independent&&!a&&this.flushBufferGap(i)}}},e.flushBufferGap=function(t){var i=this.media;if(i)if(he.isBuffered(i,i.currentTime)){var a=i.currentTime,l=he.bufferInfo(i,a,0),d=t.duration,c=Math.min(2*this.config.maxFragLookUpTolerance,.25*d),h=Math.max(Math.min(t.start-c,l.end-c),a+c);t.start-h>c&&this.flushMainBuffer(h,t.start)}else this.flushMainBuffer(0,t.start)},e.getFwdBufferInfo=function(t,i){var a=this.getLoadPosition();return re(a)?this.getFwdBufferInfoAtPos(t,a,i):null},e.getFwdBufferInfoAtPos=function(t,i,a){var l=this.config.maxBufferHole,d=he.bufferInfo(t,i,l);if(d.len===0&&d.nextStart!==void 0){var c=this.fragmentTracker.getBufferedFrag(i,a);if(c&&d.nextStart<c.end)return he.bufferInfo(t,i,Math.max(d.nextStart,l))}return d},e.getMaxBufferLength=function(t){var i,a=this.config;return i=t?Math.max(8*a.maxBufferSize/t,a.maxBufferLength):a.maxBufferLength,Math.min(i,a.maxMaxBufferLength)},e.reduceMaxBufferLength=function(t){var i=this.config,a=t||i.maxBufferLength;return i.maxMaxBufferLength>=a&&(i.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+i.maxMaxBufferLength+"s"),!0)},e.getAppendedFrag=function(t,i){var a=this.fragmentTracker.getAppendedFrag(t,rt);return a&&"fragment"in a?a.fragment:a},e.getNextFragment=function(t,i){var a=i.fragments,l=a.length;if(!l)return null;var d,c=this.config,h=a[0].start;if(i.live){var f=c.initialLiveManifestSize;if(l<f)return this.warn("Not enough fragments to start playback (have: "+l+", need: "+f+")"),null;i.PTSKnown||this.startFragRequested||this.startPosition!==-1||(d=this.getInitialLiveFragment(i,a),this.startPosition=d?this.hls.liveSyncPosition||d.start:t)}else t<=h&&(d=a[0]);if(!d){var p=c.lowLatencyMode?i.partEnd:i.fragmentEnd;d=this.getFragmentAtPosition(t,p,i)}return this.mapToInitFragWhenRequired(d)},e.isLoopLoading=function(t,i){var a=this.fragmentTracker.getState(t);return(a===Re||a===_e&&!!t.gap)&&this.nextLoadPosition>i},e.getNextFragmentLoopLoading=function(t,i,a,l,d){var c=t.gap,h=this.getNextFragment(this.nextLoadPosition,i);if(h===null)return h;if(t=h,c&&t&&!t.gap&&a.nextStart){var f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,a.nextStart,l);if(f!==null&&a.len+f.len>=d)return this.log('buffer full after gaps in "'+l+'" playlist starting at sn: '+t.sn),null}return t},e.mapToInitFragWhenRequired=function(t){return t==null||!t.initSegment||t!=null&&t.initSegment.data||this.bitrateTest?t:t.initSegment},e.getNextPart=function(t,i,a){for(var l=-1,d=!1,c=!0,h=0,f=t.length;h<f;h++){var p=t[h];if(c=c&&!p.independent,l>-1&&a<p.start)break;var E=p.loaded;E?l=-1:(d||p.independent||c)&&p.fragment===i&&(l=h),d=E}return l},e.loadedEndOfParts=function(t,i){var a=t[t.length-1];return a&&i>a.start&&a.loaded},e.getInitialLiveFragment=function(t,i){var a=this.fragPrevious,l=null;if(a){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+a.programDateTime),l=function(f,p,E){if(p===null||!Array.isArray(f)||!f.length||!re(p)||p<(f[0].programDateTime||0)||p>=(f[f.length-1].endProgramDateTime||0))return null;E=E||0;for(var b=0;b<f.length;++b){var A=f[b];if(bi(p,E,A))return A}return null}(i,a.endProgramDateTime,this.config.maxFragLookUpTolerance)),!l){var d=a.sn+1;if(d>=t.startSN&&d<=t.endSN){var c=i[d-t.startSN];a.cc===c.cc&&(l=c,this.log("Live playlist, switching playlist, load frag with next SN: "+l.sn))}l||(l=function(f,p){return Wo(f,function(E){return E.cc<p?1:E.cc>p?-1:0})}(i,a.cc),l&&this.log("Live playlist, switching playlist, load frag with same CC: "+l.sn))}}else{var h=this.hls.liveSyncPosition;h!==null&&(l=this.getFragmentAtPosition(h,this.bitrateTest?t.fragmentEnd:t.edge,t))}return l},e.getFragmentAtPosition=function(t,i,a){var l,d=this.config,c=this.fragPrevious,h=a.fragments,f=a.endSN,p=a.fragmentHint,E=d.maxFragLookUpTolerance,b=a.partList,A=!!(d.lowLatencyMode&&b!=null&&b.length&&p);if(A&&p&&!this.bitrateTest&&(h=h.concat(p),f=p.sn),l=t<i?Ra(c,h,t,t>i-E?0:E):h[h.length-1]){var w=l.sn-a.startSN,D=this.fragmentTracker.getState(l);if((D===Re||D===_e&&l.gap)&&(c=l),c&&l.sn===c.sn&&(!A||b[0].fragment.sn>l.sn)&&c&&l.level===c.level){var S=h[w+1];l=l.sn<f&&this.fragmentTracker.getState(S)!==Re?S:null}}return l},e.synchronizeToLiveEdge=function(t){var i=this.config,a=this.media;if(a){var l=this.hls.liveSyncPosition,d=a.currentTime,c=t.fragments[0].start,h=t.edge,f=d>=c-i.maxFragLookUpTolerance&&d<=h;if(l!==null&&a.duration>l&&(d<l||!f)){var p=i.liveMaxLatencyDuration!==void 0?i.liveMaxLatencyDuration:i.liveMaxLatencyDurationCount*t.targetduration;(!f&&a.readyState<4||d<h-p)&&(this.loadedmetadata||(this.nextLoadPosition=l),a.readyState&&(this.warn("Playback: "+d.toFixed(3)+" is located too far from the end of live sliding playlist: "+h+", reset currentTime to : "+l.toFixed(3)),a.currentTime=l))}}},e.alignPlaylists=function(t,i){var a=this.levels,l=this.levelLastLoaded,d=this.fragPrevious,c=l!==null?a[l]:null,h=t.fragments.length;if(!h)return this.warn("No fragments in live playlist"),0;var f=t.fragments[0].start,p=!i,E=t.alignedSliding&&re(f);if(p||!E&&!f){ni(d,c,t);var b=t.fragments[0].start;return this.log("Live playlist sliding: "+b.toFixed(2)+" start-sn: "+(i?i.startSN:"na")+"->"+t.startSN+" prev-sn: "+(d?d.sn:"na")+" fragments: "+h),b}return f},e.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},e.setStartPosition=function(t,i){var a=this.startPosition;if(a<i&&(a=-1),a===-1||this.lastCurrentTime===-1){var l=this.startTimeOffset!==null,d=l?this.startTimeOffset:t.startTimeOffset;d!==null&&re(d)?(a=i+d,d<0&&(a+=t.totalduration),a=Math.min(Math.max(i,a),i+t.totalduration),this.log("Start time offset "+d+" found in "+(l?"multivariant":"media")+" playlist, adjust startPosition to "+a),this.startPosition=a):t.live?a=this.hls.liveSyncPosition||i:this.startPosition=a=0,this.lastCurrentTime=a}this.nextLoadPosition=a},e.getLoadPosition=function(){var t=this.media,i=0;return this.loadedmetadata&&t?i=t.currentTime:this.nextLoadPosition&&(i=this.nextLoadPosition),i},e.handleFragLoadAborted=function(t,i){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(i?" part "+i.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},e.resetFragmentLoading=function(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===Zr)||(this.state=De)},e.onFragmentOrKeyLoadError=function(t,i){if(i.chunkMeta&&!i.frag){var a=this.getCurrentContext(i.chunkMeta);a&&(i.frag=a.frag)}var l=i.frag;if(l&&l.type===t&&this.levels)if(this.fragContextChanged(l)){var d;this.warn("Frag load error must match current frag to retry "+l.url+" > "+((d=this.fragCurrent)==null?void 0:d.url))}else{var c=i.details===q.FRAG_GAP;c&&this.fragmentTracker.fragBuffered(l,!0);var h=i.errorAction,f=h||{},p=f.action,E=f.retryCount,b=E===void 0?0:E,A=f.retryConfig;if(h&&p===g&&A){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var w=ys(A,b);this.warn("Fragment "+l.sn+" of "+t+" "+l.level+" errored with "+i.details+", retrying loading "+(b+1)+"/"+A.maxNumRetry+" in "+w+"ms"),h.resolved=!0,this.retryDate=self.performance.now()+w,this.state=Zr}else A&&h?(this.resetFragmentErrors(t),b<A.maxNumRetry?c||(h.resolved=!0):B.warn(i.details+" reached or exceeded max retry ("+b+")")):this.state=fn;this.tickImmediate()}},e.reduceLengthAndFlushBuffer=function(t){if(this.state===Lr||this.state===Yo){var i=t.parent,a=this.getFwdBufferInfo(this.mediaBuffer,i),l=a&&a.len>.5;l&&this.reduceMaxBufferLength(a.len);var d=!l;return d&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+i+" buffer"),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),d}return!1},e.resetFragmentErrors=function(t){t===Di&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Bt&&(this.state=De)},e.afterBufferFlushed=function(t,i,a){if(t){var l=he.getBuffered(t);this.fragmentTracker.detectEvictedFragments(i,l,a),this.state===bs&&this.resetLoadingState()}},e.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=De},e.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var i=this.levels?this.levels[t].details:null;i!=null&&i.live?(this.startPosition=-1,this.setStartPosition(i,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},e.resetWhenMissingContext=function(t){this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(t.level),this.resetLoadingState()},e.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},e.updateLevelTiming=function(t,i,a,l){var d,c=this,h=a.details;if(h){if(Object.keys(t.elementaryStreams).reduce(function(p,E){var b=t.elementaryStreams[E];if(b){var A=b.endPTS-b.startPTS;if(A<=0)return c.warn("Could not parse fragment "+t.sn+" "+E+" duration reliably ("+A+")"),p||!1;var w=l?0:La(h,t,b.startPTS,b.endPTS,b.startDTS,b.endDTS);return c.hls.trigger(k.LEVEL_PTS_UPDATED,{details:h,level:a,drift:w,type:E,frag:t,start:b.startPTS,end:b.endPTS}),!0}return p},!1))a.fragmentError=0;else if(((d=this.transmuxer)==null?void 0:d.error)===null){var f=new Error("Found no media in fragment "+t.sn+" of level "+a.id+" resetting transmuxer to fallback to playlist timing");if(this.warn(f.message),this.hls.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,error:f,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+a.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=Yo,this.hls.trigger(k.FRAG_PARSED,{frag:t,part:i})}else this.warn("level.details undefined")},e.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},e.recoverWorkerError=function(t){t.event==="demuxerWorker"&&(this.resetTransmuxer(),this.resetLoadingState())},M(s,[{key:"state",get:function(){return this._state},set:function(t){var i=this._state;i!==t&&(this._state=t,this.log(i+"->"+t))}}]),s}(tt);function Ch(){return self.SourceBuffer||self.WebKitSourceBuffer}function or(u,s){return u===void 0&&(u=""),s===void 0&&(s=9e4),{type:u,id:-1,pid:-1,inputTimeScale:s,sequenceNumber:-1,samples:[],dropped:0}}var Mh=function(){function u(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var s=u.prototype;return s.resetInitSegment=function(e,t,i,a){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},s.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},s.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},s.canParse=function(e,t){return!1},s.appendFrame=function(e,t,i){},s.demux=function(e,t){this.cachedData&&(e=Tr(this.cachedData,e),this.cachedData=null);var i,a=ga(e,0),l=a?a.length:0,d=this._audioTrack,c=this._id3Track,h=a?function(b){for(var A=is(b),w=0;w<A.length;w++){var D=A[w];if(Eo(D))return To(D)}}(a):void 0,f=e.length;for((this.basePTS===null||this.frameIndex===0&&re(h))&&(this.basePTS=Gv(h,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),a&&a.length>0&&c.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:a,type:Aa,duration:Number.POSITIVE_INFINITY});l<f;){if(this.canParse(e,l)){var p=this.appendFrame(d,e,l);p?(this.frameIndex++,this.lastPTS=p.sample.pts,i=l+=p.length):l=f}else go(e,l)?(a=ga(e,l),c.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:a,type:Aa,duration:Number.POSITIVE_INFINITY}),i=l+=a.length):l++;if(l===f&&i!==f){var E=xi(e,i);this.cachedData?this.cachedData=Tr(this.cachedData,E):this.cachedData=E}}return{audioTrack:d,videoTrack:or(),id3Track:c,textTrack:or()}},s.demuxSampleAes=function(e,t,i){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},s.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:or(),id3Track:this._id3Track,textTrack:or()}},s.destroy=function(){},u}(),Gv=function(u,s,e){return re(u)?90*u:9e4*s+(e?9e4*e.baseTime/e.timescale:0)};function xh(u,s){return u[s]===255&&(246&u[s+1])==240}function Ph(u,s){return 1&u[s+1]?7:9}function Ju(u,s){return(3&u[s+3])<<11|u[s+4]<<3|(224&u[s+5])>>>5}function $o(u,s){return s+1<u.length&&xh(u,s)}function Vv(u,s){if($o(u,s)){var e=Ph(u,s);if(s+e>=u.length)return!1;var t=Ju(u,s);if(t<=e)return!1;var i=s+t;return i===u.length||$o(u,i)}return!1}function Oh(u,s,e,t,i){if(!u.samplerate){var a=function(l,d,c,h){var f,p,E,b,A=navigator.userAgent.toLowerCase(),w=h,D=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];f=1+((192&d[c+2])>>>6);var S=(60&d[c+2])>>>2;if(!(S>D.length-1))return E=(1&d[c+2])<<2,E|=(192&d[c+3])>>>6,B.log("manifest codec:"+h+", ADTS type:"+f+", samplingIndex:"+S),/firefox/i.test(A)?S>=6?(f=5,b=new Array(4),p=S-3):(f=2,b=new Array(2),p=S):A.indexOf("android")!==-1?(f=2,b=new Array(2),p=S):(f=5,b=new Array(4),h&&(h.indexOf("mp4a.40.29")!==-1||h.indexOf("mp4a.40.5")!==-1)||!h&&S>=6?p=S-3:((h&&h.indexOf("mp4a.40.2")!==-1&&(S>=6&&E===1||/vivaldi/i.test(A))||!h&&E===1)&&(f=2,b=new Array(2)),p=S)),b[0]=f<<3,b[0]|=(14&S)>>1,b[1]|=(1&S)<<7,b[1]|=E<<3,f===5&&(b[1]|=(14&p)>>1,b[2]=(1&p)<<7,b[2]|=8,b[3]=0),{config:b,samplerate:D[S],channelCount:E,codec:"mp4a.40."+f,manifestCodec:w};l.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+S})}(s,e,t,i);if(!a)return;u.config=a.config,u.samplerate=a.samplerate,u.channelCount=a.channelCount,u.codec=a.codec,u.manifestCodec=a.manifestCodec,B.log("parsed codec:"+u.codec+", rate:"+a.samplerate+", channels:"+a.channelCount)}}function Nh(u){return 9216e4/u}function Fh(u,s,e,t,i){var a,l=t+i*Nh(u.samplerate),d=function(A,w){var D=Ph(A,w);if(w+D<=A.length){var S=Ju(A,w)-D;if(S>0)return{headerLength:D,frameLength:S}}}(s,e);if(d){var c=d.frameLength,h=d.headerLength,f=h+c,p=Math.max(0,e+f-s.length);p?(a=new Uint8Array(f-h)).set(s.subarray(e+h,s.length),0):a=s.subarray(e+h,e+f);var E={unit:a,pts:l};return p||u.samples.push(E),{sample:E,length:f,missing:p}}var b=s.length-e;return(a=new Uint8Array(b)).set(s.subarray(e,s.length),0),{sample:{unit:a,pts:l},length:b,missing:-1}}var Kv=function(u){function s(t,i){var a;return(a=u.call(this)||this).observer=void 0,a.config=void 0,a.observer=t,a.config=i,a}z(s,u);var e=s.prototype;return e.resetInitSegment=function(t,i,a,l){u.prototype.resetInitSegment.call(this,t,i,a,l),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:i,duration:l,inputTimeScale:9e4,dropped:0}},s.probe=function(t){if(!t)return!1;for(var i=(ga(t,0)||[]).length,a=t.length;i<a;i++)if(Vv(t,i))return B.log("ADTS sync word found !"),!0;return!1},e.canParse=function(t,i){return function(a,l){return function(d,c){return c+5<d.length}(a,l)&&xh(a,l)&&Ju(a,l)<=a.length-l}(t,i)},e.appendFrame=function(t,i,a){Oh(t,this.observer,i,a,t.manifestCodec);var l=Fh(t,i,a,this.basePTS,this.frameIndex);if(l&&l.missing===0)return l},s}(Mh),Wv=/\/emsg[-/]ID3/i,qv=function(){function u(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}var s=u.prototype;return s.resetTimeStamp=function(){},s.resetInitSegment=function(e,t,i,a){var l=this.videoTrack=or("video",1),d=this.audioTrack=or("audio",1),c=this.txtTrack=or("text",1);if(this.id3Track=or("id3",1),this.timeOffset=0,e!=null&&e.byteLength){var h=ns(e);if(h.video){var f=h.video,p=f.id,E=f.timescale,b=f.codec;l.id=p,l.timescale=c.timescale=E,l.codec=b}if(h.audio){var A=h.audio,w=A.id,D=A.timescale,S=A.codec;d.id=w,d.timescale=D,d.codec=S}c.id=_o.text,l.sampleDuration=0,l.duration=d.duration=a}},s.resetContiguity=function(){this.remainderData=null},u.probe=function(e){return Je(e=e.length>16384?e.subarray(0,16384):e,["moof"]).length>0},s.demux=function(e,t){this.timeOffset=t;var i=e,a=this.videoTrack,l=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=Tr(this.remainderData,e));var d=function(h){var f={valid:null,remainder:null},p=Je(h,["moof"]);if(!p)return f;if(p.length<2)return f.remainder=h,f;var E=p[p.length-1];return f.valid=xi(h,0,E.byteOffset-8),f.remainder=xi(h,E.byteOffset-8),f}(i);this.remainderData=d.remainder,a.samples=d.valid||new Uint8Array}else a.samples=i;var c=this.extractID3Track(a,t);return l.samples=os(t,a),{videoTrack:a,audioTrack:this.audioTrack,id3Track:c,textTrack:this.txtTrack}},s.flush=function(){var e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var a=this.extractID3Track(t,this.timeOffset);return i.samples=os(e,t),{videoTrack:t,audioTrack:or(),id3Track:a,textTrack:or()}},s.extractID3Track=function(e,t){var i=this.id3Track;if(e.samples.length){var a=Je(e.samples,["emsg"]);a&&a.forEach(function(l){var d=function(p){var E=p[0],b="",A="",w=0,D=0,S=0,L=0,N=0,P=0;if(E===0){for(;xt(p.subarray(P,P+1))!=="\0";)b+=xt(p.subarray(P,P+1)),P+=1;for(b+=xt(p.subarray(P,P+1)),P+=1;xt(p.subarray(P,P+1))!=="\0";)A+=xt(p.subarray(P,P+1)),P+=1;A+=xt(p.subarray(P,P+1)),P+=1,w=He(p,12),D=He(p,16),L=He(p,20),N=He(p,24),P=28}else if(E===1){w=He(p,P+=4);var V=He(p,P+=4),Y=He(p,P+=4);for(P+=4,S=Math.pow(2,32)*V+Y,Number.isSafeInteger(S)||(S=Number.MAX_SAFE_INTEGER,B.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),L=He(p,P),N=He(p,P+=4),P+=4;xt(p.subarray(P,P+1))!=="\0";)b+=xt(p.subarray(P,P+1)),P+=1;for(b+=xt(p.subarray(P,P+1)),P+=1;xt(p.subarray(P,P+1))!=="\0";)A+=xt(p.subarray(P,P+1)),P+=1;A+=xt(p.subarray(P,P+1)),P+=1}return{schemeIdUri:b,value:A,timeScale:w,presentationTime:S,presentationTimeDelta:D,eventDuration:L,id:N,payload:p.subarray(P,p.byteLength)}}(l);if(Wv.test(d.schemeIdUri)){var c=re(d.presentationTime)?d.presentationTime/d.timeScale:t+d.presentationTimeDelta/d.timeScale,h=d.eventDuration===4294967295?Number.POSITIVE_INFINITY:d.eventDuration/d.timeScale;h<=.001&&(h=Number.POSITIVE_INFINITY);var f=d.payload;i.samples.push({data:f,len:f.byteLength,dts:c,pts:c,type:Sr,duration:h})}})}return i},s.demuxSampleAes=function(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},s.destroy=function(){},u}(),jo=null,Yv=[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],$v=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],jv=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],zv=[0,1,1,4];function Uh(u,s,e,t,i){if(!(e+24>s.length)){var a=Bh(s,e);if(a&&e+a.frameLength<=s.length){var l=t+i*(9e4*a.samplesPerFrame/a.sampleRate),d={unit:s.subarray(e,e+a.frameLength),pts:l,dts:l};return u.config=[],u.channelCount=a.channelCount,u.samplerate=a.sampleRate,u.samples.push(d),{sample:d,length:a.frameLength,missing:0}}}}function Bh(u,s){var e=u[s+1]>>3&3,t=u[s+1]>>1&3,i=u[s+2]>>4&15,a=u[s+2]>>2&3;if(e!==1&&i!==0&&i!==15&&a!==3){var l=u[s+2]>>1&1,d=u[s+3]>>6,c=1e3*Yv[14*(e===3?3-t:t===3?3:4)+i-1],h=$v[3*(e===3?0:e===2?1:2)+a],f=d===3?1:2,p=jv[e][t],E=zv[t],b=8*p*E,A=Math.floor(p*c/h+l)*E;if(jo===null){var w=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);jo=w?parseInt(w[1]):0}return!!jo&&jo<=87&&t===2&&c>=224e3&&d===0&&(u[s+3]=128|u[s+3]),{sampleRate:h,channelCount:f,frameLength:A,samplesPerFrame:b}}}function ed(u,s){return u[s]===255&&(224&u[s+1])==224&&(6&u[s+1])!=0}function Hh(u,s){return s+1<u.length&&ed(u,s)}function Qv(u,s){if(s+1<u.length&&ed(u,s)){var e=Bh(u,s),t=4;e!=null&&e.frameLength&&(t=e.frameLength);var i=s+t;return i===u.length||Hh(u,i)}return!1}var Gh=function(){function u(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}var s=u.prototype;return s.loadWord=function(){var e=this.data,t=this.bytesAvailable,i=e.byteLength-t,a=new Uint8Array(4),l=Math.min(4,t);if(l===0)throw new Error("no bytes available");a.set(e.subarray(i,i+l)),this.word=new DataView(a.buffer).getUint32(0),this.bitsAvailable=8*l,this.bytesAvailable-=l},s.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},s.readBits=function(e){var t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(e>32&&B.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?i<<t|this.readBits(t):i},s.skipLZ=function(){var 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()},s.skipUEG=function(){this.skipBits(1+this.skipLZ())},s.skipEG=function(){this.skipBits(1+this.skipLZ())},s.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},s.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},s.readBoolean=function(){return this.readBits(1)===1},s.readUByte=function(){return this.readBits(8)},s.readUShort=function(){return this.readBits(16)},s.readUInt=function(){return this.readBits(32)},s.skipScalingList=function(e){for(var t=8,i=8,a=0;a<e;a++)i!==0&&(i=(t+this.readEG()+256)%256),t=i===0?t:i},s.readSPS=function(){var e,t,i,a=0,l=0,d=0,c=0,h=this.readUByte.bind(this),f=this.readBits.bind(this),p=this.readUEG.bind(this),E=this.readBoolean.bind(this),b=this.skipBits.bind(this),A=this.skipEG.bind(this),w=this.skipUEG.bind(this),D=this.skipScalingList.bind(this);h();var S=h();if(f(5),b(3),h(),w(),S===100||S===110||S===122||S===244||S===44||S===83||S===86||S===118||S===128){var L=p();if(L===3&&b(1),w(),w(),b(1),E())for(t=L!==3?8:12,i=0;i<t;i++)E()&&D(i<6?16:64)}w();var N=p();if(N===0)p();else if(N===1)for(b(1),A(),A(),e=p(),i=0;i<e;i++)A();w(),b(1);var P=p(),V=p(),Y=f(1);Y===0&&b(1),b(1),E()&&(a=p(),l=p(),d=p(),c=p());var j=[1,1];if(E()&&E())switch(h()){case 1:j=[1,1];break;case 2:j=[12,11];break;case 3:j=[10,11];break;case 4:j=[16,11];break;case 5:j=[40,33];break;case 6:j=[24,11];break;case 7:j=[20,11];break;case 8:j=[32,11];break;case 9:j=[80,33];break;case 10:j=[18,11];break;case 11:j=[15,11];break;case 12:j=[64,33];break;case 13:j=[160,99];break;case 14:j=[4,3];break;case 15:j=[3,2];break;case 16:j=[2,1];break;case 255:j=[h()<<8|h(),h()<<8|h()]}return{width:Math.ceil(16*(P+1)-2*a-2*l),height:(2-Y)*(V+1)*16-(Y?2:4)*(d+c),pixelRatio:j}},s.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},u}(),Xv=function(){function u(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Ni(t,{removePKCS7Padding:!1})}var s=u.prototype;return s.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},s.decryptAacSample=function(e,t,i){var a=this,l=e[t].unit;if(!(l.length<=16)){var d=l.subarray(16,l.length-l.length%16),c=d.buffer.slice(d.byteOffset,d.byteOffset+d.length);this.decryptBuffer(c).then(function(h){var f=new Uint8Array(h);l.set(f,16),a.decrypter.isSync()||a.decryptAacSamples(e,t+1,i)})}},s.decryptAacSamples=function(e,t,i){for(;;t++){if(t>=e.length)return void i();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,i),this.decrypter.isSync())))return}},s.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,i=new Int8Array(t),a=0,l=32;l<e.length-16;l+=160,a+=16)i.set(e.subarray(l,l+16),a);return i},s.getAvcDecryptedUnit=function(e,t){for(var i=new Uint8Array(t),a=0,l=32;l<e.length-16;l+=160,a+=16)e.set(i.subarray(a,a+16),l);return e},s.decryptAvcSample=function(e,t,i,a,l){var d=this,c=Lo(l.data),h=this.getAvcEncryptedData(c);this.decryptBuffer(h.buffer).then(function(f){l.data=d.getAvcDecryptedUnit(c,f),d.decrypter.isSync()||d.decryptAvcSamples(e,t,i+1,a)})},s.decryptAvcSamples=function(e,t,i,a){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void a();for(var l=e[t].units;!(i>=l.length);i++){var d=l[i];if(!(d.data.length<=48||d.type!==1&&d.type!==5||(this.decryptAvcSample(e,t,i,a,d),this.decrypter.isSync())))return}}},u}(),Ti=188,Zv=function(){function u(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}u.probe=function(e){var t=u.syncOffset(e);return t>0&&B.warn("MPEG2-TS detected but first sync word found @ offset "+t),t!==-1},u.syncOffset=function(e){for(var t=e.length,i=Math.min(940,e.length-Ti)+1,a=0;a<i;){for(var l=!1,d=-1,c=0,h=a;h<t;h+=Ti){if(e[h]!==71){if(c)return-1;break}if(c++,d===-1&&(d=h)!==0&&(i=Math.min(d+18612,e.length-Ti)+1),l||(l=td(e,h)===0),l&&c>1&&(d===0&&c>2||h+Ti>i))return d}a++}return-1},u.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:_o[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var s=u.prototype;return s.resetInitSegment=function(e,t,i,a){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=u.createTrack("video"),this._audioTrack=u.createTrack("audio",a),this._id3Track=u.createTrack("id3"),this._txtTrack=u.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,this._duration=a},s.resetTimeStamp=function(){},s.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,i=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},s.demux=function(e,t,i,a){var l;i===void 0&&(i=!1),a===void 0&&(a=!1),i||(this.sampleAes=null);var d=this._avcTrack,c=this._audioTrack,h=this._id3Track,f=this._txtTrack,p=d.pid,E=d.pesData,b=c.pid,A=h.pid,w=c.pesData,D=h.pesData,S=null,L=this.pmtParsed,N=this._pmtId,P=e.length;if(this.remainderData&&(P=(e=Tr(this.remainderData,e)).length,this.remainderData=null),P<Ti&&!a)return this.remainderData=e,{audioTrack:c,videoTrack:d,id3Track:h,textTrack:f};var V=Math.max(0,u.syncOffset(e));(P-=(P-V)%Ti)<e.byteLength&&!a&&(this.remainderData=new Uint8Array(e.buffer,P,e.buffer.byteLength-P));for(var Y=0,j=V;j<P;j+=Ti)if(e[j]===71){var ie=!!(64&e[j+1]),Q=td(e,j),X=void 0;if((48&e[j+3])>>4>1){if((X=j+5+e[j+4])===j+Ti)continue}else X=j+4;switch(Q){case p:ie&&(E&&(l=pn(E))&&this.parseAVCPES(d,f,l,!1),E={data:[],size:0}),E&&(E.data.push(e.subarray(X,j+Ti)),E.size+=j+Ti-X);break;case b:if(ie){if(w&&(l=pn(w)))switch(c.segmentCodec){case"aac":this.parseAACPES(c,l);break;case"mp3":this.parseMPEGPES(c,l)}w={data:[],size:0}}w&&(w.data.push(e.subarray(X,j+Ti)),w.size+=j+Ti-X);break;case A:ie&&(D&&(l=pn(D))&&this.parseID3PES(h,l),D={data:[],size:0}),D&&(D.data.push(e.subarray(X,j+Ti)),D.size+=j+Ti-X);break;case 0:ie&&(X+=e[X]+1),N=this._pmtId=Jv(e,X);break;case N:ie&&(X+=e[X]+1);var ce=eg(e,X,this.typeSupported,i);(p=ce.avc)>0&&(d.pid=p),(b=ce.audio)>0&&(c.pid=b,c.segmentCodec=ce.segmentCodec),(A=ce.id3)>0&&(h.pid=A),S===null||L||(B.warn("MPEG-TS PMT found at "+j+" after unknown PID '"+S+"'. Backtracking to sync byte @"+V+" to parse all TS packets."),S=null,j=V-188),L=this.pmtParsed=!0;break;case 17:case 8191:break;default:S=Q}}else Y++;if(Y>0){var le=new Error("Found "+Y+" TS packet/s that do not start with 0x47");this.observer.emit(k.ERROR,k.ERROR,{type:oe.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,error:le,reason:le.message})}d.pesData=E,c.pesData=w,h.pesData=D;var Ae={audioTrack:c,videoTrack:d,id3Track:h,textTrack:f};return a&&this.extractRemainingSamples(Ae),Ae},s.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},s.extractRemainingSamples=function(e){var t,i=e.audioTrack,a=e.videoTrack,l=e.id3Track,d=e.textTrack,c=a.pesData,h=i.pesData,f=l.pesData;if(c&&(t=pn(c))?(this.parseAVCPES(a,d,t,!0),a.pesData=null):a.pesData=c,h&&(t=pn(h))){switch(i.segmentCodec){case"aac":this.parseAACPES(i,t);break;case"mp3":this.parseMPEGPES(i,t)}i.pesData=null}else h!=null&&h.size&&B.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=h;f&&(t=pn(f))?(this.parseID3PES(l,t),l.pesData=null):l.pesData=f},s.demuxSampleAes=function(e,t,i){var a=this.demux(e,i,!0,!this.config.progressive),l=this.sampleAes=new Xv(this.observer,this.config,t);return this.decrypt(a,l)},s.decrypt=function(e,t){return new Promise(function(i){var a=e.audioTrack,l=e.videoTrack;a.samples&&a.segmentCodec==="aac"?t.decryptAacSamples(a.samples,0,function(){l.samples?t.decryptAvcSamples(l.samples,0,0,function(){i(e)}):i(e)}):l.samples&&t.decryptAvcSamples(l.samples,0,0,function(){i(e)})})},s.destroy=function(){this._duration=0},s.parseAVCPES=function(e,t,i,a){var l,d=this,c=this.parseAVCNALu(e,i.data),h=this.avcSample,f=!1;i.data=null,h&&c.length&&!e.audFound&&(id(h,e),h=this.avcSample=zo(!1,i.pts,i.dts,"")),c.forEach(function(p){switch(p.type){case 1:l=!0,h||(h=d.avcSample=zo(!0,i.pts,i.dts,"")),h.frame=!0;var E=p.data;if(f&&E.length>4){var b=new Gh(E).readSliceType();b!==2&&b!==4&&b!==7&&b!==9||(h.key=!0)}break;case 5:l=!0,h||(h=d.avcSample=zo(!0,i.pts,i.dts,"")),h.key=!0,h.frame=!0;break;case 6:l=!0,wo(p.data,1,i.pts,t.samples);break;case 7:if(l=!0,f=!0,!e.sps){var A=p.data,w=new Gh(A).readSPS();e.width=w.width,e.height=w.height,e.pixelRatio=w.pixelRatio,e.sps=[A],e.duration=d._duration;for(var D=A.subarray(1,4),S="avc1.",L=0;L<3;L++){var N=D[L].toString(16);N.length<2&&(N="0"+N),S+=N}e.codec=S}break;case 8:l=!0,e.pps||(e.pps=[p.data]);break;case 9:l=!1,e.audFound=!0,h&&id(h,e),h=d.avcSample=zo(!1,i.pts,i.dts,"");break;case 12:l=!0;break;default:l=!1,h&&(h.debug+="unknown NAL "+p.type+" ")}h&&l&&h.units.push(p)}),a&&h&&(id(h,e),this.avcSample=null)},s.getLastNalUnit=function(e){var t,i,a=this.avcSample;if(a&&a.units.length!==0||(a=e[e.length-1]),(t=a)!=null&&t.units){var l=a.units;i=l[l.length-1]}return i},s.parseAVCNALu=function(e,t){var i,a,l=t.byteLength,d=e.naluState||0,c=d,h=[],f=0,p=-1,E=0;for(d===-1&&(p=0,E=31&t[0],d=0,f=1);f<l;)if(i=t[f++],d)if(d!==1)if(i)if(i===1){if(p>=0){var b={data:t.subarray(p,f-d-1),type:E};h.push(b)}else{var A=this.getLastNalUnit(e.samples);if(A&&(c&&f<=4-c&&A.state&&(A.data=A.data.subarray(0,A.data.byteLength-c)),(a=f-d-1)>0)){var w=new Uint8Array(A.data.byteLength+a);w.set(A.data,0),w.set(t.subarray(0,a),A.data.byteLength),A.data=w,A.state=0}}f<l?(p=f,E=31&t[f],d=0):d=-1}else d=0;else d=3;else d=i?0:2;else d=i?0:1;if(p>=0&&d>=0){var D={data:t.subarray(p,l),type:E,state:d};h.push(D)}if(h.length===0){var S=this.getLastNalUnit(e.samples);if(S){var L=new Uint8Array(S.data.byteLength+t.byteLength);L.set(S.data,0),L.set(t,S.data.byteLength),S.data=L}}return e.naluState=d,h},s.parseAACPES=function(e,t){var i,a,l,d=0,c=this.aacOverFlow,h=t.data;if(c){this.aacOverFlow=null;var f=c.missing,p=c.sample.unit.byteLength;if(f===-1){var E=new Uint8Array(p+h.byteLength);E.set(c.sample.unit,0),E.set(h,p),h=E}else{var b=p-f;c.sample.unit.set(h.subarray(0,f),b),e.samples.push(c.sample),d=c.missing}}for(i=d,a=h.length;i<a-1&&!$o(h,i);i++);if(i!==d){var A,w=i<a-1;A=w?"AAC PES did not start with ADTS header,offset:"+i:"No ADTS header found in AAC PES";var D=new Error(A);if(B.warn("parsing error: "+A),this.observer.emit(k.ERROR,k.ERROR,{type:oe.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,levelRetry:w,error:D,reason:A}),!w)return}if(Oh(e,this.observer,h,i,this.audioCodec),t.pts!==void 0)l=t.pts;else{if(!c)return void B.warn("[tsdemuxer]: AAC PES unknown PTS");var S=Nh(e.samplerate);l=c.sample.pts+S}for(var L,N=0;i<a;){if(i+=(L=Fh(e,h,i,l,N)).length,L.missing){this.aacOverFlow=L;break}for(N++;i<a-1&&!$o(h,i);i++);}},s.parseMPEGPES=function(e,t){var i=t.data,a=i.length,l=0,d=0,c=t.pts;if(c!==void 0)for(;d<a;)if(Hh(i,d)){var h=Uh(e,i,d,c,l);if(!h)break;d+=h.length,l++}else d++;else B.warn("[tsdemuxer]: MPEG PES unknown PTS")},s.parseID3PES=function(e,t){if(t.pts!==void 0){var i=H({},t,{type:this._avcTrack?Sr:Aa,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}else B.warn("[tsdemuxer]: ID3 PES unknown PTS")},u}();function zo(u,s,e,t){return{key:u,frame:!1,pts:s,dts:e,units:[],debug:t,length:0}}function td(u,s){return((31&u[s+1])<<8)+u[s+2]}function Jv(u,s){return(31&u[s+10])<<8|u[s+11]}function eg(u,s,e,t){var i={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},a=s+3+((15&u[s+1])<<8|u[s+2])-4;for(s+=12+((15&u[s+10])<<8|u[s+11]);s<a;){var l=td(u,s);switch(u[s]){case 207:if(!t){B.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:i.audio===-1&&(i.audio=l);break;case 21:i.id3===-1&&(i.id3=l);break;case 219:if(!t){B.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:i.avc===-1&&(i.avc=l);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?B.log("MPEG audio found, not supported in this browser"):i.audio===-1&&(i.audio=l,i.segmentCodec="mp3");break;case 36:B.warn("Unsupported HEVC stream type found")}s+=5+((15&u[s+3])<<8|u[s+4])}return i}function pn(u){var s,e,t,i,a,l=0,d=u.data;if(!u||u.size===0)return null;for(;d[0].length<19&&d.length>1;){var c=new Uint8Array(d[0].length+d[1].length);c.set(d[0]),c.set(d[1],d[0].length),d[0]=c,d.splice(1,1)}if(((s=d[0])[0]<<16)+(s[1]<<8)+s[2]===1){if((e=(s[4]<<8)+s[5])&&e>u.size-6)return null;var h=s[7];192&h&&(i=536870912*(14&s[9])+4194304*(255&s[10])+16384*(254&s[11])+128*(255&s[12])+(254&s[13])/2,64&h?i-(a=536870912*(14&s[14])+4194304*(255&s[15])+16384*(254&s[16])+128*(255&s[17])+(254&s[18])/2)>54e5&&(B.warn(Math.round((i-a)/9e4)+"s delta between PTS and DTS, align them"),i=a):a=i);var f=(t=s[8])+9;if(u.size<=f)return null;u.size-=f;for(var p=new Uint8Array(u.size),E=0,b=d.length;E<b;E++){var A=(s=d[E]).byteLength;if(f){if(f>A){f-=A;continue}s=s.subarray(f),A-=f,f=0}p.set(s,l),l+=A}return e&&(e-=t+3),{data:p,pts:i,dts:a,len:e}}return null}function id(u,s){if(u.units.length&&u.frame){if(u.pts===void 0){var e=s.samples,t=e.length;if(!t)return void s.dropped++;var i=e[t-1];u.pts=i.pts,u.dts=i.dts}s.samples.push(u)}u.debug.length&&B.log(u.pts+"/"+u.dts+":"+u.debug)}var tg=function(u){function s(){return u.apply(this,arguments)||this}z(s,u);var e=s.prototype;return e.resetInitSegment=function(t,i,a,l){u.prototype.resetInitSegment.call(this,t,i,a,l),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:i,duration:l,inputTimeScale:9e4,dropped:0}},s.probe=function(t){if(!t)return!1;for(var i=(ga(t,0)||[]).length,a=t.length;i<a;i++)if(Qv(t,i))return B.log("MPEG Audio sync word found !"),!0;return!1},e.canParse=function(t,i){return function(a,l){return ed(a,l)&&4<=a.length-l}(t,i)},e.appendFrame=function(t,i,a){if(this.basePTS!==null)return Uh(t,i,a,this.basePTS,this.frameIndex)},s}(Mh),Vh=function(){function u(){}return u.getSilentFrame=function(s,e){if(s==="mp4a.40.2"){if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===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(e===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])}else{if(e===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(e===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(e===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])}},u}(),Jr=Math.pow(2,32)-1,ei=function(){function u(){}return u.init=function(){var s;for(s in u.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},u.types)u.types.hasOwnProperty(s)&&(u.types[s]=[s.charCodeAt(0),s.charCodeAt(1),s.charCodeAt(2),s.charCodeAt(3)]);var e=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]),t=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);u.HDLR_TYPES={video:e,audio:t};var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);u.STTS=u.STSC=u.STCO=a,u.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),u.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),u.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),u.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var l=new Uint8Array([105,115,111,109]),d=new Uint8Array([97,118,99,49]),c=new Uint8Array([0,0,0,1]);u.FTYP=u.box(u.types.ftyp,l,c,l,d),u.DINF=u.box(u.types.dinf,u.box(u.types.dref,i))},u.box=function(s){for(var e=8,t=arguments.length,i=new Array(t>1?t-1:0),a=1;a<t;a++)i[a-1]=arguments[a];for(var l=i.length,d=l;l--;)e+=i[l].byteLength;var c=new Uint8Array(e);for(c[0]=e>>24&255,c[1]=e>>16&255,c[2]=e>>8&255,c[3]=255&e,c.set(s,4),l=0,e=8;l<d;l++)c.set(i[l],e),e+=i[l].byteLength;return c},u.hdlr=function(s){return u.box(u.types.hdlr,u.HDLR_TYPES[s])},u.mdat=function(s){return u.box(u.types.mdat,s)},u.mdhd=function(s,e){e*=s;var t=Math.floor(e/(Jr+1)),i=Math.floor(e%(Jr+1));return u.box(u.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,s>>24&255,s>>16&255,s>>8&255,255&s,t>>24,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))},u.mdia=function(s){return u.box(u.types.mdia,u.mdhd(s.timescale,s.duration),u.hdlr(s.type),u.minf(s))},u.mfhd=function(s){return u.box(u.types.mfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s]))},u.minf=function(s){return s.type==="audio"?u.box(u.types.minf,u.box(u.types.smhd,u.SMHD),u.DINF,u.stbl(s)):u.box(u.types.minf,u.box(u.types.vmhd,u.VMHD),u.DINF,u.stbl(s))},u.moof=function(s,e,t){return u.box(u.types.moof,u.mfhd(s),u.traf(t,e))},u.moov=function(s){for(var e=s.length,t=[];e--;)t[e]=u.trak(s[e]);return u.box.apply(null,[u.types.moov,u.mvhd(s[0].timescale,s[0].duration)].concat(t).concat(u.mvex(s)))},u.mvex=function(s){for(var e=s.length,t=[];e--;)t[e]=u.trex(s[e]);return u.box.apply(null,[u.types.mvex].concat(t))},u.mvhd=function(s,e){e*=s;var t=Math.floor(e/(Jr+1)),i=Math.floor(e%(Jr+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,s>>24&255,s>>16&255,s>>8&255,255&s,t>>24,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return u.box(u.types.mvhd,a)},u.sdtp=function(s){var e,t,i=s.samples||[],a=new Uint8Array(4+i.length);for(e=0;e<i.length;e++)t=i[e].flags,a[e+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return u.box(u.types.sdtp,a)},u.stbl=function(s){return u.box(u.types.stbl,u.stsd(s),u.box(u.types.stts,u.STTS),u.box(u.types.stsc,u.STSC),u.box(u.types.stsz,u.STSZ),u.box(u.types.stco,u.STCO))},u.avc1=function(s){var e,t,i,a=[],l=[];for(e=0;e<s.sps.length;e++)i=(t=s.sps[e]).byteLength,a.push(i>>>8&255),a.push(255&i),a=a.concat(Array.prototype.slice.call(t));for(e=0;e<s.pps.length;e++)i=(t=s.pps[e]).byteLength,l.push(i>>>8&255),l.push(255&i),l=l.concat(Array.prototype.slice.call(t));var d=u.box(u.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|s.sps.length].concat(a).concat([s.pps.length]).concat(l))),c=s.width,h=s.height,f=s.pixelRatio[0],p=s.pixelRatio[1];return u.box(u.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c>>8&255,255&c,h>>8&255,255&h,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]),d,u.box(u.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),u.box(u.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,255&f,p>>24,p>>16&255,p>>8&255,255&p])))},u.esds=function(s){var e=s.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(s.config).concat([6,1,2]))},u.mp4a=function(s){var e=s.samplerate;return u.box(u.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,s.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),u.box(u.types.esds,u.esds(s)))},u.mp3=function(s){var e=s.samplerate;return u.box(u.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,s.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))},u.stsd=function(s){return s.type==="audio"?s.segmentCodec==="mp3"&&s.codec==="mp3"?u.box(u.types.stsd,u.STSD,u.mp3(s)):u.box(u.types.stsd,u.STSD,u.mp4a(s)):u.box(u.types.stsd,u.STSD,u.avc1(s))},u.tkhd=function(s){var e=s.id,t=s.duration*s.timescale,i=s.width,a=s.height,l=Math.floor(t/(Jr+1)),d=Math.floor(t%(Jr+1));return u.box(u.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,l>>24,l>>16&255,l>>8&255,255&l,d>>24,d>>16&255,d>>8&255,255&d,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,i>>8&255,255&i,0,0,a>>8&255,255&a,0,0]))},u.traf=function(s,e){var t=u.sdtp(s),i=s.id,a=Math.floor(e/(Jr+1)),l=Math.floor(e%(Jr+1));return u.box(u.types.traf,u.box(u.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),u.box(u.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,l>>24,l>>16&255,l>>8&255,255&l])),u.trun(s,t.length+16+20+8+16+8+8),t)},u.trak=function(s){return s.duration=s.duration||4294967295,u.box(u.types.trak,u.tkhd(s),u.mdia(s))},u.trex=function(s){var e=s.id;return u.box(u.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},u.trun=function(s,e){var t,i,a,l,d,c,h=s.samples||[],f=h.length,p=12+16*f,E=new Uint8Array(p);for(e+=8+p,E.set([s.type==="video"?1:0,0,15,1,f>>>24&255,f>>>16&255,f>>>8&255,255&f,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),t=0;t<f;t++)a=(i=h[t]).duration,l=i.size,d=i.flags,c=i.cts,E.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,l>>>24&255,l>>>16&255,l>>>8&255,255&l,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|d.isNonSync,61440&d.degradPrio,15&d.degradPrio,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*t);return u.box(u.types.trun,E)},u.initSegment=function(s){u.types||u.init();var e=u.moov(s),t=new Uint8Array(u.FTYP.byteLength+e.byteLength);return t.set(u.FTYP),t.set(e,u.FTYP.byteLength),t},u}();function rd(u,s,e,t){e===void 0&&(e=1),t===void 0&&(t=!1);var i=u*s*e;return t?Math.round(i):i}function _s(u,s){return s===void 0&&(s=!1),rd(u,1e3,1/9e4,s)}ei.types=void 0,ei.HDLR_TYPES=void 0,ei.STTS=void 0,ei.STSC=void 0,ei.STCO=void 0,ei.STSZ=void 0,ei.VMHD=void 0,ei.SMHD=void 0,ei.STSD=void 0,ei.FTYP=void 0,ei.DINF=void 0;var Qo=null,ad=null,nd=function(){function u(e,t,i,a){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){var l=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Qo=l?parseInt(l[1]):0}if(ad===null){var d=navigator.userAgent.match(/Safari\/(\d+)/i);ad=d?parseInt(d[1]):0}}var s=u.prototype;return s.destroy=function(){},s.resetTimeStamp=function(e){B.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},s.resetNextTimestamp=function(){B.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},s.resetInitSegment=function(){B.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},s.getVideoStartPts=function(e){var t=!1,i=e.reduce(function(a,l){var d=l.pts-a;return d<-4294967296?(t=!0,Fi(a,l.pts)):d>0?a:l.pts},e[0].pts);return t&&B.debug("PTS rollover detected"),i},s.remux=function(e,t,i,a,l,d,c,h){var f,p,E,b,A,w,D=l,S=l,L=e.pid>-1,N=t.pid>-1,P=t.samples.length,V=e.samples.length>0,Y=c&&P>0||P>1;if((!L||V)&&(!N||Y)||this.ISGenerated||c){this.ISGenerated||(E=this.generateIS(e,t,l,d));var j,ie=this.isVideoContiguous,Q=-1;if(Y&&(Q=function(xe){for(var Le=0;Le<xe.length;Le++)if(xe[Le].key)return Le;return-1}(t.samples),!ie&&this.config.forceKeyFrameOnDiscontinuity))if(w=!0,Q>0){B.warn("[mp4-remuxer]: Dropped "+Q+" out of "+P+" video samples due to a missing keyframe");var X=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(Q),t.dropped+=Q,j=S+=(t.samples[0].pts-X)/t.inputTimeScale}else Q===-1&&(B.warn("[mp4-remuxer]: No keyframe found out of "+P+" video samples"),w=!1);if(this.ISGenerated){if(V&&Y){var ce=this.getVideoStartPts(t.samples),le=(Fi(e.samples[0].pts,ce)-ce)/t.inputTimeScale;D+=Math.max(0,le),S+=Math.max(0,-le)}if(V){if(e.samplerate||(B.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),E=this.generateIS(e,t,l,d)),p=this.remuxAudio(e,D,this.isAudioContiguous,d,N||Y||h===Di?S:void 0),Y){var Ae=p?p.endPTS-p.startPTS:0;t.inputTimeScale||(B.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),E=this.generateIS(e,t,l,d)),f=this.remuxVideo(t,S,ie,Ae)}}else Y&&(f=this.remuxVideo(t,S,ie,0));f&&(f.firstKeyFrame=Q,f.independent=Q!==-1,f.firstKeyFramePTS=j)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(A=Kh(i,l,this._initPTS,this._initDTS)),a.samples.length&&(b=Wh(a,l,this._initPTS))),{audio:p,video:f,initSegment:E,independent:w,text:b,id3:A}},s.generateIS=function(e,t,i,a){var l,d,c,h=e.samples,f=t.samples,p=this.typeSupported,E={},b=this._initPTS,A=!b||a,w="audio/mp4";if(A&&(l=d=1/0),e.config&&h.length&&(e.timescale=e.samplerate,e.segmentCodec==="mp3"&&(p.mpeg?(w="audio/mpeg",e.codec=""):p.mp3&&(e.codec="mp3")),E.audio={id:"audio",container:w,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&p.mpeg?new Uint8Array(0):ei.initSegment([e]),metadata:{channelCount:e.channelCount}},A&&(c=e.inputTimeScale,b&&c===b.timescale?A=!1:l=d=h[0].pts-Math.round(c*i))),t.sps&&t.pps&&f.length&&(t.timescale=t.inputTimeScale,E.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:ei.initSegment([t]),metadata:{width:t.width,height:t.height}},A))if(c=t.inputTimeScale,b&&c===b.timescale)A=!1;else{var D=this.getVideoStartPts(f),S=Math.round(c*i);d=Math.min(d,Fi(f[0].dts,D)-S),l=Math.min(l,D-S)}if(Object.keys(E).length)return this.ISGenerated=!0,A?(this._initPTS={baseTime:l,timescale:c},this._initDTS={baseTime:d,timescale:c}):l=c=void 0,{tracks:E,initPTS:l,timescale:c}},s.remuxVideo=function(e,t,i,a){var l,d,c=e.inputTimeScale,h=e.samples,f=[],p=h.length,E=this._initPTS,b=this.nextAvcDts,A=8,w=this.videoSampleDuration,D=Number.POSITIVE_INFINITY,S=Number.NEGATIVE_INFINITY,L=!1;i&&b!==null||(b=t*c-(h[0].pts-Fi(h[0].dts,h[0].pts)));for(var N=E.baseTime*c/E.timescale,P=0;P<p;P++){var V=h[P];V.pts=Fi(V.pts-N,b),V.dts=Fi(V.dts-N,b),V.dts<h[P>0?P-1:P].dts&&(L=!0)}L&&h.sort(function(rl,Lf){var Jg=rl.dts-Lf.dts,eE=rl.pts-Lf.pts;return Jg||eE}),l=h[0].dts;var Y=(d=h[h.length-1].dts)-l,j=Y?Math.round(Y/(p-1)):w||e.inputTimeScale/30;if(i){var ie=l-b,Q=ie>j,X=ie<-1;if((Q||X)&&(Q?B.warn("AVC: "+_s(ie,!0)+" ms ("+ie+"dts) hole between fragments detected, filling it"):B.warn("AVC: "+_s(-ie,!0)+" ms ("+ie+"dts) overlapping between fragments detected"),!X||b>=h[0].pts)){l=b;var ce=h[0].pts-ie;h[0].dts=l,h[0].pts=ce,B.log("Video: First PTS/DTS adjusted: "+_s(ce,!0)+"/"+_s(l,!0)+", delta: "+_s(ie,!0)+" ms")}}l=Math.max(0,l);for(var le=0,Ae=0,xe=0;xe<p;xe++){for(var Le=h[xe],Me=Le.units,Oe=Me.length,Pe=0,Ke=0;Ke<Oe;Ke++)Pe+=Me[Ke].data.length;Ae+=Pe,le+=Oe,Le.length=Pe,Le.dts=Math.max(Le.dts,l),D=Math.min(Le.pts,D),S=Math.max(Le.pts,S)}d=h[p-1].dts;var je,et=Ae+4*le+8;try{je=new Uint8Array(et)}catch(rl){return void this.observer.emit(k.ERROR,k.ERROR,{type:oe.MUX_ERROR,details:q.REMUX_ALLOC_ERROR,fatal:!1,error:rl,bytes:et,reason:"fail allocating video mdat "+et})}var lt=new DataView(je.buffer);lt.setUint32(0,et),je.set(ei.types.mdat,4);for(var _i=!1,Wt=Number.POSITIVE_INFINITY,Qi=Number.POSITIVE_INFINITY,Bi=Number.NEGATIVE_INFINITY,Hi=Number.NEGATIVE_INFINITY,qt=0;qt<p;qt++){for(var ti=h[qt],lr=ti.units,ea=0,Ci=0,As=lr.length;Ci<As;Ci++){var Ss=lr[Ci],il=Ss.data,En=Ss.data.byteLength;lt.setUint32(A,En),A+=4,je.set(il,A),A+=En,ea+=4+En}var Oa=void 0;if(qt<p-1)w=h[qt+1].dts-ti.dts,Oa=h[qt+1].pts-ti.pts;else{var ks=this.config,Dr=qt>0?ti.dts-h[qt-1].dts:j;if(Oa=qt>0?ti.pts-h[qt-1].pts:j,ks.stretchShortVideoTrack&&this.nextAudioPts!==null){var jg=Math.floor(ks.maxBufferHole*c),kd=(a?D+a*c:this.nextAudioPts)-ti.pts;kd>jg?((w=kd-Dr)<0?w=Dr:_i=!0,B.log("[mp4-remuxer]: It is approximately "+kd/90+" ms to the next segment; using duration "+w/90+" ms for the last video frame.")):w=Dr}else w=Dr}var zg=Math.round(ti.pts-ti.dts);Wt=Math.min(Wt,w),Bi=Math.max(Bi,w),Qi=Math.min(Qi,Oa),Hi=Math.max(Hi,Oa),f.push(new qh(ti.key,w,ea,zg))}if(f.length){if(Qo){if(Qo<70){var Sf=f[0].flags;Sf.dependsOn=2,Sf.isNonSync=0}}else if(ad&&Hi-Qi<Bi-Wt&&j/Bi<.025&&f[0].cts===0){B.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var wd=l,Xi=0,kf=f.length;Xi<kf;Xi++){var wf=wd+f[Xi].duration,Qg=wd+f[Xi].cts;if(Xi<kf-1){var Xg=wf+f[Xi+1].cts;f[Xi].duration=Xg-Qg}else f[Xi].duration=Xi?f[Xi-1].duration:j;f[Xi].cts=0,wd=wf}}}w=_i||!w?j:w,this.nextAvcDts=b=d+w,this.videoSampleDuration=w,this.isVideoContiguous=!0;var Zg={data1:ei.moof(e.sequenceNumber++,l,H({},e,{samples:f})),data2:je,startPTS:D/c,endPTS:(S+w)/c,startDTS:l/c,endDTS:b/c,type:"video",hasAudio:!1,hasVideo:!0,nb:f.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Zg},s.remuxAudio=function(e,t,i,a,l){var d=e.inputTimeScale,c=d/(e.samplerate?e.samplerate:d),h=e.segmentCodec==="aac"?1024:1152,f=h*c,p=this._initPTS,E=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,b=[],A=l!==void 0,w=e.samples,D=E?0:8,S=this.nextAudioPts||-1,L=t*d,N=p.baseTime*d/p.timescale;if(this.isAudioContiguous=i=i||w.length&&S>0&&(a&&Math.abs(L-S)<9e3||Math.abs(Fi(w[0].pts-N,L)-S)<20*f),w.forEach(function(Ci){Ci.pts=Fi(Ci.pts-N,L)}),!i||S<0){if(w=w.filter(function(Ci){return Ci.pts>=0}),!w.length)return;S=l===0?0:a&&!A?Math.max(0,L):w[0].pts}if(e.segmentCodec==="aac")for(var P=this.config.maxAudioFramesDrift,V=0,Y=S;V<w.length;V++){var j=w[V],ie=j.pts,Q=ie-Y,X=Math.abs(1e3*Q/d);if(Q<=-P*f&&A)V===0&&(B.warn("Audio frame @ "+(ie/d).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Q/d)+" ms."),this.nextAudioPts=S=Y=ie);else if(Q>=P*f&&X<1e4&&A){var ce=Math.round(Q/f);(Y=ie-ce*f)<0&&(ce--,Y+=f),V===0&&(this.nextAudioPts=S=Y),B.warn("[mp4-remuxer]: Injecting "+ce+" audio frame @ "+(Y/d).toFixed(3)+"s due to "+Math.round(1e3*Q/d)+" ms gap.");for(var le=0;le<ce;le++){var Ae=Math.max(Y,0),xe=Vh.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);xe||(B.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),xe=j.unit.subarray()),w.splice(V,0,{unit:xe,pts:Ae}),Y+=f,V++}}j.pts=Y,Y+=f}for(var Le,Me=null,Oe=null,Pe=0,Ke=w.length;Ke--;)Pe+=w[Ke].unit.byteLength;for(var je=0,et=w.length;je<et;je++){var lt=w[je],_i=lt.unit,Wt=lt.pts;if(Oe!==null)b[je-1].duration=Math.round((Wt-Oe)/c);else{if(i&&e.segmentCodec==="aac"&&(Wt=S),Me=Wt,!(Pe>0))return;Pe+=D;try{Le=new Uint8Array(Pe)}catch(Ci){return void this.observer.emit(k.ERROR,k.ERROR,{type:oe.MUX_ERROR,details:q.REMUX_ALLOC_ERROR,fatal:!1,error:Ci,bytes:Pe,reason:"fail allocating audio mdat "+Pe})}E||(new DataView(Le.buffer).setUint32(0,Pe),Le.set(ei.types.mdat,4))}Le.set(_i,D);var Qi=_i.byteLength;D+=Qi,b.push(new qh(!0,h,Qi,0)),Oe=Wt}var Bi=b.length;if(Bi){var Hi=b[b.length-1];this.nextAudioPts=S=Oe+c*Hi.duration;var qt=E?new Uint8Array(0):ei.moof(e.sequenceNumber++,Me/c,H({},e,{samples:b}));e.samples=[];var ti=Me/d,lr=S/d,ea={data1:qt,data2:Le,startPTS:ti,endPTS:lr,startDTS:ti,endDTS:lr,type:"audio",hasAudio:!0,hasVideo:!1,nb:Bi};return this.isAudioContiguous=!0,ea}},s.remuxEmptyAudio=function(e,t,i,a){var l=e.inputTimeScale,d=l/(e.samplerate?e.samplerate:l),c=this.nextAudioPts,h=this._initDTS,f=9e4*h.baseTime/h.timescale,p=(c!==null?c:a.startDTS*l)+f,E=a.endDTS*l+f,b=1024*d,A=Math.ceil((E-p)/b),w=Vh.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(B.warn("[mp4-remuxer]: remux empty Audio"),w){for(var D=[],S=0;S<A;S++){var L=p+S*b;D.push({unit:w,pts:L,dts:L})}return e.samples=D,this.remuxAudio(e,t,i,!1)}B.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},u}();function Fi(u,s){var e;if(s===null)return u;for(e=s<u?-8589934592:8589934592;Math.abs(u-s)>4294967296;)u+=e;return u}function Kh(u,s,e,t){var i=u.samples.length;if(i){for(var a=u.inputTimeScale,l=0;l<i;l++){var d=u.samples[l];d.pts=Fi(d.pts-e.baseTime*a/e.timescale,s*a)/a,d.dts=Fi(d.dts-t.baseTime*a/t.timescale,s*a)/a}var c=u.samples;return u.samples=[],{samples:c}}}function Wh(u,s,e){var t=u.samples.length;if(t){for(var i=u.inputTimeScale,a=0;a<t;a++){var l=u.samples[a];l.pts=Fi(l.pts-9e4*e.baseTime/e.timescale,s*i)/i}u.samples.sort(function(c,h){return c.pts-h.pts});var d=u.samples;return u.samples=[],{samples:d}}}var Ir,qh=function(u,s,e,t){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=s,this.size=e,this.cts=t,this.flags=new ig(u)},ig=function(u){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=u?2:1,this.isNonSync=u?0:1},rg=function(){function u(){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}var s=u.prototype;return s.destroy=function(){},s.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},s.resetNextTimestamp=function(){this.lastEndTime=null},s.resetInitSegment=function(e,t,i,a){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(function(l,d){if(!l||!d)return l;var c=d.keyId;return c&&d.isCommonEncryption&&Je(l,["moov","trak"]).forEach(function(h){var f=Je(h,["mdia","minf","stbl","stsd"])[0].subarray(8),p=Je(f,["enca"]),E=p.length>0;E||(p=Je(f,["encv"])),p.forEach(function(b){Je(E?b.subarray(28):b.subarray(78),["sinf"]).forEach(function(A){var w=ss(A);if(w){var D=w.subarray(8,24);D.some(function(S){return S!==0})||(B.log("[eme] Patching keyId in 'enc"+(E?"a":"v")+">sinf>>tenc' box: "+Pi(D)+" -> "+Pi(c)),w.set(c,8))}})})}),l}(e,a)),this.emitInitSegment=!0},s.generateInitSegment=function(e){var t=this.audioCodec,i=this.videoCodec;if(e==null||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var a=this.initData=ns(e);t||(t=Yh(a.audio,Et)),i||(i=Yh(a.video,Mt));var l={};a.audio&&a.video?l.audiovideo={container:"video/mp4",codec:t+","+i,initSegment:e,id:"main"}:a.audio?l.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:a.video?l.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}:B.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=l},s.remux=function(e,t,i,a,l,d){var c,h,f=this.initPTS,p=this.lastEndTime,E={audio:void 0,video:void 0,text:a,id3:i,initSegment:void 0};re(p)||(p=this.lastEndTime=l||0);var b=t.samples;if(b==null||!b.length)return E;var A={initPTS:void 0,timescale:1},w=this.initData;if((c=w)!=null&&c.length||(this.generateInitSegment(b),w=this.initData),(h=w)==null||!h.length)return B.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),E;this.emitInitSegment&&(A.tracks=this.initTracks,this.emitInitSegment=!1);var D=function(Q,X){for(var ce=0,le=0,Ae=0,xe=Je(Q,["moof","traf"]),Le=0;Le<xe.length;Le++){var Me=xe[Le],Oe=Je(Me,["tfhd"])[0],Pe=X[He(Oe,4)];if(Pe){var Ke=Pe.default,je=He(Oe,0)|(Ke==null?void 0:Ke.flags),et=Ke==null?void 0:Ke.duration;8&je&&(et=He(Oe,2&je?12:8));for(var lt=Pe.timescale||9e4,_i=Je(Me,["trun"]),Wt=0;Wt<_i.length;Wt++)!(ce=Ku(_i[Wt]))&&et&&(ce=et*He(_i[Wt],4)),Pe.type===Mt?le+=ce/lt:Pe.type===Et&&(Ae+=ce/lt)}}if(le===0&&Ae===0){for(var Qi=0,Bi=Je(Q,["sidx"]),Hi=0;Hi<Bi.length;Hi++){var qt=So(Bi[Hi]);qt!=null&&qt.references&&(Qi+=qt.references.reduce(function(ti,lr){return ti+lr.info.duration||0},0))}return Qi}return le||Ae}(b,w),S=function(Q,X){return Je(X,["moof","traf"]).reduce(function(ce,le){var Ae=Je(le,["tfdt"])[0],xe=Ae[0],Le=Je(le,["tfhd"]).reduce(function(Me,Oe){var Pe=He(Oe,4),Ke=Q[Pe];if(Ke){var je=He(Ae,4);if(xe===1){if(je===Ea)return B.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),Me;je*=Ea+1,je+=He(Ae,8)}var et=je/(Ke.timescale||9e4);if(isFinite(et)&&(Me===null||et<Me))return et}return Me},null);return Le!==null&&isFinite(Le)&&(ce===null||Le<ce)?Le:ce},null)}(w,b),L=S===null?l:S;(function(Q,X,ce,le){if(Q===null)return!0;var Ae=Math.max(le,1),xe=X-Q.baseTime/Q.timescale;return Math.abs(xe-ce)>Ae}(f,L,l,D)||A.timescale!==f.timescale&&d)&&(A.initPTS=L-l,f&&f.timescale===1&&B.warn("Adjusting initPTS by "+(A.initPTS-f.baseTime)),this.initPTS=f={baseTime:A.initPTS,timescale:1});var N=e?L-f.baseTime/f.timescale:p,P=N+D;(function(Q,X,ce){Je(X,["moof","traf"]).forEach(function(le){Je(le,["tfhd"]).forEach(function(Ae){var xe=He(Ae,4),Le=Q[xe];if(Le){var Me=Le.timescale||9e4;Je(le,["tfdt"]).forEach(function(Oe){var Pe=Oe[0],Ke=He(Oe,4);if(Pe===0)Ke-=ce*Me,as(Oe,4,Ke=Math.max(Ke,0));else{Ke*=Math.pow(2,32),Ke+=He(Oe,8),Ke-=ce*Me,Ke=Math.max(Ke,0);var je=Math.floor(Ke/(Ea+1)),et=Math.floor(Ke%(Ea+1));as(Oe,4,je),as(Oe,8,et)}})}})})})(w,b,f.baseTime/f.timescale),D>0?this.lastEndTime=P:(B.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var V=!!w.audio,Y=!!w.video,j="";V&&(j+="audio"),Y&&(j+="video");var ie={data1:b,startPTS:N,startDTS:N,endPTS:P,endDTS:P,type:j,hasAudio:V,hasVideo:Y,nb:1,dropped:0};return E.audio=ie.type==="audio"?ie:void 0,E.video=ie.type!=="audio"?ie:void 0,E.initSegment=A,E.id3=Kh(i,l,f,f),a.samples.length&&(E.text=Wh(a,l,f)),E},u}();function Yh(u,s){var e=u==null?void 0:u.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||s===Mt?"avc1.42e01e":"mp4a.40.5"}try{Ir=self.performance.now.bind(self.performance)}catch{B.debug("Unable to use Performance API on this environment"),Ir=typeof self!="undefined"&&self.Date.now}var sd=[{demux:qv,remux:rg},{demux:Zv,remux:nd},{demux:Kv,remux:nd},{demux:tg,remux:nd}],od=function(){function u(e,t,i,a,l){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=a,this.id=l}var s=u.prototype;return s.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},s.push=function(e,t,i,a){var l=this,d=i.transmuxing;d.executeStart=Ir();var c=new Uint8Array(e),h=this.currentTransmuxState,f=this.transmuxConfig;a&&(this.currentTransmuxState=a);var p=a||h,E=p.contiguous,b=p.discontinuity,A=p.trackSwitch,w=p.accurateTimeOffset,D=p.timeOffset,S=p.initSegmentChange,L=f.audioCodec,N=f.videoCodec,P=f.defaultInitPts,V=f.duration,Y=f.initSegmentData,j=function(xe,Le){var Me=null;return xe.byteLength>0&&Le!=null&&Le.key!=null&&Le.iv!==null&&Le.method!=null&&(Me=Le),Me}(c,t);if(j&&j.method==="AES-128"){var ie=this.getDecrypter();if(!ie.isSync())return this.decryptionPromise=ie.webCryptoDecrypt(c,j.key.buffer,j.iv.buffer).then(function(xe){var Le=l.push(xe,null,i);return l.decryptionPromise=null,Le}),this.decryptionPromise;var Q=ie.softwareDecrypt(c,j.key.buffer,j.iv.buffer);if(i.part>-1&&(Q=ie.flush()),!Q)return d.executeEnd=Ir(),ld(i);c=new Uint8Array(Q)}var X=this.needsProbing(b,A);if(X){var ce=this.configureTransmuxer(c);if(ce)return B.warn("[transmuxer] "+ce.message),this.observer.emit(k.ERROR,k.ERROR,{type:oe.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,error:ce,reason:ce.message}),d.executeEnd=Ir(),ld(i)}(b||A||S||X)&&this.resetInitSegment(Y,L,N,V,t),(b||S||X)&&this.resetInitialTimestamp(P),E||this.resetContiguity();var le=this.transmux(c,j,D,w,i),Ae=this.currentTransmuxState;return Ae.contiguous=!0,Ae.discontinuity=!1,Ae.trackSwitch=!1,d.executeEnd=Ir(),le},s.flush=function(e){var t=this,i=e.transmuxing;i.executeStart=Ir();var a=this.decrypter,l=this.currentTransmuxState,d=this.decryptionPromise;if(d)return d.then(function(){return t.flush(e)});var c=[],h=l.timeOffset;if(a){var f=a.flush();f&&c.push(this.push(f,null,e))}var p=this.demuxer,E=this.remuxer;if(!p||!E)return i.executeEnd=Ir(),[ld(e)];var b=p.flush(h);return Ma(b)?b.then(function(A){return t.flushRemux(c,A,e),c}):(this.flushRemux(c,b,e),c)},s.flushRemux=function(e,t,i){var a=t.audioTrack,l=t.videoTrack,d=t.id3Track,c=t.textTrack,h=this.currentTransmuxState,f=h.accurateTimeOffset,p=h.timeOffset;B.log("[transmuxer.ts]: Flushed fragment "+i.sn+(i.part>-1?" p: "+i.part:"")+" of level "+i.level);var E=this.remuxer.remux(a,l,d,c,p,f,!0,this.id);e.push({remuxResult:E,chunkMeta:i}),i.transmuxing.executeEnd=Ir()},s.resetInitialTimestamp=function(e){var t=this.demuxer,i=this.remuxer;t&&i&&(t.resetTimeStamp(e),i.resetTimeStamp(e))},s.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},s.resetInitSegment=function(e,t,i,a,l){var d=this.demuxer,c=this.remuxer;d&&c&&(d.resetInitSegment(e,t,i,a),c.resetInitSegment(e,t,i,l))},s.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},s.transmux=function(e,t,i,a,l){return t&&t.method==="SAMPLE-AES"?this.transmuxSampleAes(e,t,i,a,l):this.transmuxUnencrypted(e,i,a,l)},s.transmuxUnencrypted=function(e,t,i,a){var l=this.demuxer.demux(e,t,!1,!this.config.progressive),d=l.audioTrack,c=l.videoTrack,h=l.id3Track,f=l.textTrack;return{remuxResult:this.remuxer.remux(d,c,h,f,t,i,!1,this.id),chunkMeta:a}},s.transmuxSampleAes=function(e,t,i,a,l){var d=this;return this.demuxer.demuxSampleAes(e,t,i).then(function(c){return{remuxResult:d.remuxer.remux(c.audioTrack,c.videoTrack,c.id3Track,c.textTrack,i,a,!1,d.id),chunkMeta:l}})},s.configureTransmuxer=function(e){for(var t,i=this.config,a=this.observer,l=this.typeSupported,d=this.vendor,c=0,h=sd.length;c<h;c++)if(sd[c].demux.probe(e)){t=sd[c];break}if(!t)return new Error("Failed to find demuxer by probing fragment data");var f=this.demuxer,p=this.remuxer,E=t.remux,b=t.demux;p&&p instanceof E||(this.remuxer=new E(a,i,l,d)),f&&f instanceof b||(this.demuxer=new b(a,i,l),this.probe=b.probe)},s.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},s.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new Ni(this.config)),e},u}(),ld=function(u){return{remuxResult:{},chunkMeta:u}};function Ma(u){return"then"in u&&u.then instanceof Function}var ag=function(u,s,e,t,i){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=u,this.videoCodec=s,this.initSegmentData=e,this.duration=t,this.defaultInitPts=i||null},ng=function(u,s,e,t,i,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=u,this.contiguous=s,this.accurateTimeOffset=e,this.trackSwitch=t,this.timeOffset=i,this.initSegmentChange=a},$h={exports:{}};(function(u){var s=Object.prototype.hasOwnProperty,e="~";function t(){}function i(c,h,f){this.fn=c,this.context=h,this.once=f||!1}function a(c,h,f,p,E){if(typeof f!="function")throw new TypeError("The listener must be a function");var b=new i(f,p||c,E),A=e?e+h:h;return c._events[A]?c._events[A].fn?c._events[A]=[c._events[A],b]:c._events[A].push(b):(c._events[A]=b,c._eventsCount++),c}function l(c,h){--c._eventsCount==0?c._events=new t:delete c._events[h]}function d(){this._events=new t,this._eventsCount=0}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1)),d.prototype.eventNames=function(){var c,h,f=[];if(this._eventsCount===0)return f;for(h in c=this._events)s.call(c,h)&&f.push(e?h.slice(1):h);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(c)):f},d.prototype.listeners=function(c){var h=e?e+c:c,f=this._events[h];if(!f)return[];if(f.fn)return[f.fn];for(var p=0,E=f.length,b=new Array(E);p<E;p++)b[p]=f[p].fn;return b},d.prototype.listenerCount=function(c){var h=e?e+c:c,f=this._events[h];return f?f.fn?1:f.length:0},d.prototype.emit=function(c,h,f,p,E,b){var A=e?e+c:c;if(!this._events[A])return!1;var w,D,S=this._events[A],L=arguments.length;if(S.fn){switch(S.once&&this.removeListener(c,S.fn,void 0,!0),L){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,h),!0;case 3:return S.fn.call(S.context,h,f),!0;case 4:return S.fn.call(S.context,h,f,p),!0;case 5:return S.fn.call(S.context,h,f,p,E),!0;case 6:return S.fn.call(S.context,h,f,p,E,b),!0}for(D=1,w=new Array(L-1);D<L;D++)w[D-1]=arguments[D];S.fn.apply(S.context,w)}else{var N,P=S.length;for(D=0;D<P;D++)switch(S[D].once&&this.removeListener(c,S[D].fn,void 0,!0),L){case 1:S[D].fn.call(S[D].context);break;case 2:S[D].fn.call(S[D].context,h);break;case 3:S[D].fn.call(S[D].context,h,f);break;case 4:S[D].fn.call(S[D].context,h,f,p);break;default:if(!w)for(N=1,w=new Array(L-1);N<L;N++)w[N-1]=arguments[N];S[D].fn.apply(S[D].context,w)}}return!0},d.prototype.on=function(c,h,f){return a(this,c,h,f,!1)},d.prototype.once=function(c,h,f){return a(this,c,h,f,!0)},d.prototype.removeListener=function(c,h,f,p){var E=e?e+c:c;if(!this._events[E])return this;if(!h)return l(this,E),this;var b=this._events[E];if(b.fn)b.fn!==h||p&&!b.once||f&&b.context!==f||l(this,E);else{for(var A=0,w=[],D=b.length;A<D;A++)(b[A].fn!==h||p&&!b[A].once||f&&b[A].context!==f)&&w.push(b[A]);w.length?this._events[E]=w.length===1?w[0]:w:l(this,E)}return this},d.prototype.removeAllListeners=function(c){var h;return c?(h=e?e+c:c,this._events[h]&&l(this,h)):(this._events=new t,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=e,d.EventEmitter=d,u.exports=d})($h);var Xo=de($h.exports);function ud(u,s){if(!((e=s.remuxResult).audio||e.video||e.text||e.id3||e.initSegment))return!1;var e,t=[],i=s.remuxResult,a=i.audio,l=i.video;return a&&jh(t,a),l&&jh(t,l),u.postMessage({event:"transmuxComplete",data:s},t),!0}function jh(u,s){s.data1&&u.push(s.data1.buffer),s.data2&&u.push(s.data2.buffer)}function zh(u,s,e){s.reduce(function(t,i){return ud(u,i)||t},!1)||u.postMessage({event:"transmuxComplete",data:s[0]}),u.postMessage({event:"flush",data:e})}r!==void 0&&r&&function(u){var s=new Xo,e=function(i,a){u.postMessage({event:i,data:a})};s.on(k.FRAG_DECRYPTED,e),s.on(k.ERROR,e);var t=function(){var i=function(l){var d=function(c){e("workerLog",{logType:l,message:c})};B[l]=d};for(var a in B)i(a)};u.addEventListener("message",function(i){var a=i.data;switch(a.cmd){case"init":var l=JSON.parse(a.config);u.transmuxer=new od(s,a.typeSupported,l,a.vendor,a.id),it(l.debug,a.id),t(),e("init",null);break;case"configure":u.transmuxer.configure(a.config);break;case"demux":var d=u.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);Ma(d)?(u.transmuxer.async=!0,d.then(function(f){ud(u,f)}).catch(function(f){e(k.ERROR,{type:oe.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,chunkMeta:a.chunkMeta,fatal:!1,error:f,err:f,reason:"transmuxer-worker push error"})})):(u.transmuxer.async=!1,ud(u,d));break;case"flush":var c=a.chunkMeta,h=u.transmuxer.flush(c);Ma(h)||u.transmuxer.async?(Ma(h)||(h=Promise.resolve(h)),h.then(function(f){zh(u,f,c)}).catch(function(f){e(k.ERROR,{type:oe.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,chunkMeta:a.chunkMeta,fatal:!1,error:f,err:f,reason:"transmuxer-worker flush error"})})):zh(u,h,c)}})}(self);var dd=sn()||{isTypeSupported:function(){return!1}},Qh=function(){function u(e,t,i,a){var l=this;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;var d=e.config;this.hls=e,this.id=t,this.useWorker=!!d.enableWorker,this.onTransmuxComplete=i,this.onFlush=a;var c=function(D,S){(S=S||{}).frag=l.frag,S.id=l.id,D===k.ERROR&&(l.error=S.error),l.hls.trigger(D,S)};this.observer=new Xo,this.observer.on(k.FRAG_DECRYPTED,c),this.observer.on(k.ERROR,c);var h,f,p,E,b={mp4:dd.isTypeSupported("video/mp4"),mpeg:dd.isTypeSupported("audio/mpeg"),mp3:dd.isTypeSupported('audio/mp4; codecs="mp3"')},A=navigator.vendor;if(!this.useWorker||typeof Worker=="undefined"||(d.workerPath,0))this.transmuxer=new od(this.observer,b,d,A,t);else try{d.workerPath?(B.log("loading Web Worker "+d.workerPath+' for "'+t+'"'),this.workerContext=(p=d.workerPath,E=new self.URL(p,self.location.href).href,{worker:new self.Worker(E),scriptURL:E})):(B.log('injecting Web Worker for "'+t+'"'),this.workerContext=(h=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+n.toString()+")(true);"],{type:"text/javascript"}),f=self.URL.createObjectURL(h),{worker:new self.Worker(f),objectURL:f})),this.onwmsg=function(D){return l.onWorkerMessage(D)};var w=this.workerContext.worker;w.addEventListener("message",this.onwmsg),w.onerror=function(D){var S=new Error(D.message+" ("+D.filename+":"+D.lineno+")");d.enableWorker=!1,B.warn('Error in "'+t+'" Web Worker, fallback to inline'),l.hls.trigger(k.ERROR,{type:oe.OTHER_ERROR,details:q.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:S})},w.postMessage({cmd:"init",typeSupported:b,vendor:A,id:t,config:JSON.stringify(d)})}catch(D){B.warn('Error setting up "'+t+'" Web Worker, fallback to inline',D),this.resetWorker(),this.error=null,this.transmuxer=new od(this.observer,b,d,A,t)}}var s=u.prototype;return s.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,i=e.objectURL;i&&self.URL.revokeObjectURL(i),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},s.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},s.push=function(e,t,i,a,l,d,c,h,f,p){var E,b,A=this;f.transmuxing.start=self.performance.now();var w=this.transmuxer,D=d?d.start:l.start,S=l.decryptdata,L=this.frag,N=!(L&&l.cc===L.cc),P=!(L&&f.level===L.level),V=L?f.sn-L.sn:-1,Y=this.part?f.part-this.part.index:-1,j=V===0&&f.id>1&&f.id===(L==null?void 0:L.stats.chunkCount),ie=!P&&(V===1||V===0&&(Y===1||j&&Y<=0)),Q=self.performance.now();(P||V||l.stats.parsing.start===0)&&(l.stats.parsing.start=Q),!d||!Y&&ie||(d.stats.parsing.start=Q);var X=!(L&&((E=l.initSegment)==null?void 0:E.url)===((b=L.initSegment)==null?void 0:b.url)),ce=new ng(N,ie,h,P,D,X);if(!ie||N||X){B.log("[transmuxer-interface, "+l.type+"]: Starting new transmux session for sn: "+f.sn+" p: "+f.part+" level: "+f.level+" id: "+f.id+`
|
|
21
|
-
discontinuity: `+N+`
|
|
22
|
-
trackSwitch: `+P+`
|
|
23
|
-
contiguous: `+ie+`
|
|
24
|
-
accurateTimeOffset: `+h+`
|
|
25
|
-
timeOffset: `+D+`
|
|
26
|
-
initSegmentChange: `+X);var le=new ag(i,a,t,c,p);this.configureTransmuxer(le)}if(this.frag=l,this.part=d,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:S,chunkMeta:f,state:ce},e instanceof ArrayBuffer?[e]:[]);else if(w){var Ae=w.push(e,S,f,ce);Ma(Ae)?(w.async=!0,Ae.then(function(xe){A.handleTransmuxComplete(xe)}).catch(function(xe){A.transmuxerError(xe,f,"transmuxer-interface push error")})):(w.async=!1,this.handleTransmuxComplete(Ae))}},s.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var i=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(i){var a=i.flush(e);Ma(a)||i.async?(Ma(a)||(a=Promise.resolve(a)),a.then(function(l){t.handleFlushResult(l,e)}).catch(function(l){t.transmuxerError(l,e,"transmuxer-interface flush error")})):this.handleFlushResult(a,e)}},s.transmuxerError=function(e,t,i){this.hls&&(this.error=e,this.hls.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i}))},s.handleFlushResult=function(e,t){var i=this;e.forEach(function(a){i.handleTransmuxComplete(a)}),this.onFlush(t)},s.onWorkerMessage=function(e){var t=e.data,i=this.hls;switch(t.event){case"init":var a,l=(a=this.workerContext)==null?void 0:a.objectURL;l&&self.URL.revokeObjectURL(l);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":B[t.data.logType]&&B[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)}},s.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},s.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},u}(),sg=function(){function u(e,t,i,a){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=i,this.hls=a}var s=u.prototype;return s.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},s.poll=function(e,t){var i=this.config,a=this.media,l=this.stalled;if(a!==null){var d=a.currentTime,c=a.seeking,h=this.seeking&&!c,f=!this.seeking&&c;if(this.seeking=c,d===e){if(f||h)this.stalled=null;else if(!(a.paused&&!c||a.ended||a.playbackRate===0)&&he.getBuffered(a).length){var p=he.bufferInfo(a,d,0),E=p.len>0,b=p.nextStart||0;if(E||b){if(c){var A=p.len>2,w=!b||t&&t.start<=d||b-d>2&&!this.fragmentTracker.getPartialFragment(d);if(A||w)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var D,S=Math.max(b,p.start||0)-d,L=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,N=!(L==null||(D=L.details)==null)&&D.live?2*L.details.targetduration:2,P=this.fragmentTracker.getPartialFragment(d);if(S>0&&(S<=N||P))return void this._trySkipBufferHole(P)}var V=self.performance.now();if(l!==null){var Y=V-l;if(c||!(Y>=250)||(this._reportStall(p),this.media)){var j=he.bufferInfo(a,d,i.maxBufferHole);this._tryFixBufferStall(j,Y)}}else this.stalled=V}}}else if(this.moved=!0,l!==null){if(this.stallReported){var ie=self.performance.now()-l;B.warn("playback not stuck anymore @"+d+", after "+Math.round(ie)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},s._tryFixBufferStall=function(e,t){var i=this.config,a=this.fragmentTracker,l=this.media;if(l!==null){var d=l.currentTime,c=a.getPartialFragment(d);if(c&&(this._trySkipBufferHole(c)||!this.media))return;(e.len>i.maxBufferHole||e.nextStart&&e.nextStart-d<i.maxBufferHole)&&t>1e3*i.highBufferWatchdogPeriod&&(B.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},s._reportStall=function(e){var t=this.hls,i=this.media;if(!this.stallReported&&i){this.stallReported=!0;var a=new Error("Playback stalling at @"+i.currentTime+" due to low buffer ("+JSON.stringify(e)+")");B.warn(a.message),t.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.BUFFER_STALLED_ERROR,fatal:!1,error:a,buffer:e.len})}},s._trySkipBufferHole=function(e){var t=this.config,i=this.hls,a=this.media;if(a===null)return 0;var l=a.currentTime,d=he.bufferInfo(a,l,0),c=l<d.start?d.start:d.nextStart;if(c){var h=d.len<=t.maxBufferHole,f=d.len>0&&d.len<1&&a.readyState<3,p=c-l;if(p>0&&(h||f)){if(p>t.maxBufferHole){var E=this.fragmentTracker,b=!1;if(l===0){var A=E.getAppendedFrag(0,rt);A&&c<A.end&&(b=!0)}if(!b){var w=e||E.getAppendedFrag(l,rt);if(w){for(var D=!1,S=w.end;S<c;){var L=E.getPartialFragment(S);if(!L){D=!0;break}S+=L.duration}if(D)return 0}}}var N=Math.max(c+.05,l+.1);if(B.warn("skipping hole, adjusting currentTime from "+l+" to "+N),this.moved=!0,this.stalled=null,a.currentTime=N,e&&!e.gap){var P=new Error("fragment loaded with buffer holes, seeking from "+l+" to "+N);i.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:P,reason:P.message,frag:e})}return N}}return 0},s._tryNudgeBuffer=function(){var e=this.config,t=this.hls,i=this.media,a=this.nudgeRetry;if(i!==null){var l=i.currentTime;if(this.nudgeRetry++,a<e.nudgeMaxRetry){var d=l+(a+1)*e.nudgeOffset,c=new Error("Nudging 'currentTime' from "+l+" to "+d);B.warn(c.message),i.currentTime=d,t.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.BUFFER_NUDGE_ON_STALL,error:c,fatal:!1})}else{var h=new Error("Playhead still not moving while enough data buffered @"+l+" after "+e.nudgeMaxRetry+" nudges");B.error(h.message),t.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.BUFFER_STALLED_ERROR,error:h,fatal:!0})}}},u}(),og=function(u){function s(t,i,a){var l;return(l=u.call(this,t,i,a,"[stream-controller]",rt)||this).audioCodecSwap=!1,l.gapController=null,l.level=-1,l._forceStartLoad=!1,l.altAudio=!1,l.audioOnly=!1,l.fragPlaying=null,l.onvplaying=null,l.onvseeked=null,l.fragLastKbps=0,l.couldBacktrack=!1,l.backtrackFragment=null,l.audioCodecSwitch=!1,l.videoBuffer=null,l._registerListeners(),l}z(s,u);var e=s.prototype;return e._registerListeners=function(){var t=this.hls;t.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(k.MANIFEST_LOADING,this.onManifestLoading,this),t.on(k.MANIFEST_PARSED,this.onManifestParsed,this),t.on(k.LEVEL_LOADING,this.onLevelLoading,this),t.on(k.LEVEL_LOADED,this.onLevelLoaded,this),t.on(k.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(k.ERROR,this.onError,this),t.on(k.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(k.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(k.BUFFER_CREATED,this.onBufferCreated,this),t.on(k.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(k.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(k.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(k.MANIFEST_LOADING,this.onManifestLoading,this),t.off(k.MANIFEST_PARSED,this.onManifestParsed,this),t.off(k.LEVEL_LOADED,this.onLevelLoaded,this),t.off(k.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(k.ERROR,this.onError,this),t.off(k.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(k.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(k.BUFFER_CREATED,this.onBufferCreated,this),t.off(k.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(k.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(k.FRAG_BUFFERED,this.onFragBuffered,this)},e.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},e.startLoad=function(t){if(this.levels){var i=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var l=a.startLevel;l===-1&&(a.config.testBandwidth&&this.levels.length>1?(l=0,this.bitrateTest=!0):l=a.nextAutoLevel),this.level=a.nextLoadLevel=l,this.loadedmetadata=!1}i>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),t=i),this.state=De,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Bt},e.stopLoad=function(){this._forceStartLoad=!1,u.prototype.stopLoad.call(this)},e.doTick=function(){switch(this.state){case mn:var t,i=this.levels,a=this.level,l=i==null||(t=i[a])==null?void 0:t.details;if(l&&(!l.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(l))break;this.state=De;break}if(this.hls.nextLoadLevel!==this.level){this.state=De;break}break;case Zr:var d,c=self.performance.now(),h=this.retryDate;(!h||c>=h||(d=this.media)!=null&&d.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=De)}this.state===De&&this.doTickIdle(),this.onTickEnd()},e.onTickEnd=function(){u.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},e.doTickIdle=function(){var t=this.hls,i=this.levelLastLoaded,a=this.levels,l=this.media,d=t.config,c=t.nextLoadLevel;if(i!==null&&(l||!this.startFragRequested&&d.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&a!=null&&a[c]){var h=a[c],f=this.getMainFwdBufferInfo();if(f!==null){var p=this.getLevelDetails();if(p&&this._streamEnded(f,p)){var E={};return this.altAudio&&(E.type="video"),this.hls.trigger(k.BUFFER_EOS,E),void(this.state=bs)}t.loadLevel!==c&&t.manualLevel===-1&&this.log("Adapting to level "+c+" from level "+this.level),this.level=t.nextLoadLevel=c;var b=h.details;if(!b||this.state===mn||b.live&&this.levelLastLoaded!==c)return this.level=c,void(this.state=mn);var A=f.len,w=this.getMaxBufferLength(h.maxBitrate);if(!(A>=w)){this.backtrackFragment&&this.backtrackFragment.start>f.end&&(this.backtrackFragment=null);var D=this.backtrackFragment?this.backtrackFragment.start:f.end,S=this.getNextFragment(D,b);if(this.couldBacktrack&&!this.fragPrevious&&S&&S.sn!=="initSegment"&&this.fragmentTracker.getState(S)!==Re){var L,N=((L=this.backtrackFragment)!=null?L:S).sn-b.startSN,P=b.fragments[N-1];P&&S.cc===P.cc&&(S=P,this.fragmentTracker.removeFragment(P))}else this.backtrackFragment&&f.len&&(this.backtrackFragment=null);if(S&&this.isLoopLoading(S,D)){if(!S.gap){var V=this.audioOnly&&!this.altAudio?Et:Mt,Y=(V===Mt?this.videoBuffer:this.mediaBuffer)||this.media;Y&&this.afterBufferFlushed(Y,V,rt)}S=this.getNextFragmentLoopLoading(S,b,f,rt,w)}S&&(!S.initSegment||S.initSegment.data||this.bitrateTest||(S=S.initSegment),this.loadFragment(S,h,D))}}}},e.loadFragment=function(t,i,a){var l=this.fragmentTracker.getState(t);this.fragCurrent=t,l===ee||l===_e?t.sn==="initSegment"?this._loadInitSegment(t,i):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,i)):(this.startFragRequested=!0,u.prototype.loadFragment.call(this,t,i,a)):this.clearTrackerIfNeeded(t)},e.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,rt)},e.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},e.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},e.nextLevelSwitch=function(){var t=this.levels,i=this.media;if(i!=null&&i.readyState){var a,l=this.getAppendedFrag(i.currentTime);l&&l.start>1&&this.flushMainBuffer(0,l.start-1);var d=this.getLevelDetails();if(d!=null&&d.live){var c=this.getMainFwdBufferInfo();if(!c||c.len<2*d.targetduration)return}if(!i.paused&&t){var h=t[this.hls.nextLoadLevel],f=this.fragLastKbps;a=f&&this.fragCurrent?this.fragCurrent.duration*h.maxBitrate/(1e3*f)+1:0}else a=0;var p=this.getBufferedFrag(i.currentTime+a);if(p){var E=this.followingBufferedFrag(p);if(E){this.abortCurrentFrag();var b=E.maxStartPTS?E.maxStartPTS:E.start,A=E.duration,w=Math.max(p.end,b+Math.min(Math.max(A-this.config.maxFragLookUpTolerance,.5*A),.75*A));this.flushMainBuffer(w,Number.POSITIVE_INFINITY)}}}},e.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case wr:case Xr:case Zr:case Lr:case Yo:this.state=De}this.nextLoadPosition=this.getLoadPosition()},e.flushMainBuffer=function(t,i){u.prototype.flushMainBuffer.call(this,t,i,this.altAudio?"video":null)},e.onMediaAttached=function(t,i){u.prototype.onMediaAttached.call(this,t,i);var a=i.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),a.addEventListener("playing",this.onvplaying),a.addEventListener("seeked",this.onvseeked),this.gapController=new sg(this.config,a,this.fragmentTracker,this.hls)},e.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),u.prototype.onMediaDetaching.call(this)},e.onMediaPlaying=function(){this.tick()},e.onMediaSeeked=function(){var t=this.media,i=t?t.currentTime:null;re(i)&&this.log("Media seeked to "+i.toFixed(3));var a=this.getMainFwdBufferInfo();a!==null&&a.len!==0?this.tick():this.warn('Main forward buffer length on "seeked" event '+(a?a.len:"empty")+")")},e.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(k.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},e.onManifestParsed=function(t,i){var a,l,d,c=!1,h=!1;i.levels.forEach(function(f){(a=f.audioCodec)&&(a.indexOf("mp4a.40.2")!==-1&&(c=!0),a.indexOf("mp4a.40.5")!==-1&&(h=!0))}),this.audioCodecSwitch=c&&h&&typeof((d=Ch())==null||(l=d.prototype)==null?void 0:l.changeType)!="function",this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=i.levels,this.startFragRequested=!1},e.onLevelLoading=function(t,i){var a=this.levels;if(a&&this.state===De){var l=a[i.level];(!l.details||l.details.live&&this.levelLastLoaded!==i.level||this.waitForCdnTuneIn(l.details))&&(this.state=mn)}},e.onLevelLoaded=function(t,i){var a,l=this.levels,d=i.level,c=i.details,h=c.totalduration;if(l){this.log("Level "+d+" loaded ["+c.startSN+","+c.endSN+"]"+(c.lastPartSn?"[part-"+c.lastPartSn+"-"+c.lastPartIndex+"]":"")+", cc ["+c.startCC+", "+c.endCC+"] duration:"+h);var f=l[d],p=this.fragCurrent;!p||this.state!==Xr&&this.state!==Zr||p.level===i.level&&p.urlId===f.urlId||!p.loader||this.abortCurrentFrag();var E=0;if(c.live||(a=f.details)!=null&&a.live){if(c.fragments[0]||(c.deltaUpdateFailed=!0),c.deltaUpdateFailed)return;E=this.alignPlaylists(c,f.details)}if(f.details=c,this.levelLastLoaded=d,this.hls.trigger(k.LEVEL_UPDATED,{details:c,level:d}),this.state===mn){if(this.waitForCdnTuneIn(c))return;this.state=De}this.startFragRequested?c.live&&this.synchronizeToLiveEdge(c):this.setStartPosition(c,E),this.tick()}else this.warn("Levels were reset while loading level "+d)},e._handleFragmentLoadProgress=function(t){var i,a=t.frag,l=t.part,d=t.payload,c=this.levels;if(c){var h=c[a.level],f=h.details;if(!f)return this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset"),void this.fragmentTracker.removeFragment(a);var p=h.videoCodec,E=f.PTSKnown||!f.live,b=(i=a.initSegment)==null?void 0:i.data,A=this._getAudioCodec(h),w=this.transmuxer=this.transmuxer||new Qh(this.hls,rt,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),D=l?l.index:-1,S=D!==-1,L=new fe(a.level,a.sn,a.stats.chunkCount,d.byteLength,D,S),N=this.initPTS[a.cc];w.push(d,b,A,p,a,l,f.totalduration,E,L,N)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered")},e.onAudioTrackSwitching=function(t,i){var a=this.altAudio;if(!i.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var l=this.fragCurrent;l&&(this.log("Switching to main audio track, cancel main fragment load"),l.abortRequests(),this.fragmentTracker.removeFragment(l)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var d=this.hls;a&&(d.trigger(k.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),d.trigger(k.AUDIO_TRACK_SWITCHED,i)}},e.onAudioTrackSwitched=function(t,i){var a=i.id,l=!!this.hls.audioTracks[a].url;if(l){var d=this.videoBuffer;d&&this.mediaBuffer!==d&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=d)}this.altAudio=l,this.tick()},e.onBufferCreated=function(t,i){var a,l,d=i.tracks,c=!1;for(var h in d){var f=d[h];if(f.id==="main"){if(l=h,a=f,h==="video"){var p=d[h];p&&(this.videoBuffer=p.buffer)}}else c=!0}c&&a?(this.log("Alternate track found, use "+l+".buffered to schedule main fragment loading"),this.mediaBuffer=a.buffer):this.mediaBuffer=this.media},e.onFragBuffered=function(t,i){var a=i.frag,l=i.part;if(!a||a.type===rt){if(this.fragContextChanged(a))return this.warn("Fragment "+a.sn+(l?" p: "+l.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Yo&&(this.state=De));var d=l?l.stats:a.stats;this.fragLastKbps=Math.round(8*d.total/(d.buffering.end-d.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,l)}},e.onError=function(t,i){var a;if(i.fatal)this.state=fn;else switch(i.details){case q.FRAG_GAP:case q.FRAG_PARSING_ERROR:case q.FRAG_DECRYPT_ERROR:case q.FRAG_LOAD_ERROR:case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_ERROR:case q.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(rt,i);break;case q.LEVEL_LOAD_ERROR:case q.LEVEL_LOAD_TIMEOUT:case q.LEVEL_PARSING_ERROR:i.levelRetry||this.state!==mn||((a=i.context)==null?void 0:a.type)!==Ar||(this.state=De);break;case q.BUFFER_FULL_ERROR:if(!i.parent||i.parent!=="main")return;this.reduceLengthAndFlushBuffer(i)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case q.INTERNAL_EXCEPTION:this.recoverWorkerError(i)}},e.checkBuffer=function(){var t=this.media,i=this.gapController;if(t&&i&&t.readyState){if(this.loadedmetadata||!he.getBuffered(t).length){var a=this.state!==De?this.fragCurrent:null;i.poll(this.lastCurrentTime,a)}this.lastCurrentTime=t.currentTime}},e.onFragLoadEmergencyAborted=function(){this.state=De,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},e.onBufferFlushed=function(t,i){var a=i.type;if(a!==Et||this.audioOnly&&!this.altAudio){var l=(a===Mt?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(l,a,rt)}},e.onLevelsUpdated=function(t,i){this.levels=i.levels},e.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},e.seekToStartPos=function(){var t=this.media;if(t){var i=t.currentTime,a=this.startPosition;if(a>=0&&i<a){if(t.seeking)return void this.log("could not seek to "+a+", already seeking at "+i);var l=he.getBuffered(t),d=(l.length?l.start(0):0)-a;d>0&&(d<this.config.maxBufferHole||d<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+d+" to match buffer start"),a+=d,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+i),t.currentTime=a}}},e._getAudioCodec=function(t){var i=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&i&&(this.log("Swapping audio codec"),i=i.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),i},e._loadBitrateTestFrag=function(t,i){var a=this;t.bitrateTest=!0,this._doFragLoad(t,i).then(function(l){var d=a.hls;if(l&&!a.fragContextChanged(t)){i.fragmentError=0,a.state=De,a.startFragRequested=!1,a.bitrateTest=!1;var c=t.stats;c.parsing.start=c.parsing.end=c.buffering.start=c.buffering.end=self.performance.now(),d.trigger(k.FRAG_LOADED,l),t.bitrateTest=!1}})},e._handleTransmuxComplete=function(t){var i,a="main",l=this.hls,d=t.remuxResult,c=t.chunkMeta,h=this.getCurrentContext(c);if(h){var f=h.frag,p=h.part,E=h.level,b=d.video,A=d.text,w=d.id3,D=d.initSegment,S=E.details,L=this.altAudio?void 0:d.audio;if(this.fragContextChanged(f))this.fragmentTracker.removeFragment(f);else{if(this.state=Lr,D){if(D!=null&&D.tracks){var N=f.initSegment||f;this._bufferInitSegment(E,D.tracks,N,c),l.trigger(k.FRAG_PARSING_INIT_SEGMENT,{frag:N,id:a,tracks:D.tracks})}var P=D.initPTS,V=D.timescale;re(P)&&(this.initPTS[f.cc]={baseTime:P,timescale:V},l.trigger(k.INIT_PTS_FOUND,{frag:f,id:a,initPTS:P,timescale:V}))}if(b&&d.independent!==!1){if(S){var Y=b.startPTS,j=b.endPTS,ie=b.startDTS,Q=b.endDTS;if(p)p.elementaryStreams[b.type]={startPTS:Y,endPTS:j,startDTS:ie,endDTS:Q};else if(b.firstKeyFrame&&b.independent&&c.id===1&&(this.couldBacktrack=!0),b.dropped&&b.independent){var X=this.getMainFwdBufferInfo();if((X?X.end:this.getLoadPosition())+this.config.maxBufferHole<(b.firstKeyFramePTS?b.firstKeyFramePTS:Y)-this.config.maxBufferHole)return void this.backtrack(f);f.setElementaryStreamInfo(b.type,f.start,j,f.start,Q,!0)}f.setElementaryStreamInfo(b.type,Y,j,ie,Q),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(b,f,p,c)}}else if(d.independent===!1)return void this.backtrack(f);if(L){var ce=L.startPTS,le=L.endPTS,Ae=L.startDTS,xe=L.endDTS;p&&(p.elementaryStreams[Et]={startPTS:ce,endPTS:le,startDTS:Ae,endDTS:xe}),f.setElementaryStreamInfo(Et,ce,le,Ae,xe),this.bufferFragmentData(L,f,p,c)}if(S&&w!=null&&(i=w.samples)!=null&&i.length){var Le={id:a,frag:f,details:S,samples:w.samples};l.trigger(k.FRAG_PARSING_METADATA,Le)}if(S&&A){var Me={id:a,frag:f,details:S,samples:A.samples};l.trigger(k.FRAG_PARSING_USERDATA,Me)}}}else this.resetWhenMissingContext(c)},e._bufferInitSegment=function(t,i,a,l){var d=this;if(this.state===Lr){this.audioOnly=!!i.audio&&!i.video,this.altAudio&&!this.audioOnly&&delete i.audio;var c=i.audio,h=i.video,f=i.audiovideo;if(c){var p=t.audioCodec,E=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(p&&(p=p.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),c.metadata.channelCount!==1&&E.indexOf("firefox")===-1&&(p="mp4a.40.5")),E.indexOf("android")!==-1&&c.container!=="audio/mpeg"&&(p="mp4a.40.2",this.log("Android: force audio codec to "+p)),t.audioCodec&&t.audioCodec!==p&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+p+'"'),c.levelCodec=p,c.id="main",this.log("Init audio buffer, container:"+c.container+", codecs[selected/level/parsed]=["+(p||"")+"/"+(t.audioCodec||"")+"/"+c.codec+"]")}h&&(h.levelCodec=t.videoCodec,h.id="main",this.log("Init video buffer, container:"+h.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+h.codec+"]")),f&&this.log("Init audiovideo buffer, container:"+f.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+f.codec+"]"),this.hls.trigger(k.BUFFER_CODECS,i),Object.keys(i).forEach(function(b){var A=i[b].initSegment;A!=null&&A.byteLength&&d.hls.trigger(k.BUFFER_APPENDING,{type:b,data:A,frag:a,part:null,chunkMeta:l,parent:a.type})}),this.tick()}},e.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,rt)},e.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=De},e.checkFragmentChanged=function(){var t=this.media,i=null;if(t&&t.readyState>1&&t.seeking===!1){var a=t.currentTime;if(he.isBuffered(t,a)?i=this.getAppendedFrag(a):he.isBuffered(t,a+.1)&&(i=this.getAppendedFrag(a+.1)),i){this.backtrackFragment=null;var l=this.fragPlaying,d=i.level;l&&i.sn===l.sn&&l.level===d&&i.urlId===l.urlId||(this.fragPlaying=i,this.hls.trigger(k.FRAG_CHANGED,{frag:i}),l&&l.level===d||this.hls.trigger(k.LEVEL_SWITCHED,{level:d}))}}},M(s,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var i=t.currentTime,a=this.currentFrag;if(a&&re(i)&&re(a.programDateTime)){var l=a.programDateTime+1e3*(i-a.start);return new Date(l)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),s}(Zu),vn=function(){function u(e,t,i){t===void 0&&(t=0),i===void 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}var s=u.prototype;return s.sample=function(e,t){var i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e},s.getTotalWeight=function(){return this.totalWeight_},s.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},u}(),lg=function(){function u(e,t,i,a){a===void 0&&(a=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 vn(e),this.fast_=new vn(t),this.defaultTTFB_=a,this.ttfb_=new vn(e)}var s=u.prototype;return s.update=function(e,t){var i=this.slow_,a=this.fast_,l=this.ttfb_;i.halfLife!==e&&(this.slow_=new vn(e,i.getEstimate(),i.getTotalWeight())),a.halfLife!==t&&(this.fast_=new vn(t,a.getEstimate(),a.getTotalWeight())),l.halfLife!==e&&(this.ttfb_=new vn(e,l.getEstimate(),l.getTotalWeight()))},s.sample=function(e,t){var i=(e=Math.max(e,this.minDelayMs_))/1e3,a=8*t/i;this.fast_.sample(i,a),this.slow_.sample(i,a)},s.sampleTTFB=function(e){var t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))},s.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},s.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},s.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},s.destroy=function(){},u}(),ug=function(){function u(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;var t=e.config;this.bwEstimator=new lg(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}var s=u.prototype;return s.registerListeners=function(){var e=this.hls;e.on(k.FRAG_LOADING,this.onFragLoading,this),e.on(k.FRAG_LOADED,this.onFragLoaded,this),e.on(k.FRAG_BUFFERED,this.onFragBuffered,this),e.on(k.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(k.LEVEL_LOADED,this.onLevelLoaded,this)},s.unregisterListeners=function(){var e=this.hls;e.off(k.FRAG_LOADING,this.onFragLoading,this),e.off(k.FRAG_LOADED,this.onFragLoaded,this),e.off(k.FRAG_BUFFERED,this.onFragBuffered,this),e.off(k.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(k.LEVEL_LOADED,this.onLevelLoaded,this)},s.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},s.onFragLoading=function(e,t){var i,a=t.frag;this.ignoreFragment(a)||(this.fragCurrent=a,this.partCurrent=(i=t.part)!=null?i:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},s.onLevelSwitching=function(e,t){this.clearTimer()},s.getTimeToLoadFrag=function(e,t,i,a){return e+i/t+(a?this.lastLevelLoadSec:0)},s.onLevelLoaded=function(e,t){var i=this.hls.config,a=t.stats,l=a.total,d=a.bwEstimate;re(l)&&re(d)&&(this.lastLevelLoadSec=8*l/d),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)},s._abandonRulesCheck=function(){var e=this.fragCurrent,t=this.partCurrent,i=this.hls,a=i.autoLevelEnabled,l=i.media;if(e&&l){var d=performance.now(),c=t?t.stats:e.stats,h=t?t.duration:e.duration,f=d-c.loading.start;if(c.aborted||c.loaded&&c.loaded===c.total||e.level===0)return this.clearTimer(),void(this._nextAutoLevel=-1);if(a&&!l.paused&&l.playbackRate&&l.readyState){var p=i.mainForwardBufferInfo;if(p!==null){var E=this.bwEstimator.getEstimateTTFB(),b=Math.abs(l.playbackRate);if(!(f<=Math.max(E,h/(2*b)*1e3))){var A=p.len/b;if(!(A>=2*h/b)){var w=c.loading.first?c.loading.first-c.loading.start:-1,D=c.loaded&&w>-1,S=this.bwEstimator.getEstimate(),L=i.levels,N=i.minAutoLevel,P=L[e.level],V=c.total||Math.max(c.loaded,Math.round(h*P.maxBitrate/8)),Y=f-w;Y<1&&D&&(Y=Math.min(f,8*c.loaded/S));var j=D?1e3*c.loaded/Y:0,ie=j?(V-c.loaded)/j:8*V/S+E/1e3;if(!(ie<=A)){var Q,X=j?8*j:S,ce=Number.POSITIVE_INFINITY;for(Q=e.level-1;Q>N;Q--){var le=L[Q].maxBitrate;if((ce=this.getTimeToLoadFrag(E/1e3,X,h*le,!L[Q].details))<A)break}ce>=ie||ce>10*h||(i.nextLoadLevel=Q,D?this.bwEstimator.sample(f-Math.min(E,w),c.loaded):this.bwEstimator.sampleTTFB(f),this.clearTimer(),B.warn("[abr] Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+` is loading too slowly;
|
|
27
|
-
Time to underbuffer: `+A.toFixed(3)+` s
|
|
28
|
-
Estimated load time for current fragment: `+ie.toFixed(3)+` s
|
|
29
|
-
Estimated load time for down switch fragment: `+ce.toFixed(3)+` s
|
|
30
|
-
TTFB estimate: `+w+`
|
|
31
|
-
Current BW estimate: `+(re(S)?(S/1024).toFixed(3):"Unknown")+` Kb/s
|
|
32
|
-
New BW estimate: `+(this.bwEstimator.getEstimate()/1024).toFixed(3)+` Kb/s
|
|
33
|
-
Aborting and switching to level `+Q),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),i.trigger(k.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:c}))}}}}}}},s.onFragLoaded=function(e,t){var i=t.frag,a=t.part,l=a?a.stats:i.stats;if(i.type===rt&&this.bwEstimator.sampleTTFB(l.loading.first-l.loading.start),!this.ignoreFragment(i)){if(this.clearTimer(),this.lastLoadedFragLevel=i.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var d=a?a.duration:i.duration,c=this.hls.levels[i.level],h=(c.loaded?c.loaded.bytes:0)+l.loaded,f=(c.loaded?c.loaded.duration:0)+d;c.loaded={bytes:h,duration:f},c.realBitrate=Math.round(8*h/f)}if(i.bitrateTest){var p={stats:l,frag:i,part:a,id:i.type};this.onFragBuffered(k.FRAG_BUFFERED,p),i.bitrateTest=!1}}},s.onFragBuffered=function(e,t){var i=t.frag,a=t.part,l=a!=null&&a.stats.loaded?a.stats:i.stats;if(!l.aborted&&!this.ignoreFragment(i)){var d=l.parsing.end-l.loading.start-Math.min(l.loading.first-l.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(d,l.loaded),l.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=d/1e3:this.bitrateTestDelay=0}},s.ignoreFragment=function(e){return e.type!==rt||e.sn==="initSegment"},s.clearTimer=function(){self.clearInterval(this.timer)},s.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,i=this.hls,a=i.maxAutoLevel,l=i.config,d=i.minAutoLevel,c=i.media,h=t?t.duration:e?e.duration:0,f=c&&c.playbackRate!==0?Math.abs(c.playbackRate):1,p=this.bwEstimator?this.bwEstimator.getEstimate():l.abrEwmaDefaultEstimate,E=i.mainForwardBufferInfo,b=(E?E.len:0)/f,A=this.findBestLevel(p,d,a,b,l.abrBandWidthFactor,l.abrBandWidthUpFactor);if(A>=0)return A;B.trace("[abr] "+(b?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var w=h?Math.min(h,l.maxStarvationDelay):l.maxStarvationDelay,D=l.abrBandWidthFactor,S=l.abrBandWidthUpFactor;if(!b){var L=this.bitrateTestDelay;L&&(w=(h?Math.min(h,l.maxLoadingDelay):l.maxLoadingDelay)-L,B.trace("[abr] bitrate test took "+Math.round(1e3*L)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*w)+" ms"),D=S=1)}return A=this.findBestLevel(p,d,a,b+w,D,S),Math.max(A,0)},s.findBestLevel=function(e,t,i,a,l,d){for(var c,h=this.fragCurrent,f=this.partCurrent,p=this.lastLoadedFragLevel,E=this.hls.levels,b=E[p],A=!(b==null||(c=b.details)==null||!c.live),w=b==null?void 0:b.codecSet,D=f?f.duration:h?h.duration:0,S=this.bwEstimator.getEstimateTTFB()/1e3,L=t,N=-1,P=i;P>=t;P--){var V=E[P];if(!V||w&&V.codecSet!==w)V&&(L=Math.min(P,L),N=Math.max(P,N));else{N!==-1&&B.trace("[abr] Skipped level(s) "+L+"-"+N+' with CODECS:"'+E[N].attrs.CODECS+'"; not compatible with "'+b.attrs.CODECS+'"');var Y=V.details,j=(f?Y==null?void 0:Y.partTarget:Y==null?void 0:Y.averagetargetduration)||D,ie=void 0;ie=P<=p?l*e:d*e;var Q=E[P].maxBitrate,X=this.getTimeToLoadFrag(S,ie,Q*j,Y===void 0);if(B.trace("[abr] level:"+P+" adjustedbw-bitrate:"+Math.round(ie-Q)+" avgDuration:"+j.toFixed(1)+" maxFetchDuration:"+a.toFixed(1)+" fetchDuration:"+X.toFixed(1)),ie>Q&&(X===0||!re(X)||A&&!this.bitrateTestDelay||X<a))return P}}return-1},M(u,[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this.bwEstimator;if(e!==-1&&!t.canEstimate())return e;var i=this.getNextABRAutoLevel();if(e!==-1){var a=this.hls.levels;if(a.length>Math.max(e,i)&&a[e].loadError<=a[i].loadError)return e}return e!==-1&&(i=Math.min(e,i)),i},set:function(e){this._nextAutoLevel=e}}]),u}(),Xh=function(){function u(){this.chunks=[],this.dataLength=0}var s=u.prototype;return s.push=function(e){this.chunks.push(e),this.dataLength+=e.length},s.flush=function(){var e,t=this.chunks,i=this.dataLength;return t.length?(e=t.length===1?t[0]:function(a,l){for(var d=new Uint8Array(l),c=0,h=0;h<a.length;h++){var f=a[h];d.set(f,c),c+=f.length}return d}(t,i),this.reset(),e):new Uint8Array(0)},s.reset=function(){this.chunks.length=0,this.dataLength=0},u}(),dg=function(u){function s(t,i,a){var l;return(l=u.call(this,t,i,a,"[audio-stream-controller]",Di)||this).videoBuffer=null,l.videoTrackCC=-1,l.waitingVideoCC=-1,l.bufferedTrack=null,l.switchingTrack=null,l.trackId=-1,l.waitingData=null,l.mainDetails=null,l.bufferFlushed=!1,l.cachedTrackLoadedData=null,l._registerListeners(),l}z(s,u);var e=s.prototype;return e.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null},e._registerListeners=function(){var t=this.hls;t.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(k.MANIFEST_LOADING,this.onManifestLoading,this),t.on(k.LEVEL_LOADED,this.onLevelLoaded,this),t.on(k.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(k.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(k.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(k.ERROR,this.onError,this),t.on(k.BUFFER_RESET,this.onBufferReset,this),t.on(k.BUFFER_CREATED,this.onBufferCreated,this),t.on(k.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(k.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(k.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(k.MANIFEST_LOADING,this.onManifestLoading,this),t.off(k.LEVEL_LOADED,this.onLevelLoaded,this),t.off(k.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(k.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(k.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(k.ERROR,this.onError,this),t.off(k.BUFFER_RESET,this.onBufferReset,this),t.off(k.BUFFER_CREATED,this.onBufferCreated,this),t.off(k.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(k.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(k.FRAG_BUFFERED,this.onFragBuffered,this)},e.onInitPtsFound=function(t,i){var a=i.frag,l=i.id,d=i.initPTS,c=i.timescale;if(l==="main"){var h=a.cc;this.initPTS[a.cc]={baseTime:d,timescale:c},this.log("InitPTS for cc: "+h+" found from main: "+d),this.videoTrackCC=h,this.state===Ts&&this.tick()}},e.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=Bt);var i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),i>0&&t===-1?(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),t=i,this.state=De):(this.loadedmetadata=!1,this.state=Ca),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.doTick=function(){switch(this.state){case De:this.doTickIdle();break;case Ca:var t,i=this.levels,a=this.trackId,l=i==null||(t=i[a])==null?void 0:t.details;if(l){if(this.waitForCdnTuneIn(l))break;this.state=Ts}break;case Zr:var d,c=performance.now(),h=this.retryDate;(!h||c>=h||(d=this.media)!=null&&d.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=De);break;case Ts:var f=this.waitingData;if(f){var p=f.frag,E=f.part,b=f.cache,A=f.complete;if(this.initPTS[p.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=Xr;var w={frag:p,part:E,payload:b.flush(),networkDetails:null};this._handleFragmentLoadProgress(w),A&&u.prototype._handleFragmentLoadComplete.call(this,w)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+p.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var D=this.getLoadPosition(),S=he.bufferInfo(this.mediaBuffer,D,this.config.maxBufferHole);hn(S.end,this.config.maxFragLookUpTolerance,p)<0&&(this.log("Waiting fragment cc ("+p.cc+") @ "+p.start+" cancelled because another fragment at "+S.end+" is needed"),this.clearWaitingFragment())}}else this.state=De}this.onTickEnd()},e.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=De)},e.resetLoadingState=function(){this.clearWaitingFragment(),u.prototype.resetLoadingState.call(this)},e.onTickEnd=function(){var t=this.media;t!=null&&t.readyState&&(this.lastCurrentTime=t.currentTime)},e.doTickIdle=function(){var t=this.hls,i=this.levels,a=this.media,l=this.trackId,d=t.config;if(i!=null&&i[l]&&(a||!this.startFragRequested&&d.startFragPrefetch)){var c=i[l],h=c.details;if(!h||h.live&&this.levelLastLoaded!==l||this.waitForCdnTuneIn(h))this.state=Ca;else{var f=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&f&&(this.bufferFlushed=!1,this.afterBufferFlushed(f,Et,Di));var p=this.getFwdBufferInfo(f,Di);if(p!==null){var E=this.bufferedTrack,b=this.switchingTrack;if(!b&&this._streamEnded(p,h))return t.trigger(k.BUFFER_EOS,{type:"audio"}),void(this.state=bs);var A=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,rt),w=p.len,D=this.getMaxBufferLength(A==null?void 0:A.len);if(!(w>=D)||b){var S=h.fragments[0].start,L=p.end;if(b&&a){var N=this.getLoadPosition();E&&b.attrs!==E.attrs&&(L=N),h.PTSKnown&&N<S&&(p.end>S||p.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),a.currentTime=S+.05)}var P=this.getNextFragment(L,h),V=!1;if(P&&this.isLoopLoading(P,L)&&(V=!!P.gap,P=this.getNextFragmentLoopLoading(P,h,p,rt,D)),P){var Y=A&&P.start>A.end+h.targetduration;if(Y||(A==null||!A.len)&&p.len){var j=this.getAppendedFrag(P.start,rt);if(j===null||(V||(V=!!j.gap||!!Y&&A.len===0),Y&&!V||V&&p.nextStart&&p.nextStart<j.end))return}this.loadFragment(P,c,L)}else this.bufferFlushed=!0}}}}},e.getMaxBufferLength=function(t){var i=u.prototype.getMaxBufferLength.call(this);return t?Math.min(Math.max(i,t),this.config.maxMaxBufferLength):i},e.onMediaDetaching=function(){this.videoBuffer=null,u.prototype.onMediaDetaching.call(this)},e.onAudioTracksUpdated=function(t,i){var a=i.audioTracks;this.resetTransmuxer(),this.levels=a.map(function(l){return new wa(l)})},e.onAudioTrackSwitching=function(t,i){var a=!!i.url;this.trackId=i.id;var l=this.fragCurrent;l&&(l.abortRequests(),this.removeUnbufferedFrags(l.start)),this.resetLoadingState(),a?this.setInterval(100):this.resetTransmuxer(),a?(this.switchingTrack=i,this.state=De):(this.switchingTrack=null,this.bufferedTrack=i,this.state=Bt),this.tick()},e.onManifestLoading=function(){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},e.onLevelLoaded=function(t,i){this.mainDetails=i.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(k.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},e.onAudioTrackLoaded=function(t,i){var a;if(this.mainDetails!=null){var l=this.levels,d=i.details,c=i.id;if(l){this.log("Track "+c+" loaded ["+d.startSN+","+d.endSN+"]"+(d.lastPartSn?"[part-"+d.lastPartSn+"-"+d.lastPartIndex+"]":"")+",duration:"+d.totalduration);var h=l[c],f=0;if(d.live||(a=h.details)!=null&&a.live){var p=this.mainDetails;if(d.fragments[0]||(d.deltaUpdateFailed=!0),d.deltaUpdateFailed||!p)return;!h.details&&d.hasProgramDateTime&&p.hasProgramDateTime?(Nt(d,p),f=d.fragments[0].start):f=this.alignPlaylists(d,h.details)}h.details=d,this.levelLastLoaded=c,this.startFragRequested||!this.mainDetails&&d.live||this.setStartPosition(h.details,f),this.state!==Ca||this.waitForCdnTuneIn(d)||(this.state=De),this.tick()}else this.warn("Audio tracks were reset while loading level "+c)}else this.cachedTrackLoadedData=i},e._handleFragmentLoadProgress=function(t){var i,a=t.frag,l=t.part,d=t.payload,c=this.config,h=this.trackId,f=this.levels;if(f){var p=f[h];if(p){var E=p.details;if(!E)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(a.start);var b=c.defaultAudioCodec||p.audioCodec||"mp4a.40.2",A=this.transmuxer;A||(A=this.transmuxer=new Qh(this.hls,Di,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var w=this.initPTS[a.cc],D=(i=a.initSegment)==null?void 0:i.data;if(w!==void 0){var S=l?l.index:-1,L=S!==-1,N=new fe(a.level,a.sn,a.stats.chunkCount,d.byteLength,S,L);A.push(d,D,b,"",a,l,E.totalduration,!1,N,w)}else this.log("Unknown video PTS for cc "+a.cc+", waiting for video PTS before demuxing audio frag "+a.sn+" of ["+E.startSN+" ,"+E.endSN+"],track "+h),(this.waitingData=this.waitingData||{frag:a,part:l,cache:new Xh,complete:!1}).cache.push(new Uint8Array(d)),this.waitingVideoCC=this.videoTrackCC,this.state=Ts}else this.warn("Audio track is undefined on fragment load progress")}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered")},e._handleFragmentLoadComplete=function(t){this.waitingData?this.waitingData.complete=!0:u.prototype._handleFragmentLoadComplete.call(this,t)},e.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},e.onBufferCreated=function(t,i){var a=i.tracks.audio;a&&(this.mediaBuffer=a.buffer||null),i.tracks.video&&(this.videoBuffer=i.tracks.video.buffer||null)},e.onFragBuffered=function(t,i){var a=i.frag,l=i.part;if(a.type===Di)if(this.fragContextChanged(a))this.warn("Fragment "+a.sn+(l?" p: "+l.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+(this.switchingTrack?this.switchingTrack.name:"false"));else{if(a.sn!=="initSegment"){this.fragPrevious=a;var d=this.switchingTrack;d&&(this.bufferedTrack=d,this.switchingTrack=null,this.hls.trigger(k.AUDIO_TRACK_SWITCHED,y({},d)))}this.fragBufferedComplete(a,l)}else if(!this.loadedmetadata&&a.type===rt){var c=this.videoBuffer||this.media;c&&he.getBuffered(c).length&&(this.loadedmetadata=!0)}},e.onError=function(t,i){var a;if(i.fatal)this.state=fn;else switch(i.details){case q.FRAG_GAP:case q.FRAG_PARSING_ERROR:case q.FRAG_DECRYPT_ERROR:case q.FRAG_LOAD_ERROR:case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_ERROR:case q.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Di,i);break;case q.AUDIO_TRACK_LOAD_ERROR:case q.AUDIO_TRACK_LOAD_TIMEOUT:case q.LEVEL_PARSING_ERROR:i.levelRetry||this.state!==Ca||((a=i.context)==null?void 0:a.type)!==yi||(this.state=De);break;case q.BUFFER_FULL_ERROR:if(!i.parent||i.parent!=="audio")return;this.reduceLengthAndFlushBuffer(i)&&(this.bufferedTrack=null,u.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case q.INTERNAL_EXCEPTION:this.recoverWorkerError(i)}},e.onBufferFlushed=function(t,i){i.type===Et&&(this.bufferFlushed=!0,this.state===bs&&(this.state=De))},e._handleTransmuxComplete=function(t){var i,a="audio",l=this.hls,d=t.remuxResult,c=t.chunkMeta,h=this.getCurrentContext(c);if(h){var f=h.frag,p=h.part,E=h.level.details,b=d.audio,A=d.text,w=d.id3,D=d.initSegment;if(!this.fragContextChanged(f)&&E){if(this.state=Lr,this.switchingTrack&&b&&this.completeAudioSwitch(this.switchingTrack),D!=null&&D.tracks){var S=f.initSegment||f;this._bufferInitSegment(D.tracks,S,c),l.trigger(k.FRAG_PARSING_INIT_SEGMENT,{frag:S,id:a,tracks:D.tracks})}if(b){var L=b.startPTS,N=b.endPTS,P=b.startDTS,V=b.endDTS;p&&(p.elementaryStreams[Et]={startPTS:L,endPTS:N,startDTS:P,endDTS:V}),f.setElementaryStreamInfo(Et,L,N,P,V),this.bufferFragmentData(b,f,p,c)}if(w!=null&&(i=w.samples)!=null&&i.length){var Y=H({id:a,frag:f,details:E},w);l.trigger(k.FRAG_PARSING_METADATA,Y)}if(A){var j=H({id:a,frag:f,details:E},A);l.trigger(k.FRAG_PARSING_USERDATA,j)}}else this.fragmentTracker.removeFragment(f)}else this.resetWhenMissingContext(c)},e._bufferInitSegment=function(t,i,a){if(this.state===Lr){t.video&&delete t.video;var l=t.audio;if(l){l.levelCodec=l.codec,l.id="audio",this.log("Init audio buffer, container:"+l.container+", codecs[parsed]=["+l.codec+"]"),this.hls.trigger(k.BUFFER_CODECS,t);var d=l.initSegment;if(d!=null&&d.byteLength){var c={type:"audio",frag:i,part:null,chunkMeta:a,parent:i.type,data:d};this.hls.trigger(k.BUFFER_APPENDING,c)}this.tick()}}},e.loadFragment=function(t,i,a){var l,d=this.fragmentTracker.getState(t);this.fragCurrent=t,this.switchingTrack||d===ee||d===_e?t.sn==="initSegment"?this._loadInitSegment(t,i):(l=i.details)!=null&&l.live&&!this.initPTS[t.cc]?(this.log("Waiting for video PTS in continuity counter "+t.cc+" of live stream before loading audio fragment "+t.sn+" of level "+this.trackId),this.state=Ts):(this.startFragRequested=!0,u.prototype.loadFragment.call(this,t,i,a)):this.clearTrackerIfNeeded(t)},e.completeAudioSwitch=function(t){var i=this.hls,a=this.media,l=this.bufferedTrack,d=l==null?void 0:l.attrs,c=t.attrs;a&&d&&(d.CHANNELS!==c.CHANNELS||d.NAME!==c.NAME||d.LANGUAGE!==c.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),u.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,i.trigger(k.AUDIO_TRACK_SWITCHED,y({},t))},s}(Zu),cg=function(u){function s(t){var i;return(i=u.call(this,t,"[audio-track-controller]")||this).tracks=[],i.groupId=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.registerListeners(),i}z(s,u);var e=s.prototype;return e.registerListeners=function(){var t=this.hls;t.on(k.MANIFEST_LOADING,this.onManifestLoading,this),t.on(k.MANIFEST_PARSED,this.onManifestParsed,this),t.on(k.LEVEL_LOADING,this.onLevelLoading,this),t.on(k.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(k.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(k.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(k.MANIFEST_LOADING,this.onManifestLoading,this),t.off(k.MANIFEST_PARSED,this.onManifestParsed,this),t.off(k.LEVEL_LOADING,this.onLevelLoading,this),t.off(k.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(k.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(k.ERROR,this.onError,this)},e.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,u.prototype.destroy.call(this)},e.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0},e.onManifestParsed=function(t,i){this.tracks=i.audioTracks||[]},e.onAudioTrackLoaded=function(t,i){var a=i.id,l=i.groupId,d=i.details,c=this.tracksInGroup[a];if(c&&c.groupId===l){var h=c.details;c.details=i.details,this.log("audio-track "+a+' "'+c.name+'" lang:'+c.lang+" group:"+l+" loaded ["+d.startSN+"-"+d.endSN+"]"),a===this.trackId&&this.playlistLoaded(a,i,h)}else this.warn("Track with id:"+a+" and group:"+l+" not found in active group "+c.groupId)},e.onLevelLoading=function(t,i){this.switchLevel(i.level)},e.onLevelSwitching=function(t,i){this.switchLevel(i.level)},e.switchLevel=function(t){var i=this.hls.levels[t];if(i!=null&&i.audioGroupIds){var a=i.audioGroupIds[i.urlId];if(this.groupId!==a){this.groupId=a||null;var l=this.tracks.filter(function(c){return!a||c.groupId===a});this.selectDefaultTrack&&!l.some(function(c){return c.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=l;var d={audioTracks:l};this.log("Updating audio tracks, "+l.length+" track(s) found in group:"+a),this.hls.trigger(k.AUDIO_TRACKS_UPDATED,d),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}},e.onError=function(t,i){!i.fatal&&i.context&&i.context.type===yi&&i.context.id===this.trackId&&i.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(i))},e.setAudioTrack=function(t){var i=this.tracksInGroup;if(t<0||t>=i.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var a=this.currentTrack;i[this.trackId];var l=i[t],d=l.groupId,c=l.name;if(this.log("Switching to audio-track "+t+' "'+c+'" lang:'+l.lang+" group:"+d),this.trackId=t,this.currentTrack=l,this.selectDefaultTrack=!1,this.hls.trigger(k.AUDIO_TRACK_SWITCHING,y({},l)),!l.details||l.details.live){var h=this.switchParams(l.url,a==null?void 0:a.details);this.loadPlaylist(h)}}},e.selectInitialTrack=function(){var t=this.tracksInGroup,i=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(i!==-1)this.setAudioTrack(i);else{var a=new Error("No track found for running audio group-ID: "+this.groupId+" track count: "+t.length);this.warn(a.message),this.hls.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:a})}},e.findTrackId=function(t){for(var i=this.tracksInGroup,a=0;a<i.length;a++){var l=i[a];if((!this.selectDefaultTrack||l.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===l.attrs["STABLE-RENDITION-ID"]||t.name===l.name&&t.lang===l.lang))return l.id}return-1},e.loadPlaylist=function(t){u.prototype.loadPlaylist.call(this);var i=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(i)){var a=i.id,l=i.groupId,d=i.url;if(t)try{d=t.addDirectives(d)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("loading audio-track playlist "+a+' "'+i.name+'" lang:'+i.lang+" group:"+l),this.clearTimer(),this.hls.trigger(k.AUDIO_TRACK_LOADING,{url:d,id:a,groupId:l,deliveryDirectives:t||null})}},M(s,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}}]),s}(x);function Zh(u,s){if(u.length!==s.length)return!1;for(var e=0;e<u.length;e++)if(!hg(u[e].attrs,s[e].attrs))return!1;return!0}function hg(u,s){var e=u["STABLE-RENDITION-ID"];return e?e===s["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(function(t){return u[t]!==s[t]})}var fg=function(u){function s(t,i,a){var l;return(l=u.call(this,t,i,a,"[subtitle-stream-controller]",Oi)||this).levels=[],l.currentTrackId=-1,l.tracksBuffered=[],l.mainDetails=null,l._registerListeners(),l}z(s,u);var e=s.prototype;return e.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},e._registerListeners=function(){var t=this.hls;t.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(k.MANIFEST_LOADING,this.onManifestLoading,this),t.on(k.LEVEL_LOADED,this.onLevelLoaded,this),t.on(k.ERROR,this.onError,this),t.on(k.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(k.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(k.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(k.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(k.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(k.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(k.MANIFEST_LOADING,this.onManifestLoading,this),t.off(k.LEVEL_LOADED,this.onLevelLoaded,this),t.off(k.ERROR,this.onError,this),t.off(k.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(k.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(k.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(k.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(k.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(k.FRAG_BUFFERED,this.onFragBuffered,this)},e.startLoad=function(t){this.stopLoad(),this.state=De,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},e.onMediaDetaching=function(){this.tracksBuffered=[],u.prototype.onMediaDetaching.call(this)},e.onLevelLoaded=function(t,i){this.mainDetails=i.details},e.onSubtitleFragProcessed=function(t,i){var a=i.frag,l=i.success;if(this.fragPrevious=a,this.state=De,l){var d=this.tracksBuffered[this.currentTrackId];if(d){for(var c,h=a.start,f=0;f<d.length;f++)if(h>=d[f].start&&h<=d[f].end){c=d[f];break}var p=a.start+a.duration;c?c.end=p:(c={start:h,end:p},d.push(c)),this.fragmentTracker.fragBuffered(a)}}},e.onBufferFlushing=function(t,i){var a=i.startOffset,l=i.endOffset;if(a===0&&l!==Number.POSITIVE_INFINITY){var d=this.currentTrackId,c=this.levels;if(!c.length||!c[d]||!c[d].details)return;var h=l-c[d].details.targetduration;if(h<=0)return;i.endOffsetSubtitles=Math.max(0,h),this.tracksBuffered.forEach(function(f){for(var p=0;p<f.length;)if(f[p].end<=h)f.shift();else{if(!(f[p].start<h))break;f[p].start=h,p++}}),this.fragmentTracker.removeFragmentsInRange(a,h,Oi)}},e.onFragBuffered=function(t,i){var a;this.loadedmetadata||i.frag.type!==rt||(a=this.media)!=null&&a.buffered.length&&(this.loadedmetadata=!0)},e.onError=function(t,i){var a=i.frag;(a==null?void 0:a.type)===Oi&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Bt&&(this.state=De))},e.onSubtitleTracksUpdated=function(t,i){var a=this,l=i.subtitleTracks;Zh(this.levels,l)?this.levels=l.map(function(d){return new wa(d)}):(this.tracksBuffered=[],this.levels=l.map(function(d){var c=new wa(d);return a.tracksBuffered[c.id]=[],c}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Oi),this.fragPrevious=null,this.mediaBuffer=null)},e.onSubtitleTrackSwitch=function(t,i){if(this.currentTrackId=i.id,this.levels.length&&this.currentTrackId!==-1){var a=this.levels[this.currentTrackId];a!=null&&a.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,a&&this.setInterval(500)}else this.clearInterval()},e.onSubtitleTrackLoaded=function(t,i){var a,l=i.details,d=i.id,c=this.currentTrackId,h=this.levels;if(h.length){var f=h[c];if(!(d>=h.length||d!==c)&&f){this.mediaBuffer=this.mediaBufferTimeRanges;var p=0;if(l.live||(a=f.details)!=null&&a.live){var E=this.mainDetails;if(l.deltaUpdateFailed||!E)return;var b=E.fragments[0];f.details?(p=this.alignPlaylists(l,f.details))===0&&b&&Ia(l,p=b.start):l.hasProgramDateTime&&E.hasProgramDateTime?(Nt(l,E),p=l.fragments[0].start):b&&Ia(l,p=b.start)}f.details=l,this.levelLastLoaded=d,this.startFragRequested||!this.mainDetails&&l.live||this.setStartPosition(f.details,p),this.tick(),l.live&&!this.fragCurrent&&this.media&&this.state===De&&(Ra(null,l.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),f.details=void 0))}}},e._handleFragmentLoadComplete=function(t){var i=this,a=t.frag,l=t.payload,d=a.decryptdata,c=this.hls;if(!this.fragContextChanged(a)&&l&&l.byteLength>0&&d&&d.key&&d.iv&&d.method==="AES-128"){var h=performance.now();this.decrypter.decrypt(new Uint8Array(l),d.key.buffer,d.iv.buffer).catch(function(f){throw c.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:a}),f}).then(function(f){var p=performance.now();c.trigger(k.FRAG_DECRYPTED,{frag:a,payload:f,stats:{tstart:h,tdecrypt:p}})}).catch(function(f){i.warn(f.name+": "+f.message),i.state=De})}},e.doTick=function(){if(this.media){if(this.state===De){var t=this.currentTrackId,i=this.levels,a=i[t];if(!i.length||!a||!a.details)return;var l=a.details,d=l.targetduration,c=this.config,h=this.getLoadPosition(),f=he.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],h-d,c.maxBufferHole),p=f.end,E=f.len,b=this.getFwdBufferInfo(this.media,rt);if(E>this.getMaxBufferLength(b==null?void 0:b.len)+d)return;var A=l.fragments,w=A.length,D=l.edge,S=null,L=this.fragPrevious;if(p<D){var N=c.maxFragLookUpTolerance;!(S=Ra(L,A,Math.max(A[0].start,p),N))&&L&&L.start<A[0].start&&(S=A[0])}else S=A[w-1];if(!S)return;S=this.mapToInitFragWhenRequired(S),this.fragmentTracker.getState(S)===ee&&this.loadFragment(S,a,p)}}else this.state=De},e.getMaxBufferLength=function(t){var i=u.prototype.getMaxBufferLength.call(this);return t?Math.max(i,t):i},e.loadFragment=function(t,i,a){this.fragCurrent=t,t.sn==="initSegment"?this._loadInitSegment(t,i):(this.startFragRequested=!0,u.prototype.loadFragment.call(this,t,i,a))},M(s,[{key:"mediaBufferTimeRanges",get:function(){return new mg(this.tracksBuffered[this.currentTrackId]||[])}}]),s}(Zu),mg=function(u){this.buffered=void 0;var s=function(e,t,i){if((t>>>=0)>i-1)throw new DOMException("Failed to execute '"+e+"' on 'TimeRanges': The index provided ("+t+") is greater than the maximum bound ("+i+")");return u[t][e]};this.buffered={get length(){return u.length},end:function(e){return s("end",e,u.length)},start:function(e){return s("start",e,u.length)}}},pg=function(u){function s(t){var i;return(i=u.call(this,t,"[subtitle-track-controller]")||this).media=null,i.tracks=[],i.groupId=null,i.tracksInGroup=[],i.trackId=-1,i.selectDefaultTrack=!0,i.queuedDefaultTrack=-1,i.trackChangeListener=function(){return i.onTextTracksChanged()},i.asyncPollTrackChange=function(){return i.pollTrackChange(0)},i.useTextTrackPolling=!1,i.subtitlePollingInterval=-1,i._subtitleDisplay=!0,i.registerListeners(),i}z(s,u);var e=s.prototype;return e.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,u.prototype.destroy.call(this)},e.registerListeners=function(){var t=this.hls;t.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(k.MANIFEST_LOADING,this.onManifestLoading,this),t.on(k.MANIFEST_PARSED,this.onManifestParsed,this),t.on(k.LEVEL_LOADING,this.onLevelLoading,this),t.on(k.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(k.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(k.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(k.MANIFEST_LOADING,this.onManifestLoading,this),t.off(k.MANIFEST_PARSED,this.onManifestParsed,this),t.off(k.LEVEL_LOADING,this.onLevelLoading,this),t.off(k.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(k.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(k.ERROR,this.onError,this)},e.onMediaAttached=function(t,i){this.media=i.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))},e.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},e.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),cd(this.media.textTracks).forEach(function(t){Qr(t)}),this.subtitleTrack=-1,this.media=null)},e.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},e.onManifestParsed=function(t,i){this.tracks=i.subtitleTracks},e.onSubtitleTrackLoaded=function(t,i){var a=i.id,l=i.details,d=this.trackId,c=this.tracksInGroup[d];if(c){var h=c.details;c.details=i.details,this.log("subtitle track "+a+" loaded ["+l.startSN+"-"+l.endSN+"]"),a===this.trackId&&this.playlistLoaded(a,i,h)}else this.warn("Invalid subtitle track id "+a)},e.onLevelLoading=function(t,i){this.switchLevel(i.level)},e.onLevelSwitching=function(t,i){this.switchLevel(i.level)},e.switchLevel=function(t){var i=this.hls.levels[t];if(i!=null&&i.textGroupIds){var a=i.textGroupIds[i.urlId],l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==a){var d=this.tracks.filter(function(f){return!a||f.groupId===a});this.tracksInGroup=d;var c=this.findTrackId(l==null?void 0:l.name)||this.findTrackId();this.groupId=a||null;var h={subtitleTracks:d};this.log("Updating subtitle tracks, "+d.length+' track(s) found in "'+a+'" group-id'),this.hls.trigger(k.SUBTITLE_TRACKS_UPDATED,h),c!==-1&&this.setSubtitleTrack(c,l)}else this.shouldReloadPlaylist(l)&&this.setSubtitleTrack(this.trackId,l)}},e.findTrackId=function(t){for(var i=this.tracksInGroup,a=0;a<i.length;a++){var l=i[a];if((!this.selectDefaultTrack||l.default)&&(!t||t===l.name))return l.id}return-1},e.onError=function(t,i){!i.fatal&&i.context&&i.context.type===zi&&i.context.id===this.trackId&&i.context.groupId===this.groupId&&this.checkRetry(i)},e.loadPlaylist=function(t){u.prototype.loadPlaylist.call(this);var i=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(i)){var a=i.id,l=i.groupId,d=i.url;if(t)try{d=t.addDirectives(d)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Loading subtitle playlist for id "+a),this.hls.trigger(k.SUBTITLE_TRACK_LOADING,{url:d,id:a,groupId:l,deliveryDirectives:t||null})}},e.toggleTrackModes=function(t){var i=this,a=this.media,l=this.trackId;if(a){var d=cd(a.textTracks),c=d.filter(function(p){return p.groupId===i.groupId});if(t===-1)[].slice.call(d).forEach(function(p){p.mode="disabled"});else{var h=c[l];h&&(h.mode="disabled")}var f=c[t];f&&(f.mode=this.subtitleDisplay?"showing":"hidden")}},e.setSubtitleTrack=function(t,i){var a,l=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(t===-1||(a=l[t])!=null&&a.details)||t<-1||t>=l.length)){this.clearTimer();var d=l[t];if(this.log("Switching to subtitle-track "+t+(d?' "'+d.name+'" lang:'+d.lang+" group:"+d.groupId:"")),this.trackId=t,d){var c=d.id,h=d.groupId,f=h===void 0?"":h,p=d.name,E=d.type,b=d.url;this.hls.trigger(k.SUBTITLE_TRACK_SWITCH,{id:c,groupId:f,name:p,type:E,url:b});var A=this.switchParams(d.url,i==null?void 0:i.details);this.loadPlaylist(A)}else this.hls.trigger(k.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},e.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,i=cd(this.media.textTracks),a=0;a<i.length;a++)if(i[a].mode==="hidden")t=a;else if(i[a].mode==="showing"){t=a;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},M(s,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1;var i=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,i)}}]),s}(x);function cd(u){for(var s=[],e=0;e<u.length;e++){var t=u[e];t.kind!=="subtitles"&&t.kind!=="captions"||!t.label||s.push(u[e])}return s}var vg=function(){function u(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var s=u.prototype;return s.append=function(e,t){var i=this.queues[t];i.push(e),i.length===1&&this.buffers[t]&&this.executeNext(t)},s.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},s.appendBlocker=function(e){var t,i=new Promise(function(l){t=l}),a={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(a,e),i},s.executeNext=function(e){var t=this.buffers,i=this.queues,a=t[e],l=i[e];if(l.length){var d=l[0];try{d.execute()}catch(c){B.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),d.onError(c),a!=null&&a.updating||(l.shift(),this.executeNext(e))}}},s.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},s.current=function(e){return this.queues[e][0]},u}(),Jh=sn(),ef=/([ha]vc.)(?:\.[^.,]+)+/,gg=function(){function u(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var i=t.media,a=t.mediaSource;B.log("[buffer-controller]: Media source opened"),i&&(i.removeEventListener("emptied",t._onMediaEmptied),t.updateMediaElementDuration(),t.hls.trigger(k.MEDIA_ATTACHED,{media:i})),a&&a.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){B.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){B.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var i=t.media,a=t._objectUrl;i&&i.src!==a&&B.error("Media element src was set while attaching MediaSource ("+a+" > "+i.src+")")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var s=u.prototype;return s.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},s.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},s.registerListeners=function(){var e=this.hls;e.on(k.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.MANIFEST_PARSED,this.onManifestParsed,this),e.on(k.BUFFER_RESET,this.onBufferReset,this),e.on(k.BUFFER_APPENDING,this.onBufferAppending,this),e.on(k.BUFFER_CODECS,this.onBufferCodecs,this),e.on(k.BUFFER_EOS,this.onBufferEos,this),e.on(k.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(k.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(k.FRAG_PARSED,this.onFragParsed,this),e.on(k.FRAG_CHANGED,this.onFragChanged,this)},s.unregisterListeners=function(){var e=this.hls;e.off(k.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.MANIFEST_PARSED,this.onManifestParsed,this),e.off(k.BUFFER_RESET,this.onBufferReset,this),e.off(k.BUFFER_APPENDING,this.onBufferAppending,this),e.off(k.BUFFER_CODECS,this.onBufferCodecs,this),e.off(k.BUFFER_EOS,this.onBufferEos,this),e.off(k.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(k.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(k.FRAG_PARSED,this.onFragParsed,this),e.off(k.FRAG_CHANGED,this.onFragChanged,this)},s._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new vg(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},s.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},s.onManifestParsed=function(e,t){var i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,B.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},s.onMediaAttaching=function(e,t){var i=this.media=t.media;if(i&&Jh){var a=this.mediaSource=new Jh;a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(a),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}},s.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,i=this._objectUrl;if(t){if(B.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(a){B.warn("[buffer-controller]: onMediaDetaching: "+a.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()):B.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(k.MEDIA_DETACHED,void 0)},s.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){var i=e.sourceBuffer[t];try{i&&(e.removeBufferListeners(t),e.mediaSource&&e.mediaSource.removeSourceBuffer(i),e.sourceBuffer[t]=void 0)}catch(a){B.warn("[buffer-controller]: Failed to reset the "+t+" buffer",a)}}),this._initSourceBuffer()},s.onBufferCodecs=function(e,t){var i=this,a=this.getSourceBufferTypes().length;Object.keys(t).forEach(function(l){if(a){var d=i.tracks[l];if(d&&typeof d.buffer.changeType=="function"){var c=t[l],h=c.id,f=c.codec,p=c.levelCodec,E=c.container,b=c.metadata,A=(d.levelCodec||d.codec).replace(ef,"$1"),w=(p||f).replace(ef,"$1");if(A!==w){var D=E+";codecs="+(p||f);i.appendChangeType(l,D),B.log("[buffer-controller]: switching codec "+A+" to "+w),i.tracks[l]={buffer:d.buffer,codec:f,container:E,levelCodec:p,metadata:b,id:h}}}}else i.pendingTracks[l]=t[l]}),a||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},s.appendChangeType=function(e,t){var i=this,a=this.operationQueue,l={execute:function(){var d=i.sourceBuffer[e];d&&(B.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),d.changeType(t)),a.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(d){B.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",d)}};a.append(l,e)},s.onBufferAppending=function(e,t){var i=this,a=this.hls,l=this.operationQueue,d=this.tracks,c=t.data,h=t.type,f=t.frag,p=t.part,E=t.chunkMeta,b=E.buffering[h],A=self.performance.now();b.start=A;var w=f.stats.buffering,D=p?p.stats.buffering:null;w.start===0&&(w.start=A),D&&D.start===0&&(D.start=A);var S=d.audio,L=!1;h==="audio"&&(S==null?void 0:S.container)==="audio/mpeg"&&(L=!this.lastMpegAudioChunk||E.id===1||this.lastMpegAudioChunk.sn!==E.sn,this.lastMpegAudioChunk=E);var N=f.start,P={execute:function(){if(b.executeStart=self.performance.now(),L){var V=i.sourceBuffer[h];if(V){var Y=N-V.timestampOffset;Math.abs(Y)>=.1&&(B.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+N+" (delta: "+Y+") sn: "+f.sn+")"),V.timestampOffset=N)}}i.appendExecutor(c,h)},onStart:function(){},onComplete:function(){var V=self.performance.now();b.executeEnd=b.end=V,w.first===0&&(w.first=V),D&&D.first===0&&(D.first=V);var Y=i.sourceBuffer,j={};for(var ie in Y)j[ie]=he.getBuffered(Y[ie]);i.appendError=0,i.hls.trigger(k.BUFFER_APPENDED,{type:h,frag:f,part:p,chunkMeta:E,parent:f.type,timeRanges:j})},onError:function(V){B.error("[buffer-controller]: Error encountered while trying to append to the "+h+" SourceBuffer",V);var Y={type:oe.MEDIA_ERROR,parent:f.type,details:q.BUFFER_APPEND_ERROR,frag:f,part:p,chunkMeta:E,error:V,err:V,fatal:!1};V.code===DOMException.QUOTA_EXCEEDED_ERR?Y.details=q.BUFFER_FULL_ERROR:(i.appendError++,Y.details=q.BUFFER_APPEND_ERROR,i.appendError>a.config.appendErrorMaxRetry&&(B.error("[buffer-controller]: Failed "+a.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),Y.fatal=!0)),a.trigger(k.ERROR,Y)}};l.append(P,h)},s.onBufferFlushing=function(e,t){var i=this,a=this.operationQueue,l=function(d){return{execute:i.removeExecutor.bind(i,d,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){i.hls.trigger(k.BUFFER_FLUSHED,{type:d})},onError:function(c){B.warn("[buffer-controller]: Failed to remove from "+d+" SourceBuffer",c)}}};t.type?a.append(l(t.type),t.type):this.getSourceBufferTypes().forEach(function(d){a.append(l(d),d)})},s.onFragParsed=function(e,t){var i=this,a=t.frag,l=t.part,d=[],c=l?l.elementaryStreams:a.elementaryStreams;c[rr]?d.push("audiovideo"):(c[Et]&&d.push("audio"),c[Mt]&&d.push("video")),d.length===0&&B.warn("Fragments must have at least one ElementaryStreamType set. type: "+a.type+" level: "+a.level+" sn: "+a.sn),this.blockBuffers(function(){var h=self.performance.now();a.stats.buffering.end=h,l&&(l.stats.buffering.end=h);var f=l?l.stats:a.stats;i.hls.trigger(k.FRAG_BUFFERED,{frag:a,part:l,stats:f,id:a.type})},d)},s.onFragChanged=function(e,t){this.flushBackBuffer()},s.onBufferEos=function(e,t){var i=this;this.getSourceBufferTypes().reduce(function(a,l){var d=i.sourceBuffer[l];return!d||t.type&&t.type!==l||(d.ending=!0,d.ended||(d.ended=!0,B.log("[buffer-controller]: "+l+" sourceBuffer now EOS"))),a&&!(d&&!d.ended)},!0)&&(B.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){i.getSourceBufferTypes().forEach(function(l){var d=i.sourceBuffer[l];d&&(d.ending=!1)});var a=i.mediaSource;a&&a.readyState==="open"?(B.log("[buffer-controller]: Calling mediaSource.endOfStream()"),a.endOfStream()):a&&B.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+a.readyState)}))},s.onLevelUpdated=function(e,t){var i=t.details;i.fragments.length&&(this.details=i,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},s.flushBackBuffer=function(){var e=this.hls,t=this.details,i=this.media,a=this.sourceBuffer;if(i&&t!==null){var l=this.getSourceBufferTypes();if(l.length){var d=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(re(d)&&!(d<0)){var c=i.currentTime,h=t.levelTargetDuration,f=Math.max(d,h),p=Math.floor(c/h)*h-f;l.forEach(function(E){var b=a[E];if(b){var A=he.getBuffered(b);if(A.length>0&&p>A.start(0)){if(e.trigger(k.BACK_BUFFER_REACHED,{bufferEnd:p}),t.live)e.trigger(k.LIVE_BACK_BUFFER_REACHED,{bufferEnd:p});else if(b.ended&&A.end(A.length-1)-c<2*h)return void B.info("[buffer-controller]: Cannot flush "+E+" back buffer while SourceBuffer is in ended state");e.trigger(k.BUFFER_FLUSHING,{startOffset:0,endOffset:p,type:E})}}})}}}},s.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var e=this.details,t=this.hls,i=this.media,a=this.mediaSource,l=e.fragments[0].start+e.totalduration,d=i.duration,c=re(a.duration)?a.duration:0;e.live&&t.config.liveDurationInfinity?(B.log("[buffer-controller]: Media Source duration is set to Infinity"),a.duration=1/0,this.updateSeekableRange(e)):(l>c&&l>d||!re(d))&&(B.log("[buffer-controller]: Updating Media Source duration to "+l.toFixed(3)),a.duration=l)}},s.updateSeekableRange=function(e){var t=this.mediaSource,i=e.fragments;if(i.length&&e.live&&t!=null&&t.setLiveSeekableRange){var a=Math.max(0,i[0].start),l=Math.max(a,a+e.totalduration);t.setLiveSeekableRange(a,l)}},s.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,i=this.pendingTracks,a=Object.keys(i).length;if(a&&!e||a===2){this.createSourceBuffers(i),this.pendingTracks={};var l=this.getSourceBufferTypes();if(l.length)this.hls.trigger(k.BUFFER_CREATED,{tracks:this.tracks}),l.forEach(function(c){t.executeNext(c)});else{var d=new Error("could not create source buffer for media codec(s)");this.hls.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:d,reason:d.message})}}},s.createSourceBuffers=function(e){var t=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(var a in e)if(!t[a]){var l=e[a];if(!l)throw Error("source buffer exists for track "+a+", however track does not");var d=l.levelCodec||l.codec,c=l.container+";codecs="+d;B.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var h=t[a]=i.addSourceBuffer(c),f=a;this.addBufferListener(f,"updatestart",this._onSBUpdateStart),this.addBufferListener(f,"updateend",this._onSBUpdateEnd),this.addBufferListener(f,"error",this._onSBUpdateError),this.tracks[a]={buffer:h,codec:d,container:l.container,levelCodec:l.levelCodec,metadata:l.metadata,id:l.id}}catch(p){B.error("[buffer-controller]: error while trying to add sourceBuffer: "+p.message),this.hls.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:p,mimeType:c})}}},s._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},s._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},s._onSBUpdateError=function(e,t){var i=new Error(e+" SourceBuffer error");B.error("[buffer-controller]: "+i,t),this.hls.trigger(k.ERROR,{type:oe.MEDIA_ERROR,details:q.BUFFER_APPENDING_ERROR,error:i,fatal:!1});var a=this.operationQueue.current(e);a&&a.onError(t)},s.removeExecutor=function(e,t,i){var a=this.media,l=this.mediaSource,d=this.operationQueue,c=this.sourceBuffer[e];if(!a||!l||!c)return B.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void d.shiftAndExecuteNext(e);var h=re(a.duration)?a.duration:1/0,f=re(l.duration)?l.duration:1/0,p=Math.max(0,t),E=Math.min(i,h,f);E>p&&!c.ending?(c.ended=!1,B.log("[buffer-controller]: Removing ["+p+","+E+"] from the "+e+" SourceBuffer"),c.remove(p,E)):d.shiftAndExecuteNext(e)},s.appendExecutor=function(e,t){var i=this.operationQueue,a=this.sourceBuffer[t];if(!a)return B.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void i.shiftAndExecuteNext(t);a.ended=!1,a.appendBuffer(e)},s.blockBuffers=function(e,t){var i=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length)return B.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var a=this.operationQueue,l=t.map(function(d){return a.appendBlocker(d)});Promise.all(l).then(function(){e(),t.forEach(function(d){var c=i.sourceBuffer[d];c!=null&&c.updating||a.shiftAndExecuteNext(d)})})},s.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},s.addBufferListener=function(e,t,i){var a=this.sourceBuffer[e];if(a){var l=i.bind(this,e);this.listeners[e].push({event:t,listener:l}),a.addEventListener(t,l)}},s.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(i){t.removeEventListener(i.event,i.listener)})},u}(),tf={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},rf=function(u){var s=u;return tf.hasOwnProperty(u)&&(s=tf[u]),String.fromCharCode(s)},xa=15,Rr=100,Eg={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},yg={17:2,18:4,21:6,22:8,23:10,19:13,20:15},bg={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Tg={25:2,26:4,29:6,30:8,31:10,27:13,28:15},_g=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Ag=function(){function u(){this.time=null,this.verboseLevel=0}return u.prototype.log=function(s,e){if(this.verboseLevel>=s){var t=typeof e=="function"?e():e;B.log(this.time+" ["+s+"] "+t)}},u}(),Pa=function(u){for(var s=[],e=0;e<u.length;e++)s.push(u[e].toString(16));return s},af=function(){function u(e,t,i,a,l){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=a||"black",this.flash=l||!1}var s=u.prototype;return s.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},s.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],i=0;i<t.length;i++){var a=t[i];e.hasOwnProperty(a)&&(this[a]=e[a])}},s.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},s.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},s.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},s.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},u}(),Sg=function(){function u(e,t,i,a,l,d){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new af(t,i,a,l,d)}var s=u.prototype;return s.reset=function(){this.uchar=" ",this.penState.reset()},s.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},s.setPenState=function(e){this.penState.copy(e)},s.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},s.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},s.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},u}(),kg=function(){function u(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<Rr;t++)this.chars.push(new Sg);this.logger=e,this.pos=0,this.currPenState=new af}var s=u.prototype;return s.equals=function(e){for(var t=!0,i=0;i<Rr;i++)if(!this.chars[i].equals(e.chars[i])){t=!1;break}return t},s.copy=function(e){for(var t=0;t<Rr;t++)this.chars[t].copy(e.chars[t])},s.isEmpty=function(){for(var e=!0,t=0;t<Rr;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},s.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Rr&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Rr)},s.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)},s.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},s.insertChar=function(e){var t=this;e>=144&&this.backSpace();var i=rf(e);this.pos>=Rr?this.logger.log(0,function(){return"Cannot insert "+e.toString(16)+" ("+i+") at position "+t.pos+". Skipping it!"}):(this.chars[this.pos].setChar(i,this.currPenState),this.moveCursor(1))},s.clearFromPos=function(e){var t;for(t=e;t<Rr;t++)this.chars[t].reset()},s.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},s.clearToEndOfRow=function(){this.clearFromPos(this.pos)},s.getTextString=function(){for(var e=[],t=!0,i=0;i<Rr;i++){var a=this.chars[i].uchar;a!==" "&&(t=!1),e.push(a)}return t?"":e.join("")},s.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},u}(),hd=function(){function u(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<xa;t++)this.rows.push(new kg(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var s=u.prototype;return s.reset=function(){for(var e=0;e<xa;e++)this.rows[e].clear();this.currRow=14},s.equals=function(e){for(var t=!0,i=0;i<xa;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t},s.copy=function(e){for(var t=0;t<xa;t++)this.rows[t].copy(e.rows[t])},s.isEmpty=function(){for(var e=!0,t=0;t<xa;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},s.backSpace=function(){this.rows[this.currRow].backSpace()},s.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},s.insertChar=function(e){this.rows[this.currRow].insertChar(e)},s.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},s.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},s.setCursor=function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},s.setPAC=function(e){this.logger.log(2,function(){return"pacData = "+JSON.stringify(e)});var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var i=0;i<xa;i++)this.rows[i].clear();var a=this.currRow+1-this.nrRollUpRows,l=this.lastOutputScreen;if(l){var d=l.rows[a].cueStartTime,c=this.logger.time;if(d&&c!==null&&d<c)for(var h=0;h<this.nrRollUpRows;h++)this.rows[t-this.nrRollUpRows+h+1].copy(l.rows[a+h])}}this.currRow=t;var f=this.rows[this.currRow];if(e.indent!==null){var p=e.indent,E=Math.max(p-1,0);f.setCursor(e.indent),e.color=f.chars[E].penState.foreground}var b={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(b)},s.setBkgData=function(e){this.logger.log(2,function(){return"bkgData = "+JSON.stringify(e)}),this.backSpace(),this.setPen(e),this.insertChar(32)},s.setRollUpRows=function(e){this.nrRollUpRows=e},s.rollUp=function(){var e=this;if(this.nrRollUpRows!==null){this.logger.log(1,function(){return e.getDisplayText()});var t=this.currRow+1-this.nrRollUpRows,i=this.rows.splice(t,1)[0];i.clear(),this.rows.splice(this.currRow,0,i),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")},s.getDisplayText=function(e){e=e||!1;for(var t=[],i="",a=-1,l=0;l<xa;l++){var d=this.rows[l].getTextString();d&&(a=l+1,e?t.push("Row "+a+": '"+d+"'"):t.push(d.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join(`
|
|
34
|
-
`)),i},s.getTextAndFormat=function(){return this.rows},u}(),nf=function(){function u(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 hd(i),this.nonDisplayedMemory=new hd(i),this.lastOutputScreen=new hd(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}var s=u.prototype;return s.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},s.getHandler=function(){return this.outputFilter},s.setHandler=function(e){this.outputFilter=e},s.setPAC=function(e){this.writeScreen.setPAC(e)},s.setBkgData=function(e){this.writeScreen.setBkgData(e)},s.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,function(){return"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)},s.insertChars=function(e){for(var t=this,i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);var a=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,function(){return a+": "+t.writeScreen.getDisplayText(!0)}),this.mode!=="MODE_PAINT-ON"&&this.mode!=="MODE_ROLL-UP"||(this.logger.log(1,function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},s.ccRCL=function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},s.ccBS=function(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},s.ccAOF=function(){},s.ccAON=function(){},s.ccDER=function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},s.ccRU=function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},s.ccFON=function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},s.ccRDC=function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},s.ccTR=function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")},s.ccRTD=function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")},s.ccEDM=function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},s.ccCR=function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},s.ccENM=function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},s.ccEOC=function(){var e=this;if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,function(){return"DISP: "+e.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},s.ccTO=function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},s.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var i=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][i]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},s.outputDataUpdate=function(e){e===void 0&&(e=!1);var t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime!==null||this.displayedMemory.isEmpty()?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.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},s.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},u}(),sf=function(){function u(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var a=new Ag;this.channels=[null,new nf(e,t,a),new nf(e+1,i,a)],this.cmdHistory={a:null,b:null},this.logger=a}var s=u.prototype;return s.getHandler=function(e){return this.channels[e].getHandler()},s.setHandler=function(e,t){this.channels[e].setHandler(t)},s.addData=function(e,t){var i,a,l,d=!1;this.logger.time=e;for(var c=0;c<t.length;c+=2)if(a=127&t[c],l=127&t[c+1],a!==0||l!==0){if(this.logger.log(3,"["+Pa([t[c],t[c+1]])+"] -> ("+Pa([a,l])+")"),(i=this.parseCmd(a,l))||(i=this.parseMidrow(a,l)),i||(i=this.parsePAC(a,l)),i||(i=this.parseBackgroundAttributes(a,l)),!i&&(d=this.parseChars(a,l))){var h=this.currentChannel;h&&h>0?this.channels[h].insertChars(d):this.logger.log(2,"No channel found yet. TEXT-MODE?")}i||d||this.logger.log(2,"Couldn't parse cleaned data "+Pa([a,l])+" orig: "+Pa([t[c],t[c+1]]))}},s.parseCmd=function(e,t){var i=this.cmdHistory;if(!((e===20||e===28||e===21||e===29)&&t>=32&&t<=47||(e===23||e===31)&&t>=33&&t<=35))return!1;if(of(e,t,i))return gn(null,null,i),this.logger.log(3,"Repeated command ("+Pa([e,t])+") is dropped"),!0;var a=e===20||e===21||e===23?1:2,l=this.channels[a];return e===20||e===21||e===28||e===29?t===32?l.ccRCL():t===33?l.ccBS():t===34?l.ccAOF():t===35?l.ccAON():t===36?l.ccDER():t===37?l.ccRU(2):t===38?l.ccRU(3):t===39?l.ccRU(4):t===40?l.ccFON():t===41?l.ccRDC():t===42?l.ccTR():t===43?l.ccRTD():t===44?l.ccEDM():t===45?l.ccCR():t===46?l.ccENM():t===47&&l.ccEOC():l.ccTO(t-32),gn(e,t,i),this.currentChannel=a,!0},s.parseMidrow=function(e,t){var i=0;if((e===17||e===25)&&t>=32&&t<=47){if((i=e===17?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var a=this.channels[i];return!!a&&(a.ccMIDROW(t),this.logger.log(3,"MIDROW ("+Pa([e,t])+")"),!0)}return!1},s.parsePAC=function(e,t){var i,a=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(e===16||e===24)&&t>=64&&t<=95))return!1;if(of(e,t,a))return gn(null,null,a),!0;var l=e<=23?1:2;i=t>=64&&t<=95?l===1?Eg[e]:bg[e]:l===1?yg[e]:Tg[e];var d=this.channels[l];return!!d&&(d.setPAC(this.interpretPAC(i,t)),gn(e,t,a),this.currentChannel=l,!0)},s.interpretPAC=function(e,t){var i,a={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,a.underline=(1&i)==1,i<=13?a.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(a.italics=!0,a.color="white"):a.indent=4*Math.floor((i-16)/2),a},s.parseChars=function(e,t){var i,a,l=null,d=null;if(e>=25?(i=2,d=e-8):(i=1,d=e),d>=17&&d<=19?(a=d===17?t+80:d===18?t+112:t+144,this.logger.log(2,"Special char '"+rf(a)+"' in channel "+i),l=[a]):e>=32&&e<=127&&(l=t===0?[e]:[e,t]),l){var c=Pa(l);this.logger.log(3,"Char codes = "+c.join(",")),gn(e,t,this.cmdHistory)}return l},s.parseBackgroundAttributes=function(e,t){var i;if(!((e===16||e===24)&&t>=32&&t<=47||(e===23||e===31)&&t>=45&&t<=47))return!1;var a={};e===16||e===24?(i=Math.floor((t-32)/2),a.background=_g[i],t%2==1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));var l=e<=23?1:2;return this.channels[l].setBkgData(a),gn(e,t,this.cmdHistory),!0},s.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}},s.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var i=this.channels[t];i&&i.cueSplitAtTime(e)}},u}();function gn(u,s,e){e.a=u,e.b=s}function of(u,s,e){return e.a===u&&e.b===s}var Zo=function(){function u(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}var s=u.prototype;return s.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},s.newCue=function(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)},s.reset=function(){this.cueRanges=[],this.startTime=null},u}(),fd=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var u=["","lr","rl"],s=["start","middle","end","left","right"];function e(l,d){if(typeof d!="string"||!Array.isArray(l))return!1;var c=d.toLowerCase();return!!~l.indexOf(c)&&c}function t(l){return e(s,l)}function i(l){for(var d=arguments.length,c=new Array(d>1?d-1:0),h=1;h<d;h++)c[h-1]=arguments[h];for(var f=1;f<arguments.length;f++){var p=arguments[f];for(var E in p)l[E]=p[E]}return l}function a(l,d,c){var h=this,f={enumerable:!0};h.hasBeenReset=!1;var p="",E=!1,b=l,A=d,w=c,D=null,S="",L=!0,N="auto",P="start",V=50,Y="middle",j=50,ie="middle";Object.defineProperty(h,"id",i({},f,{get:function(){return p},set:function(Q){p=""+Q}})),Object.defineProperty(h,"pauseOnExit",i({},f,{get:function(){return E},set:function(Q){E=!!Q}})),Object.defineProperty(h,"startTime",i({},f,{get:function(){return b},set:function(Q){if(typeof Q!="number")throw new TypeError("Start time must be set to a number.");b=Q,this.hasBeenReset=!0}})),Object.defineProperty(h,"endTime",i({},f,{get:function(){return A},set:function(Q){if(typeof Q!="number")throw new TypeError("End time must be set to a number.");A=Q,this.hasBeenReset=!0}})),Object.defineProperty(h,"text",i({},f,{get:function(){return w},set:function(Q){w=""+Q,this.hasBeenReset=!0}})),Object.defineProperty(h,"region",i({},f,{get:function(){return D},set:function(Q){D=Q,this.hasBeenReset=!0}})),Object.defineProperty(h,"vertical",i({},f,{get:function(){return S},set:function(Q){var X=function(ce){return e(u,ce)}(Q);if(X===!1)throw new SyntaxError("An invalid or illegal string was specified.");S=X,this.hasBeenReset=!0}})),Object.defineProperty(h,"snapToLines",i({},f,{get:function(){return L},set:function(Q){L=!!Q,this.hasBeenReset=!0}})),Object.defineProperty(h,"line",i({},f,{get:function(){return N},set:function(Q){if(typeof Q!="number"&&Q!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");N=Q,this.hasBeenReset=!0}})),Object.defineProperty(h,"lineAlign",i({},f,{get:function(){return P},set:function(Q){var X=t(Q);if(!X)throw new SyntaxError("An invalid or illegal string was specified.");P=X,this.hasBeenReset=!0}})),Object.defineProperty(h,"position",i({},f,{get:function(){return V},set:function(Q){if(Q<0||Q>100)throw new Error("Position must be between 0 and 100.");V=Q,this.hasBeenReset=!0}})),Object.defineProperty(h,"positionAlign",i({},f,{get:function(){return Y},set:function(Q){var X=t(Q);if(!X)throw new SyntaxError("An invalid or illegal string was specified.");Y=X,this.hasBeenReset=!0}})),Object.defineProperty(h,"size",i({},f,{get:function(){return j},set:function(Q){if(Q<0||Q>100)throw new Error("Size must be between 0 and 100.");j=Q,this.hasBeenReset=!0}})),Object.defineProperty(h,"align",i({},f,{get:function(){return ie},set:function(Q){var X=t(Q);if(!X)throw new SyntaxError("An invalid or illegal string was specified.");ie=X,this.hasBeenReset=!0}})),h.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),wg=function(){function u(){}return u.prototype.decode=function(s,e){if(!s)return"";if(typeof s!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(s))},u}();function lf(u){function s(t,i,a,l){return 3600*(0|t)+60*(0|i)+(0|a)+parseFloat(l||0)}var e=u.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?s(e[2],e[3],0,e[4]):s(e[1],e[2],e[3],e[4]):null}var Lg=function(){function u(){this.values=Object.create(null)}var s=u.prototype;return s.set=function(e,t){this.get(e)||t===""||(this.values[e]=t)},s.get=function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t},s.has=function(e){return e in this.values},s.alt=function(e,t,i){for(var a=0;a<i.length;++a)if(t===i[a]){this.set(e,t);break}},s.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},s.percent=function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1},u}();function uf(u,s,e,t){var i=t?u.split(t):[u];for(var a in i)if(typeof i[a]=="string"){var l=i[a].split(e);l.length===2&&s(l[0],l[1])}}var md=new fd(0,0,""),Jo=md.align==="middle"?"middle":"center";function Ig(u,s,e){var t=u;function i(){var l=lf(u);if(l===null)throw new Error("Malformed timestamp: "+t);return u=u.replace(/^[^\sa-zA-Z-]+/,""),l}function a(){u=u.replace(/^\s+/,"")}if(a(),s.startTime=i(),a(),u.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+t);u=u.slice(3),a(),s.endTime=i(),a(),function(l,d){var c=new Lg;uf(l,function(p,E){var b;switch(p){case"region":for(var A=e.length-1;A>=0;A--)if(e[A].id===E){c.set(p,e[A].region);break}break;case"vertical":c.alt(p,E,["rl","lr"]);break;case"line":b=E.split(","),c.integer(p,b[0]),c.percent(p,b[0])&&c.set("snapToLines",!1),c.alt(p,b[0],["auto"]),b.length===2&&c.alt("lineAlign",b[1],["start",Jo,"end"]);break;case"position":b=E.split(","),c.percent(p,b[0]),b.length===2&&c.alt("positionAlign",b[1],["start",Jo,"end","line-left","line-right","auto"]);break;case"size":c.percent(p,E);break;case"align":c.alt(p,E,["start",Jo,"end","left","right"])}},/:/,/\s/),d.region=c.get("region",null),d.vertical=c.get("vertical","");var h=c.get("line","auto");h==="auto"&&md.line===-1&&(h=-1),d.line=h,d.lineAlign=c.get("lineAlign","start"),d.snapToLines=c.get("snapToLines",!0),d.size=c.get("size",100),d.align=c.get("align",Jo);var f=c.get("position","auto");f==="auto"&&md.position===50&&(f=d.align==="start"||d.align==="left"?0:d.align==="end"||d.align==="right"?100:50),d.position=f}(u,s)}function df(u){return u.replace(/<br(?: \/)?>/gi,`
|
|
35
|
-
`)}var Rg=function(){function u(){this.state="INITIAL",this.buffer="",this.decoder=new wg,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var s=u.prototype;return s.parse=function(e){var t=this;function i(){var h=t.buffer,f=0;for(h=df(h);f<h.length&&h[f]!=="\r"&&h[f]!==`
|
|
36
|
-
`;)++f;var p=h.slice(0,f);return h[f]==="\r"&&++f,h[f]===`
|
|
37
|
-
`&&++f,t.buffer=h.slice(f),p}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var a="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;var l=(a=i()).match(/^()?WEBVTT([ \t].*)?$/);if(l==null||!l[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var d=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(d?d=!1:a=i(),t.state){case"HEADER":/:/.test(a)?uf(a,function(h,f){},/:/):a||(t.state="ID");continue;case"NOTE":a||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){t.state="NOTE";break}if(!a)continue;if(t.cue=new fd(0,0,""),t.state="CUE",a.indexOf("-->")===-1){t.cue.id=a;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Ig(a,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var c=a.indexOf("-->")!==-1;if(!a||c&&(d=!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+=`
|
|
38
|
-
`),t.cue.text+=a;continue;case"BADCUE":a||(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},s.flush=function(){var e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
|
|
39
|
-
|
|
40
|
-
`,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},u}(),Dg=/\r\n|\n\r|\n|\r/g,pd=function(u,s,e){return e===void 0&&(e=0),u.slice(e,e+s.length)===s},vd=function(u){for(var s=5381,e=u.length;e;)s=33*s^u.charCodeAt(--e);return(s>>>0).toString()};function gd(u,s,e){return vd(u.toString())+vd(s.toString())+vd(e)}function Cg(u,s,e,t,i,a,l){var d,c,h,f=new Rg,p=Ii(new Uint8Array(u)).trim().replace(Dg,`
|
|
41
|
-
`).split(`
|
|
42
|
-
`),E=[],b=(d=s.baseTime,(c=s.timescale)===void 0&&(c=1),rd(d,9e4,1/c)),A="00:00.000",w=0,D=0,S=!0;f.oncue=function(L){var N=e[t],P=e.ccOffset,V=(w-b)/9e4;N!=null&&N.new&&(D!==void 0?P=e.ccOffset=N.start:function(Q,X,ce){var le=Q[X],Ae=Q[le.prevCC];if(!Ae||!Ae.new&&le.new)return Q.ccOffset=Q.presentationOffset=le.start,void(le.new=!1);for(;(xe=Ae)!=null&&xe.new;){var xe;Q.ccOffset+=le.start-Ae.start,le.new=!1,Ae=Q[(le=Ae).prevCC]}Q.presentationOffset=ce}(e,t,V)),V&&(P=V-e.presentationOffset);var Y=L.endTime-L.startTime,j=Fi(9e4*(L.startTime+P-D),9e4*i)/9e4;L.startTime=Math.max(j,0),L.endTime=Math.max(j+Y,0);var ie=L.text.trim();L.text=decodeURIComponent(encodeURIComponent(ie)),L.id||(L.id=gd(L.startTime,L.endTime,ie)),L.endTime>0&&E.push(L)},f.onparsingerror=function(L){h=L},f.onflush=function(){h?l(h):a(E)},p.forEach(function(L){if(S){if(pd(L,"X-TIMESTAMP-MAP=")){S=!1,L.slice(16).split(",").forEach(function(N){pd(N,"LOCAL:")?A=N.slice(6):pd(N,"MPEGTS:")&&(w=parseInt(N.slice(7)))});try{D=function(N){var P=parseInt(N.slice(-3)),V=parseInt(N.slice(-6,-4)),Y=parseInt(N.slice(-9,-7)),j=N.length>9?parseInt(N.substring(0,N.indexOf(":"))):0;if(!(re(P)&&re(V)&&re(Y)&&re(j)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+N);return P+=1e3*V,(P+=6e4*Y)+36e5*j}(A)/1e3}catch(N){h=N}return}L===""&&(S=!1)}f.parse(L+`
|
|
43
|
-
`)}),f.flush()}var Ed="stpp.ttml.im1t",cf=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,hf=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Mg={left:"start",center:"center",right:"end",start:"start",end:"end"};function ff(u,s,e,t){var i=Je(new Uint8Array(u),["mdat"]);if(i.length!==0){var a,l,d,c,h=i.map(function(p){return Ii(p)}),f=(a=s.baseTime,l=1,(d=s.timescale)===void 0&&(d=1),c===void 0&&(c=!1),rd(a,l,1/d,c));try{h.forEach(function(p){return e(function(E,b){var A=new DOMParser().parseFromString(E,"text/xml").getElementsByTagName("tt")[0];if(!A)throw new Error("Invalid ttml");var w={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},D=Object.keys(w).reduce(function(V,Y){return V[Y]=A.getAttribute("ttp:"+Y)||w[Y],V},{}),S=A.getAttribute("xml:space")!=="preserve",L=mf(yd(A,"styling","style")),N=mf(yd(A,"layout","region")),P=yd(A,"body","[begin]");return[].map.call(P,function(V){var Y=pf(V,S);if(!Y||!V.hasAttribute("begin"))return null;var j=Td(V.getAttribute("begin"),D),ie=Td(V.getAttribute("dur"),D),Q=Td(V.getAttribute("end"),D);if(j===null)throw vf(V);if(Q===null){if(ie===null)throw vf(V);Q=j+ie}var X=new fd(j-b,Q-b,Y);X.id=gd(X.startTime,X.endTime,X.text);var ce=function(xe,Le,Me){var Oe="http://www.w3.org/ns/ttml#styling",Pe=null,Ke=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],je=xe!=null&&xe.hasAttribute("style")?xe.getAttribute("style"):null;return je&&Me.hasOwnProperty(je)&&(Pe=Me[je]),Ke.reduce(function(et,lt){var _i=bd(Le,Oe,lt)||bd(xe,Oe,lt)||bd(Pe,Oe,lt);return _i&&(et[lt]=_i),et},{})}(N[V.getAttribute("region")],L[V.getAttribute("style")],L),le=ce.textAlign;if(le){var Ae=Mg[le];Ae&&(X.lineAlign=Ae),X.align=le}return H(X,ce),X}).filter(function(V){return V!==null})}(p,f))})}catch(p){t(p)}}else t(new Error("Could not parse IMSC1 mdat"))}function yd(u,s,e){var t=u.getElementsByTagName(s)[0];return t?[].slice.call(t.querySelectorAll(e)):[]}function mf(u){return u.reduce(function(s,e){var t=e.getAttribute("xml:id");return t&&(s[t]=e),s},{})}function pf(u,s){return[].slice.call(u.childNodes).reduce(function(e,t,i){var a;return t.nodeName==="br"&&i?e+`
|
|
44
|
-
`:(a=t.childNodes)!=null&&a.length?pf(t,s):s?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function bd(u,s,e){return u&&u.hasAttributeNS(s,e)?u.getAttributeNS(s,e):null}function vf(u){return new Error("Could not parse ttml timestamp "+u)}function Td(u,s){if(!u)return null;var e=lf(u);return e===null&&(cf.test(u)?e=function(t,i){var a=cf.exec(t),l=(0|a[4])+(0|a[5])/i.subFrameRate;return 3600*(0|a[1])+60*(0|a[2])+(0|a[3])+l/i.frameRate}(u,s):hf.test(u)&&(e=function(t,i){var a=hf.exec(t),l=Number(a[1]);switch(a[2]){case"h":return 3600*l;case"m":return 60*l;case"ms":return 1e3*l;case"f":return l/i.frameRate;case"t":return l/i.tickRate}return l}(u,s))),e}var xg=function(){function u(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={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},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){var t=new Zo(this,"textTrack1"),i=new Zo(this,"textTrack2"),a=new Zo(this,"textTrack3"),l=new Zo(this,"textTrack4");this.cea608Parser1=new sf(1,t,i),this.cea608Parser2=new sf(3,a,l)}e.on(k.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(k.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(k.FRAG_LOADING,this.onFragLoading,this),e.on(k.FRAG_LOADED,this.onFragLoaded,this),e.on(k.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(k.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(k.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(k.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(k.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=u.prototype;return s.destroy=function(){var e=this.hls;e.off(k.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(k.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(k.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(k.FRAG_LOADING,this.onFragLoading,this),e.off(k.FRAG_LOADED,this.onFragLoaded,this),e.off(k.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(k.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(k.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(k.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(k.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(e,t,i,a,l){for(var d,c,h,f,p=!1,E=l.length;E--;){var b=l[E],A=(d=b[0],c=b[1],h=t,f=i,Math.min(c,f)-Math.max(d,h));if(A>=0&&(b[0]=Math.min(b[0],t),b[1]=Math.max(b[1],i),p=!0,A/(i-t)>.5))return}if(p||l.push([t,i]),this.config.renderTextTracksNatively){var w=this.captionsTracks[e];this.Cues.newCue(w,t,i,a)}else{var D=this.Cues.newCue(null,t,i,a);this.hls.trigger(k.CUES_PARSED,{type:"captions",cues:D,track:e})}},s.onInitPtsFound=function(e,t){var i=this,a=t.frag,l=t.id,d=t.initPTS,c=t.timescale,h=this.unparsedVttFrags;l==="main"&&(this.initPTS[a.cc]={baseTime:d,timescale:c}),h.length&&(this.unparsedVttFrags=[],h.forEach(function(f){i.onFragLoaded(k.FRAG_LOADED,f)}))},s.getExistingTrack=function(e){var t=this.media;if(t)for(var i=0;i<t.textTracks.length;i++){var a=t.textTracks[i];if(a[e])return a}return null},s.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},s.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,i=this.captionsTracks,a=this.media,l=t[e],d=l.label,c=l.languageCode,h=this.getExistingTrack(e);if(h)i[e]=h,Qr(i[e]),_a(i[e],a);else{var f=this.createTextTrack("captions",d,c);f&&(f[e]=!0,i[e]=f)}}},s.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var i={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(k.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}}},s.createTextTrack=function(e,t,i){var a=this.media;if(a)return a.addTextTrack(e,t,i)},s.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},s.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach(function(t){Qr(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},s._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var i=0;i<t.length;i++)Qr(t[i])}},s.onSubtitleTracksUpdated=function(e,t){var i=this,a=t.subtitleTracks||[],l=a.some(function(h){return h.textCodec===Ed});if(this.config.enableWebVTT||l&&this.config.enableIMSC1){if(Zh(this.tracks,a))return void(this.tracks=a);if(this.textTracks=[],this.tracks=a,this.config.renderTextTracksNatively){var d=this.media?this.media.textTracks:null;this.tracks.forEach(function(h,f){var p;if(d&&f<d.length){for(var E=null,b=0;b<d.length;b++)if(Pg(d[b],h)){E=d[b];break}E&&(p=E)}if(p)Qr(p);else{var A=i._captionsOrSubtitlesFromCharacteristics(h);(p=i.createTextTrack(A,h.name,h.lang))&&(p.mode="disabled")}p&&(p.groupId=h.groupId,i.textTracks.push(p))})}else if(this.tracks.length){var c=this.tracks.map(function(h){return{label:h.name,kind:h.type.toLowerCase(),default:h.default,subtitleTrack:h}});this.hls.trigger(k.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},s._captionsOrSubtitlesFromCharacteristics=function(e){if(e.attrs.CHARACTERISTICS){var 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"},s.onManifestLoaded=function(e,t){var i=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(function(a){var l=/(?:CC|SERVICE)([1-4])/.exec(a.instreamId);if(l){var d="textTrack"+l[1],c=i.captionsProperties[d];c&&(c.label=a.name,a.lang&&(c.languageCode=a.lang),c.media=a)}})},s.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]},s.onFragLoading=function(e,t){var i=this.cea608Parser1,a=this.cea608Parser2,l=this.lastSn,d=this.lastPartIndex;if(this.enabled&&i&&a&&t.frag.type===rt){var c,h,f=t.frag.sn,p=(c=t==null||(h=t.part)==null?void 0:h.index)!=null?c:-1;f===l+1||f===l&&p===d+1||(i.reset(),a.reset()),this.lastSn=f,this.lastPartIndex=p}},s.onFragLoaded=function(e,t){var i=t.frag,a=t.payload,l=this.initPTS,d=this.unparsedVttFrags;if(i.type===Oi)if(a.byteLength){if(!l[i.cc])return d.push(t),void(l.length&&this.hls.trigger(k.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Missing initial subtitle PTS")}));var c=i.decryptdata,h="stats"in t;if(c==null||!c.encrypted||h){var f=this.tracks[i.level],p=this.vttCCs;p[i.cc]||(p[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),f&&f.textCodec===Ed?this._parseIMSC1(i,a):this._parseVTTs(i,a,p)}}else this.hls.trigger(k.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(e,t){var i=this,a=this.hls;ff(t,this.initPTS[e.cc],function(l){i._appendCues(l,e.level),a.trigger(k.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(l){B.log("Failed to parse IMSC1: "+l),a.trigger(k.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:l})})},s._parseVTTs=function(e,t,i){var a,l=this,d=this.hls;Cg((a=e.initSegment)!=null&&a.data?Tr(e.initSegment.data,new Uint8Array(t)):t,this.initPTS[e.cc],i,e.cc,e.start,function(c){l._appendCues(c,e.level),d.trigger(k.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(c){l._fallbackToIMSC1(e,t),B.log("Failed to parse VTT cue: "+c),d.trigger(k.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:c})})},s._fallbackToIMSC1=function(e,t){var i=this,a=this.tracks[e.level];a.textCodec||ff(t,this.initPTS[e.cc],function(){a.textCodec=Ed,i._parseIMSC1(e,t)},function(){a.textCodec="wvtt"})},s._appendCues=function(e,t){var i=this.hls;if(this.config.renderTextTracksNatively){var a=this.textTracks[t];if(!a||a.mode==="disabled")return;e.forEach(function(c){return Uo(a,c)})}else{var l=this.tracks[t];if(!l)return;var d=l.default?"default":"subtitles"+t;i.trigger(k.CUES_PARSED,{type:"subtitles",cues:e,track:d})}},s.onFragDecrypted=function(e,t){var i=t.frag;if(i.type===Oi){if(!this.initPTS[i.cc])return void this.unparsedVttFrags.push(t);this.onFragLoaded(k.FRAG_LOADED,t)}},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(e,t){var i=this.cea608Parser1,a=this.cea608Parser2;if(this.enabled&&i&&a){var l=t.frag,d=t.samples;if(l.type!==rt||this.closedCaptionsForLevel(l)!=="NONE")for(var c=0;c<d.length;c++){var h=d[c].bytes;if(h){var f=this.extractCea608Data(h);i.addData(d[c].pts,f[0]),a.addData(d[c].pts,f[1])}}}},s.onBufferFlushing=function(e,t){var i=t.startOffset,a=t.endOffset,l=t.endOffsetSubtitles,d=t.type,c=this.media;if(c&&!(c.currentTime<a)){if(!d||d==="video"){var h=this.captionsTracks;Object.keys(h).forEach(function(p){return fs(h[p],i,a)})}if(this.config.renderTextTracksNatively&&i===0&&l!==void 0){var f=this.textTracks;Object.keys(f).forEach(function(p){return fs(f[p],i,l)})}}},s.extractCea608Data=function(e){for(var t=[[],[]],i=31&e[0],a=2,l=0;l<i;l++){var d=e[a++],c=127&e[a++],h=127&e[a++];if((c!==0||h!==0)&&(4&d)!=0){var f=3&d;f!==0&&f!==1||(t[f].push(c),t[f].push(h))}}return t},u}();function Pg(u,s){return!!u&&u.label===s.name&&!(u.textTrack1||u.textTrack2)}var Og=function(){function u(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()}var s=u.prototype;return s.setStreamController=function(e){this.streamController=e},s.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var e=this.hls;e.on(k.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(k.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(k.MANIFEST_PARSED,this.onManifestParsed,this),e.on(k.BUFFER_CODECS,this.onBufferCodecs,this),e.on(k.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var e=this.hls;e.off(k.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(k.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(k.MANIFEST_PARSED,this.onManifestParsed,this),e.off(k.BUFFER_CODECS,this.onBufferCodecs,this),e.off(k.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(e,t){var i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})},s.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null},s.onManifestParsed=function(e,t){var i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping()},s.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var e=this.hls.levels;if(e.length){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},s.getMaxLevel=function(e){var t=this,i=this.hls.levels;if(!i.length)return-1;var a=i.filter(function(l,d){return t.isLevelAllowed(l)&&d<=e});return this.clientRect=null,u.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},s.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var 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},s.isLevelAllowed=function(e){return!this.restrictedLevels.some(function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height})},u.getMaxLevelByMediaSize=function(e,t,i){if(e==null||!e.length)return-1;for(var a,l,d=e.length-1,c=0;c<e.length;c+=1){var h=e[c];if((h.width>=t||h.height>=i)&&(a=h,!(l=e[c+1])||a.width!==l.width||a.height!==l.height)){d=c;break}}return d},M(u,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}}]),u}(),Ng=function(){function u(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()}var s=u.prototype;return s.setStreamController=function(e){this.streamController=e},s.registerListeners=function(){this.hls.on(k.MEDIA_ATTACHING,this.onMediaAttaching,this)},s.unregisterListeners=function(){this.hls.off(k.MEDIA_ATTACHING,this.onMediaAttaching,this)},s.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},s.onMediaAttaching=function(e,t){var i=this.hls.config;if(i.capLevelOnFPSDrop){var a=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=a,a&&typeof a.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}},s.checkFPS=function(e,t,i){var a=performance.now();if(t){if(this.lastTime){var l=a-this.lastTime,d=i-this.lastDroppedFrames,c=t-this.lastDecodedFrames,h=1e3*d/l,f=this.hls;if(f.trigger(k.FPS_DROP,{currentDropped:d,currentDecoded:c,totalDroppedFrames:i}),h>0&&d>f.config.fpsDroppedMonitoringThreshold*c){var p=f.currentLevel;B.warn("drop FPS ratio greater than max allowed value for currentLevel: "+p),p>0&&(f.autoLevelCapping===-1||f.autoLevelCapping>=p)&&(p-=1,f.trigger(k.FPS_DROP_LEVEL_CAPPING,{level:p,droppedLevel:f.currentLevel}),f.autoLevelCapping=p,this.streamController.nextLevelSwitch())}}this.lastTime=a,this.lastDroppedFrames=i,this.lastDecodedFrames=t}},s.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},u}(),el="[eme]",gf=function(){function u(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=u.CDMCleanupPromise?[u.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=B.debug.bind(B,el),this.log=B.log.bind(B,el),this.warn=B.warn.bind(B,el),this.error=B.error.bind(B,el),this.hls=e,this.config=e.config,this.registerListeners()}var s=u.prototype;return s.destroy=function(){this.unregisterListeners(),this.onMediaDetached();var 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},s.registerListeners=function(){this.hls.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(k.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(k.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(k.MANIFEST_LOADED,this.onManifestLoaded,this)},s.unregisterListeners=function(){this.hls.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(k.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(k.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(k.MANIFEST_LOADED,this.onManifestLoaded,this)},s.getLicenseServerUrl=function(e){var t=this.config,i=t.drmSystems,a=t.widevineLicenseUrl,l=i[e];if(l)return l.licenseUrl;if(e===Ze.WIDEVINE&&a)return a;throw new Error('no license server URL configured for key-system "'+e+'"')},s.getServerCertificateUrl=function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},s.attemptKeySystemAccess=function(e){var t=this,i=this.hls.levels,a=function(c,h,f){return!!c&&f.indexOf(c)===h},l=i.map(function(c){return c.audioCodec}).filter(a),d=i.map(function(c){return c.videoCodec}).filter(a);return l.length+d.length===0&&d.push("avc1.42e01e"),new Promise(function(c,h){(function f(p){var E=p.shift();t.getMediaKeysPromise(E,l,d).then(function(b){return c({keySystem:E,mediaKeys:b})}).catch(function(b){p.length?f(p):h(b instanceof Ui?b:new Ui({type:oe.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_ACCESS,error:b,fatal:!0},b.message))})})(e)})},s.requestMediaKeySystemAccess=function(e,t){var i=this.config.requestMediaKeySystemAccessFunc;if(typeof i!="function"){var a="Configured requestMediaKeySystemAccess is not a function "+i;return $r===null&&self.location.protocol==="http:"&&(a="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(a))}return i(e,t)},s.getMediaKeysPromise=function(e,t,i){var a=this,l=function(f,p,E,b){var A;switch(f){case Ze.FAIRPLAY:A=["cenc","sinf"];break;case Ze.WIDEVINE:case Ze.PLAYREADY:A=["cenc"];break;case Ze.CLEARKEY:A=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+f)}return function(w,D,S,L){return[{initDataTypes:w,persistentState:L.persistentState||"not-allowed",distinctiveIdentifier:L.distinctiveIdentifier||"not-allowed",sessionTypes:L.sessionTypes||[L.sessionType||"temporary"],audioCapabilities:D.map(function(N){return{contentType:'audio/mp4; codecs="'+N+'"',robustness:L.audioRobustness||"",encryptionScheme:L.audioEncryptionScheme||null}}),videoCapabilities:S.map(function(N){return{contentType:'video/mp4; codecs="'+N+'"',robustness:L.videoRobustness||"",encryptionScheme:L.videoEncryptionScheme||null}})}]}(A,p,E,b)}(e,t,i,this.config.drmSystemOptions),d=this.keySystemAccessPromises[e],c=d==null?void 0:d.keySystemAccess;if(!c){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(l)),c=this.requestMediaKeySystemAccess(e,l);var h=this.keySystemAccessPromises[e]={keySystemAccess:c};return c.catch(function(f){a.log('Failed to obtain access to key-system "'+e+'": '+f)}),c.then(function(f){a.log('Access for key-system "'+f.keySystem+'" obtained');var p=a.fetchServerCertificate(e);return a.log('Create media-keys for "'+e+'"'),h.mediaKeys=f.createMediaKeys().then(function(E){return a.log('Media-keys created for "'+e+'"'),p.then(function(b){return b?a.setMediaKeysServerCertificate(E,e,b):E})}),h.mediaKeys.catch(function(E){a.error('Failed to create media-keys for "'+e+'"}: '+E)}),h.mediaKeys})}return c.then(function(){return d.mediaKeys})},s.createMediaKeySessionContext=function(e){var t=e.decryptdata,i=e.keySystem,a=e.mediaKeys;this.log('Creating key-system session "'+i+'" keyId: '+Pi(t.keyId||[]));var l=a.createSession(),d={decryptdata:t,keySystem:i,mediaKeys:a,mediaKeysSession:l,keyStatus:"status-pending"};return this.mediaKeySessions.push(d),d},s.renewKeySession=function(e){var t=e.decryptdata;if(t.pssh){var i=this.createMediaKeySessionContext(e),a=this.getKeyIdString(t);this.keyIdToKeySessionPromise[a]=this.generateRequestWithPreferredKeySession(i,"cenc",t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)},s.getKeyIdString=function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Pi(e.keyId)},s.updateKeySession=function(e,t){var i,a=e.mediaKeysSession;return this.log('Updating key-session "'+a.sessionId+'" for keyID '+Pi(((i=e.decryptdata)==null?void 0:i.keyId)||[])+`
|
|
45
|
-
} (data length: `+(t&&t.byteLength)+")"),a.update(t)},s.selectKeySystemFormat=function(e){var 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},s.getKeyFormatPromise=function(e){var t=this;return new Promise(function(i,a){var l=yr(t.config),d=e.map(Ei).filter(function(c){return!!c&&l.indexOf(c)!==-1});return t.getKeySystemSelectionPromise(d).then(function(c){var h=c.keySystem,f=nr(h);f?i(f):a(new Error('Unable to find format for key-system "'+h+'"'))}).catch(a)})},s.loadKey=function(e){var t=this,i=e.keyInfo.decryptdata,a=this.getKeyIdString(i),l="(keyId: "+a+' format: "'+i.keyFormat+'" method: '+i.method+" uri: "+i.uri+")";this.log("Starting session for key "+l);var d=this.keyIdToKeySessionPromise[a];return d||(d=this.keyIdToKeySessionPromise[a]=this.getKeySystemForKeyPromise(i).then(function(c){var h=c.keySystem,f=c.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+l),t.attemptSetMediaKeys(h,f).then(function(){t.throwIfDestroyed();var p=t.createMediaKeySessionContext({keySystem:h,mediaKeys:f,decryptdata:i});return t.generateRequestWithPreferredKeySession(p,"cenc",i.pssh,"playlist-key")})})).catch(function(c){return t.handleError(c)}),d},s.throwIfDestroyed=function(e){if(!this.hls)throw new Error("invalid state")},s.handleError=function(e){this.hls&&(this.error(e.message),e instanceof Ui?this.hls.trigger(k.ERROR,e.data):this.hls.trigger(k.ERROR,{type:oe.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))},s.getKeySystemForKeyPromise=function(e){var t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){var a=Ei(e.keyFormat),l=a?[a]:yr(this.config);return this.attemptKeySystemAccess(l)}return i},s.getKeySystemSelectionPromise=function(e){if(e.length||(e=yr(this.config)),e.length===0)throw new Ui({type:oe.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},s._onMediaEncrypted=function(e){var t=this,i=e.initDataType,a=e.initData;if(this.debug('"'+e.type+'" event: init data type: "'+i+'"'),a!==null){var l,d;if(i==="sinf"&&this.config.drmSystems[Ze.FAIRPLAY]){var c=xt(new Uint8Array(a));try{var h=Rt(JSON.parse(c).sinf),f=ss(new Uint8Array(h));if(!f)return;l=f.subarray(8,24),d=Ze.FAIRPLAY}catch{return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var p=function(N){if(!(N instanceof ArrayBuffer)||N.byteLength<32)return null;var P={version:0,systemId:"",kids:null,data:null},V=new DataView(N),Y=V.getUint32(0);if(N.byteLength!==Y&&Y>44||V.getUint32(4)!==1886614376||(P.version=V.getUint32(8)>>>24,P.version>1))return null;P.systemId=Pi(new Uint8Array(N,12,16));var j=V.getUint32(28);if(P.version===0){if(Y-32<j)return null;P.data=new Uint8Array(N,32,j)}else if(P.version===1){P.kids=[];for(var ie=0;ie<j;ie++)P.kids.push(new Uint8Array(N,32+16*ie,16))}return P}(a);if(p===null)return;p.version===0&&p.systemId===ft&&p.data&&(l=p.data.subarray(8,24)),d=function(N){if(N===ft)return Ze.WIDEVINE}(p.systemId)}if(d&&l){for(var E=Pi(l),b=this.keyIdToKeySessionPromise,A=this.mediaKeySessions,w=b[E],D=function(){var N=A[S],P=N.decryptdata;if(P.pssh||!P.keyId)return"continue";var V=Pi(P.keyId);return E===V||P.uri.replace(/-/g,"").indexOf(E)!==-1?(w=b[V],delete b[V],P.pssh=new Uint8Array(a),P.keyId=l,w=b[E]=w.then(function(){return t.generateRequestWithPreferredKeySession(N,i,a,"encrypted-event-key-match")}),"break"):void 0},S=0;S<A.length;S++){var L=D();if(L!=="continue"&&L==="break")break}w||(w=b[E]=this.getKeySystemSelectionPromise([d]).then(function(N){var P,V=N.keySystem,Y=N.mediaKeys;t.throwIfDestroyed();var j=new ba("ISO-23001-7",E,(P=nr(V))!=null?P:"");return j.pssh=new Uint8Array(a),j.keyId=l,t.attemptSetMediaKeys(V,Y).then(function(){t.throwIfDestroyed();var ie=t.createMediaKeySessionContext({decryptdata:j,keySystem:V,mediaKeys:Y});return t.generateRequestWithPreferredKeySession(ie,i,a,"encrypted-event-no-match")})})),w.catch(function(N){return t.handleError(N)})}}},s._onWaitingForKey=function(e){this.log('"'+e.type+'" event')},s.attemptSetMediaKeys=function(e,t){var i=this,a=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+e+'"');var l=Promise.all(a).then(function(){if(!i.media)throw new Error("Attempted to set mediaKeys without media element attached");return i.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(l),l.then(function(){i.log('Media-keys set for "'+e+'"'),a.push(l),i.setMediaKeysQueue=i.setMediaKeysQueue.filter(function(d){return a.indexOf(d)===-1})})},s.generateRequestWithPreferredKeySession=function(e,t,i,a){var l,d,c=this,h=(l=this.config.drmSystems)==null||(d=l[e.keySystem])==null?void 0:d.generateRequest;if(h)try{var f=h.call(this.hls,t,i,e);if(!f)throw new Error("Invalid response from configured generateRequest filter");t=f.initDataType,i=e.decryptdata.pssh=f.initData?new Uint8Array(f.initData):null}catch(w){var p;if(this.warn(w.message),(p=this.hls)!=null&&p.config.debug)throw w}if(i===null)return this.log('Skipping key-session request for "'+a+'" (no initData)'),Promise.resolve(e);var E=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'+a+'": '+E+" (init data type: "+t+" length: "+(i?i.byteLength:null)+")");var b=new Xo;e.mediaKeysSession.onmessage=function(w){var D=e.mediaKeysSession;if(D){var S=w.messageType,L=w.message;c.log('"'+S+'" message event for session "'+D.sessionId+'" message size: '+L.byteLength),S==="license-request"||S==="license-renewal"?c.renewLicense(e,L).catch(function(N){c.handleError(N),b.emit("error",N)}):S==="license-release"?e.keySystem===Ze.FAIRPLAY&&(c.updateKeySession(e,$i("acknowledged")),c.removeSession(e)):c.warn('unhandled media key message type "'+S+'"')}else b.emit("error",new Error("invalid state"))},e.mediaKeysSession.onkeystatuseschange=function(w){if(e.mediaKeysSession){c.onKeyStatusChange(e);var D=e.keyStatus;b.emit("keyStatus",D),D==="expired"&&(c.warn(e.keySystem+" expired for key "+E),c.renewKeySession(e))}else b.emit("error",new Error("invalid state"))};var A=new Promise(function(w,D){b.on("error",D),b.on("keyStatus",function(S){S.startsWith("usable")?w():S==="output-restricted"?D(new Ui({type:oe.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):S==="internal-error"?D(new Ui({type:oe.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+S+'"')):S==="expired"?D(new Error("key expired while generating request")):c.warn('unhandled key status change "'+S+'"')})});return e.mediaKeysSession.generateRequest(t,i).then(function(){var w;c.log('Request generated for key-session "'+((w=e.mediaKeysSession)==null?void 0:w.sessionId)+'" keyId: '+E)}).catch(function(w){throw new Ui({type:oe.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_SESSION,error:w,fatal:!1},"Error generating key-session request: "+w)}).then(function(){return A}).catch(function(w){throw b.removeAllListeners(),c.removeSession(e),w}).then(function(){return b.removeAllListeners(),e})},s.onKeyStatusChange=function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach(function(i,a){t.log('key status change "'+i+'" for keyStatuses keyId: '+Pi("buffer"in a?new Uint8Array(a.buffer,a.byteOffset,a.byteLength):new Uint8Array(a))+" session keyId: "+Pi(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=i})},s.fetchServerCertificate=function(e){var t=this.config,i=new t.loader(t),a=this.getServerCertificateUrl(e);return a?(this.log('Fetching serverCertificate for "'+e+'"'),new Promise(function(l,d){var c={responseType:"arraybuffer",url:a},h=t.certLoadPolicy.default,f={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},p={onSuccess:function(E,b,A,w){l(E.data)},onError:function(E,b,A,w){d(new Ui({type:oe.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:A,response:y({url:c.url,data:void 0},E)},'"'+e+'" certificate request failed ('+a+"). Status: "+E.code+" ("+E.text+")"))},onTimeout:function(E,b,A){d(new Ui({type:oe.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:A,response:{url:c.url,data:void 0}},'"'+e+'" certificate request timed out ('+a+")"))},onAbort:function(E,b,A){d(new Error("aborted"))}};i.load(c,f,p)})):Promise.resolve()},s.setMediaKeysServerCertificate=function(e,t,i){var a=this;return new Promise(function(l,d){e.setServerCertificate(i).then(function(c){a.log("setServerCertificate "+(c?"success":"not supported by CDM")+" ("+(i==null?void 0:i.byteLength)+') on "'+t+'"'),l(e)}).catch(function(c){d(new Ui({type:oe.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:c,fatal:!0},c.message))})})},s.renewLicense=function(e,t){var i=this;return this.requestLicense(e,new Uint8Array(t)).then(function(a){return i.updateKeySession(e,new Uint8Array(a)).catch(function(l){throw new Ui({type:oe.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:l,fatal:!0},l.message)})})},s.setupLicenseXHR=function(e,t,i,a){var l=this,d=this.config.licenseXhrSetup;return d?Promise.resolve().then(function(){if(!i.decryptdata)throw new Error("Key removed");return d.call(l.hls,e,t,i,a)}).catch(function(c){if(!i.decryptdata)throw c;return e.open("POST",t,!0),d.call(l.hls,e,t,i,a)}).then(function(c){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:c||a}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:a}))},s.requestLicense=function(e,t){var i=this,a=this.config.keyLoadPolicy.default;return new Promise(function(l,d){var c=i.getLicenseServerUrl(e.keySystem);i.log("Sending license request to URL: "+c);var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=function(){if(!i.hls||!e.mediaKeysSession)return d(new Error("invalid state"));if(h.readyState===4)if(h.status===200){i._requestLicenseFailureCount=0;var f=h.response;i.log("License received "+(f instanceof ArrayBuffer?f.byteLength:f));var p=i.config.licenseResponseCallback;if(p)try{f=p.call(i.hls,h,c,e)}catch(w){i.error(w)}l(f)}else{var E=a.errorRetry,b=E?E.maxNumRetry:0;if(i._requestLicenseFailureCount++,i._requestLicenseFailureCount>b||h.status>=400&&h.status<500)d(new Ui({type:oe.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:h,response:{url:c,data:void 0,code:h.status,text:h.statusText}},"License Request XHR failed ("+c+"). Status: "+h.status+" ("+h.statusText+")"));else{var A=b-i._requestLicenseFailureCount+1;i.warn("Retrying license request, "+A+" attempts left"),i.requestLicense(e,t).then(l,d)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=h,i.setupLicenseXHR(h,c,e,t).then(function(f){var p=f.xhr,E=f.licenseChallenge;p.send(E)})})},s.onMediaAttached=function(e,t){if(this.config.emeEnabled){var i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}},s.onMediaDetached=function(){var e=this,t=this.media,i=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},ba.clearKeyUriToKeyIdMap();var a=i.length;u.CDMCleanupPromise=Promise.all(i.map(function(l){return e.removeSession(l)}).concat(t==null?void 0:t.setMediaKeys(null).catch(function(l){e.log("Could not clear media keys: "+l+". media.src: "+(t==null?void 0:t.src))}))).then(function(){a&&(e.log("finished closing key sessions and clearing media keys"),i.length=0)}).catch(function(l){e.log("Could not close sessions and clear media keys: "+l+". media.src: "+(t==null?void 0:t.src))})},s.onManifestLoading=function(){this.keyFormatPromise=null},s.onManifestLoaded=function(e,t){var i=t.sessionKeys;if(i&&this.config.emeEnabled&&!this.keyFormatPromise){var a=i.reduce(function(l,d){return l.indexOf(d.keyFormat)===-1&&l.push(d.keyFormat),l},[]);this.log("Selecting key-system from session-keys "+a.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(a)}},s.removeSession=function(e){var t=this,i=e.mediaKeysSession,a=e.licenseXhr;if(i){this.log("Remove licenses and keys and close session "+i.sessionId),i.onmessage=null,i.onkeystatuseschange=null,a&&a.readyState!==XMLHttpRequest.DONE&&a.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var l=this.mediaKeySessions.indexOf(e);return l>-1&&this.mediaKeySessions.splice(l,1),i.remove().catch(function(d){t.log("Could not remove session: "+d)}).then(function(){return i.close()}).catch(function(d){t.log("Could not close session: "+d)})}},u}();gf.CDMCleanupPromise=void 0;var Ui=function(u){function s(e,t){var i;return(i=u.call(this,t)||this).data=void 0,e.error||(e.error=new Error(t)),i.data=e,e.err=e.error,i}return z(s,u),s}(Te(Error)),Fg="m",tl="a",_d="v",Ad="av",Ef="i",Ug="tt",Bg=function(){function u(e){var t=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){t.initialized&&(t.starved=!0),t.buffering=!0},this.onPlaying=function(){t.initialized||(t.initialized=!0),t.buffering=!1},this.applyPlaylistData=function(l){try{t.apply(l,{ot:Fg,su:!t.initialized})}catch(d){B.warn("Could not generate manifest CMCD data.",d)}},this.applyFragmentData=function(l){try{var d=l.frag,c=t.hls.levels[d.level],h=t.getObjectType(d),f={d:1e3*d.duration,ot:h};h!==_d&&h!==tl&&h!=Ad||(f.br=c.bitrate/1e3,f.tb=t.getTopBandwidth(h)/1e3,f.bl=t.getBufferLength(h)),t.apply(l,f)}catch(p){B.warn("Could not generate segment CMCD data.",p)}},this.hls=e;var i=this.config=e.config,a=i.cmcd;a!=null&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=a.sessionId||u.uuid(),this.cid=a.contentId,this.useHeaders=a.useHeaders===!0,this.registerListeners())}var s=u.prototype;return s.registerListeners=function(){var e=this.hls;e.on(k.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(k.MEDIA_DETACHED,this.onMediaDetached,this),e.on(k.BUFFER_CREATED,this.onBufferCreated,this)},s.unregisterListeners=function(){var e=this.hls;e.off(k.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(k.MEDIA_DETACHED,this.onMediaDetached,this),e.off(k.BUFFER_CREATED,this.onBufferCreated,this)},s.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},s.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},s.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},s.onBufferCreated=function(e,t){var i,a;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(a=t.tracks.video)==null?void 0:a.buffer},s.createData=function(){var e;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},s.apply=function(e,t){t===void 0&&(t={}),H(t,this.createData());var i=t.ot===Ef||t.ot===_d||t.ot===Ad;if(this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){var a=u.toHeaders(t);if(!Object.keys(a).length)return;e.headers||(e.headers={}),H(e.headers,a)}else{var l=u.toQuery(t);if(!l)return;e.url=u.appendQueryToUri(e.url,l)}},s.getObjectType=function(e){var t=e.type;return t==="subtitle"?Ug:e.sn==="initSegment"?Ef:t==="audio"?tl:t==="main"?this.hls.audioTracks.length?_d:Ad:void 0},s.getTopBandwidth=function(e){var t,i=0,a=this.hls;if(e===tl)t=a.audioTracks;else{var l=a.maxAutoLevel,d=l>-1?l+1:a.levels.length;t=a.levels.slice(0,d)}for(var c,h=ye(t);!(c=h()).done;){var f=c.value;f.bitrate>i&&(i=f.bitrate)}return i>0?i:NaN},s.getBufferLength=function(e){var t=this.hls.media,i=e===tl?this.audioBuffer:this.videoBuffer;return i&&t?1e3*he.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len:NaN},s.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,i=e||this.config.loader;return function(){function a(d){this.loader=void 0,this.loader=new i(d)}var l=a.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(d,c,h){t(d),this.loader.load(d,c,h)},M(a,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),a}()},s.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,i=e||this.config.loader;return function(){function a(d){this.loader=void 0,this.loader=new i(d)}var l=a.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(d,c,h){t(d),this.loader.load(d,c,h)},M(a,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),a}()},u.uuid=function(){var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)},u.serialize=function(e){for(var t,i=[],a=function(w){return!Number.isNaN(w)&&w!=null&&w!==""&&w!==!1},l=function(w){return Math.round(w)},d=function(w){return 100*l(w/100)},c={br:l,d:l,bl:d,dl:d,mtp:d,nor:function(w){return encodeURIComponent(w)},rtp:d,tb:l},h=ye(Object.keys(e||{}).sort());!(t=h()).done;){var f=t.value,p=e[f];if(a(p)&&!(f==="v"&&p===1||f=="pr"&&p===1)){var E=c[f];E&&(p=E(p));var b=typeof p,A=void 0;A=f==="ot"||f==="sf"||f==="st"?f+"="+p:b==="boolean"?f:b==="number"?f+"="+p:f+"="+JSON.stringify(p),i.push(A)}}return i.join(",")},u.toHeaders=function(e){for(var t={},i=["Object","Request","Session","Status"],a=[{},{},{},{}],l={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},d=0,c=Object.keys(e);d<c.length;d++){var h=c[d];a[l[h]!=null?l[h]:1][h]=e[h]}for(var f=0;f<a.length;f++){var p=u.serialize(a[f]);p&&(t["CMCD-"+i[f]]=p)}return t},u.toQuery=function(e){return"CMCD="+encodeURIComponent(u.serialize(e))},u.appendQueryToUri=function(e,t){if(!t)return e;var i=e.includes("?")?"&":"?";return""+e+i+t},u}(),Hg=function(){function u(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=B.log.bind(B,"[content-steering]:"),this.registerListeners()}var s=u.prototype;return s.registerListeners=function(){var e=this.hls;e.on(k.MANIFEST_LOADING,this.onManifestLoading,this),e.on(k.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(k.MANIFEST_PARSED,this.onManifestParsed,this),e.on(k.ERROR,this.onError,this)},s.unregisterListeners=function(){var e=this.hls;e&&(e.off(k.MANIFEST_LOADING,this.onManifestLoading,this),e.off(k.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(k.MANIFEST_PARSED,this.onManifestParsed,this),e.off(k.ERROR,this.onError,this))},s.startLoad=function(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){var e=Math.max(1e3*this.timeToLoad-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}else this.loadSteeringManifest(this.uri)},s.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)},s.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},s.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter(function(i){return i!==e}))},s.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},s.onManifestLoaded=function(e,t){var i=t.contentSteering;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())},s.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},s.onError=function(e,t){var i=t.errorAction;if((i==null?void 0:i.action)===_&&i.flags===R){var a=this.pathwayPriority,l=this.pathwayId;this.penalizedPathways[l]||(this.penalizedPathways[l]=performance.now()),!a&&this.levels&&(a=this.levels.reduce(function(d,c){return d.indexOf(c.pathwayId)===-1&&d.push(c.pathwayId),d},[])),a&&a.length>1&&(this.updatePathwayPriority(a),i.resolved=this.pathwayId!==l)}},s.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){var 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},s.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(t){return e===t.pathwayId})},s.updatePathwayPriority=function(e){var t;this.pathwayPriority=e;var i=this.penalizedPathways,a=performance.now();Object.keys(i).forEach(function(p){a-i[p]>3e5&&delete i[p]});for(var l=0;l<e.length;l++){var d=e[l];if(!i[d]){if(d===this.pathwayId)return;var c=this.hls.nextLoadLevel,h=this.hls.levels[c];if((t=this.getLevelsForPathway(d)).length>0){this.log('Setting Pathway to "'+d+'"'),this.pathwayId=d,this.hls.trigger(k.LEVELS_UPDATED,{levels:t});var f=this.hls.levels[c];h&&f&&this.levels&&(f.attrs["STABLE-VARIANT-ID"]!==h.attrs["STABLE-VARIANT-ID"]&&f.bitrate!==h.bitrate&&this.log("Unstable Pathways change from bitrate "+h.bitrate+" to "+f.bitrate),this.hls.nextLoadLevel=c);break}}}},s.clonePathways=function(e){var t=this,i=this.levels;if(i){var a={},l={};e.forEach(function(d){var c=d.ID,h=d["BASE-ID"],f=d["URI-REPLACEMENT"];if(!i.some(function(E){return E.pathwayId===c})){var p=t.getLevelsForPathway(h).map(function(E){var b=H({},E);b.details=void 0,b.url=bf(E.uri,E.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f);var A=new nt(E.attrs);A["PATHWAY-ID"]=c;var w=A.AUDIO&&A.AUDIO+"_clone_"+c,D=A.SUBTITLES&&A.SUBTITLES+"_clone_"+c;w&&(a[A.AUDIO]=w,A.AUDIO=w),D&&(l[A.SUBTITLES]=D,A.SUBTITLES=D),b.attrs=A;var S=new wa(b);return $(S,"audio",w),$(S,"text",D),S});i.push.apply(i,p),yf(t.audioTracks,a,f,c),yf(t.subtitleTracks,l,f,c)}})}},s.loadSteeringManifest=function(e){var t,i=this,a=this.hls.config,l=a.loader;this.loader&&this.loader.destroy(),this.loader=new l(a);try{t=new self.URL(e)}catch{return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if(t.protocol!=="data:"){var d=0|(this.hls.bandwidthEstimate||a.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+d)}var c={responseType:"json",url:t.href},h=a.steeringManifestLoadPolicy.default,f=h.errorRetry||h.timeoutRetry||{},p={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:f.maxNumRetry||0,retryDelay:f.retryDelayMs||0,maxRetryDelay:f.maxRetryDelayMs||0},E={onSuccess:function(b,A,w,D){i.log('Loaded steering manifest: "'+t+'"');var S=b.data;if(S.VERSION===1){i.updated=performance.now(),i.timeToLoad=S.TTL;var L=S["RELOAD-URI"],N=S["PATHWAY-CLONES"],P=S["PATHWAY-PRIORITY"];if(L)try{i.uri=new self.URL(L,t).href}catch{return i.enabled=!1,void i.log("Failed to parse Steering Manifest RELOAD-URI: "+L)}i.scheduleRefresh(i.uri||w.url),N&&i.clonePathways(N),P&&i.updatePathwayPriority(P)}else i.log("Steering VERSION "+S.VERSION+" not supported!")},onError:function(b,A,w,D){if(i.log("Error loading steering manifest: "+b.code+" "+b.text+" ("+A.url+")"),i.stopLoad(),b.code===410)return i.enabled=!1,void i.log("Steering manifest "+A.url+" no longer available");var S=1e3*i.timeToLoad;if(b.code!==429)i.scheduleRefresh(i.uri||A.url,S);else{var L=i.loader;if(typeof(L==null?void 0:L.getResponseHeader)=="function"){var N=L.getResponseHeader("Retry-After");N&&(S=1e3*parseFloat(N))}i.log("Steering manifest "+A.url+" rate limited")}},onTimeout:function(b,A,w){i.log("Timeout loading steering manifest ("+A.url+")"),i.scheduleRefresh(i.uri||A.url)}};this.log("Requesting steering manifest: "+t),this.loader.load(c,p,E)},s.scheduleRefresh=function(e,t){var i=this;t===void 0&&(t=1e3*this.timeToLoad),self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(function(){i.loadSteeringManifest(e)},t)},u}();function yf(u,s,e,t){u&&Object.keys(s).forEach(function(i){var a=u.filter(function(l){return l.groupId===i}).map(function(l){var d=H({},l);return d.details=void 0,d.attrs=new nt(d.attrs),d.url=d.attrs.URI=bf(l.url,l.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),d.groupId=d.attrs["GROUP-ID"]=s[i],d.attrs["PATHWAY-ID"]=t,d});u.push.apply(u,a)})}function bf(u,s,e,t){var i,a=t.HOST,l=t.PARAMS,d=t[e];s&&(i=d==null?void 0:d[s])&&(u=i);var c=new self.URL(u);return a&&!i&&(c.host=a),l&&Object.keys(l).sort().forEach(function(h){h&&c.searchParams.set(h,l[h])}),c.href}var Gg=/^age:\s*[\d.]+\s*$/im,Tf=function(){function u(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 Vt,this.retryDelay=0}var s=u.prototype;return s.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},s.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))},s.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},s.load=function(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()},s.loadInternal=function(){var e=this,t=this.config,i=this.context;if(t){var a=this.loader=new self.XMLHttpRequest,l=this.stats;l.loading.first=0,l.loaded=0;var d=this.xhrSetup;d?Promise.resolve().then(function(){if(!e.stats.aborted)return d(a,i.url)}).catch(function(c){return a.open("GET",i.url,!0),d(a,i.url)}).then(function(){e.stats.aborted||e.openAndSendXhr(a,i,t)}).catch(function(c){e.callbacks.onError({code:a.status,text:c.message},i,a,l)}):this.openAndSendXhr(a,i,t)}},s.openAndSendXhr=function(e,t,i){e.readyState||e.open("GET",t.url,!0);var a=this.context.headers,l=i.loadPolicy,d=l.maxTimeToFirstByteMs,c=l.maxLoadTimeMs;if(a)for(var h in a)e.setRequestHeader(h,a[h]);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=d&&re(d)?d:c,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()},s.readystatechange=function(){var e=this.context,t=this.loader,i=this.stats;if(e&&t){var a=t.readyState,l=this.config;if(!i.aborted&&a>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),l.timeout!==l.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),l.timeout=l.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),l.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),a===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var d=t.status,c=t.responseType!=="text";if(d>=200&&d<300&&(c&&t.response||t.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);var h=c?t.response:t.responseText,f=t.responseType==="arraybuffer"?h.byteLength:h.length;if(i.loaded=i.total=f,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first),!this.callbacks)return;var p=this.callbacks.onProgress;if(p&&p(i,e,h,t),!this.callbacks)return;var E={url:t.responseURL,data:h,code:d};this.callbacks.onSuccess(E,i,e,t)}else{var b=l.loadPolicy.errorRetry;cn(b,i.retry,!1,d)?this.retry(b):(B.error(d+" while loading "+e.url),this.callbacks.onError({code:d,text:t.statusText},e,t,i))}}}},s.loadtimeout=function(){var e,t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry;if(cn(t,this.stats.retry,!0))this.retry(t);else{B.warn("timeout while loading "+this.context.url);var i=this.callbacks;i&&(this.abortInternal(),i.onTimeout(this.stats,this.context,this.loader))}},s.retry=function(e){var t=this.context,i=this.stats;this.retryDelay=ys(e,i.retry),i.retry++,B.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)},s.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},s.getCacheAge=function(){var e=null;if(this.loader&&Gg.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},s.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},u}(),Vg=/(\d+)-(\d+)\/(\d+)/,_f=function(){function u(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||Kg,this.controller=new self.AbortController,this.stats=new Vt}var s=u.prototype;return s.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},s.abortInternal=function(){var e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())},s.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},s.load=function(e,t,i){var a=this,l=this.stats;if(l.loading.start)throw new Error("Loader can only be used once.");l.loading.start=self.performance.now();var d=function(A,w){var D={method:"GET",mode:"cors",credentials:"same-origin",signal:w,headers:new self.Headers(H({},A.headers))};return A.rangeEnd&&D.headers.set("Range","bytes="+A.rangeStart+"-"+String(A.rangeEnd-1)),D}(e,this.controller.signal),c=i.onProgress,h=e.responseType==="arraybuffer",f=h?"byteLength":"length",p=t.loadPolicy,E=p.maxTimeToFirstByteMs,b=p.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,d),self.clearTimeout(this.requestTimeout),t.timeout=E&&re(E)?E:b,this.requestTimeout=self.setTimeout(function(){a.abortInternal(),i.onTimeout(l,e,a.response)},t.timeout),self.fetch(this.request).then(function(A){a.response=a.loader=A;var w=Math.max(self.performance.now(),l.loading.start);if(self.clearTimeout(a.requestTimeout),t.timeout=b,a.requestTimeout=self.setTimeout(function(){a.abortInternal(),i.onTimeout(l,e,a.response)},b-(w-l.loading.start)),!A.ok){var D=A.status,S=A.statusText;throw new Wg(S||"fetch, bad network response",D,A)}return l.loading.first=w,l.total=function(L){var N=L.get("Content-Range");if(N){var P=function(Y){var j=Vg.exec(Y);if(j)return parseInt(j[2])-parseInt(j[1])+1}(N);if(re(P))return P}var V=L.get("Content-Length");if(V)return parseInt(V)}(A.headers)||l.total,c&&re(t.highWaterMark)?a.loadProgressively(A,l,e,t.highWaterMark,c):h?A.arrayBuffer():e.responseType==="json"?A.json():A.text()}).then(function(A){var w=a.response;self.clearTimeout(a.requestTimeout),l.loading.end=Math.max(self.performance.now(),l.loading.first);var D=A[f];D&&(l.loaded=l.total=D);var S={url:w.url,data:A,code:w.status};c&&!re(t.highWaterMark)&&c(l,e,A,w),i.onSuccess(S,l,e,w)}).catch(function(A){if(self.clearTimeout(a.requestTimeout),!l.aborted){var w=A&&A.code||0,D=A?A.message:null;i.onError({code:w,text:D},e,A?A.details:null,l)}})},s.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},s.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},s.loadProgressively=function(e,t,i,a,l){a===void 0&&(a=0);var d=new Xh,c=e.body.getReader();return function h(){return c.read().then(function(f){if(f.done)return d.dataLength&&l(t,i,d.flush(),e),Promise.resolve(new ArrayBuffer(0));var p=f.value,E=p.length;return t.loaded+=E,E<a||d.dataLength?(d.push(p),d.dataLength>=a&&l(t,i,d.flush(),e)):l(t,i,p,e),h()}).catch(function(){return Promise.reject()})}()},u}();function Kg(u,s){return new self.Request(u.url,s)}var Wg=function(u){function s(e,t,i){var a;return(a=u.call(this,e)||this).code=void 0,a.details=void 0,a.code=t,a.details=i,a}return z(s,u),s}(Te(Error)),qg=/\s/,Yg=y(y({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,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:Tf,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:ug,bufferController:gg,capLevelController:Og,errorController:O,fpsController:Ng,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:$r,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},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},{cueHandler:{newCue:function(u,s,e,t){for(var i,a,l,d,c,h=[],f=self.VTTCue||self.TextTrackCue,p=0;p<t.rows.length;p++)if(l=!0,d=0,c="",!(i=t.rows[p]).isEmpty()){for(var E,b=0;b<i.chars.length;b++)qg.test(i.chars[b].uchar)&&l?d++:(c+=i.chars[b].uchar,l=!1);i.cueStartTime=s,s===e&&(e+=1e-4),d>=16?d--:d++;var A=df(c.trim()),w=gd(s,e,A);u!=null&&(E=u.cues)!=null&&E.getCueById(w)||((a=new f(s,e,A)).id=w,a.line=p+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*d/32)),h.push(a))}return u&&h.length&&(h.sort(function(D,S){return D.line==="auto"||S.line==="auto"?0:D.line>8&&S.line>8?S.line-D.line:D.line-S.line}),h.forEach(function(D){return Uo(u,D)})),h}},enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:fg,subtitleTrackController:pg,timelineController:xg,audioStreamController:dg,audioTrackController:cg,emeController:gf,cmcdController:Bg,contentSteeringController:Hg});function Sd(u){return u&&typeof u=="object"?Array.isArray(u)?u.map(Sd):Object.keys(u).reduce(function(s,e){return s[e]=Sd(u[e]),s},{}):u}function $g(u){var s=u.loader;s!==_f&&s!==Tf?(B.log("[config]: Custom loader detected, cannot enable progressive streaming"),u.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}()&&(u.loader=_f,u.progressive=!0,u.enableSoftwareAES=!0,B.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Af=function(){function u(e){e===void 0&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Xo,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,it(e.debug||!1,"Hls instance");var t=this.config=function(ce,le){if((le.liveSyncDurationCount||le.liveMaxLatencyDurationCount)&&(le.liveSyncDuration||le.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(le.liveMaxLatencyDurationCount!==void 0&&(le.liveSyncDurationCount===void 0||le.liveMaxLatencyDurationCount<=le.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(le.liveMaxLatencyDuration!==void 0&&(le.liveSyncDuration===void 0||le.liveMaxLatencyDuration<=le.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var Ae=Sd(ce),xe=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(Le){var Me=(Le==="level"?"playlist":Le)+"LoadPolicy",Oe=le[Me]===void 0,Pe=[];xe.forEach(function(Ke){var je=Le+"Loading"+Ke,et=le[je];if(et!==void 0&&Oe){Pe.push(je);var lt=Ae[Me].default;switch(le[Me]={default:lt},Ke){case"TimeOut":lt.maxLoadTimeMs=et,lt.maxTimeToFirstByteMs=et;break;case"MaxRetry":lt.errorRetry.maxNumRetry=et,lt.timeoutRetry.maxNumRetry=et;break;case"RetryDelay":lt.errorRetry.retryDelayMs=et,lt.timeoutRetry.retryDelayMs=et;break;case"MaxRetryTimeout":lt.errorRetry.maxRetryDelayMs=et,lt.timeoutRetry.maxRetryDelayMs=et}}}),Pe.length&&B.warn('hls.js config: "'+Pe.join('", "')+'" setting(s) are deprecated, use "'+Me+'": '+JSON.stringify(le[Me]))}),y(y({},Ae),le)}(u.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&$g(t);var i=t.abrController,a=t.bufferController,l=t.capLevelController,d=t.errorController,c=t.fpsController,h=new d(this),f=this.abrController=new i(this),p=this.bufferController=new a(this),E=this.capLevelController=new l(this),b=new c(this),A=new Pt(this),w=new $u(this),D=t.contentSteeringController,S=D?new D(this):null,L=this.levelController=new G(this,S),N=new we(this),P=new St(this.config),V=this.streamController=new og(this,N,P);E.setStreamController(V),b.setStreamController(V);var Y=[A,L,V];S&&Y.splice(1,0,S),this.networkControllers=Y;var j=[f,p,E,b,w,N];this.audioTrackController=this.createController(t.audioTrackController,Y);var ie=t.audioStreamController;ie&&Y.push(new ie(this,N,P)),this.subtitleTrackController=this.createController(t.subtitleTrackController,Y);var Q=t.subtitleStreamController;Q&&Y.push(new Q(this,N,P)),this.createController(t.timelineController,j),P.emeController=this.emeController=this.createController(t.emeController,j),this.cmcdController=this.createController(t.cmcdController,j),this.latencyController=this.createController(ju,j),this.coreComponents=j,Y.push(h);var X=h.onErrorOut;typeof X=="function"&&this.on(k.ERROR,X,h)}u.isSupported=function(){return function(){var e=sn();if(!e)return!1;var t=Ch(),i=e&&typeof e.isTypeSupported=="function"&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),a=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!i&&!!a}()};var s=u.prototype;return s.createController=function(e,t){if(e){var i=new e(this);return t&&t.push(i),i}return null},s.on=function(e,t,i){i===void 0&&(i=this),this._emitter.on(e,t,i)},s.once=function(e,t,i){i===void 0&&(i=this),this._emitter.once(e,t,i)},s.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},s.off=function(e,t,i,a){i===void 0&&(i=this),this._emitter.off(e,t,i,a)},s.listeners=function(e){return this._emitter.listeners(e)},s.emit=function(e,t,i){return this._emitter.emit(e,t,i)},s.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){B.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(k.ERROR,{type:oe.OTHER_ERROR,details:q.INTERNAL_EXCEPTION,fatal:!1,event:e,error:i})}return!1},s.listenerCount=function(e){return this._emitter.listenerCount(e)},s.destroy=function(){B.log("destroy"),this.trigger(k.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(t){return t.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(t){return t.destroy()}),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},s.attachMedia=function(e){B.log("attachMedia"),this._media=e,this.trigger(k.MEDIA_ATTACHING,{media:e})},s.detachMedia=function(){B.log("detachMedia"),this.trigger(k.MEDIA_DETACHING,void 0),this._media=null},s.loadSource=function(e){this.stopLoad();var t=this.media,i=this.url,a=this.url=Ge.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});B.log("loadSource:"+a),t&&i&&(i!==a||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(k.MANIFEST_LOADING,{url:e})},s.startLoad=function(e){e===void 0&&(e=-1),B.log("startLoad("+e+")"),this.networkControllers.forEach(function(t){t.startLoad(e)})},s.stopLoad=function(){B.log("stopLoad"),this.networkControllers.forEach(function(e){e.stopLoad()})},s.swapAudioCodec=function(){B.log("swapAudioCodec"),this.streamController.swapAudioCodec()},s.recoverMediaError=function(){B.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},s.removeLevel=function(e,t){t===void 0&&(t=0),this.levelController.removeLevel(e,t)},M(u,[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){B.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){B.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){B.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){B.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){B.log("set startLevel:"+e),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(B.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){ms.indexOf(e)>-1&&(this._maxHdcpLevel=e)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var i=e.length,a=0;a<i;a++)if(e[a].maxBitrate>=t)return a;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,i=this.autoLevelCapping,a=this.maxHdcpLevel;if(e=i===-1&&t&&t.length?t.length-1:i,a)for(var l=e;l--;){var d=t[l].attrs["HDCP-LEVEL"];if(d&&d<=a)return l}return e}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.4.5"}},{key:"Events",get:function(){return k}},{key:"ErrorTypes",get:function(){return oe}},{key:"ErrorDetails",get:function(){return q}},{key:"DefaultConfig",get:function(){return u.defaultConfig?u.defaultConfig:Yg},set:function(e){u.defaultConfig=e}}]),u}();return Af.defaultConfig=void 0,Af},typeof yp=="object"&&typeof Kc!="undefined"?Kc.exports=m():typeof define=="function"&&define.amd?define(m):(o=typeof globalThis!="undefined"?globalThis:o||self).Hls=m()})(!1)});var yn=class{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}};if(typeof DocumentFragment=="undefined"){class n extends yn{}globalThis.DocumentFragment=n}var ws=class extends yn{},Id=class extends yn{},oE={get(n){},define(n,r,o){},upgrade(n){},whenDefined(n){return Promise.resolve(ws)}},Ls,Rd=class{constructor(r,o={}){Ht(this,Ls,void 0);Gi(this,Ls,o==null?void 0:o.detail)}get detail(){return ot(this,Ls)}initCustomEvent(){}};Ls=new WeakMap;function lE(n,r){return new ws}var Cf={document:{createElement:lE},DocumentFragment,customElements:oE,CustomEvent:Rd,EventTarget:yn,HTMLElement:ws,HTMLVideoElement:Id},Mf=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Yt=Mf?Cf:globalThis,Mi=Mf?Cf.document:globalThis.document;var Ie={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_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},Ne={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},Na={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",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"},xf=Object.entries(Na),F=xf.reduce((n,[r,o])=>(n[r]=`${o.toLowerCase()}`,n),{}),bn=xf.reduce((n,[r,o])=>(n[r]=`${o.toLowerCase()}`,n),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange"}),ub=Object.entries(bn).reduce((n,[r,o])=>{let m=F[r];return m&&(n[o]=m),n},{userinactivechange:"userinactive"}),Pf=Object.entries(F).reduce((n,[r,o])=>{let m=bn[r];return m&&(n[o]=m),n},{userinactive:"userinactivechange"}),Tn={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},al={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var Dd={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Cr={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},Zi={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var si={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:n=1}={})=>`current playback rate ${n}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading"},bt={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:n=30}={})=>`seek forward ${n} seconds`,SEEK_BACK_N_SECS:({seekOffset:n=30}={})=>`seek back ${n} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"},dE={...si,...bt};function nl(n,r=!1){return n.split("_").map(function(o,m){return(m||r?o[0].toUpperCase():o[0].toLowerCase())+o.slice(1).toLowerCase()}).join("")}function Of(n){return n.replace(/[-_]([a-z])/g,(r,o)=>o.toUpperCase())}function Nf(n){return typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n)}function sl(n){return typeof n!="string"?!1:!isNaN(n)&&!isNaN(parseFloat(n))}var ol=n=>new Promise(r=>setTimeout(r,n));var Ff=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],cE=(n,r)=>{let o=n===1?Ff[r].singular:Ff[r].plural;return`${n} ${o}`},Fa=n=>{if(!Nf(n))return"";let r=Math.abs(n),o=r!==n,m=new Date(0,0,0,0,0,r,0);return`${[m.getHours(),m.getMinutes(),m.getSeconds()].map((M,U)=>M&&cE(M,U)).filter(M=>M).join(", ")}${o?" remaining":""}`};function ur(n,r){let o=!1;n<0&&(o=!0,n=0-n),n=n<0?0:n;let m=Math.floor(n%60),v=Math.floor(n/60%60),y=Math.floor(n/3600),I=Math.floor(r/60%60),M=Math.floor(r/3600);return(isNaN(n)||n===1/0)&&(y=v=m="-"),y=y>0||M>0?y+":":"",v=((y||I>=10)&&v<10?"0"+v:v)+":",m=m<10?"0"+m:m,(o?"-":"")+y+v+m}var fb=Object.freeze({length:0,start(n){let r=n>>>0;if(r>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${r}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(n){let r=n>>>0;if(r>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${r}) is greater than or equal to the maximum bound (${this.length}).`);return 0}});var Uf=(n,r,o=".value")=>{let m=n.querySelector(o);!m||(m.textContent=r)},fE=(n,r)=>{let o=`slot[name="${r}"]`,m=n.shadowRoot.querySelector(o);return m?m.children:[]},Bf=(n,r)=>fE(n,r)[0],Is=(n,r)=>!n||!r?!1:n.contains(r)?!0:Is(n,r.getRootNode().host),Ua=(n,r)=>{if(!n)return null;let o=n.closest(r);return o||Ua(n.getRootNode().host,r)};function pt(n,r){var o;let m;for(m of n.querySelectorAll("style")){let v;try{v=(o=m.sheet)==null?void 0:o.cssRules}catch{continue}for(let y of v!=null?v:[])if(y.selectorText===r)return y}return m!=null&&m.sheet?(m.sheet.insertRule(`${r}{}`,m.sheet.cssRules.length),m.sheet.cssRules[m.sheet.cssRules.length-1]):{style:{setProperty:()=>{},removeProperty:()=>{}}}}function kt(n,r,o=Number.NaN){let m=n.getAttribute(r);return m!=null?+m:o}function Tt(n,r,o){let m=+o;if(o==null||Number.isNaN(m)){n.hasAttribute(r)&&n.removeAttribute(r);return}kt(n,r,void 0)!==m&&n.setAttribute(r,`${m}`)}function ht(n,r){return n.hasAttribute(r)}function ut(n,r,o){if(o==null){n.hasAttribute(r)&&n.removeAttribute(r);return}ht(n,r)!=o&&n.toggleAttribute(r,o)}function Gt(n,r,o=null){var m;return(m=n.getAttribute(r))!=null?m:o}function Dt(n,r,o){if(o==null){n.hasAttribute(r)&&n.removeAttribute(r);return}let m=`${o}`;Gt(n,r,void 0)!==m&&n.setAttribute(r,m)}var ll=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},Cd=class{observe(){}},Hf={ResizeObserver:Cd,HTMLElement:class extends ll{},DocumentFragment:class extends ll{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},CustomEvent:function(){},getComputedStyle:function(){},requestAnimationFrame:function(n){return 1},queueMicrotask:function(n){}},mE={createElement:function(){return new Hf.HTMLElement},addEventListener(){},removeEventListener(){}},Gf=typeof window=="undefined"||typeof window.customElements=="undefined",W=Gf?Hf:window,ae=Gf?mE:window.document;var pE=Object.defineProperty,vE=(n,r,o)=>r in n?pE(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o,gE=(n,r,o)=>(vE(n,typeof r!="symbol"?r+"":r,o),o),Vf=(n,r,o)=>{if(!r.has(n))throw TypeError("Cannot "+o)},Vi=(n,r,o)=>(Vf(n,r,"read from private field"),o?o.call(n):r.get(n)),ul=(n,r,o)=>{if(r.has(n))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(n):r.set(n,o)},dl=(n,r,o,m)=>(Vf(n,r,"write to private field"),m?m.call(n,o):r.set(n,o),o),dr,cl,_n,hl,Kf=ae.createElement("template");Kf.innerHTML=`
|
|
1
|
+
"use strict";(()=>{var wv=Object.create;var Oh=Object.defineProperty;var kv=Object.getOwnPropertyDescriptor;var Dv=Object.getOwnPropertyNames;var Cv=Object.getPrototypeOf,Mv=Object.prototype.hasOwnProperty;var Ov=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Pv=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Dv(e))!Mv.call(r,s)&&s!==t&&Oh(r,s,{get:()=>e[s],enumerable:!(i=kv(e,s))||i.enumerable});return r};var Nv=(r,e,t)=>(t=r!=null?wv(Cv(r)):{},Pv(e||!r||!r.__esModule?Oh(t,"default",{value:r,enumerable:!0}):t,r));var Sl=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var Oe=(r,e,t)=>(Sl(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)},ti=(r,e,t,i)=>(Sl(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var Et=(r,e,t)=>(Sl(r,e,"access private method"),t);var Am=Ov((no,Bd)=>{(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 xv}});var l=o(48),d=o.n(l),u=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)})},c=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||c()),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]"],I=0;I<arguments.length;I++)_.push(arguments[I]);b.apply(void 0,_)}},E().setLevel(E().getLevel());var A=E();function L(){return(d().doNotTrack||d().navigator&&d().navigator.doNotTrack)==="1"}var S={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)}},P=function(v){return k(v)[0]},k=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 M(v,f,p){p=p===void 0?1:p,v[f]=v[f]||0,v[f]+=p}var G=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],W=["x-cdn","content-type"].concat(G);function O(v){var f={};return(v=v||"").trim().split(/[\r\n]+/).forEach(function(p){if(p){var b=p.split(": "),_=b.shift();_&&(W.indexOf(_.toLowerCase())>=0||_.toLowerCase().indexOf("x-litix-")===0)&&(f[_]=b.join(": "))}}),f}function z(v){if(v){var f=G.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 be(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 ge(v){for(var f=1;f<arguments.length;f++){var p=arguments[f]!=null?arguments[f]:{};f%2?be(Object(p),!0).forEach(function(b){ve(v,b,p[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):be(Object(p)).forEach(function(b){Object.defineProperty(v,b,Object.getOwnPropertyDescriptor(p,b))})}return v}function ve(v,f,p){return f in v?Object.defineProperty(v,f,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[f]=p,v}var Re=function(v){if(!v)return{};var f=$.navigationStart(),p=v.loading,b=p?p.start:v.trequest,_=p?p.first:v.tfirst,I=p?p.end:v.tload;return{bytesLoaded:v.total,requestStart:Math.round(f+b),responseStart:Math.round(f+_),responseEnd:Math.round(f+I)}},Te=function(v){if(v&&typeof v.getAllResponseHeaders=="function")return O(v.getAllResponseHeaders())};function Q(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 ie(v){for(var f=1;f<arguments.length;f++){var p=arguments[f]!=null?arguments[f]:{};f%2?Q(Object(p),!0).forEach(function(b){re(v,b,p[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Q(Object(p)).forEach(function(b){Object.defineProperty(v,b,Object.getOwnPropertyDescriptor(p,b))})}return v}function re(v,f,p){return f in v?Object.defineProperty(v,f,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[f]=p,v}var _e=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],I=P(_.url),x=_.url,w=_.bytesLoaded,U=new Date(_.requestStartDate).getTime(),D=new Date(_.firstByteDate).getTime(),V=new Date(_.requestEndDate).getTime(),pe=isNaN(_.duration)?0:_.duration,oe=typeof f.getMetricsFor=="function"?f.getMetricsFor(_.mediaType).HttpList:f.getDashMetrics().getHttpRequests(_.mediaType);return oe.length>0&&(b=O(oe[oe.length-1]._responseHeaders||"")),{requestStart:U,requestResponseStart:D,requestResponseEnd:V,requestBytesLoaded:w,requestResponseHeaders:b,requestMediaDuration:pe,requestHostname:I,requestUrl:x,requestId:b?z(b):void 0}},Se=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}:{}},Ne=function(v){var f;return(f=v.match(/.*codecs\*?="(.*)"/))===null||f===void 0?void 0:f[1]};function ut(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 H=0,Z=function(){function v(){(function(_,I){if(!(_ instanceof I))throw new TypeError("Cannot call a class as a function")})(this,v)}var f,p,b;return f=v,p=[{key:"on",value:function(_,I,x){return I._eventEmitterGuid=I._eventEmitterGuid||++H,this._listeners=this._listeners||{},this._listeners[_]=this._listeners[_]||[],x&&(I=I.bind(x)),this._listeners[_].push(I),I}},{key:"off",value:function(_,I){var x=this._listeners&&this._listeners[_];x&&x.forEach(function(w,U){w._eventEmitterGuid===I._eventEmitterGuid&&x.splice(U,1)})}},{key:"one",value:function(_,I,x){var w=this;I._eventEmitterGuid=I._eventEmitterGuid||++H;var U=function D(){w.off(_,D),I.apply(x||this,arguments)};U._eventEmitterGuid=I._eventEmitterGuid,this.on(_,U)}},{key:"emit",value:function(_,I){var x=this;if(this._listeners){I=I||{};var w=this._listeners["before*"]||[],U=this._listeners[_]||[],D=this._listeners["after"+_]||[],V=function(pe,oe){(pe=pe.slice()).forEach(function(de){de.call(x,{type:_},oe)})};V(w,I),V(U,I),V(D,I)}}}],p&&ut(f.prototype,p),b&&ut(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}(),Ie=Z;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 Tt=function(){function v(_){var I=this;(function(x,w){if(!(x instanceof w))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,_.on("playing",function(){I._playheadShouldBeProgressing=!0}),_.on("play",this._startPlaybackHeartbeatInterval.bind(this)),_.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),_.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),_.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),_.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),_.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),_.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),_.on("seeked",function(){_.data.player_is_paused?I._stopPlaybackHeartbeatInterval():I._startPlaybackHeartbeatInterval()}),_.on("timeupdate",function(){I._playbackHeartbeatInterval!==null&&_.emit("playbackheartbeat")}),_.on("devicesleep",function(x,w){I._playbackHeartbeatInterval!==null&&(d().clearInterval(I._playbackHeartbeatInterval),_.emit("playbackheartbeatend",{viewer_time:w.viewer_time}),I._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 zt(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 tr(v,f,p){return f&&zt(v.prototype,f),p&&zt(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Zt=tr(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 I=f.errorTranslator({player_error_code:_.player_error_code,player_error_message:_.player_error_message,player_error_context:_.player_error_context});I?(f.data.player_error_code=I.player_error_code||_.player_error_code,f.data.player_error_message=I.player_error_message||_.player_error_message,f.data.player_error_context=I.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(x){f.mux.log.warn("Exception in error translator callback.",x),p.viewErrored=!0}})});function Ei(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 yi=function(){function v(_){(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._watchTimeTrackerLastCheckedTime=null,_.on("playbackheartbeat",this._updateWatchTime.bind(this)),_.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var f,p,b;return f=v,(p=[{key:"_updateWatchTime",value:function(_,I){var x=I.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=x),M(this.pm.data,"view_watch_time",x-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=x}},{key:"_clearWatchTimeState",value:function(_,I){this._updateWatchTime(_,I),this._watchTimeTrackerLastCheckedTime=null}}])&&Ei(f.prototype,p),b&&Ei(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}();function Zr(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 Vs=function(){function v(_){(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,this._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 I=_-this._playbackTimeTrackerLastPlayheadPosition;I<=1e3&&M(this.pm.data,"view_content_playback_time",I)}this._playbackTimeTrackerLastPlayheadPosition=_}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&Zr(f.prototype,p),b&&Zr(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 Je=function(){function v(_){(function(x,w){if(!(x instanceof w))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_;var I=this._updatePlayheadTime.bind(this);_.on("playbackheartbeat",I),_.on("playbackheartbeatend",I),_.on("timeupdate",I),_.on("destroy",function(){_.off("timeupdate",I)})}var 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(_,I){var x=this,w=function(){x.pm.currentFragmentPDT&&x.pm.currentFragmentStart&&(x.pm.data.player_program_time=x.pm.currentFragmentPDT+x.pm.data.player_playhead_time-x.pm.currentFragmentStart)};if(I&&I.player_playhead_time)this.pm.data.player_playhead_time=I.player_playhead_time,w(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var U=this.pm.getPlayheadTime();U!==void 0&&(this.pm.data.player_playhead_time=U,w(),this._updateMaxPlayheadPosition())}}}])&&li(f.prototype,p),b&&li(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}();function _r(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 Ks(v,f,p){return f&&_r(v.prototype,f),p&&_r(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Ws=3e5,ea=Ks(function v(f){if(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")}(this,v),!f.disableRebufferTracking){var p,b=function(I,x){_(x),p=void 0},_=function(I){if(p){var x=I.viewer_time-p;M(f.data,"view_rebuffer_duration",x),p=I.viewer_time,f.data.view_rebuffer_duration>Ws&&(f.emit("viewend"),f.send("viewend"),f.mux.log.warn("Ending view after rebuffering for longer than ".concat(Ws,"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(I,x){return _(x)}),f.on("rebufferstart",function(I,x){p||(M(f.data,"view_rebuffer_count",1),p=x.viewer_time,f.one("rebufferend",b))}),f.on("viewinit",function(){p=void 0,f.off("rebufferend",b)})}});function qs(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 b0=function(){function v(_){var I=this;(function(x,w){if(!(x instanceof w))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.disableRebufferTracking||_.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,_.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),_.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),_.on("seeking",function(){I._cleanupRebufferTracker(null,{viewer_time:S.now()})}))}var f,p,b;return f=v,p=[{key:"_checkIfRebuffering",value:function(_,I){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(_,I);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var x=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&x>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=I.viewer_time}else this._cleanupRebufferTracker(_,I,!0);else this._prepareRebufferTrackerState(I.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(_){this._lastCheckedTime=_,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=_}},{key:"_cleanupRebufferTracker",value:function(_,I){var x=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:I.viewer_time});else{if(this._lastCheckedTime===null)return;var w=this.pm.data.player_playhead_time-this._lastPlayheadTime,U=I.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&w>0&&U-w>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+U-w}))}x?this._prepareRebufferTrackerState(I.viewer_time):this._clearRebufferTrackerState()}}],p&&qs(f.prototype,p),b&&qs(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}(),T0=b0;function sh(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 _0=function(){function v(_){var I=this;(function(x,w){if(!(x instanceof w))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){var x=_.data,w=x.view_id;if(!x.view_program_changed){var U=function(D,V){var pe=V.viewer_time;D.type==="playing"&&_.data.view_time_to_first_frame===void 0?I.calculateTimeToFirstFrame(pe||S.now(),w):D.type!=="adplaying"||_.data.view_time_to_first_frame!==void 0&&!I._inPrerollPosition()||I.calculateTimeToFirstFrame(pe||S.now(),w)};_.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(_,I){I===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:_}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}])&&sh(f.prototype,p),b&&sh(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}();function nh(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 A0(v,f,p){return f&&nh(v.prototype,f),p&&nh(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var S0=A0(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 I=Math.min(p._lastPlayerWidth/p._lastSourceWidth,p._lastPlayerHeight/p._lastSourceHeight),x=Math.max(0,I-1),w=Math.max(0,1-I);f.data.view_max_upscale_percentage=Math.max(f.data.view_max_upscale_percentage||0,x),f.data.view_max_downscale_percentage=Math.max(f.data.view_max_downscale_percentage||0,w),M(f.data,"view_total_content_playback_time",_),M(f.data,"view_total_upscaling",x*_),M(f.data,"view_total_downscaling",w*_)}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 ah(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 x0(v,f,p){return f&&ah(v.prototype,f),p&&ah(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var I0=x0(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=S.now(),p.isSeeking===!1&&(p.isSeeking=!0,f.send("seeking"))}),f.on("seeked",function(){p.isSeeking=!1;var b=p._lastSeekingTime||S.now(),_=S.now()-b;M(f.data,"view_seek_count",1),M(f.data,"view_seek_duration",_);var I=f.data.view_max_seek_time||0;f.data.view_max_seek_time=Math.max(I,_)}),f.on("viewend",function(){p.isSeeking=!1})});function oh(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 I,x,w=[],U=!0,D=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(w.push(I.value),!b||w.length!==b);U=!0);}catch(V){D=!0,x=V}finally{try{U||_.return==null||_.return()}finally{if(D)throw x}}return w}}(v,f)||function(p,b){if(p){if(typeof p=="string")return lh(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(_)?lh(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 lh(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 dh(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 uh=function(v,f){v.push(f),v.sort(function(p,b){return p.viewer_time-b.viewer_time})},L0=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],R0=function(){function v(_){var I=this;(function(w,U){if(!(w instanceof U))throw new TypeError("Cannot call a class as a function")})(this,v),this.pm=_,_.on("viewinit",function(){I.isAdBreak=!1,I._currentAdRequestNumber=0,I._currentAdResponseNumber=0,I._adRequests=[],I._adResponses=[],I._adHasPlayed=!1,I._wouldBeNewAdPlay=!0,I._prerollPlayTime=void 0}),L0.forEach(function(w){return _.on(w,I._updateAdData.bind(I))});var x=function(){I.isAdBreak=!1};_.on("adbreakstart",function(){I.isAdBreak=!0}),_.on("play",x),_.on("playing",x),_.on("viewend",x),_.on("adrequest",function(w,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdRequestNumber++},U),uh(I._adRequests,U),M(_.data,"view_ad_request_count"),I.inPrerollPosition()&&(_.data.view_preroll_requested=!0,I._adHasPlayed||M(_.data,"view_preroll_request_count"))}),_.on("adresponse",function(w,U){U=Object.assign({ad_request_id:"generatedAdRequestId"+I._currentAdResponseNumber++},U),uh(I._adResponses,U);var D=I.findAdRequest(U.ad_request_id);D&&M(_.data,"view_ad_request_time",Math.max(0,U.viewer_time-D.viewer_time))}),_.on("adplay",function(w,U){I._adHasPlayed=!0,I._wouldBeNewAdPlay&&(I._wouldBeNewAdPlay=!1,M(_.data,"view_ad_played_count")),I.inPrerollPosition()&&!_.data.view_preroll_played&&(_.data.view_preroll_played=!0,I._adRequests.length>0&&(_.data.view_preroll_request_time=Math.max(0,U.viewer_time-I._adRequests[0].viewer_time)),_.data.view_start&&(_.data.view_startup_preroll_request_time=Math.max(0,U.viewer_time-_.data.view_start)),I._prerollPlayTime=U.viewer_time)}),_.on("adplaying",function(w,U){I.inPrerollPosition()&&_.data.view_preroll_load_time===void 0&&I._prerollPlayTime!==void 0&&(_.data.view_preroll_load_time=U.viewer_time-I._prerollPlayTime,_.data.view_startup_preroll_load_time=U.viewer_time-I._prerollPlayTime)}),_.on("adended",function(){I._wouldBeNewAdPlay=!0}),_.on("aderror",function(){I._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 I=0;I<this._adRequests.length;I++)if(this._adRequests[I].ad_request_id===_)return this._adRequests[I]}},{key:"_updateAdData",value:function(_,I){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&I.ad_tag_url){var x=oh(k(I.ad_tag_url),2),w=x[0],U=x[1];this.pm.data.view_preroll_ad_tag_domain=U,this.pm.data.view_preroll_ad_tag_hostname=w}if(!this.pm.data.view_preroll_ad_asset_hostname&&I.ad_asset_url){var D=oh(k(I.ad_asset_url),2),V=D[0],pe=D[1];this.pm.data.view_preroll_ad_asset_domain=pe,this.pm.data.view_preroll_ad_asset_hostname=V}}this.pm.data.ad_asset_url=I==null?void 0:I.ad_asset_url,this.pm.data.ad_tag_url=I==null?void 0:I.ad_tag_url,this.pm.data.ad_creative_id=I==null?void 0:I.ad_creative_id,this.pm.data.ad_id=I==null?void 0:I.ad_id,this.pm.data.ad_universal_id=I==null?void 0:I.ad_universal_id}}])&&dh(f.prototype,p),b&&dh(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}();function ch(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 w0(v,f,p){return f&&ch(v.prototype,f),p&&ch(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var k0=w0(function v(f){var p,b;(function(w,U){if(!(w instanceof U))throw new TypeError("Cannot call a class as a function")})(this,v);var _=function(){f.disableRebufferTracking||p&&(M(f.data,"view_waiting_rebuffer_duration",S.now()-p),p=!1,d().clearInterval(b))},I=!1,x=function(){I=!1,_()};f.on("waiting",function(){I&&(f.disableRebufferTracking||(M(f.data,"view_waiting_rebuffer_count",1),p=S.now(),b=d().setInterval(function(){if(p){var w=S.now();M(f.data,"view_waiting_rebuffer_duration",w-p),p=w}},250)))}),f.on("playing",function(){_(),I=!0}),f.on("pause",x),f.on("seeking",x)});function hh(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 D0(v,f,p){return f&&hh(v.prototype,f),p&&hh(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var C0=D0(function v(f){var p=this;(function(I,x){if(!(I instanceof x))throw new TypeError("Cannot call a class as a function")})(this,v);var b=function(){p.lastWallClockTime=S.now(),f.on("before*",_)},_=function(I){var x=S.now(),w=p.lastWallClockTime;p.lastWallClockTime=x,x-w>3e4&&(f.emit("devicesleep",{viewer_time:w}),Object.assign(f.data,{viewer_time:w}),f.send("devicesleep"),f.emit("devicewake",{viewer_time:x}),Object.assign(f.data,{viewer_time:x}),f.send("devicewake"))};f.one("playbackheartbeat",b),f.on("playbackheartbeatend",function(){f.off("before*",_),f.one("playbackheartbeat",b)})}),fh=o(375),M0=o(655),mh=o.n(M0),ph="muxData",gh=function(){var v;try{v=fh.parse(mh().get(ph)||"")}catch{v={}}return v},vh=function(v){try{mh().set(ph,fh.stringify(v),{expires:7300})}catch{}},O0=function(){var v=gh();return v.mux_viewer_id=v.mux_viewer_id||u(),v.msn=v.msn||Math.random(),vh(v),{mux_viewer_id:v.mux_viewer_id,mux_sample_number:v.msn}};function P0(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 Eh=function(){var v;switch(yh()){case"cellular":v="cellular";break;case"ethernet":v="wired";break;case"wifi":v="wifi";break;case void 0:break;default:v="other"}return v},yh=function(){var v=d().navigator,f=v&&(v.connection||v.mozConnection||v.webkitConnection);return f&&f.type};Eh.getConnectionFromAPI=yh;var N0=Eh,F0=Th({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"}),bh=Th({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 Th(v){var f={};for(var p in v)v.hasOwnProperty(p)&&(f[v[p]]=p);return f}function El(v){var f={},p={};return Object.keys(v).forEach(function(b){var _=!1;if(v.hasOwnProperty(b)&&v[b]!==void 0){var I=b.split("_"),x=I[0],w=F0[x];w||(A.info("Data key word `"+I[0]+"` not expected in "+b),w=x+"_"),I.splice(1).forEach(function(U){U==="url"&&(_=!0),bh[U]?w+=bh[U]:Number(U)&&Math.floor(Number(U))===Number(U)?w+=U:(A.info("Data key word `"+U+"` not expected in "+b),w+="_"+U+"_")}),_?p[w]=v[b]:f[w]=v[b]}}),Object.assign(f,p)}var U0={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},B0=["hb","requestcompleted","requestfailed","requestcanceled"],$0="https://img.litix.io",Ni=function(v){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=v||$0,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},U0,f)};Ni.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)},Ni.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())},Ni.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)},Ni.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],El({mux_view_message:"event queue truncated"}));var p=this._createPayload(f);_h(this._beaconUrl,p,!0,function(){})},Ni.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=S.now();_h(this._beaconUrl,p,!1,function(_,I){I?(v._eventQueue=f.concat(v._eventQueue),v._failureCount+=1,A.info("Error sending beacon: "+I)):v._failureCount=0,v._roundTripTime=S.now()-b,v._postInFlight=!1})}},Ni.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},Ni.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()))},Ni.prototype._createPayload=function(v){var f,p,b,_=this,I={transmission_timestamp:Math.round(S.now())};this._roundTripTime&&(I.rtt_ms=Math.round(this._roundTripTime));var x=function(){f=JSON.stringify({metadata:I,events:p||v}),b=f.length/1024},w=function(){return b<=_._options.maxPayloadKBSize};return x(),w()||(A.info("Payload size is too big ("+b+" kb). Removing unnecessary events."),p=v.filter(function(U){return B0.indexOf(U.e)===-1}),x()),w()||(A.info("Payload size still too big ("+b+" kb). Cropping fields.."),p.forEach(function(U){for(var D in U){var V=U[D];typeof V=="string"&&V.length>51200&&(U[D]=V.substring(0,51200))}}),x()),f};var G0=function(v){return v.length<=57344},_h=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:G0(f)}).then(function(I){return b(null,I.ok?null:"Error")}).catch(function(I){return b(null,I)});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()}},H0=Ni;function V0(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 I,x,w=[],U=!0,D=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(w.push(I.value),!b||w.length!==b);U=!0);}catch(V){D=!0,x=V}finally{try{U||_.return==null||_.return()}finally{if(D)throw x}}return w}}(v,f)||function(p,b){if(p){if(typeof p=="string")return Ah(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(_)?Ah(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 Ah(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 Sh(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 Jr(v){for(var f=1;f<arguments.length;f++){var p=arguments[f]!=null?arguments[f]:{};f%2?Sh(Object(p),!0).forEach(function(b){ta(v,b,p[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(p)):Sh(Object(p)).forEach(function(b){Object.defineProperty(v,b,Object.getOwnPropertyDescriptor(p,b))})}return v}function Ys(v){return Ys=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},Ys(v)}function K0(v,f){if(!(v instanceof f))throw new TypeError("Cannot call a class as a function")}function xh(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 ta(v,f,p){return f in v?Object.defineProperty(v,f,{value:p,enumerable:!0,configurable:!0,writable:!0}):v[f]=p,v}var W0=["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"],q0=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse"],Y0=["viewstart","error","ended","viewend"],j0=function(){function v(_,I){var x,w,U,D,V,pe,oe,de,ae,he,De,_t,At,Ft,ei,ke=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};K0(this,v),ta(this,"previousBeaconData",null),ta(this,"lastEventTime",0),ta(this,"rateLimited",!1),this.mux=_,this.envKey=I,this.options=ke,this.eventQueue=new H0(P0(this.envKey,this.options)),this.sampleRate=(x=this.options.sampleRate)!==null&&x!==void 0?x:1,this.disableCookies=(w=this.options.disableCookies)!==null&&w!==void 0&&w,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:(D=this.options.platform)===null||D===void 0?void 0:D.name,viewer_application_version:(V=this.options.platform)===null||V===void 0?void 0:V.version,viewer_application_engine:(pe=this.options.platform)===null||pe===void 0?void 0:pe.layout,viewer_device_name:(oe=this.options.platform)===null||oe===void 0?void 0:oe.product,viewer_device_category:"",viewer_device_manufacturer:(de=this.options.platform)===null||de===void 0?void 0:de.manufacturer,viewer_os_family:(ae=this.options.platform)===null||ae===void 0||(he=ae.os)===null||he===void 0?void 0:he.family,viewer_os_architecture:(De=this.options.platform)===null||De===void 0||(_t=De.os)===null||_t===void 0?void 0:_t.architecture,viewer_os_version:(At=this.options.platform)===null||At===void 0||(Ft=At.os)===null||Ft===void 0?void 0:Ft.version,viewer_connection_type:N0(),page_url:d()===null||d()===void 0||(ei=d().location)===null||ei===void 0?void 0:ei.href},this.viewerData=this.disableCookies?{}:O0()}var f,p,b;return f=v,(p=[{key:"send",value:function(_,I){var x;if(_&&I!=null&&I.view_id){if(this.respectDoNotTrack&&L())return A.info("Not sending `"+_+"` because Do Not Track is enabled");if(!I||Ys(I)!=="object")return A.error("A data object was expected in send() but was not provided");var w,U,D=this.disableCookies?{}:(w=gh(),U=S.now(),w.session_start&&(w.sst=w.session_start,delete w.session_start),w.session_id&&(w.sid=w.session_id,delete w.session_id),w.session_expires&&(w.sex=w.session_expires,delete w.session_expires),(!w.sex||w.sex<U)&&(w.sid=u(),w.sst=U),w.sex=U+15e5,vh(w),{session_id:w.sid,session_start:w.sst,session_expires:w.sex}),V=Jr(Jr(Jr(Jr(Jr({},this.pageLevelData),I),D),this.viewerData),{},{event:_,env_key:this.envKey});V.user_id&&(V.viewer_user_id=V.user_id,delete V.user_id);var pe=((x=V.mux_sample_number)!==null&&x!==void 0?x:0)>=this.sampleRate,oe=El(this._deduplicateBeaconData(_,V));if(this.lastEventTime=this.mux.utils.now(),pe)return A.info("Not sending event due to sample rate restriction",_,V,oe);if(this.envKey||A.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",_,V,oe),!this.rateLimited){if(A.info("Sending event",_,V,oe),this.rateLimited=!this.eventQueue.queueEvent(_,oe),this.mux.WINDOW_UNLOADING&&_==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&_==="hb"?this.eventQueue.flushEvents(!0):Y0.indexOf(_)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return V.event="eventrateexceeded",oe=El(V),this.eventQueue.queueEvent(V.event,oe),A.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(_,I){var x=this,w={},U=I.view_id;if(U==="-1"||_==="viewstart"||_==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)w=Jr({},I),U&&(this.previousBeaconData=w),U&&_==="viewend"&&(this.previousBeaconData=null);else{var D=_.indexOf("request")===0;Object.entries(I).forEach(function(V){var pe=V0(V,2),oe=pe[0],de=pe[1];x.previousBeaconData&&(de!==x.previousBeaconData[oe]||W0.indexOf(oe)>-1||x.objectHasChanged(D,oe,de,x.previousBeaconData[oe])||x.eventRequiresKey(_,oe))&&(w[oe]=de,x.previousBeaconData[oe]=de)})}return w}},{key:"objectHasChanged",value:function(_,I,x,w){return!(!_||I.indexOf("request_")!==0||I!=="request_response_headers"&&Ys(x)==="object"&&Ys(w)==="object"&&Object.keys(x||{}).length===Object.keys(w||{}).length)}},{key:"eventRequiresKey",value:function(_,I){return _==="renditionchange"&&I.indexOf("video_source_")===0||!(I.indexOf("ad_id")!==0||!q0.includes(_))}}])&&xh(f.prototype,p),b&&xh(f,b),Object.defineProperty(f,"prototype",{writable:!1}),v}();function Ih(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 z0(v,f,p){return f&&Ih(v.prototype,f),p&&Ih(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var X0=z0(function v(f){(function(D,V){if(!(D instanceof V))throw new TypeError("Cannot call a class as a function")})(this,v);var p=0,b=0,_=0,I=0,x=0,w=0,U=0;f.on("requestcompleted",function(D,V){var pe,oe,de=V.request_start,ae=V.request_response_start,he=V.request_response_end,De=V.request_bytes_loaded;if(I++,ae?(pe=ae-(de!=null?de:0),oe=(he!=null?he:0)-ae):oe=(he!=null?he:0)-(de!=null?de:0),oe>0&&De&&De>0){var _t=De/oe*8e3;x++,b+=De,_+=oe,f.data.view_min_request_throughput=Math.min(f.data.view_min_request_throughput||1/0,_t),f.data.view_average_request_throughput=b/_*8e3,f.data.view_request_count=I,pe>0&&(p+=pe,f.data.view_max_request_latency=Math.max(f.data.view_max_request_latency||0,pe),f.data.view_average_request_latency=p/x)}}),f.on("requestfailed",function(D,V){I++,w++,f.data.view_request_count=I,f.data.view_request_failed_count=w}),f.on("requestcanceled",function(D,V){I++,U++,f.data.view_request_count=I,f.data.view_request_canceled_count=U})});function Lh(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 Q0(v,f,p){return f&&Lh(v.prototype,f),p&&Lh(v,p),Object.defineProperty(v,"prototype",{writable:!1}),v}var Z0=Q0(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 I=_.viewer_time,x=S.now(),w=p._lastEventTime;if(p._lastEventTime=x,w&&x-w>36e5){var U=Object.keys(f.data).reduce(function(D,V){return V.indexOf("video_")===0?Object.assign(D,function(pe,oe,de){return oe in pe?Object.defineProperty(pe,oe,{value:de,enumerable:!0,configurable:!0,writable:!0}):pe[oe]=de,pe}({},V,f.data[V])):D},{});f.mux.log.info("Received event after at least an hour inactivity, creating a new view"),f.emit("viewinit",Object.assign({viewer_time:I},U)),f.playbackHeartbeat._playheadShouldBeProgressing&&b.type!=="play"&&b.type!=="adbreakstart"&&(f.emit("play",{viewer_time:I}),b.type!=="playing"&&f.emit("playing",{viewer_time:I}))}})});function yl(v){return yl=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},yl(v)}function J0(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 I,x,w=[],U=!0,D=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(w.push(I.value),!b||w.length!==b);U=!0);}catch(V){D=!0,x=V}finally{try{U||_.return==null||_.return()}finally{if(D)throw x}}return w}}(v,f)||function(p,b){if(p){if(typeof p=="string")return Rh(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(_)?Rh(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 Rh(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 wh(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 bl(v,f){return bl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,b){return p.__proto__=b,p},bl(v,f)}function ev(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=ia(v);if(f){var _=ia(this).constructor;p=Reflect.construct(b,arguments,_)}else p=b.apply(this,arguments);return tv(this,p)}}function tv(v,f){if(f&&(yl(f)==="object"||typeof f=="function"))return f;if(f!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return pt(v)}function pt(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function ia(v){return ia=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(f){return f.__proto__||Object.getPrototypeOf(f)},ia(v)}var iv=["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"],rv=function(v){(function(x,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function");x.prototype=Object.create(w&&w.prototype,{constructor:{value:x,writable:!0,configurable:!0}}),Object.defineProperty(x,"prototype",{writable:!1}),w&&bl(x,w)})(I,v);var f,p,b,_=ev(I);function I(x,w,U){var D;(function(ae,he){if(!(ae instanceof he))throw new TypeError("Cannot call a class as a function")})(this,I),(D=_.call(this)).DOM_CONTENT_LOADED_EVENT_END=$.domContentLoadedEventEnd(),D.NAVIGATION_START=$.navigationStart(),D.mux=x,D.id=w,(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(ae){return ae}},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"),D.getPlayheadTime=U.getPlayheadTime,D.getStateData=U.getStateData||function(){return{}},D.getAdData=U.getAdData||function(){},D.minimumRebufferDuration=U.minimumRebufferDuration,D.sustainedRebufferThreshold=U.sustainedRebufferThreshold,D.playbackHeartbeatTime=U.playbackHeartbeatTime,D.disableRebufferTracking=U.disableRebufferTracking,D.disableRebufferTracking&&D.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),D.disablePlayheadRebufferTracking=U.disablePlayheadRebufferTracking,D.errorTranslator=U.errorTranslator,D.playbackEventDispatcher=new j0(x,U.data.env_key,U),D.data={player_instance_id:u(),mux_sample_rate:U.sampleRate,beacon_domain:U.beaconCollectionDomain?U.beaconCollectionDomain:U.beaconDomain},D.data.view_sequence_number=1,D.data.player_sequence_number=1,D.oldEmit=D.emit,D.emit=function(ae,he){he=Object.assign({viewer_time:this.mux.utils.now()},he),this.oldEmit(ae,he)};var V=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(pt(D));D.on("viewinit",function(ae,he){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,he),this._initializeViewData(),this.one("play",V),this.one("adbreakstart",V)});var pe=function(ae){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",ae)}.bind(pt(D));if(D.on("videochange",function(ae,he){pe(he)}),D.on("programchange",function(ae,he){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."),pe(Object.assign(he,{view_program_changed:!0})),V(),this.emit("play"),this.emit("playing")}),D.on("fragmentchange",function(ae,he){this.currentFragmentPDT=he.currentFragmentPDT,this.currentFragmentStart=he.currentFragmentStart}),D.on("destroy",D.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var oe=function(){var ae=D.data.view_start!==void 0;D.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",ae&&D.mux.WINDOW_HIDDEN&&(D.data.player_is_paused||D.emit("hb"))};window.addEventListener("visibilitychange",oe,!1);var de=function(ae){ae.persisted||D.destroy()};window.addEventListener("pagehide",de,!1),D.on("destroy",function(){window.removeEventListener("visibilitychange",oe),window.removeEventListener("pagehide",de)})}return D.on("playerready",function(ae,he){Object.assign(this.data,he)}),iv.forEach(function(ae){D.on(ae,function(he,De){ae.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,De),this._sanitizeData()}),D.on("after"+ae,function(){(ae!=="error"||this.errorTracker.viewErrored)&&this.send(ae)})}),D.on("viewend",function(ae,he){Object.assign(D.data,he)}),D.one("playerready",function(ae){var he=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=he-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),D.longResumeTracker=new Z0(pt(D)),D.errorTracker=new Zt(pt(D)),new C0(pt(D)),D.seekingTracker=new I0(pt(D)),D.playheadTime=new Je(pt(D)),D.playbackHeartbeat=new Tt(pt(D)),new S0(pt(D)),D.watchTimeTracker=new yi(pt(D)),new Vs(pt(D)),D.adTracker=new R0(pt(D)),new T0(pt(D)),new ea(pt(D)),new _0(pt(D)),new k0(pt(D)),new X0(pt(D)),U.hlsjs&&D.addHLSJS(U),U.dashjs&&D.addDashJS(U),D.emit("viewinit",U.data),D}return f=I,p=[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(x){if(this.data.view_id){var w=Object.assign({},this.data);if(w.video_source_is_live===void 0&&(w.player_source_duration===1/0||w.video_source_duration===1/0?w.video_source_is_live=!0:(w.player_source_duration>0||w.video_source_duration>0)&&(w.video_source_is_live=!1)),w.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(pe){w[pe]=void 0}),w.video_source_url=w.video_source_url||w.player_source_url,w.video_source_url){var U=J0(k(w.video_source_url),2),D=U[0],V=U[1];w.video_source_domain=V,w.video_source_hostname=D}delete w.ad_request_id,this.playbackEventDispatcher.send(x,w),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),x==="viewend"&&delete this.data.view_id}}},{key:"_updateStateData",value:function(){Object.assign(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var x=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(w){var U=parseInt(x.data[w],10);x.data[w]=isNaN(U)?void 0:U}),["player_source_url","video_source_url"].forEach(function(w){if(x.data[w]){var U=x.data[w].toLowerCase();U.indexOf("data:")!==0&&U.indexOf("blob:")!==0||(x.data[w]="MSE style URL")}})}},{key:"_resetVideoData",value:function(x,w){var U=this;Object.keys(this.data).forEach(function(D){D.indexOf("video_")===0&&delete U.data[D]})}},{key:"_resetViewData",value:function(){var x=this;Object.keys(this.data).forEach(function(w){w.indexOf("view_")===0&&delete x.data[w]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(x,w){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var x=this,w=this.data.view_id=u(),U=function(){w===x.data.view_id&&M(x.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",U):U()}},{key:"_restartHeartBeat",value:function(){var x=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){x.data.player_is_paused||x.emit("hb")},1e4))}},{key:"addHLSJS",value:function(x){x.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=x.hlsjs,function(w,U,D){var V=arguments.length>4?arguments[4]:void 0,pe=w.log,oe=w.utils.secondsToMs,de=function(Ce){var X,ue=parseInt(V.version);return ue===1&&Ce.programDateTime!==null&&(X=Ce.programDateTime),ue===0&&Ce.pdt!==null&&(X=Ce.pdt),X};if($.exists()){var ae=function(Ce,X){return w.emit(U,Ce,X)},he=function(Ce,X){var ue=X.levels,J=X.audioTracks,ye=X.url,we=X.stats,ot=X.networkDetails,Ut=X.sessionData,St={},Ct={};ue.forEach(function(ct,Qs){St[Qs]={width:ct.width,height:ct.height,bitrate:ct.bitrate,attrs:ct.attrs}}),J.forEach(function(ct,Qs){Ct[Qs]={name:ct.name,language:ct.lang,bitrate:ct.bitrate}});var gt=Re(we),vt=gt.bytesLoaded,ir=gt.requestStart,Xs=gt.responseStart,Ar=gt.responseEnd;ae("requestcompleted",ge(ge({},j(Ut)),{},{request_event_type:Ce,request_bytes_loaded:vt,request_start:ir,request_response_start:Xs,request_response_end:Ar,request_type:"manifest",request_hostname:P(ye),request_response_headers:Te(ot),request_rendition_lists:{media:St,audio:Ct,video:{}}}))};D.on(V.Events.MANIFEST_LOADED,he);var De=function(Ce,X){var ue=X.details,J=X.level,ye=X.networkDetails,we=X.stats,ot=Re(we),Ut=ot.bytesLoaded,St=ot.requestStart,Ct=ot.responseStart,gt=ot.responseEnd,vt=ue.fragments[ue.fragments.length-1],ir=de(vt)+oe(vt.duration);ae("requestcompleted",{request_event_type:Ce,request_bytes_loaded:Ut,request_start:St,request_response_start:Ct,request_response_end:gt,request_current_level:J,request_type:"manifest",request_hostname:P(ue.url),request_response_headers:Te(ye),video_holdback:ue.holdBack&&oe(ue.holdBack),video_part_holdback:ue.partHoldBack&&oe(ue.partHoldBack),video_part_target_duration:ue.partTarget&&oe(ue.partTarget),video_target_duration:ue.targetduration&&oe(ue.targetduration),video_source_is_live:ue.live,player_manifest_newest_program_time:isNaN(ir)?void 0:ir})};D.on(V.Events.LEVEL_LOADED,De);var _t=function(Ce,X){var ue=X.details,J=X.networkDetails,ye=X.stats,we=Re(ye),ot=we.bytesLoaded,Ut=we.requestStart,St=we.responseStart,Ct=we.responseEnd;ae("requestcompleted",{request_event_type:Ce,request_bytes_loaded:ot,request_start:Ut,request_response_start:St,request_response_end:Ct,request_type:"manifest",request_hostname:P(ue.url),request_response_headers:Te(J)})};D.on(V.Events.AUDIO_TRACK_LOADED,_t);var At=function(Ce,X){var ue=X.stats,J=X.networkDetails,ye=X.frag;ue=ue||ye.stats;var we=Re(ue),ot=we.bytesLoaded,Ut=we.requestStart,St=we.responseStart,Ct=we.responseEnd,gt=J?Te(J):void 0,vt={request_event_type:Ce,request_bytes_loaded:ot,request_start:Ut,request_response_start:St,request_response_end:Ct,request_hostname:J?P(J.responseURL):void 0,request_id:gt?z(gt):void 0,request_response_headers:gt,request_media_duration:ye.duration,request_url:J==null?void 0:J.responseURL};ye.type==="main"?(vt.request_type="media",vt.request_current_level=ye.level,vt.request_video_width=(D.levels[ye.level]||{}).width,vt.request_video_height=(D.levels[ye.level]||{}).height,vt.request_labeled_bitrate=(D.levels[ye.level]||{}).bitrate):vt.request_type=ye.type,ae("requestcompleted",vt)};D.on(V.Events.FRAG_LOADED,At);var Ft=function(Ce,X){var ue=X.frag,J=ue.start,ye={currentFragmentPDT:de(ue),currentFragmentStart:oe(J)};ae("fragmentchange",ye)};D.on(V.Events.FRAG_CHANGED,Ft);var ei=function(Ce,X){var ue=X.type,J=X.details,ye=X.response,we=X.fatal,ot=X.frag,Ut=X.networkDetails,St=(ot==null?void 0:ot.url)||X.url||"",Ct=Ut?Te(Ut):void 0;if(J!==V.ErrorDetails.MANIFEST_LOAD_ERROR&&J!==V.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&J!==V.ErrorDetails.FRAG_LOAD_ERROR&&J!==V.ErrorDetails.FRAG_LOAD_TIMEOUT&&J!==V.ErrorDetails.LEVEL_LOAD_ERROR&&J!==V.ErrorDetails.LEVEL_LOAD_TIMEOUT&&J!==V.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&J!==V.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&J!==V.ErrorDetails.SUBTITLE_LOAD_ERROR&&J!==V.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&J!==V.ErrorDetails.KEY_LOAD_ERROR&&J!==V.ErrorDetails.KEY_LOAD_TIMEOUT||ae("requestfailed",{request_error:J,request_url:St,request_hostname:P(St),request_id:Ct?z(Ct):void 0,request_type:J===V.ErrorDetails.FRAG_LOAD_ERROR||J===V.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":J===V.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||J===V.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":J===V.ErrorDetails.SUBTITLE_LOAD_ERROR||J===V.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":J===V.ErrorDetails.KEY_LOAD_ERROR||J===V.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:ye==null?void 0:ye.code,request_error_text:ye==null?void 0:ye.text}),we){var gt,vt="".concat(St?"url: ".concat(St,`
|
|
5
|
+
`):"")+"".concat(ye&&(ye.code||ye.text)?"response: ".concat(ye.code,", ").concat(ye.text,`
|
|
6
|
+
`):"")+"".concat(X.reason?"failure reason: ".concat(X.reason,`
|
|
7
|
+
`):"")+"".concat(X.level?"level: ".concat(X.level,`
|
|
8
|
+
`):"")+"".concat(X.parent?"parent stream controller: ".concat(X.parent,`
|
|
9
|
+
`):"")+"".concat(X.buffer?"buffer length: ".concat(X.buffer,`
|
|
10
|
+
`):"")+"".concat(X.error?"error: ".concat(X.error,`
|
|
11
|
+
`):"")+"".concat(X.event?"event: ".concat(X.event,`
|
|
12
|
+
`):"")+"".concat(X.err?"error message: ".concat((gt=X.err)===null||gt===void 0?void 0:gt.message,`
|
|
13
|
+
`):"");ae("error",{player_error_code:ue,player_error_message:J,player_error_context:vt})}};D.on(V.Events.ERROR,ei);var ke=function(Ce,X){var ue=X.frag,J=ue&&ue._url||"";ae("requestcanceled",{request_event_type:Ce,request_url:J,request_type:"media",request_hostname:P(J)})};D.on(V.Events.FRAG_LOAD_EMERGENCY_ABORTED,ke);var st=function(Ce,X){var ue=X.level,J=D.levels[ue];if(J&&J.attrs&&J.attrs.BANDWIDTH){var ye,we=J.attrs.BANDWIDTH,ot=parseFloat(J.attrs["FRAME-RATE"]);isNaN(ot)||(ye=ot),we?ae("renditionchange",{video_source_fps:ye,video_source_bitrate:we,video_source_width:J.width,video_source_height:J.height,video_source_rendition_name:J.name,video_source_codec:J==null?void 0:J.videoCodec}):pe.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};D.on(V.Events.LEVEL_SWITCHED,st),D._stopMuxMonitor=function(){D.off(V.Events.MANIFEST_LOADED,he),D.off(V.Events.LEVEL_LOADED,De),D.off(V.Events.AUDIO_TRACK_LOADED,_t),D.off(V.Events.FRAG_LOADED,At),D.off(V.Events.FRAG_CHANGED,Ft),D.off(V.Events.ERROR,ei),D.off(V.Events.FRAG_LOAD_EMERGENCY_ABORTED,ke),D.off(V.Events.LEVEL_SWITCHED,st),D.off(V.Events.DESTROYING,D._stopMuxMonitor),delete D._stopMuxMonitor},D.on(V.Events.DESTROYING,D._stopMuxMonitor)}else pe.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,x.hlsjs,{},x.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var x;this.hlsjs&&((x=this.hlsjs)&&typeof x._stopMuxMonitor=="function"&&x._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(x){x.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=x.dashjs,function(w,U,D){var V=w.log;if(D&&D.on){var pe=function(ke,st){return w.emit(U,ke,st)},oe=function(ke){var st=ke.type,Ce=(ke.data||{}).url;pe("requestcompleted",{request_event_type:st,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:P(Ce),request_url:Ce})};D.on("manifestLoaded",oe);var de={},ae=function(ke){var st=ke.type,Ce=ke.fragmentModel,X=(ke.chunk||{}).mediaInfo||{},ue=X.type,J=X.bitrateList,ye={};(J=J||[]).forEach(function(Ar,ct){ye[ct]={},ye[ct].width=Ar.width,ye[ct].height=Ar.height,ye[ct].bitrate=Ar.bandwidth,ye[ct].attrs={}}),ue==="video"?de.video=ye:ue==="audio"?de.audio=ye:de.media=ye;var we=_e(Ce,D),ot=we.requestStart,Ut=we.requestResponseStart,St=we.requestResponseEnd,Ct=we.requestResponseHeaders,gt=we.requestMediaDuration,vt=we.requestHostname,ir=we.requestUrl,Xs=we.requestId;pe("requestcompleted",{request_event_type:st,request_start:ot,request_response_start:Ut,request_response_end:St,request_bytes_loaded:-1,request_type:ue+"_init",request_response_headers:Ct,request_hostname:vt,request_id:Xs,request_url:ir,request_media_duration:gt,request_rendition_lists:de})};D.on("initFragmentLoaded",ae);var he=function(ke){var st=ke.type,Ce=ke.fragmentModel,X=ke.chunk||{},ue=X.mediaInfo,J=X.start,ye=(ue||{}).type,we=_e(Ce,D),ot=we.requestStart,Ut=we.requestResponseStart,St=we.requestResponseEnd,Ct=we.requestBytesLoaded,gt=we.requestResponseHeaders,vt=we.requestMediaDuration,ir=we.requestHostname,Xs=we.requestUrl,Ar=we.requestId,ct=Se(ye,D),Qs=ct.currentLevel,Iv=ct.renditionWidth,Lv=ct.renditionHeight,Rv=ct.renditionBitrate;pe("requestcompleted",{request_event_type:st,request_start:ot,request_response_start:Ut,request_response_end:St,request_bytes_loaded:Ct,request_type:ye,request_response_headers:gt,request_hostname:ir,request_id:Ar,request_url:Xs,request_media_start_time:J,request_media_duration:vt,request_current_level:Qs,request_labeled_bitrate:Rv,request_video_width:Iv,request_video_height:Lv})};D.on("mediaFragmentLoaded",he);var De={video:void 0,audio:void 0,totalBitrate:void 0},_t=function(){if(De.video&&typeof De.video.bitrate=="number"){if(De.video.width&&De.video.height){var ke=De.video.bitrate;return De.audio&&typeof De.audio.bitrate=="number"&&(ke+=De.audio.bitrate),ke!==De.totalBitrate?(De.totalBitrate=ke,{video_source_bitrate:ke,video_source_height:De.video.height,video_source_width:De.video.width,video_source_codec:Ne(De.video.codec)}):void 0}V.warn("have bitrate info for video but missing width/height")}},At=function(ke,st,Ce){if(typeof ke.newQuality=="number"){var X=ke.mediaType;if(X==="audio"||X==="video"){var ue=D.getBitrateInfoListFor(X).find(function(ye){return ye.qualityIndex===ke.newQuality});if(ue&&typeof ue.bitrate=="number"){De[X]=ie(ie({},ue),{},{codec:D.getCurrentTrackFor(X).codec});var J=_t();J&&pe("renditionchange",J)}else V.warn("missing bitrate info for ".concat(X))}}else V.warn("missing evt.newQuality in qualityChangeRendered event",ke)};D.on("qualityChangeRendered",At);var Ft=function(ke){var st=ke.request,Ce=ke.mediaType;pe("requestcanceled",{request_event_type:(st=st||{}).type+"_"+st.action,request_url:st.url,request_type:Ce,request_hostname:P(st.url)})};D.on("fragmentLoadingAbandoned",Ft);var ei=function(ke){var st,Ce,X=ke.error,ue=(X==null||(st=X.data)===null||st===void 0?void 0:st.request)||{},J=(X==null||(Ce=X.data)===null||Ce===void 0?void 0:Ce.response)||{};(X==null?void 0:X.code)===27&&pe("requestfailed",{request_error:ue.type+"_"+ue.action,request_url:ue.url,request_hostname:P(ue.url),request_type:ue.mediaType,request_error_code:J.status,request_error_text:J.statusText});var ye="".concat(ue!=null&&ue.url?"url: ".concat(ue.url,`
|
|
14
|
+
`):"")+"".concat(J!=null&&J.status||J!=null&&J.statusText?"response: ".concat(J==null?void 0:J.status,", ").concat(J==null?void 0:J.statusText,`
|
|
15
|
+
`):"");pe("error",{player_error_code:X==null?void 0:X.code,player_error_message:X==null?void 0:X.message,player_error_context:ye})};D.on("error",ei),D._stopMuxMonitor=function(){D.off("manifestLoaded",oe),D.off("initFragmentLoaded",ae),D.off("mediaFragmentLoaded",he),D.off("qualityChangeRendered",At),D.off("error",ei),D.off("fragmentLoadingAbandoned",Ft),delete D._stopMuxMonitor}}else V.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,x.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var x;this.dashjs&&((x=this.dashjs)&&typeof x._stopMuxMonitor=="function"&&x._stopMuxMonitor(),this.dashjs=void 0)}}],p&&wh(f.prototype,p),b&&wh(f,b),Object.defineProperty(f,"prototype",{writable:!1}),I}(Ie),sv=rv,nv=o(153),js=o.n(nv);function Tl(v){return Tl=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},Tl(v)}function kh(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 I,x,w=[],U=!0,D=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(w.push(I.value),!b||w.length!==b);U=!0);}catch(V){D=!0,x=V}finally{try{U||_.return==null||_.return()}finally{if(D)throw x}}return w}}(v,f)||function(p,b){if(p){if(typeof p=="string")return Dh(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(_)?Dh(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 Dh(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 es,av=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],ov={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};d()&&d().WeakMap&&(es=new WeakMap);var lv="#EXT-X-TARGETDURATION",dv="#EXT-X-PART-INF",uv="#EXT-X-SERVER-CONTROL",cv="#EXTINF",hv="#EXT-X-PROGRAM-DATE-TIME",fv="#EXT-X-VERSION",mv="#EXT-X-SESSION-DATA",ra=function(v){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(v),this.manifest};ra.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)},ra.prototype.processLine=function(v){var f=v.indexOf(":"),p=Ev(v,f),b=p[0],_=p.length===2?Al(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 lv:if(!isFinite(_)||_<0)return;this.manifest.targetDuration=_,this.setHoldBack();break;case dv:_l(this.manifest,p),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case uv:_l(this.manifest,p),this.setHoldBack();break;case cv:_===0?this.currentUri.duration=.01:_>0&&(this.currentUri.duration=_);break;case hv:var I=_,x=new Date(I);this.manifest.dateTimeString||(this.manifest.dateTimeString=I,this.manifest.dateTimeObject=x),this.currentUri.dateTimeString=I,this.currentUri.dateTimeObject=x;break;case fv:_l(this.manifest,p);break;case mv:var w=yv(p[1]),U=j(w);Object.assign(this.manifest.sessionData,U)}},ra.prototype.setHoldBack=function(){var v=this.manifest,f=v.serverControl,p=v.targetDuration,b=v.partTargetDuration;if(f){var _="holdBack",I="partHoldBack",x=p&&3*p,w=b&&2*b;p&&!f.hasOwnProperty(_)&&(f[_]=x),x&&f[_]<x&&(f[_]=x),b&&!f.hasOwnProperty(I)&&(f[I]=3*b),b&&f[I]<w&&(f[I]=w)}};var _l=function(v,f){var p,b=Ch(f[0].replace("#EXT-X-",""));vv(f[1])?(p={},p=Object.assign(gv(f[1]),p)):p=Al(f[1]),v[b]=p},Ch=function(v){return v.toLowerCase().replace(/-(\w)/g,function(f){return f[1].toUpperCase()})},Al=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},pv=function(v){var f={},p=v.split("=");return p.length>1&&(f[Ch(p[0])]=Al(p[1])),f},gv=function(v){for(var f=v.split(","),p={},b=0;f.length>b;b++){var _=f[b],I=pv(_);p=Object.assign(I,p)}return p},vv=function(v){return v.indexOf("=")>-1},Ev=function(v,f){return f===-1?[v]:[v.substring(0,f),v.substring(f+1)]},yv=function(v){var f={};if(v){var p=v.search(",");return[v.slice(0,p),v.slice(p+1)].forEach(function(b,_){for(var I=b.replace(/['"]+/g,"").split("="),x=0;x<I.length;x++)I[x]==="DATA-ID"&&(f["DATA-ID"]=I[1-x]),I[x]==="VALUE"&&(f.VALUE=I[1-x])}),{data:f}}},bv=ra,Tv={safeCall:function(v,f,p,b){var _=b;if(v&&typeof v[f]=="function")try{_=v[f].apply(v,p)}catch(I){A.info("safeCall error",I)}return _},safeIncrement:M,getComputedStyle:function(v,f){var p;if(v&&f&&d()&&typeof d().getComputedStyle=="function")return es&&es.has(v)&&(p=es.get(v)),p||(p=d().getComputedStyle(v,null),es&&es.set(v,p)),p.getPropertyValue(f)},secondsToMs:function(v){return Math.floor(1e3*v)},assign:Object.assign,headersStringToObject:O,cdnHeadersToRequestId:z,extractHostnameAndDomain:k,extractHostname:P,manifestParser:bv,generateShortID:c,generateUUID:u,now:S.now},_v={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 Av(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 I,x,w=[],U=!0,D=!1;try{for(_=_.call(p);!(U=(I=_.next()).done)&&(w.push(I.value),!b||w.length!==b);U=!0);}catch(V){D=!0,x=V}finally{try{U||_.return==null||_.return()}finally{if(D)throw x}}return w}}(v,f)||function(p,b){if(p){if(typeof p=="string")return Mh(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(_)?Mh(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 Mh(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 Jt={},zs=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.")},Sv={loaded:S.now(),NAME:"mux-embed",VERSION:"4.24.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(v,f){return function(p,b,_){var I=kh(m(b),3),x=I[0],w=I[1],U=I[2],D=p.log,V=p.utils.getComputedStyle,pe=p.utils.secondsToMs;if(!x)return D.error("No element was found with the `"+w+"` query selector.");if(U!=="video"&&U!=="audio")return D.error("The element of `"+w+"` was not a media element.");x.mux&&(x.mux.destroy(),delete x.mux,D.warn("Already monitoring this video element, replacing existing event listeners")),(_=Object.assign({automaticErrorTracking:!0},_)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:p.VERSION},_.data),_.getPlayheadTime=function(){return pe(x.currentTime)},_.getStateData=function(){var de,ae,he=this.hlsjs&&this.hlsjs.url,De=this.dashjs&&Tl(this.dashjs.getSource==="function")&&this.dashjs.getSource(),_t={player_is_paused:x.paused,player_playhead_time:pe(x.currentTime),player_width:parseInt(V(x,"width")),player_height:parseInt(V(x,"height")),player_autoplay_on:x.autoplay,player_preload_on:x.preload,player_language_code:x.lang,player_is_fullscreen:js()&&!!(js().fullscreenElement||js().webkitFullscreenElement||js().mozFullScreenElement||js().msFullscreenElement),video_poster_url:x.poster,video_source_url:he||De||x.currentSrc,video_source_duration:pe(x.duration),video_source_height:x.videoHeight,video_source_width:x.videoWidth,view_dropped_frame_count:(de=x)===null||de===void 0||(ae=de.getVideoPlaybackQuality)===null||ae===void 0?void 0:ae.call(de).droppedVideoFrames},At=_.getPlayheadTime();if(x.getStartDate&&At>0){var Ft=x.getStartDate();if(Ft&&typeof Ft.getTime=="function"&&Ft.getTime()){var ei=Ft.getTime();if(_t.player_program_time=ei+At,x.seekable.length>0){var ke=ei+x.seekable.end(x.seekable.length-1);_t.player_live_edge_program_time=ke}}}return _t},x.mux=x.mux||{},x.mux.deleted=!1,x.mux.emit=function(de,ae){p.emit(w,de,ae)};var oe=function(){D.error("The monitor for this video element has already been destroyed.")};x.mux.destroy=function(){Object.keys(x.mux.listeners).forEach(function(de){x.removeEventListener(de,x.mux.listeners[de],!1)}),delete x.mux.listeners,x.mux.destroy=oe,x.mux.swapElement=oe,x.mux.emit=oe,x.mux.addHLSJS=oe,x.mux.addDashJS=oe,x.mux.removeHLSJS=oe,x.mux.removeDashJS=oe,x.mux.deleted=!0,p.emit(w,"destroy")},x.mux.swapElement=function(de){var ae=kh(m(de),3),he=ae[0],De=ae[1],_t=ae[2];return he?_t!=="video"&&_t!=="audio"?p.log.error("The element of `"+De+"` was not a media element."):(he.muxId=x.muxId,delete x.muxId,he.mux=he.mux||{},he.mux.listeners=Object.assign({},x.mux.listeners),delete x.mux.listeners,Object.keys(he.mux.listeners).forEach(function(At){x.removeEventListener(At,he.mux.listeners[At],!1),he.addEventListener(At,he.mux.listeners[At],!1)}),he.mux.swapElement=x.mux.swapElement,he.mux.destroy=x.mux.destroy,delete x.mux,void(x=he)):p.log.error("No element was found with the `"+De+"` query selector.")},x.mux.addHLSJS=function(de){p.addHLSJS(w,de)},x.mux.addDashJS=function(de){p.addDashJS(w,de)},x.mux.removeHLSJS=function(){p.removeHLSJS(w)},x.mux.removeDashJS=function(){p.removeDashJS(w)},p.init(w,_),p.emit(w,"playerready"),x.paused||(p.emit(w,"play"),x.readyState>2&&p.emit(w,"playing")),x.mux.listeners={},av.forEach(function(de){(de!=="error"||_.automaticErrorTracking)&&(x.mux.listeners[de]=function(){var ae={};if(de==="error"){if(!x.error||x.error.code===1)return;ae.player_error_code=x.error.code,ae.player_error_message=ov[x.error.code]||x.error.message}p.emit(w,de,ae)},x.addEventListener(de,x.mux.listeners[de],!1))})}(zs,v,f)},destroyMonitor:function(v){var f=Av(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);Jt[p]?Jt[p].addHLSJS(f):A.error("A monitor for `"+p+"` has not been initialized.")},addDashJS:function(v,f){var p=h(v);Jt[p]?Jt[p].addDashJS(f):A.error("A monitor for `"+p+"` has not been initialized.")},removeHLSJS:function(v){var f=h(v);Jt[f]?Jt[f].removeHLSJS():A.error("A monitor for `"+f+"` has not been initialized.")},removeDashJS:function(v){var f=h(v);Jt[f]?Jt[f].removeDashJS():A.error("A monitor for `"+f+"` has not been initialized.")},init:function(v,f){L()&&f&&f.respectDoNotTrack&&A.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var p=h(v);Jt[p]=new sv(zs,p,f)},emit:function(v,f,p){var b=h(v);Jt[b]?(Jt[b].emit(f,p),f==="destroy"&&delete Jt[b]):A.error("A monitor for `"+b+"` has not been initialized.")},checkDoNotTrack:L,log:A,utils:Tv,events:_v,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(zs,Sv),d()!==void 0&&typeof d().addEventListener=="function"&&d().addEventListener("pagehide",function(v){v.persisted||(zs.WINDOW_UNLOADING=!0)},!1);var xv=zs},655:function(n,a,o){var l,d;function u(c){return u=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},u(c);}(function(c){var h=!1;if((d=typeof(l=c)=="function"?l.call(a,o,a,n):l)===void 0||(n.exports=d),h=!0,u(a)==="object"&&(n.exports=c(),h=!0),!h){var m=window.Cookies,g=window.Cookies=c();g.noConflict=function(){return window.Cookies=m,g}}})(function(){var c=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 L;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(A=c({path:"/"},g.defaults,A)).expires=="number"){var S=new Date;S.setMilliseconds(S.getMilliseconds()+864e5*A.expires),A.expires=S}try{L=JSON.stringify(T),/^[\{\[]/.test(L)&&(T=L)}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||(L={});for(var P=document.cookie?document.cookie.split("; "):[],k=/(%[0-9A-Z]{2})+/g,$=0;$<P.length;$++){var M=P[$].split("="),G=M.slice(1).join("=");G.charAt(0)==='"'&&(G=G.slice(1,-1));try{var W=M[0].replace(k,decodeURIComponent);if(G=m.read?m.read(G,W):m(G,W)||G.replace(k,decodeURIComponent),this.json)try{G=JSON.parse(G)}catch{}if(E===W){L=G;break}E||(L[W]=G)}catch{}}return L}}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,"",c(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:{},u=o(558);typeof document!="undefined"?l=document:(l=d["__GLOBAL_DOCUMENT_CACHE@4"])||(l=d["__GLOBAL_DOCUMENT_CACHE@4"]=u),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(u,c){"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(O,z){var j=O[z];if(typeof j.bind=="function")return j.bind(O);try{return Function.prototype.bind.call(j,O)}catch{return function(){return Function.prototype.apply.apply(j,[O,arguments])}}}function A(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function L(O){return O==="debug"&&(O="log"),typeof console!==m&&(O==="trace"&&g?A:console[O]!==void 0?T(console,O):console.log!==void 0?T(console,"log"):h)}function S(O,z){for(var j=0;j<E.length;j++){var be=E[j];this[be]=j<O?h:this.methodFactory(be,O,z)}this.log=this.debug}function P(O,z,j){return function(){typeof console!==m&&(S.call(this,z,j),this[O].apply(this,arguments))}}function k(O,z,j){return L(O)||P.apply(this,arguments)}function $(O,z,j){var be,ge=this;z=z==null?"WARN":z;var ve="loglevel";function Re(re){var _e=(E[re]||"silent").toUpperCase();if(typeof window!==m&&ve){try{return void(window.localStorage[ve]=_e)}catch{}try{window.document.cookie=encodeURIComponent(ve)+"="+_e+";"}catch{}}}function Te(){var re;if(typeof window!==m&&ve){try{re=window.localStorage[ve]}catch{}if(typeof re===m)try{var _e=window.document.cookie,Se=_e.indexOf(encodeURIComponent(ve)+"=");Se!==-1&&(re=/^([^;]+)/.exec(_e.slice(Se))[1])}catch{}return ge.levels[re]===void 0&&(re=void 0),re}}function Q(){if(typeof window!==m&&ve){try{return void window.localStorage.removeItem(ve)}catch{}try{window.document.cookie=encodeURIComponent(ve)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof O=="string"?ve+=":"+O:typeof O=="symbol"&&(ve=void 0),ge.name=O,ge.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},ge.methodFactory=j||k,ge.getLevel=function(){return be},ge.setLevel=function(re,_e){if(typeof re=="string"&&ge.levels[re.toUpperCase()]!==void 0&&(re=ge.levels[re.toUpperCase()]),!(typeof re=="number"&&re>=0&&re<=ge.levels.SILENT))throw"log.setLevel() called with invalid level: "+re;if(be=re,_e!==!1&&Re(re),S.call(ge,re,O),typeof console===m&&re<ge.levels.SILENT)return"No console available for logging"},ge.setDefaultLevel=function(re){z=re,Te()||ge.setLevel(re,!1)},ge.resetLevel=function(){ge.setLevel(z,!1),Q()},ge.enableAll=function(re){ge.setLevel(ge.levels.TRACE,re)},ge.disableAll=function(re){ge.setLevel(ge.levels.SILENT,re)};var ie=Te();ie==null&&(ie=z),ge.setLevel(ie,!1)}var M=new $,G={};M.getLogger=function(O){if(typeof O!="symbol"&&typeof O!="string"||O==="")throw new TypeError("You must supply a name when creating a logger.");var z=G[O];return z||(z=G[O]=new $(O,M.getLevel(),M.methodFactory)),z};var W=typeof window!==m?window.log:void 0;return M.noConflict=function(){return typeof window!==m&&window.log===M&&(window.log=W),M},M.getLoggers=function(){return G},M.default=M,M},(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(u){try{return decodeURIComponent(u.replace(/\+/g," "))}catch{return null}}function d(u){try{return encodeURIComponent(u)}catch{return null}}a.stringify=function(u,c){c=c||"";var h,m,g=[];for(m in typeof c!="string"&&(c="?"),u)if(o.call(u,m)){if((h=u[m])||h!=null&&!isNaN(h)||(h=""),m=d(m),h=d(h),m===null||h===null)continue;g.push(m+"="+h)}return g.length?c+g.join("&"):""},a.parse=function(u){for(var c,h=/([^=?#&]+)=?([^&]*)/g,m={};c=h.exec(u);){var g=l(c[1]),E=l(c[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 no=="object"&&typeof Bd=="object"?Bd.exports=e():typeof no=="object"?no.mux=e():r.mux=e()})()});var ts=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class r extends ts{}globalThis.DocumentFragment=r}var Zs=class extends ts{},xl=class extends ts{},Fv={get(r){},define(r,e,t){},upgrade(r){},whenDefined(r){return Promise.resolve(Zs)}},Js,Il=class{constructor(e,t={}){lt(this,Js,void 0);ti(this,Js,t==null?void 0:t.detail)}get detail(){return Oe(this,Js)}initCustomEvent(){}};Js=new WeakMap;function Uv(r,e){return new Zs}var Ph={document:{createElement:Uv},DocumentFragment,customElements:Fv,CustomEvent:Il,EventTarget:ts,HTMLElement:Zs,HTMLVideoElement:xl},Nh=typeof window=="undefined"||typeof globalThis.customElements=="undefined",ht=Nh?Ph:globalThis,Xt=Nh?Ph.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_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},ce={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},Sr={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",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"},Fh=Object.entries(Sr),R=Fh.reduce((r,[e,t])=>(r[e]=`${t.toLowerCase()}`,r),{}),is=Fh.reduce((r,[e,t])=>(r[e]=`${t.toLowerCase()}`,r),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange"}),EA=Object.entries(is).reduce((r,[e,t])=>{let i=R[e];return i&&(r[t]=i),r},{userinactivechange:"userinactive"}),Uh=Object.entries(R).reduce((r,[e,t])=>{let i=is[e];return i&&(r[t]=i),r},{userinactive:"userinactivechange"}),rs={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},sa={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var Ll={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Fi={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},di={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var Lt={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:r=1}={})=>`current playback rate ${r}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading"},ze={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",AIRPLAY:()=>"air play",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:r=30}={})=>`seek forward ${r} seconds`,SEEK_BACK_N_SECS:({seekOffset:r=30}={})=>`seek back ${r} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"},$v={...Lt,...ze};function na(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 Bh(r){return r.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function $h(r){return typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r)}function aa(r){return typeof r!="string"?!1:!isNaN(r)&&!isNaN(parseFloat(r))}var oa=r=>new Promise(e=>setTimeout(e,r));var Gh=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],Gv=(r,e)=>{let t=r===1?Gh[e].singular:Gh[e].plural;return`${r} ${t}`},xr=r=>{if(!$h(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&&Gv(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function bi(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="-"),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 _A=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 Hh=(r,e,t=".value")=>{let i=r.querySelector(t);!i||(i.textContent=e)},Vv=(r,e)=>{let t=`slot[name="${e}"]`,i=r.shadowRoot.querySelector(t);return i?i.children:[]},Vh=(r,e)=>Vv(r,e)[0],en=(r,e)=>!r||!e?!1:r.contains(e)?!0:en(r,e.getRootNode().host),Ir=(r,e)=>{if(!r)return null;let t=r.closest(e);return t||Ir(r.getRootNode().host,e)};function Ke(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 et(r,e,t=Number.NaN){let i=r.getAttribute(e);return i!=null?+i:t}function Xe(r,e,t){let i=+t;if(t==null||Number.isNaN(i)){r.hasAttribute(e)&&r.removeAttribute(e);return}et(r,e,void 0)!==i&&r.setAttribute(e,`${i}`)}function Ge(r,e){return r.hasAttribute(e)}function Fe(r,e,t){if(t==null){r.hasAttribute(e)&&r.removeAttribute(e);return}Ge(r,e)!=t&&r.toggleAttribute(e,t)}function dt(r,e,t=null){var i;return(i=r.getAttribute(e))!=null?i:t}function nt(r,e,t){if(t==null){r.hasAttribute(e)&&r.removeAttribute(e);return}let i=`${t}`;dt(r,e,void 0)!==i&&r.setAttribute(e,i)}var la=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},Rl=class{observe(){}},Kh={ResizeObserver:Rl,HTMLElement:class extends la{},DocumentFragment:class extends la{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},CustomEvent:function(){},getComputedStyle:function(){},requestAnimationFrame:function(r){return 1},queueMicrotask:function(r){}},Kv={createElement:function(){return new Kh.HTMLElement},addEventListener(){},removeEventListener(){}},Wh=typeof window=="undefined"||typeof window.customElements=="undefined",N=Wh?Kh:window,q=Wh?Kv:window.document;var Wv=Object.defineProperty,qv=(r,e,t)=>e in r?Wv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Yv=(r,e,t)=>(qv(r,typeof e!="symbol"?e+"":e,t),t),qh=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},ii=(r,e,t)=>(qh(r,e,"read from private field"),t?t.call(r):e.get(r)),da=(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)=>(qh(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Ti,ca,ss,ha,Yh=q.createElement("template");Yh.innerHTML=`
|
|
46
20
|
<style>
|
|
47
21
|
:host {
|
|
48
22
|
font: var(--media-font,
|
|
@@ -90,38 +64,38 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
90
64
|
min-width: 100%;
|
|
91
65
|
}
|
|
92
66
|
</style>
|
|
93
|
-
`;var
|
|
67
|
+
`;var We=class extends N.HTMLElement{constructor(e={}){if(super(),da(this,Ti,void 0),Yv(this,"preventClick",!1),da(this,ca,i=>{this.preventClick||this.handleClick(i)}),da(this,ss,i=>{let{key:s}=i;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",ii(this,ss));return}this.preventClick||this.handleClick(i)}),da(this,ha,i=>{let{metaKey:s,altKey:n,key:a}=i;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",ii(this,ss));return}this.addEventListener("keyup",ii(this,ss),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});let i=Yh.content.cloneNode(!0);this.nativeEl=i;let s=e.slotTemplate;s||(s=q.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),this.shadowRoot.appendChild(i)}let{style:t}=Ke(this.shadowRoot,":host");t.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`)}static get observedAttributes(){return["disabled",ce.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",ii(this,ca)),this.addEventListener("keydown",ii(this,ha)),this.tabIndex=0}disable(){this.removeEventListener("click",ii(this,ca)),this.removeEventListener("keydown",ii(this,ha)),this.removeEventListener("keyup",ii(this,ss)),this.tabIndex=-1}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===ce.MEDIA_CONTROLLER?(t&&((n=(s=ii(this,Ti))==null?void 0:s.unassociateElement)==null||n.call(s,this),ua(this,Ti,null)),i&&(ua(this,Ti,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=ii(this,Ti))==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(ce.MEDIA_CONTROLLER);s&&(ua(this,Ti,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=ii(this,Ti))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=ii(this,Ti))==null?void 0:e.unassociateElement)==null||t.call(e,this),ua(this,Ti,null)}get keysUsed(){return["Enter"," "]}handleClick(e){}};Ti=new WeakMap;ca=new WeakMap;ss=new WeakMap;ha=new WeakMap;N.customElements.get("media-chrome-button")||N.customElements.define("media-chrome-button",We);var jv=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
94
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"/>
|
|
95
69
|
</svg>
|
|
96
|
-
`,
|
|
97
|
-
<slot name="icon">${
|
|
98
|
-
`;var
|
|
70
|
+
`,jh=q.createElement("template");jh.innerHTML=`
|
|
71
|
+
<slot name="icon">${jv}</slot>
|
|
72
|
+
`;var wl=class extends We{static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:jh,...e})}connectedCallback(){this.setAttribute("aria-label",ze.AIRPLAY()),super.connectedCallback()}get mediaAirplayUnavailable(){return dt(this,R.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){nt(this,R.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new N.CustomEvent(ne.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};N.customElements.get("media-airplay-button")||N.customElements.define("media-airplay-button",wl);var zv='<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>',Xv='<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>',Xh=q.createElement("template");Xh.innerHTML=`
|
|
99
73
|
<style>
|
|
100
|
-
:host([${
|
|
74
|
+
:host([${R.MEDIA_IS_CASTING}]) slot:not([name=exit]):not([name=icon]) {
|
|
101
75
|
display: none !important;
|
|
102
76
|
}
|
|
103
77
|
|
|
104
78
|
|
|
105
|
-
:host(:not([${
|
|
79
|
+
:host(:not([${R.MEDIA_IS_CASTING}])) slot:not([name=enter]):not([name=icon]) {
|
|
106
80
|
display: none !important;
|
|
107
81
|
}
|
|
108
82
|
</style>
|
|
109
83
|
|
|
110
84
|
<slot name="icon">
|
|
111
|
-
<slot name="enter">${
|
|
112
|
-
<slot name="exit">${
|
|
85
|
+
<slot name="enter">${zv}</slot>
|
|
86
|
+
<slot name="exit">${Xv}</slot>
|
|
113
87
|
</slot>
|
|
114
|
-
`;var
|
|
88
|
+
`;var zh=r=>{let t=r.getAttribute(R.MEDIA_IS_CASTING)!=null?ze.EXIT_CAST():ze.ENTER_CAST();r.setAttribute("aria-label",t)},kl=class extends We{static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_IS_CASTING,R.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Xh,...e})}connectedCallback(){zh(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===R.MEDIA_IS_CASTING&&zh(this),super.attributeChangedCallback(e,t,i)}get mediaIsCasting(){return Ge(this,R.MEDIA_IS_CASTING)}set mediaIsCasting(e){Fe(this,R.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return dt(this,R.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){nt(this,R.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?ne.MEDIA_EXIT_CAST_REQUEST:ne.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new N.CustomEvent(e,{composed:!0,bubbles:!0}))}};N.customElements.get("media-cast-button")||N.customElements.define("media-cast-button",kl);var Qh=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},rr=(r,e,t)=>(Qh(r,e,"read from private field"),t?t.call(r):e.get(r)),Qv=(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)},fa=(r,e,t,i)=>(Qh(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Bt,Zh=q.createElement("template");Zh.innerHTML=`
|
|
115
89
|
<style>
|
|
116
90
|
:host {
|
|
117
91
|
display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
|
|
118
92
|
box-sizing: border-box;
|
|
119
93
|
}
|
|
120
94
|
</style>
|
|
121
|
-
`;var
|
|
95
|
+
`;var Dl=class extends N.HTMLElement{constructor(e={}){if(super(),Qv(this,Bt,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),i=Zh.content.cloneNode(!0);this.nativeEl=i;let s=e.slotTemplate;s||(s=q.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),t.appendChild(i)}}static get observedAttributes(){return[ce.MEDIA_CONTROLLER,R.MEDIA_PAUSED]}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===ce.MEDIA_CONTROLLER&&(t&&((n=(s=rr(this,Bt))==null?void 0:s.unassociateElement)==null||n.call(s,this),fa(this,Bt,null)),i&&(fa(this,Bt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=rr(this,Bt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,i,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),fa(this,Bt,Zv(this)),this.getAttribute(ce.MEDIA_CONTROLLER)&&((t=(e=rr(this,Bt))==null?void 0:e.associateElement)==null||t.call(e,this)),(i=rr(this,Bt))==null||i.addEventListener("pointerdown",this),(s=rr(this,Bt))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,i,s;this.getAttribute(ce.MEDIA_CONTROLLER)&&((t=(e=rr(this,Bt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(i=rr(this,Bt))==null||i.removeEventListener("pointerdown",this),(s=rr(this,Bt))==null||s.removeEventListener("click",this),fa(this,Bt,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:u}=this.getBoundingClientRect(),c=n-o,h=a-l;if(c<0||h<0||c>d||h>u||d===0&&u===0)return;let{pointerType:m=this._pointerType}=e;if(this._pointerType=void 0,m===Ll.TOUCH){this.handleTap(e);return}else if(m===Ll.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return Ge(this,R.MEDIA_PAUSED)}set mediaPaused(e){Fe(this,R.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?ne.MEDIA_PLAY_REQUEST:ne.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new N.CustomEvent(t,{composed:!0,bubbles:!0}))}};Bt=new WeakMap;function Zv(r){var e;let t=r.getAttribute(ce.MEDIA_CONTROLLER);return t?(e=r.getRootNode())==null?void 0:e.getElementById(t):Ir(r,"media-controller")}N.customElements.get("media-gesture-receiver")||N.customElements.define("media-gesture-receiver",Dl);var Ue={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},Jh=q.createElement("template");Jh.innerHTML=`
|
|
122
96
|
<style>
|
|
123
97
|
|
|
124
|
-
:host([${
|
|
98
|
+
:host([${R.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
|
|
125
99
|
outline: none;
|
|
126
100
|
}
|
|
127
101
|
|
|
@@ -133,7 +107,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
133
107
|
background-color: var(--media-background-color, #000);
|
|
134
108
|
}
|
|
135
109
|
|
|
136
|
-
:host(:not([${
|
|
110
|
+
:host(:not([${Ue.AUDIO}])) [part~=layer]:not([part~=media-layer]) {
|
|
137
111
|
position: absolute;
|
|
138
112
|
top: 0;
|
|
139
113
|
left: 0;
|
|
@@ -151,19 +125,19 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
151
125
|
}
|
|
152
126
|
|
|
153
127
|
|
|
154
|
-
:host([${
|
|
128
|
+
:host([${Ue.AUDIO}]) slot[name=media] {
|
|
155
129
|
display: var(--media-slot-display, none);
|
|
156
130
|
}
|
|
157
131
|
|
|
158
132
|
|
|
159
|
-
:host([${
|
|
133
|
+
:host([${Ue.AUDIO}]) [part~=layer][part~=gesture-layer] {
|
|
160
134
|
height: 0;
|
|
161
135
|
display: block;
|
|
162
136
|
}
|
|
163
137
|
|
|
164
138
|
|
|
165
|
-
:host(:not([${
|
|
166
|
-
:host(:not([${
|
|
139
|
+
:host(:not([${Ue.AUDIO}])[${Ue.GESTURES_DISABLED}]) ::slotted([slot=gestures-chrome]),
|
|
140
|
+
:host(:not([${Ue.AUDIO}])[${Ue.GESTURES_DISABLED}]) media-gesture-receiver[slot=gestures-chrome] {
|
|
167
141
|
display: none;
|
|
168
142
|
}
|
|
169
143
|
|
|
@@ -172,13 +146,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
172
146
|
pointer-events: auto;
|
|
173
147
|
}
|
|
174
148
|
|
|
175
|
-
:host(:not([${
|
|
149
|
+
:host(:not([${Ue.AUDIO}])) *[part~=layer][part~=centered-layer] {
|
|
176
150
|
align-items: center;
|
|
177
151
|
justify-content: center;
|
|
178
152
|
}
|
|
179
153
|
|
|
180
|
-
:host(:not([${
|
|
181
|
-
:host(:not([${
|
|
154
|
+
:host(:not([${Ue.AUDIO}])) ::slotted(media-gesture-receiver[slot=gestures-chrome]),
|
|
155
|
+
:host(:not([${Ue.AUDIO}])) media-gesture-receiver[slot=gestures-chrome] {
|
|
182
156
|
align-self: stretch;
|
|
183
157
|
flex-grow: 1;
|
|
184
158
|
}
|
|
@@ -198,7 +172,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
198
172
|
}
|
|
199
173
|
|
|
200
174
|
|
|
201
|
-
:host(:not([${
|
|
175
|
+
:host(:not([${Ue.AUDIO}])) .spacer {
|
|
202
176
|
flex-grow: 1;
|
|
203
177
|
}
|
|
204
178
|
|
|
@@ -210,13 +184,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
210
184
|
}
|
|
211
185
|
|
|
212
186
|
|
|
213
|
-
::slotted(:not([slot=media]):not([${
|
|
187
|
+
::slotted(:not([slot=media]):not([${Ue.NO_AUTOHIDE}])) {
|
|
214
188
|
opacity: 1;
|
|
215
189
|
transition: opacity 0.25s;
|
|
216
190
|
}
|
|
217
191
|
|
|
218
192
|
|
|
219
|
-
:host([${
|
|
193
|
+
:host([${Ue.USER_INACTIVE}]:not([${R.MEDIA_PAUSED}]):not([${R.MEDIA_IS_CASTING}]):not([${Ue.AUDIO}])) ::slotted(:not([slot=media]):not([${Ue.NO_AUTOHIDE}])) {
|
|
220
194
|
opacity: 0;
|
|
221
195
|
transition: opacity 1s;
|
|
222
196
|
}
|
|
@@ -225,7 +199,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
225
199
|
align-self: stretch;
|
|
226
200
|
}
|
|
227
201
|
|
|
228
|
-
:host([${
|
|
202
|
+
:host([${R.MEDIA_HAS_PLAYED}]) ::slotted([slot=poster]) {
|
|
229
203
|
display: none;
|
|
230
204
|
}
|
|
231
205
|
</style>
|
|
@@ -242,7 +216,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
242
216
|
|
|
243
217
|
<slot part="bottom chrome"></slot>
|
|
244
218
|
</span>
|
|
245
|
-
`;var AE=Object.values(F),SE="sm:384 md:576 lg:768 xl:960",kE=n=>{var r;for(let o of n){let m=o.target;if(!m.isConnected)continue;let v=(r=m.getAttribute(dt.BREAKPOINTS))!=null?r:SE,y=wE(v),I=LE(y,o.contentRect),M=!1;if(Object.keys(y).forEach(U=>{if(I.includes(U)){m.hasAttribute(`breakpoint${U}`)||(m.setAttribute(`breakpoint${U}`,""),M=!0);return}m.hasAttribute(`breakpoint${U}`)&&(m.removeAttribute(`breakpoint${U}`),M=!0)}),M){let U=new CustomEvent(bn.BREAKPOINTS_CHANGE,{detail:I});m.dispatchEvent(U)}}};function wE(n){let r=n.split(/\s+/);return Object.fromEntries(r.map(o=>o.split(":")))}function LE(n,r){return Object.keys(n).filter(o=>r.width>=n[o])}var ml=class extends W.HTMLElement{constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(zf.content.cloneNode(!0)));let r=U=>{let H=this.media;for(let z of U)z.type==="childList"&&(z.removedNodes.forEach(J=>{if(J.slot=="media"&&z.target==this){let Z=z.previousSibling&&z.previousSibling.previousElementSibling;if(!Z||!H)this.mediaUnsetCallback(J);else{let se=Z.slot!=="media";for(;(Z=Z.previousSibling)!==null;)Z.slot=="media"&&(se=!1);se&&this.mediaUnsetCallback(J)}}}),H&&z.addedNodes.forEach(J=>{J==H&&this.handleMediaUpdated(H).then(Z=>this.mediaSetCallback(Z))}))};new MutationObserver(r).observe(this,{childList:!0,subtree:!0});let m=!1,v=U=>{m||(W.queueMicrotask(()=>{kE(U),m=!1}),m=!0)},y=new ResizeObserver(v);this.resizeObserver=y,y.observe(this);let I=this.media,M=this.querySelector(":scope > slot[slot=media]");M&&M.addEventListener("slotchange",()=>{if(!M.assignedElements({flatten:!0}).length){this.mediaUnsetCallback(I);return}this.media&&(I=this.media,this.handleMediaUpdated(this.media).then(H=>this.mediaSetCallback(H)))})}static get observedAttributes(){return[dt.AUTOHIDE,dt.GESTURES_DISABLED].concat(AE)}attributeChangedCallback(r,o,m){r.toLowerCase()==dt.AUTOHIDE&&(this.autohide=m)}get media(){let r=this.querySelector(":scope > [slot=media]");return(r==null?void 0:r.nodeName)=="SLOT"&&(r=r.assignedElements({flatten:!0})[0]),r}mediaSetCallback(r){this._mediaClickPlayToggle=()=>{let o=r.paused?Ie.MEDIA_PLAY_REQUEST:Ie.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new W.CustomEvent(o,{composed:!0,bubbles:!0}))}}handleMediaUpdated(r){let o=y=>Promise.resolve(y),m=y=>(console.error('<media-chrome>: Media element set with slot="media" does not appear to be compatible.',y),Promise.reject(y));if(!r)return m(r);let v=r.nodeName.toLowerCase();return v.includes("-")?W.customElements.whenDefined(v).then(()=>o(r)):o(r)}mediaUnsetCallback(r){}connectedCallback(){let o=this.getAttribute(dt.AUDIO)!=null?si.AUDIO_PLAYER():si.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",o),this.media&&this.handleMediaUpdated(this.media).then(I=>this.mediaSetCallback(I)),this.setAttribute(dt.USER_INACTIVE,"");let m=()=>{if(this.autohide<0||this.hasAttribute(dt.USER_INACTIVE))return;this.setAttribute(dt.USER_INACTIVE,"");let I=new W.CustomEvent(bn.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(I)},v=()=>{if(!this.hasAttribute(dt.USER_INACTIVE))return;this.removeAttribute(dt.USER_INACTIVE);let I=new W.CustomEvent(bn.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(I)},y=()=>{v(),W.clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=W.setTimeout(()=>{m()},this.autohide*1e3))};this.addEventListener("keyup",()=>{y()}),this.addEventListener("pointerup",I=>{I.pointerType==="touch"?[this,this.media].includes(I.target)&&!this.hasAttribute(dt.USER_INACTIVE)?m():y():I.composedPath().some(M=>{var U;return["media-play-button","media-fullscreen-button"].includes((U=M==null?void 0:M.nodeName)==null?void 0:U.toLowerCase())})&&y()}),this.addEventListener("pointermove",I=>{I.pointerType==="mouse"&&(v(),W.clearTimeout(this._inactiveTimeout),[this,this.media].includes(I.target)&&y())}),this.addEventListener("mouseleave",()=>{m()}),this.addEventListener("keyup",()=>{this.setAttribute(dt.KEYBOARD_CONTROL,"")}),W.addEventListener("mouseup",()=>{this.removeAttribute(dt.KEYBOARD_CONTROL)})}set autohide(r){r=Number(r),this._autohide=isNaN(r)?0:r}get autohide(){return this._autohide===void 0?2:this._autohide}};var Qf=(n,r,o)=>{if(!r.has(n))throw TypeError("Cannot "+o)},Xt=(n,r,o)=>(Qf(n,r,"read from private field"),o?o.call(n):r.get(n)),Rs=(n,r,o)=>{if(r.has(n))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(n):r.set(n,o)},pl=(n,r,o,m)=>(Qf(n,r,"write to private field"),m?m.call(n,o):r.set(n,o),o),An,Sn,vl,Ba,Mr,ia,kn=class{constructor(r,o,{defaultValue:m}={defaultValue:void 0}){Rs(this,Mr),Rs(this,An,void 0),Rs(this,Sn,void 0),Rs(this,vl,void 0),Rs(this,Ba,new Set),pl(this,An,r),pl(this,Sn,o),pl(this,vl,new Set(m))}[Symbol.iterator](){return Xt(this,Mr,ia).values()}get length(){return Xt(this,Mr,ia).size}get value(){var r;return(r=[...Xt(this,Mr,ia)].join(" "))!=null?r:""}set value(r){var o;r!==this.value&&(pl(this,Ba,new Set),this.add(...(o=r==null?void 0:r.split(" "))!=null?o:[]))}toString(){return this.value}item(r){return[...Xt(this,Mr,ia)][r]}values(){return Xt(this,Mr,ia).values()}forEach(r){Xt(this,Mr,ia).forEach(r)}add(...r){var o,m;r.forEach(v=>Xt(this,Ba).add(v)),!(this.value===""&&!((o=Xt(this,An))!=null&&o.hasAttribute(`${Xt(this,Sn)}`)))&&((m=Xt(this,An))==null||m.setAttribute(`${Xt(this,Sn)}`,`${this.value}`))}remove(...r){var o;r.forEach(m=>Xt(this,Ba).delete(m)),(o=Xt(this,An))==null||o.setAttribute(`${Xt(this,Sn)}`,`${this.value}`)}contains(r){return Xt(this,Mr,ia).has(r)}toggle(r,o){return typeof o!="undefined"?o?(this.add(r),!0):(this.remove(r),!1):this.contains(r)?(this.remove(r),!1):(this.add(r),!0)}replace(r,o){return this.remove(r),this.add(o),r===o}};An=new WeakMap;Sn=new WeakMap;vl=new WeakMap;Ba=new WeakMap;Mr=new WeakSet;ia=function(){return Xt(this,Ba).size?Xt(this,Ba):Xt(this,vl)};var Xf=(n="")=>n.split(/\s+/),Zf=(n="")=>{let[r,o,m]=n.split(":"),v=m?decodeURIComponent(m):void 0;return r=r==="cc"?"captions":"subtitles",{kind:r,language:o,label:v}},wn=(n="",r={})=>Xf(n).map(o=>{let m=Zf(o);return{...r,...m}}),IE=n=>Array.isArray(n)?n.map(r=>typeof r=="string"?Zf(r):r):typeof n=="string"?wn(n):[n],Od=({kind:n,label:r,language:o}={kind:"subtitles"})=>r?`${n==="captions"?"cc":"sb"}:${o}:${encodeURIComponent(r)}`:o,Ds=(n=[])=>Array.prototype.map.call(n,Od).join(" "),RE=(n,r)=>o=>o[n]===r,Jf=n=>{let r=Object.entries(n).map(([o,m])=>RE(o,m));return o=>r.every(m=>m(o))},Nd=(n,r=[],o=[])=>{let m=IE(o).map(Jf),v=y=>m.some(I=>I(y));Array.from(r).filter(v).forEach(y=>{y.mode=n})},gl=(n,r=()=>!0)=>{if(!(n!=null&&n.textTracks))return[];let o=typeof r=="function"?r:Jf(r);return Array.from(n.textTracks).filter(o)},Fd=n=>!!n.getAttribute(F.MEDIA_SUBTITLES_SHOWING),xr=(n,r)=>{var o,m;let v=Fd(n);if(v||r===!1){let y=n.getAttribute(F.MEDIA_SUBTITLES_SHOWING);if(y){let I=new window.CustomEvent(Ie.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:y});n.dispatchEvent(I)}}else if(!v||r===!0){let[y]=(m=Xf((o=n.getAttribute(F.MEDIA_SUBTITLES_LIST))!=null?o:""))!=null?m:[];if(y){let I=new window.CustomEvent(Ie.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:y});n.dispatchEvent(I)}}else console.error("Attempting to enable captions or subtitles but none are available! Please verify your media content if this is unexpected.")};var It={enter:"requestFullscreen",exit:"exitFullscreen",rootEvents:["fullscreenchange"],mediaEvents:[],element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};ae.fullscreenElement===void 0&&(It.enter="webkitRequestFullScreen",It.exit=ae.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",It.rootEvents=["webkitfullscreenchange"],It.mediaEvents=["webkitbeginfullscreen","webkitendfullscreen"],It.element="webkitFullscreenElement",It.error="webkitfullscreenerror",It.enabled="webkitFullscreenEnabled");var El,Ud=()=>{var n,r;return El||(El=(r=(n=ae)==null?void 0:n.createElement)==null?void 0:r.call(n,"video"),El)},em=async(n=Ud())=>{if(!n)return!1;let r=n.volume;return n.volume=r/2+.1,await ol(0),n.volume!==r},DE=(n=Ud())=>typeof(n==null?void 0:n.requestPictureInPicture)=="function",CE=(n=Ud())=>{let r=ae[It.enabled];return!r&&n&&(r="webkitSupportsFullscreen"in n),r},Bd=CE(),tm=DE(),im=!!W.WebKitPlaybackTargetAvailabilityEvent,rm=!!W.chrome;var yl,am=em().then(n=>(yl=n,yl)),ME=Object.values(Zi),Hd=n=>gl(n.media,r=>[Tn.SUBTITLES,Tn.CAPTIONS].includes(r.kind)).sort((r,o)=>r.kind>=o.kind?1:-1),xE=n=>gl(n.media,r=>r.mode===al.SHOWING&&[Tn.SUBTITLES,Tn.CAPTIONS].includes(r.kind)),Si={MEDIA_PAUSED:{get:function(n){let{media:r}=n;return r?r.paused:!0},mediaEvents:["play","playing","pause","emptied"]},MEDIA_HAS_PLAYED:{get:function(n){let{media:r}=n;return r?!r.paused:!1},mediaEvents:["playing","emptied"]},MEDIA_ENDED:{get:function(n){let{media:r}=n;return r?r.ended:!1},mediaEvents:["seeked","ended","emptied"]},MEDIA_PLAYBACK_RATE:{get:function(n){let{media:r}=n;return!r||typeof r.playbackRate=="undefined"?1:r.playbackRate},mediaEvents:["ratechange","loadstart"]},MEDIA_MUTED:{get:function(n){let{media:r}=n;return!r||typeof r.muted=="undefined"?!1:r.muted},mediaEvents:["volumechange"]},MEDIA_VOLUME:{get:function(n){let{media:r}=n;return!r||typeof r.volume=="undefined"?1:Number(r.volume)},mediaEvents:["volumechange"]},MEDIA_VOLUME_LEVEL:{get:function(n){let{media:r}=n,o="high";if(!r||typeof r.volume=="undefined")return o;let{muted:m,volume:v}=r;return v===0||m?o="off":v<.5?o="low":v<.75&&(o="medium"),o},mediaEvents:["volumechange"]},MEDIA_CURRENT_TIME:{get:function(n){let{media:r}=n;return!r||typeof r.currentTime=="undefined"?0:r.currentTime},mediaEvents:["timeupdate","loadedmetadata"]},MEDIA_DURATION:{get:function(n){let{media:r}=n;return!r||!Number.isFinite(r.duration)?NaN:r.duration},mediaEvents:["durationchange","loadedmetadata","emptied"]},MEDIA_SEEKABLE:{get:function(n){var r;let{media:o}=n;if(!((r=o==null?void 0:o.seekable)!=null&&r.length))return;let m=o.seekable.start(0),v=o.seekable.end(o.seekable.length-1);if(!(!m&&!v))return[Number(m.toFixed(3)),Number(v.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress"]},MEDIA_LOADING:{get:function(n){var r;return((r=n.media)==null?void 0:r.readyState)<3},mediaEvents:["waiting","playing","emptied"]},MEDIA_BUFFERED:{get:function(n){var r,o,m;let v=(r=n.media)==null?void 0:r.buffered;return Array.from((m=(o=n.media)==null?void 0:o.buffered)!=null?m:[]).map((y,I)=>[Number(v.start(I)).toFixed(3),Number(v.end(I)).toFixed(3)])},mediaEvents:["progress","emptied"]},MEDIA_STREAM_TYPE:{get:function(n){let{media:r}=n;if(!r)return;let{streamType:o}=r;if(ME.includes(o)){if(o===Zi.UNKNOWN){let v=n.getAttribute("defaultstreamtype");return[Zi.LIVE,Zi.ON_DEMAND].includes(v)?v:void 0}return o}let m=r.duration;if(m===1/0)return Zi.LIVE;if(Number.isFinite(m))return Zi.ON_DEMAND;{let v=n.getAttribute("defaultstreamtype");if([Zi.LIVE,Zi.ON_DEMAND].includes(v))return v}},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},MEDIA_TARGET_LIVE_WINDOW:{get:function(n){let{media:r}=n;if(!r)return Number.NaN;let{targetLiveWindow:o}=r,m=Si.MEDIA_STREAM_TYPE.get(n);return(o==null||Number.isNaN(o))&&m===Zi.LIVE?0:o},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},MEDIA_TIME_IS_LIVE:{get:function(n){let{media:r}=n;if(!r)return!1;if(typeof r.liveEdgeStart=="number")return Number.isNaN(r.liveEdgeStart)?!1:r.currentTime>=r.liveEdgeStart;if(!(Si.MEDIA_STREAM_TYPE.get(n)==="live"))return!1;let m=r.seekable;if(!m)return!0;if(!m.length)return!1;let v=n.hasAttribute("liveedgeoffset")?Number(n.getAttribute("liveedgeoffset")):10,y=m.end(m.length-1)-v;return r.currentTime>=y},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},MEDIA_IS_FULLSCREEN:{get:function(n,r){var o;let m=n.media;if(m&&ae[It.element]===void 0&&"webkitDisplayingFullscreen"in m)return m.webkitDisplayingFullscreen&&m.webkitPresentationMode==="fullscreen";let v;return r?v=ae[It.element]?r.target:null:v=(o=n.getRootNode().fullscreenElement)!=null?o:ae[It.element],Is(n.fullscreenElement,v)},rootEvents:It.rootEvents,mediaEvents:It.mediaEvents},MEDIA_IS_PIP:{get:function(n,r){var o;let m=n.media;if(!m)return!1;if(r)return r.type=="enterpictureinpicture";{let v=(o=n.getRootNode().pictureInPictureElement)!=null?o:ae.pictureInPictureElement;return Is(m,v)}},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},MEDIA_IS_CASTING:{get:function(n,r){var o;let{media:m}=n;if(!m)return!1;let v=(o=globalThis.CastableVideoElement)==null?void 0:o.castElement,y=Is(m,v);return(r==null?void 0:r.type)==="castchange"&&(r==null?void 0:r.detail)==="CONNECTING"&&(y="connecting"),y},mediaEvents:["entercast","leavecast","castchange"]},MEDIA_AIRPLAY_UNAVAILABLE:{get:function(n,r){if(!im)return Cr.UNSUPPORTED;if(!!r&&r.availability!=="available"&&r.availability==="not-available")return Cr.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"]},MEDIA_CAST_UNAVAILABLE:{get:function(){var n;let r=(n=globalThis.CastableVideoElement)==null?void 0:n.castState;if(!rm||!r)return Cr.UNSUPPORTED;if(!r.includes("CONNECT"))return Cr.UNAVAILABLE},mediaEvents:["castchange"]},MEDIA_FULLSCREEN_UNAVAILABLE:{get:function(){return Bd?void 0:Cr.UNAVAILABLE}},MEDIA_PIP_UNAVAILABLE:{get:function(){return tm?void 0:Cr.UNSUPPORTED}},MEDIA_VOLUME_UNAVAILABLE:{get:function(n){if(yl!==void 0&&!yl)return Cr.UNSUPPORTED;let{media:r}=n;if(r&&typeof r.volume=="undefined")return Cr.UNAVAILABLE},mediaEvents:["loadstart"]},MEDIA_SUBTITLES_LIST:{get:function(n){return Hd(n).map(({kind:r,label:o,language:m})=>({kind:r,label:o,language:m}))},mediaEvents:["loadstart"],trackListEvents:["addtrack","removetrack"]},MEDIA_SUBTITLES_SHOWING:{get:function(n){return n.hasAttribute("defaultsubtitles")&&!n.hasAttribute(F.MEDIA_HAS_PLAYED)&&!n.hasAttribute(F.MEDIA_SUBTITLES_SHOWING)&&xr(n,!0),xE(n).map(({kind:r,label:o,language:m})=>({kind:r,label:o,language:m}))},mediaEvents:["loadstart"],trackListEvents:["addtrack","removetrack","change"]}},bl={MEDIA_PLAY_REQUEST:(n,r,o)=>{var m;let v=Si.MEDIA_STREAM_TYPE.get(o),y=o.getAttribute("noautoseektolive")===null;v==Zi.LIVE&&y&&bl.MEDIA_SEEK_TO_LIVE_REQUEST(n),(m=n.play())==null||m.catch(()=>{})},MEDIA_PAUSE_REQUEST:n=>n.pause(),MEDIA_MUTE_REQUEST:n=>n.muted=!0,MEDIA_UNMUTE_REQUEST:n=>{n.muted=!1,n.volume===0&&(n.volume=.25)},MEDIA_VOLUME_REQUEST:(n,r,o)=>{let m=r.detail;if(n.volume=m,m>0&&n.muted&&(n.muted=!1),!o.hasAttribute("novolumepref"))try{W.localStorage.setItem("media-chrome-pref-volume",m.toString())}catch{}},MEDIA_ENTER_FULLSCREEN_REQUEST:(n,r,o)=>{if(!Bd){console.warn("Fullscreen support is unavailable; not entering fullscreen");return}ae.pictureInPictureElement&&ae.exitPictureInPicture(),o[It.enter]?o.fullscreenElement[It.enter]():n.webkitEnterFullscreen?n.webkitEnterFullscreen():n.requestFullscreen?n.requestFullscreen():console.warn("MediaChrome: Fullscreen not supported")},MEDIA_EXIT_FULLSCREEN_REQUEST:()=>{ae[It.exit]()},MEDIA_ENTER_PIP_REQUEST:n=>{if(!ae.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!n.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}ae[It.element]&&ae[It.exit]();let r=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};n.requestPictureInPicture().catch(o=>{if(o.code===11)if(n.readyState===0&&n.preload==="none"){let m=()=>{n.removeEventListener("loadedmetadata",v),n.preload="none"},v=()=>{n.requestPictureInPicture().catch(r),m()};n.addEventListener("loadedmetadata",v),n.preload="metadata",setTimeout(()=>{n.readyState===0&&r(),m()},1e3)}else throw o;else throw o})},MEDIA_EXIT_PIP_REQUEST:()=>{ae.pictureInPictureElement&&ae.exitPictureInPicture()},MEDIA_ENTER_CAST_REQUEST:n=>{var r;!((r=globalThis.CastableVideoElement)!=null&&r.castEnabled)||(ae[It.element]&&ae[It.exit](),n.requestCast())},MEDIA_EXIT_CAST_REQUEST:async()=>{var n;(n=globalThis.CastableVideoElement)!=null&&n.castElement&&globalThis.CastableVideoElement.exitCast()},MEDIA_SEEK_REQUEST:(n,r)=>{let o=r.detail;(n.readyState>0||n.readyState===void 0)&&(n.currentTime=o)},MEDIA_PLAYBACK_RATE_REQUEST:(n,r)=>{n.playbackRate=r.detail},MEDIA_PREVIEW_REQUEST:(n,r,o)=>{var m;if(!n)return;let v=r.detail;v===null&&o.propagateMediaState(F.MEDIA_PREVIEW_TIME,void 0),o.propagateMediaState(F.MEDIA_PREVIEW_TIME,v);let[y]=gl(n,{kind:Tn.METADATA,label:"thumbnails"});if(!(y&&y.cues))return;if(v===null){o.propagateMediaState(F.MEDIA_PREVIEW_IMAGE,void 0),o.propagateMediaState(F.MEDIA_PREVIEW_COORDS,void 0);return}let I=Array.prototype.find.call(y.cues,z=>z.startTime>=v);if(!I)return;let M=/'^(?:[a-z]+:)?\/\//i.test(I.text)||(m=n.querySelector('track[label="thumbnails"]'))==null?void 0:m.src,U=new URL(I.text,M),H=new URLSearchParams(U.hash).get("#xywh");o.propagateMediaState(F.MEDIA_PREVIEW_IMAGE,U.href),o.propagateMediaState(F.MEDIA_PREVIEW_COORDS,H.split(","))},MEDIA_SHOW_SUBTITLES_REQUEST:(n,r,o)=>{let m=Hd(o),{detail:v=[]}=r;Nd(al.SHOWING,m,v)},MEDIA_DISABLE_SUBTITLES_REQUEST:(n,r,o)=>{let m=Hd(o),{detail:v=[]}=r;Nd(al.DISABLED,m,v)},MEDIA_AIRPLAY_REQUEST:n=>{if(!!n){if(!(n.webkitShowPlaybackTargetPicker&&W.WebKitPlaybackTargetAvailabilityEvent)){console.warn("received a request to select AirPlay but AirPlay is not supported in this environment");return}n.webkitShowPlaybackTargetPicker()}},MEDIA_SEEK_TO_LIVE_REQUEST:n=>{let r=n.seekable;if(!r){console.warn("MediaController: Media element does not support seeking to live.");return}if(!r.length){console.warn("MediaController: Media is unable to seek to live.");return}n.currentTime=r.end(r.length-1)}};var Kd=(n,r,o)=>{if(!r.has(n))throw TypeError("Cannot "+o)},Ga=(n,r,o)=>(Kd(n,r,"read from private field"),o?o.call(n):r.get(n)),Tl=(n,r,o)=>{if(r.has(n))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(n):r.set(n,o)},nm=(n,r,o,m)=>(Kd(n,r,"write to private field"),m?m.call(n,o):r.set(n,o),o),Ln=(n,r,o)=>(Kd(n,r,"access private method"),o),ra,Cs,In,Ms,_l,Gd,dm=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],PE=10,sm=0,ki={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"},Al=class extends ml{constructor(){super(),Tl(this,In),Tl(this,_l),Tl(this,ra,new kn(this,ki.HOTKEYS)),Tl(this,Cs,void 0),Si.MEDIA_VOLUME_UNAVAILABLE.get(this)===void 0&&am.then(()=>{this.propagateMediaState(F.MEDIA_VOLUME_UNAVAILABLE,Si.MEDIA_VOLUME_UNAVAILABLE.get(this))}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this),Object.keys(bl).forEach(r=>{let o=`_handle${nl(r,!0)}`;this[o]=m=>{if(m.stopPropagation(),!this.media){console.warn("MediaController: No media available.");return}bl[r](this.media,m,this)},this.addEventListener(Ie[r],this[o])}),this._mediaStatePropagators={},Object.keys(Si).forEach(r=>{this._mediaStatePropagators[r]=o=>{this.propagateMediaState(Na[r],Si[r].get(this,o))}}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(ki.NO_HOTKEYS,ki.HOTKEYS,ki.DEFAULT_STREAM_TYPE,ki.DEFAULT_SUBTITLES)}get fullscreenElement(){var r;return(r=Ga(this,Cs))!=null?r:this}set fullscreenElement(r){this.hasAttribute(ki.FULLSCREEN_ELEMENT)&&this.removeAttribute(ki.FULLSCREEN_ELEMENT),nm(this,Cs,r)}attributeChangedCallback(r,o,m){var v;if(r===ki.NO_HOTKEYS)m!==o&&m===""?(this.hasAttribute(ki.HOTKEYS)&&console.warn("Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):m!==o&&m===null&&this.enableHotkeys();else if(r===ki.HOTKEYS)Ga(this,ra).value=m;else if(r===ki.DEFAULT_SUBTITLES&&m!==o&&m==="")xr(this,!0);else if(r===ki.DEFAULT_STREAM_TYPE)this.propagateMediaState(Na.MEDIA_STREAM_TYPE);else if(r===ki.FULLSCREEN_ELEMENT){let y=m?(v=this.getRootNode())==null?void 0:v.getElementById(m):void 0;nm(this,Cs,y)}super.attributeChangedCallback(r,o,m)}mediaSetCallback(r){if(super.mediaSetCallback(r),r.hasAttribute("tabindex")||(r.tabIndex=-1),Object.keys(Si).forEach(o=>{let{mediaEvents:m,rootEvents:v,trackListEvents:y}=Si[o],I=this._mediaStatePropagators[o];m==null||m.forEach(M=>{r.addEventListener(M,I),I()}),v==null||v.forEach(M=>{this.getRootNode().addEventListener(M,I),I()}),y==null||y.forEach(M=>{var U;(U=r.textTracks)==null||U.addEventListener(M,I),I()})}),!this.hasAttribute("novolumepref"))try{let o=W.localStorage.getItem("media-chrome-pref-volume");o!==null&&(r.volume=o)}catch(o){console.debug("Error getting volume pref",o)}}mediaUnsetCallback(r){super.mediaUnsetCallback(r),Object.keys(Si).forEach(o=>{let{mediaEvents:m,rootEvents:v,trackListEvents:y}=Si[o],I=this._mediaStatePropagators[o];m==null||m.forEach(M=>{r.removeEventListener(M,I)}),v==null||v.forEach(M=>{this.getRootNode().removeEventListener(M,I)}),y==null||y.forEach(M=>{var U;(U=r.textTracks)==null||U.removeEventListener(M,I)})}),this.propagateMediaState(Na.MEDIA_PAUSED,!0)}propagateMediaState(r,o){let m=r.toLowerCase(),v=this.getAttribute(m);if(um(this.mediaStateReceivers,r,o),v===this.getAttribute(m))return;let y=new W.CustomEvent(Pf[m],{composed:!0,bubbles:!0,detail:o});this.dispatchEvent(y)}associateElement(r){if(!r)return;let{associatedElementSubscriptions:o}=this;if(o.has(r))return;let m=this.registerMediaStateReceiver.bind(this),v=this.unregisterMediaStateReceiver.bind(this),y=HE(r,m,v);Object.keys(Ie).forEach(I=>{r.addEventListener(Ie[I],this[`_handle${nl(I,!0)}`])}),o.set(r,y)}unassociateElement(r){if(!r)return;let{associatedElementSubscriptions:o}=this;if(!o.has(r))return;o.get(r)(),o.delete(r),Object.keys(Ie).forEach(v=>{r.removeEventListener(Ie[v],this[`_handle${nl(v,!0)}`])})}registerMediaStateReceiver(r){if(!r)return;let o=this.mediaStateReceivers;o.indexOf(r)>-1||(o.push(r),Object.keys(Si).forEach(v=>{let y=Si[v];um([r],Na[v],y.get(this))}))}unregisterMediaStateReceiver(r){let o=this.mediaStateReceivers,m=o.indexOf(r);m<0||o.splice(m,1)}enableHotkeys(){this.addEventListener("keydown",Ln(this,_l,Gd))}disableHotkeys(){this.removeEventListener("keydown",Ln(this,_l,Gd)),this.removeEventListener("keyup",Ln(this,In,Ms))}get hotkeys(){return Ga(this,ra)}keyboardShortcutHandler(r){var o,m,v,y;if(((y=(v=(o=r.target.getAttribute(ki.KEYS_USED))==null?void 0:o.split(" "))!=null?v:(m=r.target)==null?void 0:m.keysUsed)!=null?y:[]).map(se=>se==="Space"?" ":se).filter(Boolean).includes(r.key))return;let M,U,H,z,J,Z=PE;if(!Ga(this,ra).contains(`no${r.key.toLowerCase()}`)&&!(r.key===" "&&Ga(this,ra).contains("nospace")))switch(r.key){case" ":case"k":M=this.getAttribute(F.MEDIA_PAUSED)!=null?Ie.MEDIA_PLAY_REQUEST:Ie.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new W.CustomEvent(M,{composed:!0,bubbles:!0}));break;case"m":M=this.getAttribute(F.MEDIA_VOLUME_LEVEL)==="off"?Ie.MEDIA_UNMUTE_REQUEST:Ie.MEDIA_MUTE_REQUEST,this.dispatchEvent(new W.CustomEvent(M,{composed:!0,bubbles:!0}));break;case"f":M=this.getAttribute(F.MEDIA_IS_FULLSCREEN)!=null?Ie.MEDIA_EXIT_FULLSCREEN_REQUEST:Ie.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new W.CustomEvent(M,{composed:!0,bubbles:!0}));break;case"c":xr(this);break;case"ArrowLeft":U=this.getAttribute(F.MEDIA_CURRENT_TIME),H=U&&!Number.isNaN(+U)?+U:sm,z=Math.max(H-Z,0),J=new W.CustomEvent(Ie.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:z}),this.dispatchEvent(J);break;case"ArrowRight":U=this.getAttribute(F.MEDIA_CURRENT_TIME),H=U&&!Number.isNaN(+U)?+U:sm,z=Math.max(H+Z,0),J=new W.CustomEvent(Ie.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:z}),this.dispatchEvent(J);break;default:break}}};ra=new WeakMap;Cs=new WeakMap;In=new WeakSet;Ms=function(n){let{key:r}=n;if(!dm.includes(r)){this.removeEventListener("keyup",Ln(this,In,Ms));return}this.keyboardShortcutHandler(n)};_l=new WeakSet;Gd=function(n){let{metaKey:r,altKey:o,key:m}=n;if(r||o||!dm.includes(m)){this.removeEventListener("keyup",Ln(this,In,Ms));return}[" ","ArrowLeft","ArrowRight"].includes(m)&&!(Ga(this,ra).contains(`no${m.toLowerCase()}`)||m===" "&&Ga(this,ra).contains("nospace"))&&n.preventDefault(),this.addEventListener("keyup",Ln(this,In,Ms),{once:!0})};var OE=Object.values(F),NE=Object.values(Na),cm=n=>{var r,o,m,v;let{observedAttributes:y}=n.constructor;!y&&((r=n.nodeName)==null?void 0:r.includes("-"))&&(W.customElements.upgrade(n),{observedAttributes:y}=n.constructor);let I=(v=(m=(o=n==null?void 0:n.getAttribute)==null?void 0:o.call(n,Ne.MEDIA_CHROME_ATTRIBUTES))==null?void 0:m.split)==null?void 0:v.call(m,/\s+/);return Array.isArray(y||I)?(y||I).filter(M=>OE.includes(M)):[]},FE=n=>{var r,o;return((r=n.nodeName)==null?void 0:r.includes("-"))&&!!W.customElements.get((o=n.nodeName)==null?void 0:o.toLowerCase())&&!(n instanceof W.customElements.get(n.nodeName.toLowerCase()))&&W.customElements.upgrade(n),NE.some(m=>m in n)},Vd=n=>FE(n)||!!cm(n).length,om=n=>{var r;return(r=n==null?void 0:n.join)==null?void 0:r.call(n,":")},lm={[F.MEDIA_SUBTITLES_LIST]:Ds,[F.MEDIA_SUBTITLES_SHOWING]:Ds,[F.MEDIA_SEEKABLE]:om,[F.MEDIA_BUFFERED]:n=>n==null?void 0:n.map(om).join(" "),[F.MEDIA_PREVIEW_COORDS]:n=>n==null?void 0:n.join(" ")},UE=async(n,r,o)=>{var m,v;if(n.isConnected||await ol(0),typeof o=="boolean"||o==null)return ut(n,r,o);if(typeof o=="number")return Tt(n,r,o);if(typeof o=="string")return Dt(n,r,o);if(Array.isArray(o)&&!o.length)return n.removeAttribute(r);let y=(v=(m=lm[r])==null?void 0:m.call(lm,o))!=null?v:o;return n.setAttribute(r,y)},BE=n=>{var r;return!!((r=n.closest)!=null&&r.call(n,'*[slot="media"]'))},Ha=(n,r)=>{if(BE(n))return;let o=(v,y)=>{var I,M;Vd(v)&&y(v);let{children:U=[]}=v!=null?v:{},H=(M=(I=v==null?void 0:v.shadowRoot)==null?void 0:I.children)!=null?M:[];[...U,...H].forEach(J=>Ha(J,y))},m=n==null?void 0:n.nodeName.toLowerCase();if(m.includes("-")&&!Vd(n)){W.customElements.whenDefined(m).then(()=>{o(n,r)});return}o(n,r)},um=(n,r,o)=>{n.forEach(m=>{if(r in m){m[r]=o;return}let v=cm(m),y=r.toLowerCase();!v.includes(y)||UE(m,y,o)})},HE=(n,r,o)=>{Ha(n,r);let m=z=>{var J;let Z=(J=z==null?void 0:z.composedPath()[0])!=null?J:z.target;r(Z)},v=z=>{var J;let Z=(J=z==null?void 0:z.composedPath()[0])!=null?J:z.target;o(Z)};n.addEventListener(Ie.REGISTER_MEDIA_STATE_RECEIVER,m),n.addEventListener(Ie.UNREGISTER_MEDIA_STATE_RECEIVER,v);let y=z=>{z.forEach(J=>{let{addedNodes:Z=[],removedNodes:se=[],type:me,target:Te,attributeName:ge}=J;me==="childList"?(Array.prototype.forEach.call(Z,ye=>Ha(ye,r)),Array.prototype.forEach.call(se,ye=>Ha(ye,o))):me==="attributes"&&ge===Ne.MEDIA_CHROME_ATTRIBUTES&&(Vd(Te)?r(Te):o(Te))})},I=[],M=z=>{let J=z.target;J.name!=="media"&&(I.forEach(Z=>Ha(Z,o)),I=[...J.assignedElements({flatten:!0})],I.forEach(Z=>Ha(Z,r)))};n.addEventListener("slotchange",M);let U=new MutationObserver(y);return U.observe(n,{childList:!0,attributes:!0,subtree:!0}),()=>{Ha(n,o),n.removeEventListener("slotchange",M),U.disconnect(),n.removeEventListener(Ie.REGISTER_MEDIA_STATE_RECEIVER,m),n.removeEventListener(Ie.UNREGISTER_MEDIA_STATE_RECEIVER,v)}};W.customElements.get("media-controller")||W.customElements.define("media-controller",Al);var Wd=Al;var GE=Object.defineProperty,VE=(n,r,o)=>r in n?GE(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o,KE=(n,r,o)=>(VE(n,typeof r!="symbol"?r+"":r,o),o),fm=(n,r,o)=>{if(!r.has(n))throw TypeError("Cannot "+o)},aa=(n,r,o)=>(fm(n,r,"read from private field"),o?o.call(n):r.get(n)),qd=(n,r,o)=>{if(r.has(n))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(n):r.set(n,o)},Sl=(n,r,o,m)=>(fm(n,r,"write to private field"),m?m.call(n,o):r.set(n,o),o),cr,kl,wl,mm=ae.createElement("template"),hm=`
|
|
219
|
+
`;var Jv=Object.values(R),eE="sm:384 md:576 lg:768 xl:960",tE=r=>{var e;for(let t of r){let i=t.target;if(!i.isConnected)continue;let s=(e=i.getAttribute(Ue.BREAKPOINTS))!=null?e:eE,n=iE(s),a=rE(n,t.contentRect),o=!1;if(Object.keys(n).forEach(l=>{if(a.includes(l)){i.hasAttribute(`breakpoint${l}`)||(i.setAttribute(`breakpoint${l}`,""),o=!0);return}i.hasAttribute(`breakpoint${l}`)&&(i.removeAttribute(`breakpoint${l}`),o=!0)}),o){let l=new CustomEvent(is.BREAKPOINTS_CHANGE,{detail:a});i.dispatchEvent(l)}}};function iE(r){let e=r.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function rE(r,e){return Object.keys(r).filter(t=>e.width>=r[t])}var ma=class extends N.HTMLElement{constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Jh.content.cloneNode(!0)));let e=l=>{let d=this.media;for(let u of l)u.type==="childList"&&(u.removedNodes.forEach(c=>{if(c.slot=="media"&&u.target==this){let h=u.previousSibling&&u.previousSibling.previousElementSibling;if(!h||!d)this.mediaUnsetCallback(c);else{let m=h.slot!=="media";for(;(h=h.previousSibling)!==null;)h.slot=="media"&&(m=!1);m&&this.mediaUnsetCallback(c)}}}),d&&u.addedNodes.forEach(c=>{c==d&&this.handleMediaUpdated(d).then(h=>this.mediaSetCallback(h))}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let i=!1,s=l=>{i||(N.setTimeout(()=>{tE(l),i=!1},16),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[Ue.AUTOHIDE,Ue.GESTURES_DISABLED].concat(Jv)}attributeChangedCallback(e,t,i){e.toLowerCase()==Ue.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 N.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("-")?N.customElements.whenDefined(s).then(()=>t(e)):t(e)}mediaUnsetCallback(e){}connectedCallback(){let t=this.getAttribute(Ue.AUDIO)!=null?Lt.AUDIO_PLAYER():Lt.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",t),this.media&&this.handleMediaUpdated(this.media).then(a=>this.mediaSetCallback(a)),this.setAttribute(Ue.USER_INACTIVE,"");let i=()=>{if(this.autohide<0||this.hasAttribute(Ue.USER_INACTIVE))return;this.setAttribute(Ue.USER_INACTIVE,"");let a=new N.CustomEvent(is.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(a)},s=()=>{if(!this.hasAttribute(Ue.USER_INACTIVE))return;this.removeAttribute(Ue.USER_INACTIVE);let a=new N.CustomEvent(is.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(a)},n=()=>{s(),N.clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=N.setTimeout(()=>{i()},this.autohide*1e3))};this.addEventListener("keyup",()=>{n()}),this.addEventListener("pointerup",a=>{a.pointerType==="touch"?[this,this.media].includes(a.target)&&!this.hasAttribute(Ue.USER_INACTIVE)?i():n():a.composedPath().some(o=>{var l;return["media-play-button","media-fullscreen-button"].includes((l=o==null?void 0:o.nodeName)==null?void 0:l.toLowerCase())})&&n()}),this.addEventListener("pointermove",a=>{a.pointerType==="mouse"&&(s(),N.clearTimeout(this._inactiveTimeout),[this,this.media].includes(a.target)&&n())}),this.addEventListener("mouseleave",()=>{i()}),this.addEventListener("keyup",()=>{this.setAttribute(Ue.KEYBOARD_CONTROL,"")}),N.addEventListener("mouseup",()=>{this.removeAttribute(Ue.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 ef=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},yt=(r,e,t)=>(ef(r,e,"read from private field"),t?t.call(r):e.get(r)),tn=(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)},pa=(r,e,t,i)=>(ef(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),ns,as,ga,Lr,Ui,sr,os=class{constructor(e,t,{defaultValue:i}={defaultValue:void 0}){tn(this,Ui),tn(this,ns,void 0),tn(this,as,void 0),tn(this,ga,void 0),tn(this,Lr,new Set),pa(this,ns,e),pa(this,as,t),pa(this,ga,new Set(i))}[Symbol.iterator](){return yt(this,Ui,sr).values()}get length(){return yt(this,Ui,sr).size}get value(){var e;return(e=[...yt(this,Ui,sr)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(pa(this,Lr,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...yt(this,Ui,sr)][e]}values(){return yt(this,Ui,sr).values()}forEach(e){yt(this,Ui,sr).forEach(e)}add(...e){var t,i;e.forEach(s=>yt(this,Lr).add(s)),!(this.value===""&&!((t=yt(this,ns))!=null&&t.hasAttribute(`${yt(this,as)}`)))&&((i=yt(this,ns))==null||i.setAttribute(`${yt(this,as)}`,`${this.value}`))}remove(...e){var t;e.forEach(i=>yt(this,Lr).delete(i)),(t=yt(this,ns))==null||t.setAttribute(`${yt(this,as)}`,`${this.value}`)}contains(e){return yt(this,Ui,sr).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}};ns=new WeakMap;as=new WeakMap;ga=new WeakMap;Lr=new WeakMap;Ui=new WeakSet;sr=function(){return yt(this,Lr).size?yt(this,Lr):yt(this,ga)};var tf=(r="")=>r.split(/\s+/),rf=(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}},ls=(r="",e={})=>tf(r).map(t=>{let i=rf(t);return{...e,...i}}),sE=r=>Array.isArray(r)?r.map(e=>typeof e=="string"?rf(e):e):typeof r=="string"?ls(r):[r],Cl=({kind:r,label:e,language:t}={kind:"subtitles"})=>e?`${r==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,rn=(r=[])=>Array.prototype.map.call(r,Cl).join(" "),nE=(r,e)=>t=>t[r]===e,sf=r=>{let e=Object.entries(r).map(([t,i])=>nE(t,i));return t=>e.every(i=>i(t))},Ml=(r,e=[],t=[])=>{let i=sE(t).map(sf),s=n=>i.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=r})},va=(r,e=()=>!0)=>{if(!(r!=null&&r.textTracks))return[];let t=typeof e=="function"?e:sf(e);return Array.from(r.textTracks).filter(t)},Ol=r=>!!r.getAttribute(R.MEDIA_SUBTITLES_SHOWING),Bi=(r,e)=>{var t,i;let s=Ol(r);if(s||e===!1){let n=r.getAttribute(R.MEDIA_SUBTITLES_SHOWING);if(n){let a=new window.CustomEvent(ne.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:n});r.dispatchEvent(a)}}else if(!s||e===!0){let[n]=(i=tf((t=r.getAttribute(R.MEDIA_SUBTITLES_LIST))!=null?t:""))!=null?i:[];if(n){let a=new window.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 rt={enter:"requestFullscreen",exit:"exitFullscreen",rootEvents:["fullscreenchange"],mediaEvents:[],element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};q.fullscreenElement===void 0&&(rt.enter="webkitRequestFullScreen",rt.exit=q.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",rt.rootEvents=["webkitfullscreenchange"],rt.mediaEvents=["webkitbeginfullscreen","webkitendfullscreen"],rt.element="webkitFullscreenElement",rt.error="webkitfullscreenerror",rt.enabled="webkitFullscreenEnabled");var Ea,Pl=()=>{var r,e;return Ea||(Ea=(e=(r=q)==null?void 0:r.createElement)==null?void 0:e.call(r,"video"),Ea)},nf=async(r=Pl())=>{if(!r)return!1;let e=r.volume;return r.volume=e/2+.1,await oa(0),r.volume!==e},aE=(r=Pl())=>typeof(r==null?void 0:r.requestPictureInPicture)=="function",oE=(r=Pl())=>{let e=q[rt.enabled];return!e&&r&&(e="webkitSupportsFullscreen"in r),e},Nl=oE(),af=aE(),of=!!N.WebKitPlaybackTargetAvailabilityEvent,lf=!!N.chrome;var ya,df=nf().then(r=>(ya=r,ya)),lE=Object.values(di),Fl=r=>va(r.media,e=>[rs.SUBTITLES,rs.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),dE=r=>va(r.media,e=>e.mode===sa.SHOWING&&[rs.SUBTITLES,rs.CAPTIONS].includes(e.kind)),$t={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(lE.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=$t.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(!($t.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&&q[rt.element]===void 0&&"webkitDisplayingFullscreen"in i)return i.webkitDisplayingFullscreen&&i.webkitPresentationMode==="fullscreen";let s;return e?s=q[rt.element]?e.target:null:s=(t=r.getRootNode().fullscreenElement)!=null?t:q[rt.element],en(r.fullscreenElement,s)},rootEvents:rt.rootEvents,mediaEvents:rt.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:q.pictureInPictureElement;return en(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=globalThis.CastableVideoElement)==null?void 0:t.castElement,n=en(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(!of)return Fi.UNSUPPORTED;if(!!e&&e.availability!=="available"&&e.availability==="not-available")return Fi.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"]},MEDIA_CAST_UNAVAILABLE:{get:function(){var r;let e=(r=globalThis.CastableVideoElement)==null?void 0:r.castState;if(!lf||!e)return Fi.UNSUPPORTED;if(!e.includes("CONNECT"))return Fi.UNAVAILABLE},mediaEvents:["castchange"]},MEDIA_FULLSCREEN_UNAVAILABLE:{get:function(){return Nl?void 0:Fi.UNAVAILABLE}},MEDIA_PIP_UNAVAILABLE:{get:function(){return af?void 0:Fi.UNSUPPORTED}},MEDIA_VOLUME_UNAVAILABLE:{get:function(r){if(ya!==void 0&&!ya)return Fi.UNSUPPORTED;let{media:e}=r;if(e&&typeof e.volume=="undefined")return Fi.UNAVAILABLE},mediaEvents:["loadstart"]},MEDIA_SUBTITLES_LIST:{get:function(r){return Fl(r).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],trackListEvents:["addtrack","removetrack"]},MEDIA_SUBTITLES_SHOWING:{get:function(r){return r.hasAttribute("defaultsubtitles")&&!r.hasAttribute(R.MEDIA_HAS_PLAYED)&&!r.hasAttribute(R.MEDIA_SUBTITLES_SHOWING)&&Bi(r,!0),dE(r).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],trackListEvents:["addtrack","removetrack","change"]}},ba={MEDIA_PLAY_REQUEST:(r,e,t)=>{var i;let s=$t.MEDIA_STREAM_TYPE.get(t),n=t.getAttribute("noautoseektolive")===null;s==di.LIVE&&n&&ba.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{N.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch{}},MEDIA_ENTER_FULLSCREEN_REQUEST:(r,e,t)=>{if(!Nl){console.warn("Fullscreen support is unavailable; not entering fullscreen");return}q.pictureInPictureElement&&q.exitPictureInPicture(),t[rt.enter]?t.fullscreenElement[rt.enter]():r.webkitEnterFullscreen?r.webkitEnterFullscreen():r.requestFullscreen?r.requestFullscreen():console.warn("MediaChrome: Fullscreen not supported")},MEDIA_EXIT_FULLSCREEN_REQUEST:()=>{q[rt.exit]()},MEDIA_ENTER_PIP_REQUEST:r=>{if(!q.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}q[rt.element]&&q[rt.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:()=>{q.pictureInPictureElement&&q.exitPictureInPicture()},MEDIA_ENTER_CAST_REQUEST:r=>{var e;!((e=globalThis.CastableVideoElement)!=null&&e.castEnabled)||(q[rt.element]&&q[rt.exit](),r.requestCast())},MEDIA_EXIT_CAST_REQUEST:async()=>{var r;(r=globalThis.CastableVideoElement)!=null&&r.castElement&&globalThis.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(R.MEDIA_PREVIEW_TIME,void 0),t.propagateMediaState(R.MEDIA_PREVIEW_TIME,s);let[n]=va(r,{kind:rs.METADATA,label:"thumbnails"});if(!(n&&n.cues))return;if(s===null){t.propagateMediaState(R.MEDIA_PREVIEW_IMAGE,void 0),t.propagateMediaState(R.MEDIA_PREVIEW_COORDS,void 0);return}let a=Array.prototype.find.call(n.cues,u=>u.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(R.MEDIA_PREVIEW_IMAGE,l.href),t.propagateMediaState(R.MEDIA_PREVIEW_COORDS,d.split(","))},MEDIA_SHOW_SUBTITLES_REQUEST:(r,e,t)=>{let i=Fl(t),{detail:s=[]}=e;Ml(sa.SHOWING,i,s)},MEDIA_DISABLE_SUBTITLES_REQUEST:(r,e,t)=>{let i=Fl(t),{detail:s=[]}=e;Ml(sa.DISABLED,i,s)},MEDIA_AIRPLAY_REQUEST:r=>{if(!!r){if(!(r.webkitShowPlaybackTargetPicker&&N.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)}};var $l=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},wr=(r,e,t)=>($l(r,e,"read from private field"),t?t.call(r):e.get(r)),Ta=(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)},uf=(r,e,t,i)=>($l(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),ds=(r,e,t)=>($l(r,e,"access private method"),t),nr,sn,us,nn,_a,Ul,pf=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],uE=10,cf=0,Gt={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"},Aa=class extends ma{constructor(){super(),Ta(this,us),Ta(this,_a),Ta(this,nr,new os(this,Gt.HOTKEYS)),Ta(this,sn,void 0),$t.MEDIA_VOLUME_UNAVAILABLE.get(this)===void 0&&df.then(()=>{this.propagateMediaState(R.MEDIA_VOLUME_UNAVAILABLE,$t.MEDIA_VOLUME_UNAVAILABLE.get(this))}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this),Object.keys(ba).forEach(e=>{let t=`_handle${na(e,!0)}`;this[t]=i=>{if(i.stopPropagation(),!this.media){console.warn("MediaController: No media available.");return}ba[e](this.media,i,this)},this.addEventListener(ne[e],this[t])}),this._mediaStatePropagators={},Object.keys($t).forEach(e=>{this._mediaStatePropagators[e]=t=>{this.propagateMediaState(Sr[e],$t[e].get(this,t))}}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(Gt.NO_HOTKEYS,Gt.HOTKEYS,Gt.DEFAULT_STREAM_TYPE,Gt.DEFAULT_SUBTITLES)}get fullscreenElement(){var e;return(e=wr(this,sn))!=null?e:this}set fullscreenElement(e){this.hasAttribute(Gt.FULLSCREEN_ELEMENT)&&this.removeAttribute(Gt.FULLSCREEN_ELEMENT),uf(this,sn,e)}attributeChangedCallback(e,t,i){var s;if(e===Gt.NO_HOTKEYS)i!==t&&i===""?(this.hasAttribute(Gt.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===Gt.HOTKEYS)wr(this,nr).value=i;else if(e===Gt.DEFAULT_SUBTITLES&&i!==t&&i==="")Bi(this,!0);else if(e===Gt.DEFAULT_STREAM_TYPE)this.propagateMediaState(Sr.MEDIA_STREAM_TYPE);else if(e===Gt.FULLSCREEN_ELEMENT){let n=i?(s=this.getRootNode())==null?void 0:s.getElementById(i):void 0;uf(this,sn,n)}super.attributeChangedCallback(e,t,i)}mediaSetCallback(e){if(super.mediaSetCallback(e),e.hasAttribute("tabindex")||(e.tabIndex=-1),Object.keys($t).forEach(t=>{let{mediaEvents:i,rootEvents:s,trackListEvents:n}=$t[t],a=this._mediaStatePropagators[t];i==null||i.forEach(o=>{e.addEventListener(o,a),a()}),s==null||s.forEach(o=>{this.getRootNode().addEventListener(o,a),a()}),n==null||n.forEach(o=>{var l;(l=e.textTracks)==null||l.addEventListener(o,a),a()})}),!this.hasAttribute("novolumepref"))try{let t=N.localStorage.getItem("media-chrome-pref-volume");t!==null&&(e.volume=t)}catch(t){console.debug("Error getting volume pref",t)}}mediaUnsetCallback(e){super.mediaUnsetCallback(e),Object.keys($t).forEach(t=>{let{mediaEvents:i,rootEvents:s,trackListEvents:n}=$t[t],a=this._mediaStatePropagators[t];i==null||i.forEach(o=>{e.removeEventListener(o,a)}),s==null||s.forEach(o=>{this.getRootNode().removeEventListener(o,a)}),n==null||n.forEach(o=>{var l;(l=e.textTracks)==null||l.removeEventListener(o,a)})}),this.propagateMediaState(Sr.MEDIA_PAUSED,!0)}propagateMediaState(e,t){let i=e.toLowerCase(),s=this.getAttribute(i);if(mf(this.mediaStateReceivers,e,t),s===this.getAttribute(i))return;let n=new N.CustomEvent(Uh[i],{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=gE(e,i,s);Object.keys(ne).forEach(a=>{e.addEventListener(ne[a],this[`_handle${na(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${na(s,!0)}`])})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),Object.keys($t).forEach(s=>{let n=$t[s];mf([e],Sr[s],n.get(this))}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,i=t.indexOf(e);i<0||t.splice(i,1)}enableHotkeys(){this.addEventListener("keydown",ds(this,_a,Ul))}disableHotkeys(){this.removeEventListener("keydown",ds(this,_a,Ul)),this.removeEventListener("keyup",ds(this,us,nn))}get hotkeys(){return wr(this,nr)}keyboardShortcutHandler(e){var t,i,s,n;if(((n=(s=(t=e.target.getAttribute(Gt.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,u,c,h=uE;if(!wr(this,nr).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&wr(this,nr).contains("nospace")))switch(e.key){case" ":case"k":o=this.getAttribute(R.MEDIA_PAUSED)!=null?ne.MEDIA_PLAY_REQUEST:ne.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new N.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"m":o=this.getAttribute(R.MEDIA_VOLUME_LEVEL)==="off"?ne.MEDIA_UNMUTE_REQUEST:ne.MEDIA_MUTE_REQUEST,this.dispatchEvent(new N.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"f":o=this.getAttribute(R.MEDIA_IS_FULLSCREEN)!=null?ne.MEDIA_EXIT_FULLSCREEN_REQUEST:ne.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new N.CustomEvent(o,{composed:!0,bubbles:!0}));break;case"c":Bi(this);break;case"ArrowLeft":l=this.getAttribute(R.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:cf,u=Math.max(d-h,0),c=new N.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break;case"ArrowRight":l=this.getAttribute(R.MEDIA_CURRENT_TIME),d=l&&!Number.isNaN(+l)?+l:cf,u=Math.max(d+h,0),c=new N.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break;default:break}}};nr=new WeakMap;sn=new WeakMap;us=new WeakSet;nn=function(r){let{key:e}=r;if(!pf.includes(e)){this.removeEventListener("keyup",ds(this,us,nn));return}this.keyboardShortcutHandler(r)};_a=new WeakSet;Ul=function(r){let{metaKey:e,altKey:t,key:i}=r;if(e||t||!pf.includes(i)){this.removeEventListener("keyup",ds(this,us,nn));return}[" ","ArrowLeft","ArrowRight"].includes(i)&&!(wr(this,nr).contains(`no${i.toLowerCase()}`)||i===" "&&wr(this,nr).contains("nospace"))&&r.preventDefault(),this.addEventListener("keyup",ds(this,us,nn),{once:!0})};var cE=Object.values(R),hE=Object.values(Sr),gf=r=>{var e,t,i,s;let{observedAttributes:n}=r.constructor;!n&&((e=r.nodeName)==null?void 0:e.includes("-"))&&(N.customElements.upgrade(r),{observedAttributes:n}=r.constructor);let a=(s=(i=(t=r==null?void 0:r.getAttribute)==null?void 0:t.call(r,ce.MEDIA_CHROME_ATTRIBUTES))==null?void 0:i.split)==null?void 0:s.call(i,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>cE.includes(o)):[]},fE=r=>{var e,t;return((e=r.nodeName)==null?void 0:e.includes("-"))&&!!N.customElements.get((t=r.nodeName)==null?void 0:t.toLowerCase())&&!(r instanceof N.customElements.get(r.nodeName.toLowerCase()))&&N.customElements.upgrade(r),hE.some(i=>i in r)},Bl=r=>fE(r)||!!gf(r).length,hf=r=>{var e;return(e=r==null?void 0:r.join)==null?void 0:e.call(r,":")},ff={[R.MEDIA_SUBTITLES_LIST]:rn,[R.MEDIA_SUBTITLES_SHOWING]:rn,[R.MEDIA_SEEKABLE]:hf,[R.MEDIA_BUFFERED]:r=>r==null?void 0:r.map(hf).join(" "),[R.MEDIA_PREVIEW_COORDS]:r=>r==null?void 0:r.join(" ")},mE=async(r,e,t)=>{var i,s;if(r.isConnected||await oa(0),typeof t=="boolean"||t==null)return Fe(r,e,t);if(typeof t=="number")return Xe(r,e,t);if(typeof t=="string")return nt(r,e,t);if(Array.isArray(t)&&!t.length)return r.removeAttribute(e);let n=(s=(i=ff[e])==null?void 0:i.call(ff,t))!=null?s:t;return r.setAttribute(e,n)},pE=r=>{var e;return!!((e=r.closest)!=null&&e.call(r,'*[slot="media"]'))},Rr=(r,e)=>{if(pE(r))return;let t=(s,n)=>{var a,o;Bl(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(c=>Rr(c,n))},i=r==null?void 0:r.nodeName.toLowerCase();if(i.includes("-")&&!Bl(r)){N.customElements.whenDefined(i).then(()=>{t(r,e)});return}t(r,e)},mf=(r,e,t)=>{r.forEach(i=>{if(e in i){i[e]=t;return}let s=gf(i),n=e.toLowerCase();!s.includes(n)||mE(i,n,t)})},gE=(r,e,t)=>{Rr(r,e);let i=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;e(h)},s=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;t(h)};r.addEventListener(ne.REGISTER_MEDIA_STATE_RECEIVER,i),r.addEventListener(ne.UNREGISTER_MEDIA_STATE_RECEIVER,s);let n=u=>{u.forEach(c=>{let{addedNodes:h=[],removedNodes:m=[],type:g,target:E,attributeName:T}=c;g==="childList"?(Array.prototype.forEach.call(h,A=>Rr(A,e)),Array.prototype.forEach.call(m,A=>Rr(A,t))):g==="attributes"&&T===ce.MEDIA_CHROME_ATTRIBUTES&&(Bl(E)?e(E):t(E))})},a=[],o=u=>{let c=u.target;c.name!=="media"&&(a.forEach(h=>Rr(h,t)),a=[...c.assignedElements({flatten:!0})],a.forEach(h=>Rr(h,e)))};r.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(r,{childList:!0,attributes:!0,subtree:!0}),()=>{Rr(r,t),r.removeEventListener("slotchange",o),l.disconnect(),r.removeEventListener(ne.REGISTER_MEDIA_STATE_RECEIVER,i),r.removeEventListener(ne.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};N.customElements.get("media-controller")||N.customElements.define("media-controller",Aa);var Gl=Aa;var vE=Object.defineProperty,EE=(r,e,t)=>e in r?vE(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yE=(r,e,t)=>(EE(r,typeof e!="symbol"?e+"":e,t),t),Ef=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},ar=(r,e,t)=>(Ef(r,e,"read from private field"),t?t.call(r):e.get(r)),Hl=(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)},Sa=(r,e,t,i)=>(Ef(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),_i,xa,Ia,yf=q.createElement("template"),vf=`
|
|
246
220
|
height: var(--thumb-height);
|
|
247
221
|
width: var(--media-range-thumb-width, 10px);
|
|
248
222
|
border: var(--media-range-thumb-border, none);
|
|
@@ -253,7 +227,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
253
227
|
transition: var(--media-range-thumb-transition, none);
|
|
254
228
|
transform: var(--media-range-thumb-transform, none);
|
|
255
229
|
opacity: var(--media-range-thumb-opacity, 1);
|
|
256
|
-
`,
|
|
230
|
+
`,Vl=`
|
|
257
231
|
min-width: 40px;
|
|
258
232
|
height: var(--track-height);
|
|
259
233
|
border: var(--media-range-track-border, none);
|
|
@@ -266,7 +240,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
266
240
|
transition: var(--media-range-track-transition, none);
|
|
267
241
|
transform: translate(var(--media-range-track-translate-x, 0), var(--media-range-track-translate-y, 0));
|
|
268
242
|
cursor: pointer;
|
|
269
|
-
`;
|
|
243
|
+
`;yf.innerHTML=`
|
|
270
244
|
<style>
|
|
271
245
|
:host {
|
|
272
246
|
--thumb-height: var(--media-range-thumb-height, 10px);
|
|
@@ -324,19 +298,19 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
324
298
|
|
|
325
299
|
input[type=range]::-webkit-slider-thumb {
|
|
326
300
|
-webkit-appearance: none;
|
|
327
|
-
${
|
|
301
|
+
${vf}
|
|
328
302
|
|
|
329
303
|
margin-top: calc(calc(0px - var(--thumb-height) + var(--track-height)) / 2);
|
|
330
304
|
}
|
|
331
305
|
|
|
332
306
|
|
|
333
307
|
input[type=range]::-moz-range-thumb {
|
|
334
|
-
${
|
|
308
|
+
${vf}
|
|
335
309
|
translate: var(--media-range-track-translate-x, 0) var(--media-range-track-translate-y, 0);
|
|
336
310
|
}
|
|
337
311
|
|
|
338
|
-
input[type=range]::-webkit-slider-runnable-track { ${
|
|
339
|
-
input[type=range]::-moz-range-track { ${
|
|
312
|
+
input[type=range]::-webkit-slider-runnable-track { ${Vl} }
|
|
313
|
+
input[type=range]::-moz-range-track { ${Vl} }
|
|
340
314
|
input[type=range]::-ms-track {
|
|
341
315
|
|
|
342
316
|
width: 100%;
|
|
@@ -346,7 +320,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
346
320
|
border-color: transparent;
|
|
347
321
|
color: transparent;
|
|
348
322
|
|
|
349
|
-
${
|
|
323
|
+
${Vl}
|
|
350
324
|
}
|
|
351
325
|
|
|
352
326
|
#background,
|
|
@@ -409,7 +383,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
409
383
|
<div id="hoverzone"></div>
|
|
410
384
|
<input id="range" type="range" min="0" max="1000" step="any" value="0">
|
|
411
385
|
</div>
|
|
412
|
-
`;var
|
|
386
|
+
`;var kr=class extends N.HTMLElement{constructor(){super(),yE(this,"thumbWidth"),Hl(this,_i,void 0),Hl(this,xa,()=>{if(this.range.matches(":focus-visible")){let{style:t}=Ke(this.shadowRoot,":host");t.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),Hl(this,Ia,()=>{let{style:t}=Ke(this.shadowRoot,":host");t.removeProperty("--_focus-visible-box-shadow")}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(yf.content.cloneNode(!0)));let{style:e}=Ke(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",ce.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===ce.MEDIA_CONTROLLER?(t&&((n=(s=ar(this,_i))==null?void 0:s.unassociateElement)==null||n.call(s,this),Sa(this,_i,null)),i&&(Sa(this,_i,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=ar(this,_i))==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(ce.MEDIA_CONTROLLER);s&&(Sa(this,_i,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=ar(this,_i))==null?void 0:t.associateElement)==null||i.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",ar(this,xa)),this.shadowRoot.addEventListener("focusout",ar(this,Ia))}disconnectedCallback(){var e,t;(t=(e=ar(this,_i))==null?void 0:e.unassociateElement)==null||t.call(e,this),Sa(this,_i,null),this.shadowRoot.removeEventListener("focusin",ar(this,xa)),this.shadowRoot.removeEventListener("focusout",ar(this,Ia))}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}=Ke(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}=Ke(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"]}};_i=new WeakMap;xa=new WeakMap;Ia=new WeakMap;N.customElements.get("media-chrome-range")||N.customElements.define("media-chrome-range",kr);var bf=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},La=(r,e,t)=>(bf(r,e,"read from private field"),t?t.call(r):e.get(r)),bE=(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)},Ra=(r,e,t,i)=>(bf(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Ai,Tf=q.createElement("template");Tf.innerHTML=`
|
|
413
387
|
<style>
|
|
414
388
|
:host {
|
|
415
389
|
|
|
@@ -435,7 +409,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
435
409
|
</style>
|
|
436
410
|
|
|
437
411
|
<slot></slot>
|
|
438
|
-
`;var
|
|
412
|
+
`;var Kl=class extends N.HTMLElement{constructor(){super(),bE(this,Ai,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Tf.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}=Ke(this.shadowRoot,":host"),s=t?"unset":"initial";i.setProperty("--_range-auto-size",s)})}static get observedAttributes(){return[ce.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===ce.MEDIA_CONTROLLER&&(t&&((n=(s=La(this,Ai))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ra(this,Ai,null)),i&&(Ra(this,Ai,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=La(this,Ai))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,i;let s=this.getAttribute(ce.MEDIA_CONTROLLER);s&&(Ra(this,Ai,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=La(this,Ai))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=La(this,Ai))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ra(this,Ai,null)}};Ai=new WeakMap;N.customElements.get("media-control-bar")||N.customElements.define("media-control-bar",Kl);var _f=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},wa=(r,e,t)=>(_f(r,e,"read from private field"),t?t.call(r):e.get(r)),TE=(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)},ka=(r,e,t,i)=>(_f(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Si,Af=q.createElement("template");Af.innerHTML=`
|
|
439
413
|
<style>
|
|
440
414
|
:host {
|
|
441
415
|
font: var(--media-font,
|
|
@@ -468,11 +442,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
468
442
|
}
|
|
469
443
|
</style>
|
|
470
444
|
<slot></slot>
|
|
471
|
-
`;var
|
|
445
|
+
`;var $i=class extends N.HTMLElement{constructor(){super(),TE(this,Si,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Af.content.cloneNode(!0)));let{style:e}=Ke(this.shadowRoot,":host");e.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`)}static get observedAttributes(){return[ce.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===ce.MEDIA_CONTROLLER&&(t&&((n=(s=wa(this,Si))==null?void 0:s.unassociateElement)==null||n.call(s,this),ka(this,Si,null)),i&&(ka(this,Si,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=wa(this,Si))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,i;let s=this.getAttribute(ce.MEDIA_CONTROLLER);s&&(ka(this,Si,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=wa(this,Si))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=wa(this,Si))==null?void 0:e.unassociateElement)==null||t.call(e,this),ka(this,Si,null)}};Si=new WeakMap;N.customElements.get("media-text-display")||N.customElements.define("media-text-display",$i);var xf=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Sf=(r,e,t)=>(xf(r,e,"read from private field"),t?t.call(r):e.get(r)),_E=(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)},AE=(r,e,t,i)=>(xf(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),an,Wl=class extends $i{constructor(){super(),_E(this,an,void 0),AE(this,an,this.shadowRoot.querySelector("slot")),Sf(this,an).textContent=bi(0)}static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_DURATION]}attributeChangedCallback(e,t,i){e===R.MEDIA_DURATION&&(Sf(this,an).textContent=bi(i)),super.attributeChangedCallback(e,t,i)}get mediaDuration(){return et(this,R.MEDIA_DURATION)}set mediaDuration(e){Xe(this,R.MEDIA_DURATION,e)}};an=new WeakMap;N.customElements.get("media-duration-display")||N.customElements.define("media-duration-display",Wl);var wf=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},ql=(r,e,t)=>(wf(r,e,"read from private field"),t?t.call(r):e.get(r)),SE=(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)},xE=(r,e,t,i)=>(wf(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),cs,ui={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},If=[...Object.values(ui),R.MEDIA_CURRENT_TIME,R.MEDIA_DURATION,R.MEDIA_SEEKABLE],Lf=["Enter"," "],IE=" / ",Rf=(r,{timesSep:e=IE}={})=>{var t,i,s,n;let a=r.hasAttribute(ui.REMAINING),o=r.hasAttribute(ui.SHOW_DURATION),l=(t=r.mediaCurrentTime)!=null?t:0,[,d]=(i=r.mediaSeekable)!=null?i:[],u=(n=(s=r.mediaDuration)!=null?s:d)!=null?n:0,c=a?bi(0-(u-l)):bi(l);return o?`${c}${e}${bi(u)}`:c},LE="video not loaded, unknown time.",RE=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",LE);return}let n=r.hasAttribute(ui.REMAINING),a=r.hasAttribute(ui.SHOW_DURATION),o=n?xr(0-(s-t)):xr(t);if(!a){r.setAttribute("aria-valuetext",o);return}let l=xr(s),d=`${o} of ${l}`;r.setAttribute("aria-valuetext",d)},Yl=class extends $i{constructor(){super(),SE(this,cs,void 0),xE(this,cs,this.shadowRoot.querySelector("slot")),ql(this,cs).innerHTML=`${Rf(this)}`;let{style:e}=Ke(this.shadowRoot,":host:not([notoggle])");e.setProperty("cursor","pointer");let{style:t}=Ke(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,...If,"disabled"]}connectedCallback(){this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Lt.PLAYBACK_TIME());let e=t=>{let{key:i}=t;if(!Lf.includes(i)){this.removeEventListener("keyup",e);return}this.toggleTimeDisplay()};this.addEventListener("keydown",t=>{let{metaKey:i,altKey:s,key:n}=t;if(i||s||!Lf.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){If.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 Ge(this,ui.REMAINING)}set remaining(e){Fe(this,ui.REMAINING,e)}get showDuration(){return Ge(this,ui.SHOW_DURATION)}set showDuration(e){Fe(this,ui.SHOW_DURATION,e)}get noToggle(){return Ge(this,ui.NO_TOGGLE)}set noToggle(e){Fe(this,ui.NO_TOGGLE,e)}get mediaDuration(){return et(this,R.MEDIA_DURATION)}set mediaDuration(e){Xe(this,R.MEDIA_DURATION,e)}get mediaCurrentTime(){return et(this,R.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){Xe(this,R.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(R.MEDIA_SEEKABLE);if(!!e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(R.MEDIA_SEEKABLE);return}this.setAttribute(R.MEDIA_SEEKABLE,e.join(":"))}update(){let e=Rf(this);RE(this),e!==ql(this,cs).innerHTML&&(ql(this,cs).innerHTML=e)}};cs=new WeakMap;N.customElements.get("media-time-display")||N.customElements.define("media-time-display",Yl);var wE=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
472
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"/>
|
|
473
|
-
</svg>`,
|
|
447
|
+
</svg>`,kE=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
474
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"/>
|
|
475
|
-
</svg>`,
|
|
449
|
+
</svg>`,Mf=q.createElement("template");Mf.innerHTML=`
|
|
476
450
|
<style>
|
|
477
451
|
:host([aria-checked="true"]) slot[name=off] {
|
|
478
452
|
display: none !important;
|
|
@@ -485,32 +459,32 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
485
459
|
</style>
|
|
486
460
|
|
|
487
461
|
<slot name="icon">
|
|
488
|
-
<slot name="on">${
|
|
489
|
-
<slot name="off">${
|
|
462
|
+
<slot name="on">${wE}</slot>
|
|
463
|
+
<slot name="off">${kE}</slot>
|
|
490
464
|
</slot>
|
|
491
|
-
`;var
|
|
492
|
-
<slot name="icon">${
|
|
493
|
-
`;var
|
|
465
|
+
`;var kf=r=>{r.setAttribute("aria-checked",Ol(r))},Df=(r,e)=>{let t=r.getAttribute(e);return t?ls(t):[]},Cf=(r,e,t)=>{if(!(t!=null&&t.length)){r.removeAttribute(e);return}let i=rn(t);r.getAttribute(e)!==i&&r.setAttribute(e,i)},jl=class extends We{static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_SUBTITLES_LIST,R.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:Mf,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Lt.CLOSED_CAPTIONS()),kf(this)}attributeChangedCallback(e,t,i){e===R.MEDIA_SUBTITLES_SHOWING&&kf(this),super.attributeChangedCallback(e,t,i)}get mediaSubtitlesList(){return Df(this,R.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Cf(this,R.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Df(this,R.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Cf(this,R.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){Bi(this)}};N.customElements.get("media-captions-button")||N.customElements.define("media-captions-button",jl);function hs(r){let e=Math.abs(r.seekOffset),t=ze.SEEK_BACK_N_SECS({seekOffset:e});r.setAttribute("aria-label",t)}function fs(r){let e=Vh(r,"icon"),t=r.seekOffset;Hh(e,t)}var Da={SEEK_OFFSET:"seekoffset"},Of=30,DE=`<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)">${Of}</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>`,Pf=q.createElement("template");Pf.innerHTML=`
|
|
466
|
+
<slot name="icon">${DE}</slot>
|
|
467
|
+
`;var CE=0,zl=class extends We{static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_CURRENT_TIME,Da.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Pf,...e})}connectedCallback(){hs(this),fs(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===Da.SEEK_OFFSET&&(fs(this),hs(this)),super.attributeChangedCallback(e,t,i)}get seekOffset(){return et(this,Da.SEEK_OFFSET,Of)}set seekOffset(e){Xe(this,Da.SEEK_OFFSET,e)}get mediaCurrentTime(){return et(this,R.MEDIA_CURRENT_TIME,CE)}set mediaCurrentTime(e){Xe(this,R.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new N.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};N.customElements.get("media-seek-forward-button")||N.customElements.define("media-seek-forward-button",zl);var ME=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
494
468
|
<path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
|
|
495
|
-
</svg>`,
|
|
469
|
+
</svg>`,OE=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
496
470
|
<path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
|
|
497
|
-
</svg>`,
|
|
471
|
+
</svg>`,Ff=q.createElement("template");Ff.innerHTML=`
|
|
498
472
|
<style>
|
|
499
|
-
:host([${
|
|
473
|
+
:host([${R.MEDIA_IS_FULLSCREEN}]) slot:not([name=exit]):not([name=icon]) {
|
|
500
474
|
display: none !important;
|
|
501
475
|
}
|
|
502
476
|
|
|
503
477
|
|
|
504
|
-
:host(:not([${
|
|
478
|
+
:host(:not([${R.MEDIA_IS_FULLSCREEN}])) slot:not([name=enter]):not([name=icon]) {
|
|
505
479
|
display: none !important;
|
|
506
480
|
}
|
|
507
481
|
</style>
|
|
508
482
|
|
|
509
483
|
<slot name="icon">
|
|
510
|
-
<slot name="enter">${
|
|
511
|
-
<slot name="exit">${
|
|
484
|
+
<slot name="enter">${ME}</slot>
|
|
485
|
+
<slot name="exit">${OE}</slot>
|
|
512
486
|
</slot>
|
|
513
|
-
`;var
|
|
487
|
+
`;var Nf=r=>{let e=r.mediaIsFullscreen?ze.EXIT_FULLSCREEN():ze.ENTER_FULLSCREEN();r.setAttribute("aria-label",e)},Xl=class extends We{static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_IS_FULLSCREEN,R.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Ff,...e})}connectedCallback(){Nf(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===R.MEDIA_IS_FULLSCREEN&&Nf(this),super.attributeChangedCallback(e,t,i)}get mediaFullscreenUnavailable(){return dt(this,R.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){nt(this,R.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return Ge(this,R.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){Fe(this,R.MEDIA_IS_FULLSCREEN,e)}handleClick(){let e=this.mediaIsFullscreen?ne.MEDIA_EXIT_FULLSCREEN_REQUEST:ne.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new N.CustomEvent(e,{composed:!0,bubbles:!0}))}};N.customElements.get("media-fullscreen-button")||N.customElements.define("media-fullscreen-button",Xl);var{MEDIA_TIME_IS_LIVE:Ca,MEDIA_PAUSED:on}=R,{MEDIA_SEEK_TO_LIVE_REQUEST:PE,MEDIA_PLAY_REQUEST:NE}=ne,FE='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',Uf=q.createElement("template");Uf.innerHTML=`
|
|
514
488
|
<style>
|
|
515
489
|
|
|
516
490
|
slot[name=indicator] > *,
|
|
@@ -521,94 +495,94 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
521
495
|
color: var(--media-live-button-icon-color, rgb(140, 140, 140));
|
|
522
496
|
}
|
|
523
497
|
|
|
524
|
-
:host([${
|
|
525
|
-
:host([${
|
|
498
|
+
:host([${Ca}]:not([${on}])) slot[name=indicator] > *,
|
|
499
|
+
:host([${Ca}]:not([${on}])) ::slotted([slot=indicator]) {
|
|
526
500
|
fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));
|
|
527
501
|
color: var(--media-live-button-indicator-color, rgb(255, 0, 0));
|
|
528
502
|
}
|
|
529
503
|
|
|
530
|
-
:host([${
|
|
504
|
+
:host([${Ca}]:not([${on}])) {
|
|
531
505
|
cursor: not-allowed;
|
|
532
506
|
}
|
|
533
507
|
|
|
534
508
|
</style>
|
|
535
509
|
|
|
536
|
-
<slot name="indicator">${
|
|
510
|
+
<slot name="indicator">${FE}</slot>
|
|
537
511
|
|
|
538
512
|
<slot name="spacer"> </slot><slot name="text">LIVE</slot>
|
|
539
|
-
`;var
|
|
513
|
+
`;var Ql=class extends We{static get observedAttributes(){return[...super.observedAttributes,on,Ca]}constructor(e={}){super({slotTemplate:Uf,...e}),this.setAttribute("aria-label",ze.SEEK_LIVE())}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),this.mediaPaused||!this.mediaTimeIsLive?(this.setAttribute("aria-label",ze.SEEK_LIVE()),this.removeAttribute("aria-disabled")):(this.setAttribute("aria-label",ze.PLAYING_LIVE()),this.setAttribute("aria-disabled","true"))}get mediaPaused(){return Ge(this,R.MEDIA_PAUSED)}set mediaPaused(e){Fe(this,R.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return Ge(this,R.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){Fe(this,R.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new N.CustomEvent(PE,{composed:!0,bubbles:!0})),this.hasAttribute(on)&&this.dispatchEvent(new N.CustomEvent(NE,{composed:!0,bubbles:!0})))}};N.customElements.get("media-live-button")||N.customElements.define("media-live-button",Ql);var{MEDIA_VOLUME_LEVEL:ln}=R,UE=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
540
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"/>
|
|
541
|
-
</svg>`,
|
|
515
|
+
</svg>`,Bf=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
542
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"/>
|
|
543
|
-
</svg>`,
|
|
517
|
+
</svg>`,BE=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
544
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"/>
|
|
545
|
-
</svg>`,
|
|
519
|
+
</svg>`,Gf=q.createElement("template");Gf.innerHTML=`
|
|
546
520
|
<style>
|
|
547
521
|
|
|
548
|
-
:host(:not([${
|
|
549
|
-
:host([${
|
|
522
|
+
:host(:not([${ln}])) slot:not([name=high]):not([name=icon]),
|
|
523
|
+
:host([${ln}=high]) slot:not([name=high]):not([name=icon]) {
|
|
550
524
|
display: none !important;
|
|
551
525
|
}
|
|
552
526
|
|
|
553
|
-
:host([${
|
|
527
|
+
:host([${ln}=off]) slot:not([name=off]):not([name=icon]) {
|
|
554
528
|
display: none !important;
|
|
555
529
|
}
|
|
556
530
|
|
|
557
|
-
:host([${
|
|
531
|
+
:host([${ln}=low]) slot:not([name=low]):not([name=icon]) {
|
|
558
532
|
display: none !important;
|
|
559
533
|
}
|
|
560
534
|
|
|
561
|
-
:host([${
|
|
535
|
+
:host([${ln}=medium]) slot:not([name=medium]):not([name=icon]) {
|
|
562
536
|
display: none !important;
|
|
563
537
|
}
|
|
564
538
|
</style>
|
|
565
539
|
|
|
566
540
|
<slot name="icon">
|
|
567
|
-
<slot name="off">${
|
|
568
|
-
<slot name="low">${
|
|
569
|
-
<slot name="medium">${
|
|
570
|
-
<slot name="high">${
|
|
541
|
+
<slot name="off">${UE}</slot>
|
|
542
|
+
<slot name="low">${Bf}</slot>
|
|
543
|
+
<slot name="medium">${Bf}</slot>
|
|
544
|
+
<slot name="high">${BE}</slot>
|
|
571
545
|
</slot>
|
|
572
|
-
`;var
|
|
546
|
+
`;var $f=r=>{let t=r.mediaVolumeLevel==="off"?ze.UNMUTE():ze.MUTE();r.setAttribute("aria-label",t)},Zl=class extends We{static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:Gf,...e})}connectedCallback(){$f(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===R.MEDIA_VOLUME_LEVEL&&$f(this),super.attributeChangedCallback(e,t,i)}get mediaVolumeLevel(){return dt(this,R.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){nt(this,R.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e=this.mediaVolumeLevel==="off"?ne.MEDIA_UNMUTE_REQUEST:ne.MEDIA_MUTE_REQUEST;this.dispatchEvent(new N.CustomEvent(e,{composed:!0,bubbles:!0}))}};N.customElements.get("media-mute-button")||N.customElements.define("media-mute-button",Zl);var Hf=`<svg aria-hidden="true" viewBox="0 0 28 24">
|
|
573
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"/>
|
|
574
|
-
</svg>`,
|
|
548
|
+
</svg>`,Kf=q.createElement("template");Kf.innerHTML=`
|
|
575
549
|
<style>
|
|
576
|
-
:host([${
|
|
550
|
+
:host([${R.MEDIA_IS_PIP}]) slot:not([name=exit]):not([name=icon]) {
|
|
577
551
|
display: none !important;
|
|
578
552
|
}
|
|
579
553
|
|
|
580
554
|
|
|
581
|
-
:host(:not([${
|
|
555
|
+
:host(:not([${R.MEDIA_IS_PIP}])) slot:not([name=enter]):not([name=icon]) {
|
|
582
556
|
display: none !important;
|
|
583
557
|
}
|
|
584
558
|
</style>
|
|
585
559
|
|
|
586
560
|
<slot name="icon">
|
|
587
|
-
<slot name="enter">${
|
|
588
|
-
<slot name="exit">${
|
|
561
|
+
<slot name="enter">${Hf}</slot>
|
|
562
|
+
<slot name="exit">${Hf}</slot>
|
|
589
563
|
</slot>
|
|
590
|
-
`;var
|
|
564
|
+
`;var Vf=r=>{let e=r.mediaIsPip?ze.EXIT_PIP():ze.ENTER_PIP();r.setAttribute("aria-label",e)},Jl=class extends We{static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_IS_PIP,R.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Kf,...e})}connectedCallback(){Vf(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===R.MEDIA_IS_PIP&&Vf(this),super.attributeChangedCallback(e,t,i)}get mediaPipUnavailable(){return dt(this,R.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){nt(this,R.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return Ge(this,R.MEDIA_IS_PIP)}set mediaIsPip(e){Fe(this,R.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?ne.MEDIA_EXIT_PIP_REQUEST:ne.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new N.CustomEvent(e,{composed:!0,bubbles:!0}))}};N.customElements.get("media-pip-button")||N.customElements.define("media-pip-button",Jl);var $E=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
591
565
|
<path d="m6 21 15-9L6 3v18Z"/>
|
|
592
|
-
</svg>`,
|
|
566
|
+
</svg>`,GE=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
593
567
|
<path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
|
|
594
|
-
</svg>`,
|
|
568
|
+
</svg>`,qf=q.createElement("template");qf.innerHTML=`
|
|
595
569
|
<style>
|
|
596
|
-
:host([${
|
|
570
|
+
:host([${R.MEDIA_PAUSED}]) slot[name=pause] {
|
|
597
571
|
display: none !important;
|
|
598
572
|
}
|
|
599
573
|
|
|
600
|
-
:host(:not([${
|
|
574
|
+
:host(:not([${R.MEDIA_PAUSED}])) slot[name=play] {
|
|
601
575
|
display: none !important;
|
|
602
576
|
}
|
|
603
577
|
</style>
|
|
604
578
|
|
|
605
579
|
<slot name="icon">
|
|
606
|
-
<slot name="play">${
|
|
607
|
-
<slot name="pause">${
|
|
580
|
+
<slot name="play">${$E}</slot>
|
|
581
|
+
<slot name="pause">${GE}</slot>
|
|
608
582
|
</slot>
|
|
609
|
-
`;var
|
|
583
|
+
`;var Wf=r=>{let e=r.mediaPaused?ze.PLAY():ze.PAUSE();r.setAttribute("aria-label",e)},ed=class extends We{static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_PAUSED,R.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:qf,...e})}connectedCallback(){Wf(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===R.MEDIA_PAUSED&&Wf(this),super.attributeChangedCallback(e,t,i)}get mediaPaused(){return Ge(this,R.MEDIA_PAUSED)}set mediaPaused(e){Fe(this,R.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?ne.MEDIA_PLAY_REQUEST:ne.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new N.CustomEvent(e,{composed:!0,bubbles:!0}))}};N.customElements.get("media-play-button")||N.customElements.define("media-play-button",ed);var HE=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Ma=(r,e,t)=>(HE(r,e,"read from private field"),t?t.call(r):e.get(r)),VE=(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)},ms,td={RATES:"rates"},KE=[1,1.25,1.5,1.75,2],Oa=1,Yf=q.createElement("template");Yf.innerHTML=`
|
|
610
584
|
<span id="container"></span>
|
|
611
|
-
`;var
|
|
585
|
+
`;var id=class extends We{constructor(e={}){super({slotTemplate:Yf,...e}),VE(this,ms,new os(this,td.RATES,{defaultValue:KE})),this.container=this.shadowRoot.querySelector("#container"),this.container.innerHTML=`${Oa}x`}static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_PLAYBACK_RATE,td.RATES]}attributeChangedCallback(e,t,i){if(e===td.RATES&&(Ma(this,ms).value=i),e===R.MEDIA_PLAYBACK_RATE){let s=i?+i:Number.NaN,n=Number.isNaN(s)?Oa:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Lt.PLAYBACK_RATE({playbackRate:n}));return}super.attributeChangedCallback(e,t,i)}get rates(){return Ma(this,ms)}set rates(e){e?Array.isArray(e)&&(Ma(this,ms).value=e.join(" ")):Ma(this,ms).value=""}get mediaPlaybackRate(){return et(this,R.MEDIA_PLAYBACK_RATE,Oa)}set mediaPlaybackRate(e){Xe(this,R.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let i=Array.from(this.rates.values(),a=>+a).sort(),s=(t=(e=i.find(a=>a>this.mediaPlaybackRate))!=null?e:i[0])!=null?t:Oa,n=new N.CustomEvent(ne.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}};ms=new WeakMap;N.customElements.get("media-playback-rate-button")||N.customElements.define("media-playback-rate-button",id);var xi={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},jf=q.createElement("template");jf.innerHTML=`
|
|
612
586
|
<style>
|
|
613
587
|
:host {
|
|
614
588
|
pointer-events: none;
|
|
@@ -630,9 +604,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
630
604
|
</style>
|
|
631
605
|
|
|
632
606
|
<img aria-hidden="true" id="image"/>
|
|
633
|
-
`;var
|
|
634
|
-
<slot name="icon">${
|
|
635
|
-
`;var
|
|
607
|
+
`;var WE=r=>{r.style.removeProperty("background-image")},qE=(r,e)=>{r.style["background-image"]=`url('${e}')`},rd=class extends N.HTMLElement{static get observedAttributes(){return[xi.PLACEHOLDER_SRC,xi.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(jf.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,i){e===xi.SRC&&(i==null?this.image.removeAttribute(xi.SRC):this.image.setAttribute(xi.SRC,i)),e===xi.PLACEHOLDER_SRC&&(i==null?WE(this.image):qE(this.image,i))}get placeholderSrc(){return dt(this,xi.PLACEHOLDER_SRC)}set placeholderSrc(e){nt(this,xi.SRC,e)}get src(){return dt(this,xi.SRC)}set src(e){nt(this,xi.SRC,e)}};N.customElements.get("media-poster-image")||N.customElements.define("media-poster-image",rd);var Pa={SEEK_OFFSET:"seekoffset"},zf=30,YE=`<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)">${zf}</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>`,Xf=q.createElement("template");Xf.innerHTML=`
|
|
608
|
+
<slot name="icon">${YE}</slot>
|
|
609
|
+
`;var jE=0,sd=class extends We{static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_CURRENT_TIME,Pa.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Xf,...e})}connectedCallback(){hs(this),fs(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===Pa.SEEK_OFFSET&&(fs(this),hs(this)),super.attributeChangedCallback(e,t,i)}get seekOffset(){return et(this,Pa.SEEK_OFFSET,zf)}set seekOffset(e){Xe(this,Pa.SEEK_OFFSET,e)}get mediaCurrentTime(){return et(this,R.MEDIA_CURRENT_TIME,jE)}set mediaCurrentTime(e){Xe(this,R.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new N.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};N.customElements.get("media-seek-backward-button")||N.customElements.define("media-seek-backward-button",sd);var Zf=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Qf=(r,e,t)=>(Zf(r,e,"read from private field"),t?t.call(r):e.get(r)),zE=(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)},XE=(r,e,t,i)=>(Zf(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),dn,nd=class extends $i{constructor(){super(),zE(this,dn,void 0),XE(this,dn,this.shadowRoot.querySelector("slot")),Qf(this,dn).textContent=bi(0)}static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,i){e===R.MEDIA_PREVIEW_TIME&&i!=null&&(Qf(this,dn).textContent=bi(i)),super.attributeChangedCallback(e,t,i)}get mediaPreviewTime(){return et(this,R.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){Xe(this,R.MEDIA_PREVIEW_TIME,e)}};dn=new WeakMap;N.customElements.get("media-preview-time-display")||N.customElements.define("media-preview-time-display",nd);var Jf=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Na=(r,e,t)=>(Jf(r,e,"read from private field"),t?t.call(r):e.get(r)),QE=(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)},Fa=(r,e,t,i)=>(Jf(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Ii,em=q.createElement("template");em.innerHTML=`
|
|
636
610
|
<style>
|
|
637
611
|
:host {
|
|
638
612
|
box-sizing: border-box;
|
|
@@ -646,7 +620,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
646
620
|
}
|
|
647
621
|
</style>
|
|
648
622
|
<img crossorigin loading="eager" decoding="async">
|
|
649
|
-
`;var
|
|
623
|
+
`;var ad=class extends N.HTMLElement{constructor(){super(),QE(this,Ii,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(em.content.cloneNode(!0)))}static get observedAttributes(){return[ce.MEDIA_CONTROLLER,R.MEDIA_PREVIEW_IMAGE,R.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,i;let s=this.getAttribute(ce.MEDIA_CONTROLLER);s&&(Fa(this,Ii,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=Na(this,Ii))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Na(this,Ii))==null?void 0:e.unassociateElement)==null||t.call(e,this),Fa(this,Ii,null)}attributeChangedCallback(e,t,i){var s,n,a,o,l;[R.MEDIA_PREVIEW_IMAGE,R.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===ce.MEDIA_CONTROLLER&&(t&&((n=(s=Na(this,Ii))==null?void 0:s.unassociateElement)==null||n.call(s,this),Fa(this,Ii,null)),i&&(Fa(this,Ii,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=Na(this,Ii))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return dt(this,R.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){nt(this,R.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(R.MEDIA_PREVIEW_COORDS);if(!!e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(R.MEDIA_PREVIEW_COORDS);return}this.setAttribute(R.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:u,minWidth:c,minHeight:h}=l,m=Math.min(parseInt(d)/n,parseInt(u)/a),g=Math.max(parseInt(c)/n,parseInt(h)/a),E=m<1,T=E?m:g>1?g:1,{style:A}=Ke(this.shadowRoot,":host"),L=Ke(this.shadowRoot,"img").style,S=this.shadowRoot.querySelector("img"),P=E?"min":"max";A.setProperty(`${P}-width`,"initial","important"),A.setProperty(`${P}-height`,"initial","important"),A.width=`${n*T}px`,A.height=`${a*T}px`;let k=()=>{L.width=`${this.imgWidth*T}px`,L.height=`${this.imgHeight*T}px`,L.display="block"};S.src!==o&&(S.onload=()=>{this.imgWidth=S.naturalWidth,this.imgHeight=S.naturalHeight,k()},S.src=o,k()),k(),L.transform=`translate(-${i*T}px, -${s*T}px)`}};Ii=new WeakMap;N.customElements.get("media-preview-thumbnail")||N.customElements.define("media-preview-thumbnail",ad);var pd=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},at=(r,e,t)=>(pd(r,e,"read from private field"),t?t.call(r):e.get(r)),Rt=(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)},or=(r,e,t,i)=>(pd(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),un=(r,e,t)=>(pd(r,e,"access private method"),t),cn,Ua,hn,Va,Ka,Ba,ld,dd,tm,$a,ud,Ga,ps,fn,cd,Wa,qa,Ha,hd,fd,im,ZE="video not loaded, unknown time.",od=r=>{let e=r.range,t=xr(+e.value),i=xr(+e.max),s=t&&i?`${t} of ${i}`:ZE;e.setAttribute("aria-valuetext",s)},rm=q.createElement("template");rm.innerHTML=`
|
|
650
624
|
<style>
|
|
651
625
|
:host {
|
|
652
626
|
--media-preview-border-radius: 3px;
|
|
@@ -682,8 +656,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
682
656
|
opacity: 0;
|
|
683
657
|
}
|
|
684
658
|
|
|
685
|
-
:host([${
|
|
686
|
-
:host([${
|
|
659
|
+
:host([${R.MEDIA_PREVIEW_IMAGE}]:hover) [part~="preview-box"],
|
|
660
|
+
:host([${R.MEDIA_PREVIEW_TIME}]:hover) [part~="preview-box"] {
|
|
687
661
|
transition-duration: var(--media-preview-transition-duration-in, .5s);
|
|
688
662
|
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
689
663
|
visibility: visible;
|
|
@@ -707,8 +681,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
707
681
|
var(--media-preview-border-radius) var(--media-preview-border-radius) 0 0);
|
|
708
682
|
}
|
|
709
683
|
|
|
710
|
-
:host([${
|
|
711
|
-
:host([${
|
|
684
|
+
:host([${R.MEDIA_PREVIEW_IMAGE}]:hover) media-preview-thumbnail,
|
|
685
|
+
:host([${R.MEDIA_PREVIEW_IMAGE}]:hover) ::slotted(media-preview-thumbnail) {
|
|
712
686
|
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
713
687
|
visibility: visible;
|
|
714
688
|
}
|
|
@@ -728,15 +702,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
728
702
|
text-shadow: var(--media-preview-time-text-shadow, 0 0 4px rgb(0 0 0 / .75));
|
|
729
703
|
}
|
|
730
704
|
|
|
731
|
-
:host([${
|
|
732
|
-
:host([${
|
|
705
|
+
:host([${R.MEDIA_PREVIEW_IMAGE}]) media-preview-time-display,
|
|
706
|
+
:host([${R.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-time-display) {
|
|
733
707
|
transition-delay: var(--media-preview-transition-delay-in, .25s);
|
|
734
708
|
min-width: 100%;
|
|
735
709
|
border-radius: var(--media-preview-time-border-radius,
|
|
736
710
|
0 0 var(--media-preview-border-radius) var(--media-preview-border-radius));
|
|
737
711
|
}
|
|
738
712
|
|
|
739
|
-
:host([${
|
|
713
|
+
:host([${R.MEDIA_PREVIEW_TIME}]:hover) {
|
|
740
714
|
--media-time-range-hover-display: block;
|
|
741
715
|
}
|
|
742
716
|
</style>
|
|
@@ -751,7 +725,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
751
725
|
|
|
752
726
|
</slot>
|
|
753
727
|
</div>
|
|
754
|
-
`;var
|
|
728
|
+
`;var md=class extends kr{constructor(){super(),Rt(this,Ba),Rt(this,dd),Rt(this,$a),Rt(this,Ha),Rt(this,fd),Rt(this,cn,void 0),Rt(this,Ua,void 0),Rt(this,hn,void 0),Rt(this,Va,void 0),Rt(this,Ka,void 0),Rt(this,Ga,t=>{if([...at(this,cn)].some(u=>t.composedPath().includes(u)))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=un(this,$a,ud).call(this,at(this,Ua),n),{style:o}=Ke(this.shadowRoot,"#preview-rail");o.transform=`translateX(${a})`;let l=n*i,d=new N.CustomEvent(ne.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:l});this.dispatchEvent(d)}),Rt(this,ps,!1),Rt(this,fn,t=>{(!t.composedPath().includes(this)||[...at(this,cn)].some(i=>t.composedPath().includes(i)))&&(N.removeEventListener("pointermove",at(this,fn)),or(this,ps,!1),at(this,Wa).call(this))}),Rt(this,cd,()=>{N.addEventListener("pointermove",at(this,Ga),!1)}),Rt(this,Wa,()=>{N.removeEventListener("pointermove",at(this,Ga));let t=new N.CustomEvent(ne.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:null});this.dispatchEvent(t)}),Rt(this,qa,()=>{let t=this.getAttribute(R.MEDIA_DURATION);!at(this,ps)&&t&&(or(this,ps,!0),at(this,cd).call(this),N.addEventListener("pointermove",at(this,fn),!1))}),this.container.appendChild(rm.content.cloneNode(!0)),this.range.addEventListener("input",()=>{cancelAnimationFrame(this._refreshId);let i=this.range.value,s=new N.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)},or(this,cn,this.shadowRoot.querySelectorAll('[part~="box"]')),or(this,Ua,this.shadowRoot.querySelector('[part~="preview-box"]')),or(this,hn,this.shadowRoot.querySelector('[part~="current-box"]'));let e=getComputedStyle(this);or(this,Va,parseInt(e.getPropertyValue("--media-box-padding-left"))),or(this,Ka,parseInt(e.getPropertyValue("--media-box-padding-right"))),un(this,Ha,hd).call(this)}static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_PAUSED,R.MEDIA_DURATION,R.MEDIA_SEEKABLE,R.MEDIA_CURRENT_TIME,R.MEDIA_PREVIEW_IMAGE,R.MEDIA_PREVIEW_TIME,R.MEDIA_BUFFERED,R.MEDIA_PLAYBACK_RATE,R.MEDIA_LOADING,R.MEDIA_ENDED]}connectedCallback(){this.range.setAttribute("aria-label",Lt.SEEK()),super.connectedCallback()}disconnectedCallback(){cancelAnimationFrame(this._refreshId),super.disconnectedCallback()}attributeChangedCallback(e,t,i){var s,n,a,o,l;(e===R.MEDIA_CURRENT_TIME||e===R.MEDIA_PAUSED||e===R.MEDIA_ENDED||e===R.MEDIA_LOADING)&&(this._updateTimestamp=performance.now(),this.range.value=this.mediaCurrentTime,od(this),this.updateBar(),this.updateCurrentBox(),cancelAnimationFrame(this._refreshId),!this.mediaPaused&&!this.mediaLoading&&(this._refreshId=requestAnimationFrame(this._refreshBar))),e===R.MEDIA_DURATION&&(this.range.max=(n=(s=at(this,Ba,ld))!=null?s:this.mediaDuration)!=null?n:1e3,od(this),this.updateBar(),this.updateCurrentBox()),e===R.MEDIA_SEEKABLE&&(this.range.min=(a=at(this,dd,tm))!=null?a:0,this.range.max=(l=(o=at(this,Ba,ld))!=null?o:this.mediaDuration)!=null?l:1e3,od(this),this.updateBar()),e===R.MEDIA_BUFFERED&&this.updateBar(),e==="disabled"&&(i==null?un(this,Ha,hd).call(this):un(this,fd,im).call(this)),super.attributeChangedCallback(e,t,i)}get mediaPaused(){return Ge(this,R.MEDIA_PAUSED)}set mediaPaused(e){Fe(this,R.MEDIA_PAUSED,e)}get mediaLoading(){return Ge(this,R.MEDIA_LOADING)}set mediaLoading(e){Fe(this,R.MEDIA_LOADING,e)}get mediaDuration(){return et(this,R.MEDIA_DURATION)}set mediaDuration(e){Xe(this,R.MEDIA_DURATION,e)}get mediaCurrentTime(){return et(this,R.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){Xe(this,R.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return et(this,R.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){Xe(this,R.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(R.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(i=>+i)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(R.MEDIA_BUFFERED);return}let t=e.map((i,s)=>`${i}:${s}`).join(" ");this.setAttribute(R.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(R.MEDIA_SEEKABLE);if(!!e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(R.MEDIA_SEEKABLE);return}this.setAttribute(R.MEDIA_SEEKABLE,e.join(":"))}get mediaPreviewImage(){return dt(this,R.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){nt(this,R.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return et(this,R.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){Xe(this,R.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return Ge(this,R.MEDIA_ENDED)}set mediaEnded(e){Fe(this,R.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(([u,c])=>u<=l&&l<=c))!=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(!at(this,hn).assignedElements().length)return;let e=this.range.value/(this.range.max-this.range.min),t=un(this,$a,ud).call(this,at(this,hn),e),{style:i}=Ke(this.shadowRoot,"#current-rail");i.transform=`translateX(${t})`}};cn=new WeakMap;Ua=new WeakMap;hn=new WeakMap;Va=new WeakMap;Ka=new WeakMap;Ba=new WeakSet;ld=function(){var r;let[,e]=(r=this.mediaSeekable)!=null?r:[];return e};dd=new WeakSet;tm=function(){var r;let[e]=(r=this.mediaSeekable)!=null?r:[];return e};$a=new WeakSet;ud=function(r,e){var t;let i=`${e*100*100}%`,s=r.offsetWidth;if(!s)return i;let n=(t=this.getAttribute("bounds")?Ir(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?t:this,a=this.range.getBoundingClientRect(),o=n.getBoundingClientRect(),l=(at(this,Va)-(a.left-o.left-s/2))/a.width*100,d=(o.right-a.left-s/2-at(this,Ka))/a.width*100;return Number.isNaN(l)||(i=`max(${l*100}%, ${i})`),Number.isNaN(d)||(i=`min(${i}, ${d*100}%)`),i};Ga=new WeakMap;ps=new WeakMap;fn=new WeakMap;cd=new WeakMap;Wa=new WeakMap;qa=new WeakMap;Ha=new WeakSet;hd=function(){this.addEventListener("pointermove",at(this,qa),!1)};fd=new WeakSet;im=function(){N.removeEventListener("pointermove",at(this,fn)),this.removeEventListener("pointermove",at(this,qa)),or(this,ps,!1),at(this,Wa).call(this)};N.customElements.get("media-time-range")||N.customElements.define("media-time-range",md);var nm=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},gs=(r,e,t)=>(nm(r,e,"read from private field"),t?t.call(r):e.get(r)),gd=(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)},vs=(r,e,t,i)=>(nm(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Li,Ya,ja,sm={LOADING_DELAY:"loadingdelay"},am=500,om=q.createElement("template"),JE=`
|
|
755
729
|
<svg aria-hidden="true" viewBox="0 0 100 100">
|
|
756
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">
|
|
757
731
|
<animateTransform
|
|
@@ -764,13 +738,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
764
738
|
repeatCount="indefinite" />
|
|
765
739
|
</path>
|
|
766
740
|
</svg>
|
|
767
|
-
`;
|
|
741
|
+
`;om.innerHTML=`
|
|
768
742
|
<style>
|
|
769
743
|
:host {
|
|
770
744
|
display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
|
|
771
745
|
vertical-align: middle;
|
|
772
746
|
box-sizing: border-box;
|
|
773
|
-
--_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${
|
|
747
|
+
--_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${am}ms);
|
|
774
748
|
}
|
|
775
749
|
|
|
776
750
|
#status {
|
|
@@ -785,8 +759,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
785
759
|
transition: opacity 0.15s;
|
|
786
760
|
}
|
|
787
761
|
|
|
788
|
-
:host([${
|
|
789
|
-
:host([${
|
|
762
|
+
:host([${R.MEDIA_LOADING}]:not([${R.MEDIA_PAUSED}])) slot[name=icon] > *,
|
|
763
|
+
:host([${R.MEDIA_LOADING}]:not([${R.MEDIA_PAUSED}])) ::slotted([slot=icon]) {
|
|
790
764
|
opacity: var(--media-loading-indicator-opacity, 1);
|
|
791
765
|
transition: opacity 0.15s var(--_loading-indicator-delay);
|
|
792
766
|
}
|
|
@@ -796,7 +770,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
796
770
|
transition: visibility 0.15s;
|
|
797
771
|
}
|
|
798
772
|
|
|
799
|
-
:host([${
|
|
773
|
+
:host([${R.MEDIA_LOADING}]:not([${R.MEDIA_PAUSED}])) #status {
|
|
800
774
|
visibility: var(--media-loading-indicator-opacity, visible);
|
|
801
775
|
transition: visibility 0.15s var(--_loading-indicator-delay);
|
|
802
776
|
}
|
|
@@ -809,9 +783,9 @@ svg, img, ::slotted(svg), ::slotted(img) {
|
|
|
809
783
|
}
|
|
810
784
|
</style>
|
|
811
785
|
|
|
812
|
-
<slot name="icon">${
|
|
813
|
-
<div id="status" role="status" aria-live="polite">${
|
|
814
|
-
`;var
|
|
786
|
+
<slot name="icon">${JE}</slot>
|
|
787
|
+
<div id="status" role="status" aria-live="polite">${Lt.MEDIA_LOADING()}</div>
|
|
788
|
+
`;var vd=class extends N.HTMLElement{constructor(){if(super(),gd(this,Li,void 0),gd(this,Ya,am),gd(this,ja,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),i=om.content.cloneNode(!0);t.appendChild(i)}let{style:e}=Ke(this.shadowRoot,":host");vs(this,ja,e)}static get observedAttributes(){return[ce.MEDIA_CONTROLLER,R.MEDIA_PAUSED,R.MEDIA_LOADING,sm.LOADING_DELAY]}attributeChangedCallback(e,t,i){var s,n,a,o,l;e===sm.LOADING_DELAY&&t!==i?this.loadingDelay=Number(i):e===ce.MEDIA_CONTROLLER&&(t&&((n=(s=gs(this,Li))==null?void 0:s.unassociateElement)==null||n.call(s,this),vs(this,Li,null)),i&&(vs(this,Li,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=gs(this,Li))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,i;let s=this.getAttribute(ce.MEDIA_CONTROLLER);s&&(vs(this,Li,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(i=(t=gs(this,Li))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=gs(this,Li))==null?void 0:e.unassociateElement)==null||t.call(e,this),vs(this,Li,null)}get loadingDelay(){return gs(this,Ya)}set loadingDelay(e){vs(this,Ya,e),gs(this,ja).setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return Ge(this,R.MEDIA_PAUSED)}set mediaPaused(e){Fe(this,R.MEDIA_PAUSED,e)}get mediaLoading(){return Ge(this,R.MEDIA_LOADING)}set mediaLoading(e){Fe(this,R.MEDIA_LOADING,e)}};Li=new WeakMap;Ya=new WeakMap;ja=new WeakMap;N.customElements.get("media-loading-indicator")||N.customElements.define("media-loading-indicator",vd);var ey=100,ty=1,iy=r=>r.mediaMuted?0:Math.round(r.mediaVolume*r.range.max),ry=({value:r,max:e})=>`${Math.round(r/e*100)}%`,Ed=class extends kr{static get observedAttributes(){return[...super.observedAttributes,R.MEDIA_VOLUME,R.MEDIA_MUTED,R.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.max=ey,this.range.addEventListener("input",()=>{let t=this.range.value/this.range.max,i=new N.CustomEvent(ne.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:t});this.dispatchEvent(i)})}connectedCallback(){this.range.setAttribute("aria-label",Lt.VOLUME()),super.connectedCallback()}attributeChangedCallback(e,t,i){if(e===R.MEDIA_VOLUME||e===R.MEDIA_MUTED){let s=iy(this);this.range.value=s,this.range.setAttribute("aria-valuetext",ry(this.range)),this.updateBar()}super.attributeChangedCallback(e,t,i)}get mediaVolume(){return et(this,R.MEDIA_VOLUME,ty)}set mediaVolume(e){Xe(this,R.MEDIA_VOLUME,e)}get mediaMuted(){return Ge(this,R.MEDIA_MUTED)}set mediaMuted(e){Fe(this,R.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return dt(this,R.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){nt(this,R.MEDIA_VOLUME_UNAVAILABLE,e)}};N.customElements.get("media-volume-range")||N.customElements.define("media-volume-range",Ed);var Sd=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Be=(r,e,t)=>(Sd(r,e,"read from private field"),t?t.call(r):e.get(r)),Mt=(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)},ri=(r,e,t,i)=>(Sd(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Gi=(r,e,t)=>(Sd(r,e,"access private method"),t),dr,ys,mn,bs,pn,Hi,Ts,yd,lr,Dr,za,Xa,bd,Es,Td,gn,Qa,Za,_d,Ad,lm,xd,dm,um=q.createElement("template");um.innerHTML=`
|
|
815
789
|
<style>
|
|
816
790
|
:host ul {
|
|
817
791
|
font: var(--media-font,
|
|
@@ -849,7 +823,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
|
|
|
849
823
|
<ul tabindex="0">
|
|
850
824
|
<slot></slot>
|
|
851
825
|
</ul>
|
|
852
|
-
`;var
|
|
826
|
+
`;var Ja=class extends N.HTMLElement{constructor(e={}){if(super(),Mt(this,Hi),Mt(this,lr),Mt(this,Xa),Mt(this,gn),Mt(this,Za),Mt(this,Ad),Mt(this,xd),Mt(this,dr,""),Mt(this,ys,null),Mt(this,mn,void 0),Mt(this,bs,void 0),Mt(this,pn,!1),Mt(this,za,t=>{this.handleClick(t)}),Mt(this,Es,t=>{let{key:i}=t;if(i==="Escape"){this.removeEventListener("keyup",Be(this,Es));return}if(i==="Meta"){ri(this,pn,!1);return}Gi(this,Xa,bd).call(this,t)}),Mt(this,Td,t=>{let{key:i,altKey:s}=t;if(s){this.removeEventListener("keyup",Be(this,Es));return}if(i==="Meta"){ri(this,pn,!0);return}if(this.keysUsed.includes(i)&&t.preventDefault(),Be(this,pn)&&this.keysUsed.includes(i)){Gi(this,Xa,bd).call(this,t);return}this.addEventListener("keyup",Be(this,Es),{once:!0})}),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),i=um.content.cloneNode(!0);this.nativeEl=i;let s=e.slotTemplate;s||(s=q.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),t.appendChild(i)}ri(this,mn,this.shadowRoot.querySelector("slot")),Be(this,mn).addEventListener("slotchange",()=>{ri(this,Hi,Be(this,mn).assignedElements({flatten:!0}),yd),Be(this,Hi,Ts).length===1&&Be(this,Hi,Ts)[0].nodeName.toLowerCase()==="slot"&&ri(this,Hi,Be(this,Hi,Ts)[0].assignedElements({flatten:!0}),yd);let t=Be(this,lr,Dr);if(t.some(n=>n.getAttribute("tabindex")==="0"))return;let s=t.filter(n=>n.getAttribute("aria-selected")==="true")[0];s||(s=t[0]),s&&(s.setAttribute("tabindex",0),s.setAttribute("aria-selected","true"))})}static get observedAttributes(){return["disabled",ce.MEDIA_CONTROLLER]}get selectedOptions(){return Be(this,lr,Dr).filter(e=>e.getAttribute("aria-selected")==="true")}get value(){return this.selectedOptions[0].value||this.selectedOptions[0].textContent}set value(e){let t=Be(this,lr,Dr).find(i=>i.value===e||i.textContent===e);!t||Gi(this,Za,_d).call(this,t)}focus(){var e;(e=this.selectedOptions[0])==null||e.focus()}enable(){this.addEventListener("click",Be(this,za)),this.addEventListener("keydown",Be(this,Td))}disable(){this.removeEventListener("click",Be(this,za)),this.removeEventListener("keyup",Be(this,Es))}attributeChangedCallback(e,t,i){var s,n;if(e===ce.MEDIA_CONTROLLER){if(t){let a=q.getElementById(t);(s=a==null?void 0:a.unassociateElement)==null||s.call(a,this)}if(i){let a=q.getElementById(i);(n=a==null?void 0:a.associateElement)==null||n.call(a,this)}}else e==="disabled"&&i!==t&&(i==null?this.enable():this.disable())}connectedCallback(){var e;this.hasAttribute("disabled")||this.enable(),this.hasAttribute("role")||this.setAttribute("role","listbox");let t=this.getAttribute(ce.MEDIA_CONTROLLER);if(t){let i=q.getElementById(t);(e=i==null?void 0:i.associateElement)==null||e.call(i,this)}}disconnectedCallback(){var e;this.disable();let t=this.getAttribute(ce.MEDIA_CONTROLLER);if(t){let i=q.getElementById(t);(e=i==null?void 0:i.unassociateElement)==null||e.call(i,this)}}get keysUsed(){return["Enter"," ","ArrowDown","ArrowUp","Home","End"]}handleSelection(e,t){let i=Gi(this,gn,Qa).call(this,e);!i||Gi(this,Za,_d).call(this,i,t)}handleMovement(e){let{key:t}=e,i=Be(this,lr,Dr),s=Gi(this,gn,Qa).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=Gi(this,Ad,lm).call(this,t);break}n&&(i.forEach(a=>a.setAttribute("tabindex","-1")),n.setAttribute("tabindex","0"),n.focus())}handleClick(e){let t=Gi(this,gn,Qa).call(this,e);!t||t.hasAttribute("disabled")||(Be(this,lr,Dr).forEach(i=>i.setAttribute("tabindex","-1")),t.setAttribute("tabindex","0"),this.handleSelection(e,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"))}};dr=new WeakMap;ys=new WeakMap;mn=new WeakMap;bs=new WeakMap;pn=new WeakMap;Hi=new WeakSet;Ts=function(){return Be(this,bs)||ri(this,bs,Array.from(this.shadowRoot.querySelectorAll("media-chrome-listitem"))),Be(this,bs)};yd=function(r){ri(this,bs,r)};lr=new WeakSet;Dr=function(){return Be(this,Hi,Ts).filter(r=>!r.hasAttribute("disabled"))};za=new WeakMap;Xa=new WeakSet;bd=function(r){let{key:e}=r;e==="Enter"||e===" "?this.handleSelection(r,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"):this.handleMovement(r)};Es=new WeakMap;Td=new WeakMap;gn=new WeakSet;Qa=function(r){let e=r.composedPath(),t=e.findIndex(i=>i.nodeName==="MEDIA-CHROME-LISTITEM");return e[t]};Za=new WeakSet;_d=function(r,e){(!this.hasAttribute("aria-multiselectable")||this.getAttribute("aria-multiselectable")!=="true")&&Be(this,Hi,Ts).forEach(t=>t.setAttribute("aria-selected","false")),e&&r.getAttribute("aria-selected")==="true"?r.setAttribute("aria-selected","false"):r.setAttribute("aria-selected","true"),this.dispatchEvent(new Event("change"))};Ad=new WeakSet;lm=function(r){Gi(this,xd,dm).call(this);let e=Be(this,lr,Dr),t=e.findIndex(d=>d.getAttribute("tabindex")==="0");ri(this,dr,Be(this,dr)+r);let i=Be(this,dr).split("").every(d=>d===r),s=e.slice(t+(i?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(Be(this,dr))),n=e.slice(0,t-(i?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(Be(this,dr))),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]};xd=new WeakSet;dm=function(){N.clearTimeout(Be(this,ys)),ri(this,ys,null),ri(this,ys,N.setTimeout(()=>{ri(this,dr,""),ri(this,ys,null)},500))};N.customElements.get("media-chrome-listbox")||N.customElements.define("media-chrome-listbox",Ja);var cm=Ja;var Rd=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},se=(r,e,t)=>(Rd(r,e,"read from private field"),t?t.call(r):e.get(r)),wt=(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)},si=(r,e,t,i)=>(Rd(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Vi=(r,e,t)=>(Rd(r,e,"access private method"),t),_s,vn,As,ft,En,Qe,Ri,yn,Cr,Ss,eo,Id,hm,Ld,fm,xs,bn,wd,mm,to,kd,pm=q.createElement("template");pm.innerHTML=`
|
|
853
827
|
<style>
|
|
854
828
|
:host {
|
|
855
829
|
display: inline-flex;
|
|
@@ -877,7 +851,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
|
|
|
877
851
|
<slot></slot>
|
|
878
852
|
</media-chrome-listbox>
|
|
879
853
|
</slot>
|
|
880
|
-
`;var
|
|
854
|
+
`;var io=class extends N.HTMLElement{constructor(){var e;if(super(),wt(this,Id),wt(this,Ld),wt(this,xs),wt(this,wd),wt(this,to),wt(this,_s,void 0),wt(this,vn,void 0),wt(this,As,!0),wt(this,ft,void 0),wt(this,En,void 0),wt(this,Qe,void 0),wt(this,Ri,void 0),wt(this,yn,!1),wt(this,Cr,i=>{let{key:s}=i;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",se(this,Cr));return}i.composedPath().includes(se(this,ft))&&(s==="Enter"||s===" ")?se(this,_s).call(this):s==="Escape"&&!se(this,Ri).hidden&&Vi(this,xs,bn).call(this)}),wt(this,Ss,i=>{let{metaKey:s,altKey:n,key:a}=i;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",se(this,Cr));return}i.preventDefault(),this.addEventListener("keyup",se(this,Cr),{once:!0})}),wt(this,eo,i=>{i.composedPath().includes(this)||se(this,Ri).hidden||Vi(this,xs,bn).call(this)}),!this.shadowRoot){let i=this.attachShadow({mode:"open"}),s=pm.content.cloneNode(!0);this.nativeEl=s,i.appendChild(s)}let{style:t}=Ke(this.shadowRoot,":host");t.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),si(this,_s,Vi(this,Id,hm).bind(this)),si(this,vn,Vi(this,Ld,fm).bind(this)),(e=this.init)==null||e.call(this),si(this,ft,this.shadowRoot.querySelector("[part=button]")),si(this,Qe,this.shadowRoot.querySelector("[part=listbox]")),si(this,En,this.shadowRoot.querySelector("slot[name=button]")),se(this,En).addEventListener("slotchange",()=>{let i=se(this,En).assignedElements()[0];!i||(this.disable(),si(this,ft,i),se(this,ft).preventClick=!0,se(this,ft).hasAttribute("disabled")&&si(this,As,!1),se(this,As)?(this.enable(),se(this,ft).setAttribute("aria-haspopup","listbox")):this.disable())}),si(this,Ri,this.shadowRoot.querySelector("slot[name=listbox]")),se(this,Ri).addEventListener("slotchange",()=>{this.disable(),si(this,Qe,se(this,Ri).assignedElements()[0]||se(this,Qe)),this.enable()})}static get observedAttributes(){return["disabled",ce.MEDIA_CONTROLLER]}enable(){se(this,ft).removeAttribute("disabled"),se(this,ft).addEventListener("click",se(this,_s)),se(this,ft).addEventListener("keydown",se(this,Ss)),se(this,Qe).addEventListener("keydown",se(this,Ss)),Vi(this,to,kd).call(this),se(this,Qe).addEventListener("change",se(this,vn)),q.addEventListener("click",se(this,eo))}disable(){se(this,ft).setAttribute("disabled",""),se(this,ft).removeEventListener("click",se(this,_s)),se(this,ft).removeEventListener("keydown",se(this,Ss)),se(this,ft).removeEventListener("keyup",se(this,Cr)),se(this,Qe).removeEventListener("keydown",se(this,Ss)),se(this,Qe).removeEventListener("keyup",se(this,Cr)),se(this,Qe).addEventListener("change",se(this,vn)),q.removeEventListener("click",se(this,eo))}attributeChangedCallback(e,t,i){var s,n;if(e===ce.MEDIA_CONTROLLER){if(t){let a=q.getElementById(t);(s=a==null?void 0:a.unassociateElement)==null||s.call(a,this),se(this,Qe).removeAttribute(ce.MEDIA_CONTROLLER)}if(i){let a=q.getElementById(i);(n=a==null?void 0:a.associateElement)==null||n.call(a,this),se(this,Qe).setAttribute(ce.MEDIA_CONTROLLER,i)}}else e==="disabled"&&i!==t&&(i==null?(si(this,As,!0),this.enable()):(si(this,As,!1),this.disable()))}connectedCallback(){var e;this.hasAttribute("disabled")||this.enable();let t=this.getAttribute(ce.MEDIA_CONTROLLER);if(t){let i=q.getElementById(t);(e=i==null?void 0:i.associateElement)==null||e.call(i,this),se(this,Qe).setAttribute(ce.MEDIA_CONTROLLER,t)}}disconnectedCallback(){var e;this.disable();let t=this.getAttribute(ce.MEDIA_CONTROLLER);if(t){let i=q.getElementById(t);(e=i==null?void 0:i.unassociateElement)==null||e.call(i,this),se(this,Qe).removeAttribute(ce.MEDIA_CONTROLLER)}}get keysUsed(){return["Enter","Escape"," ","ArrowUp","ArrowDown","f","c","k","m"]}};_s=new WeakMap;vn=new WeakMap;As=new WeakMap;ft=new WeakMap;En=new WeakMap;Qe=new WeakMap;Ri=new WeakMap;yn=new WeakMap;Cr=new WeakMap;Ss=new WeakMap;eo=new WeakMap;Id=new WeakSet;hm=function(){Vi(this,xs,bn).call(this)};Ld=new WeakSet;fm=function(){Vi(this,xs,bn).call(this,!0)};xs=new WeakSet;bn=function(r){se(this,Ri).hidden=!se(this,Ri).hidden||r,Vi(this,to,kd).call(this,r),se(this,Ri).hidden?(this.shadowRoot.activeElement===se(this,Qe)||se(this,Qe).contains(this.shadowRoot.activeElement))&&se(this,ft).focus():(se(this,Qe).focus(),Vi(this,wd,mm).call(this))};wd=new WeakSet;mm=function(){var r;if(se(this,Qe).offsetWidth===0)return;let e=se(this,ft).getBoundingClientRect();if(this.hasAttribute("mediacontroller")||se(this,ft).hasAttribute("mediacontroller")||se(this,Qe).hasAttribute("mediacontroller")){se(this,Qe).style.zIndex="1",se(this,Qe).style.bottom="unset",se(this,Qe).style.top=e.height+"px";return}let i=((r=this.getAttribute("bounds")?Ir(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?r:this).getBoundingClientRect(),s=se(this,Qe).getBoundingClientRect(),n=-Math.max(e.x+s.width-i.right,0);se(this,Qe).style.transform=`translateX(${n}px)`};to=new WeakSet;kd=function(r=!1){si(this,yn,!se(this,yn)||r),se(this,ft).setAttribute("aria-expanded",se(this,yn))};N.customElements.get("media-chrome-selectmenu")||N.customElements.define("media-chrome-selectmenu",io);var gm=io;var vm=q.createElement("template");vm.innerHTML=`
|
|
881
855
|
<style>
|
|
882
856
|
:host {
|
|
883
857
|
display: list-item;
|
|
@@ -894,24 +868,49 @@ svg, img, ::slotted(svg), ::slotted(img) {
|
|
|
894
868
|
<li>
|
|
895
869
|
<slot></slot>
|
|
896
870
|
</li>
|
|
897
|
-
`;var
|
|
871
|
+
`;var Dd={VALUE:"value"},Cd=class extends N.HTMLElement{static get observedAttributes(){return["disabled","aria-selected",Dd.VALUE,ce.MEDIA_CONTROLLER]}constructor(){if(super(),!this.shadowRoot){let e=this.attachShadow({mode:"open"}),t=vm.content.cloneNode(!0);this.nativeEl=t,e.appendChild(t)}}set value(e){this.setAttribute(Dd.VALUE,e)}get value(){return this.getAttribute(Dd.VALUE)}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){var s,n;if(e===ce.MEDIA_CONTROLLER){if(t){let a=q.getElementById(t);(s=a==null?void 0:a.unassociateElement)==null||s.call(a,this)}if(i){let a=q.getElementById(i);(n=a==null?void 0:a.associateElement)==null||n.call(a,this)}}else e==="disabled"&&i!==t&&(i==null?this.enable():this.disable())}connectedCallback(){var e;this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","option");let t=this.getAttribute(ce.MEDIA_CONTROLLER);if(t){let i=q.getElementById(t);(e=i==null?void 0:i.associateElement)==null||e.call(i,this)}}disconnectedCallback(){var e;this.disable();let t=this.getAttribute(ce.MEDIA_CONTROLLER);if(t){let i=q.getElementById(t);(e=i==null?void 0:i.unassociateElement)==null||e.call(i,this)}}handleClick(){}};N.customElements.get("media-chrome-listitem")||N.customElements.define("media-chrome-listitem",Cd);var Nd=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},Ht=(r,e,t)=>(Nd(r,e,"read from private field"),t?t.call(r):e.get(r)),Mr=(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)},Or=(r,e,t,i)=>(Nd(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Pr=(r,e,t)=>(Nd(r,e,"access private method"),t),Is,Ki,ni,Md,ym,Fd,bm,Tn,ro,so,Od,Tm=`
|
|
898
872
|
fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
|
|
899
873
|
height: var(--media-captions-indicator-height, 1em);
|
|
900
874
|
vertical-align: var(--media-captions-indicator-vertical-align, bottom);
|
|
901
875
|
margin-inline-start: 1ch;
|
|
902
|
-
`,
|
|
903
|
-
<svg style="${
|
|
876
|
+
`,sy=`
|
|
877
|
+
<svg style="${Tm}" aria-hidden="true" viewBox="0 0 26 24">
|
|
904
878
|
<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"/>
|
|
905
|
-
</svg>`,
|
|
879
|
+
</svg>`,_m=q.createElement("template");_m.innerHTML=`
|
|
906
880
|
<style>
|
|
907
881
|
media-chrome-listitem {
|
|
908
882
|
white-space: var(--media-captions-listbox-white-space, nowrap);
|
|
909
883
|
}
|
|
910
884
|
</style>
|
|
911
|
-
<slot hidden name="captions-indicator">${
|
|
912
|
-
`;var fp=(n,r)=>n.label===r.label&&n.language===r.language,Uc=class extends sp{constructor(){super({slotTemplate:gp}),qa(this,Nc),qa(this,Hc),qa(this,js),qa(this,au),qa(this,Wn,[]),qa(this,Ur,void 0),qa(this,qi,void 0);let r=ae.createElement("media-chrome-listitem");r.part.add("listitem"),r.value="off",r.textContent="Off",Ya(this,Ur,r);let o=this.shadowRoot.querySelector('[name="captions-indicator"]');Ya(this,qi,o.firstElementChild),o.addEventListener("slotchange",()=>{let m=o.assignedElements();if(m.length===1&&m[0].nodeName.toLowerCase()==="slot"){let v=m[0].assignedElements();v.length===0?Ya(this,qi,m[0].firstElementChild):v.length===1&&Ya(this,qi,v[0])}wi(this,qi)||Ya(this,qi,o.firstElementChild),Ya(this,qi,wi(this,qi).cloneNode(!0)),wi(this,qi).removeAttribute("slot"),wi(this,qi).setAttribute("style",vp)})}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",F.MEDIA_SUBTITLES_LIST,F.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(r,o,m){if(r===F.MEDIA_SUBTITLES_LIST&&o!==m)Ya(this,Wn,$a(this,Nc,mp).call(this,m,wi(this,Wn))),$a(this,js,ru).call(this);else if(r===F.MEDIA_SUBTITLES_SHOWING&&o!==m){let v=wn(m!=null?m:"")[0];wi(this,Wn).forEach(y=>{y.selected=y.language===v.language&&y.label===v.label}),$a(this,js,ru).call(this)}else r==="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."));super.attributeChangedCallback(r,o,m)}connectedCallback(){$a(this,js,ru).call(this),this.addEventListener("change",$a(this,au,Fc)),super.connectedCallback()}disconnectedCallback(){this.removeEventListener("change",$a(this,au,Fc)),super.disconnectedCallback()}};Wn=new WeakMap;Ur=new WeakMap;qi=new WeakMap;Nc=new WeakSet;mp=function(n,r){let o=n?wn(n!=null?n:""):[],m=[],v=[];return r.forEach(y=>{o.some(I=>fp(I,y))||m.push(y)}),o.forEach(y=>{r.some(I=>fp(I,y))||v.push(y)}),m.forEach(y=>y.el.remove()),r.filter(y=>!m.includes(y)).concat(v)};Hc=new WeakSet;pp=function(n){let r=this.shadowRoot.querySelector("ul slot");n.forEach(o=>{var m;let v=o.el,y=!0,I=(m=o.kind)!=null?m:"subs";if(!v){v=ae.createElement("media-chrome-listitem"),y=!1,v.part.add("listitem"),v.value=Od(o);let M=ae.createElement("span");M.textContent=o.label,v.append(M),I==="captions"&&v.append(wi(this,qi).cloneNode(!0))}o.selected?v.setAttribute("aria-selected","true"):v.setAttribute("aria-selected","false"),y||(r.append(v),o.el=v)})};js=new WeakSet;ru=function(){let n=this.shadowRoot.querySelector("ul slot");n.contains(wi(this,Ur))||n.append(wi(this,Ur)),this.hasAttribute(F.MEDIA_SUBTITLES_SHOWING)?(wi(this,Ur).setAttribute("aria-selected","false"),wi(this,Ur).setAttribute("tabindex","-1")):(wi(this,Ur).setAttribute("aria-selected","true"),wi(this,Ur).setAttribute("tabindex","0")),$a(this,Hc,pp).call(this,wi(this,Wn))};au=new WeakSet;Fc=function(){var n;let r=(n=this.selectedOptions[0])==null?void 0:n.value;if(xr(this,!1),!r)return;let o=new W.CustomEvent(Ie.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:r});this.dispatchEvent(o)};W.customElements.get("media-captions-listbox")||W.customElements.define("media-captions-listbox",Uc);var Gc=class extends cp{constructor(){super()}init(){let r=ae.createElement("media-captions-button");r.part.add("button"),r.preventClick=!0;let o=ae.createElement("media-captions-listbox");o.part.add("listbox"),o.setAttribute("exportparts","listitem");let m=this.shadowRoot.querySelector("slot[name=button]"),v=this.shadowRoot.querySelector("slot[name=listbox]");m.textContent="",v.textContent="",m.append(r),v.append(o)}};W.customElements.get("media-captions-selectmenu")||W.customElements.define("media-captions-selectmenu",Gc);var su=Df(Ep(),1),Lp=Df(bp(),1),Ry=Lp.default,Li=Ry,zs=class extends Error{constructor(n,r=zs.MEDIA_ERR_CUSTOM,o,m){var v;super(n),this.name="MediaError",this.code=r,this.context=m,this.fatal=o!=null?o:r>=zs.MEDIA_ERR_NETWORK&&r<=zs.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(v=zs.defaultMessages[this.code])!=null?v:"")}},At=zs;At.MEDIA_ERR_ABORTED=1,At.MEDIA_ERR_NETWORK=2,At.MEDIA_ERR_DECODE=3,At.MEDIA_ERR_SRC_NOT_SUPPORTED=4,At.MEDIA_ERR_ENCRYPTED=5,At.MEDIA_ERR_CUSTOM=100,At.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 Dy=n=>n==null,Ip=(n,r)=>Dy(r)?!1:n in r,qc={ANY:"any",MUTED:"muted"},gt={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},Yi={MSE:"mse",NATIVE:"native"},Yc={HEADER:"header",QUERY:"query",NONE:"none"},qn=Object.values(Yc),la={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},$c={HLS:la.M3U8},BS=Object.keys($c),HS=[...Object.values(la),"hls","HLS"],er=(n,r,o,m,v=n)=>{v.addEventListener(r,o,m),n.addEventListener("teardown",()=>{v.removeEventListener(r,o)},{once:!0})};function Cy(n,r,o){r&&o>r&&(o=r);for(let m=0;m<n.length;m++)if(n.start(m)<=o&&n.end(m)>=o)return!0;return!1}var My=n=>{let r=n.indexOf("?");if(r<0)return[n];let o=n.slice(0,r),m=n.slice(r);return[o,m]},ou=n=>{let r=n.type;if(r){let m=r.toUpperCase();return Ip(m,$c)?$c[m]:r}let{src:o}=n;return o?xy(o):""},Rp=n=>n==="VOD"?gt.ON_DEMAND:gt.LIVE,Dp=n=>n==="EVENT"?Number.POSITIVE_INFINITY:n==="VOD"?Number.NaN:0,xy=n=>{let r="";try{r=new URL(n).pathname}catch{console.error("invalid url")}let o=r.lastIndexOf(".");if(o<0)return"";let m=r.slice(o+1).toUpperCase();return Ip(m,la)?la[m]:""},Py=Object.values(qc),Tp=n=>typeof n=="boolean"||typeof n=="string"&&Py.includes(n),Oy=({autoplay:n},r,o)=>{let m=!1,v=!1,y=Tp(n)?n:!!n,I=()=>{m||er(r,"playing",()=>{m=!0},{once:!0})};if(I(),er(r,"loadstart",()=>{m=!1,I(),Wc(r,y)},{once:!0}),er(r,"loadstart",()=>{o||(v=!Number.isFinite(r.duration)),Wc(r,y)},{once:!0}),o&&o.once(Li.Events.LEVEL_LOADED,(M,U)=>{var H;v=(H=U.details.live)!=null?H:!1}),!y){let M=()=>{!v||(o!=null&&o.liveSyncPosition?r.currentTime=o.liveSyncPosition:Number.isFinite(r.seekable.end(0))&&(r.currentTime=r.seekable.end(0)))};o&&er(r,"play",()=>{r.preload==="metadata"?o.once(Li.Events.LEVEL_UPDATED,M):M()},{once:!0})}return M=>{m||(y=Tp(M)?M:!!M,Wc(r,y))}},Wc=(n,r)=>{if(!r)return;let o=n.muted,m=()=>n.muted=o;switch(r){case qc.ANY:n.play().catch(()=>{n.muted=!0,n.play().catch(m)});break;case qc.MUTED:n.muted=!0,n.play().catch(m);break;default:n.play().catch(()=>{});break}},Ny=({preload:n,src:r},o,m)=>{let v=J=>{J!=null&&["","none","metadata","auto"].includes(J)?o.setAttribute("preload",J):o.removeAttribute("preload")};if(!m)return v(n),v;let y=!1,I=!1,M=m.config.maxBufferLength,U=m.config.maxBufferSize,H=J=>{v(J);let Z=J!=null?J:o.preload;I||Z==="none"||(Z==="metadata"?(m.config.maxBufferLength=1,m.config.maxBufferSize=1):(m.config.maxBufferLength=M,m.config.maxBufferSize=U),z())},z=()=>{!y&&r&&(y=!0,m.loadSource(r))};return er(o,"play",()=>{I=!0,m.config.maxBufferLength=M,m.config.maxBufferSize=U,z()},{once:!0}),H(n),H};function Fy(n,r){r.on(Li.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(v,{tracks:y})=>{y.forEach(I=>{var M;let U=(M=I.subtitleTrack)!=null?M:I.closedCaptions,H=r.subtitleTracks.findIndex(({lang:z,name:J,type:Z})=>z==(U==null?void 0:U.lang)&&J===I.label&&Z.toLowerCase()===I.kind);lu(n,I.kind,I.label,U==null?void 0:U.lang,`${I.kind}${H}`)})});let o=()=>{var v;if(!r.subtitleTracks.length)return;let y=Array.from(n.textTracks).find(M=>M.id&&M.mode==="showing"&&["subtitles","captions"].includes(M.kind)),I=`${(v=r.subtitleTracks[r.subtitleTrack])==null?void 0:v.type.toLowerCase()}${r.subtitleTrack}`;if(y&&(r.subtitleTrack<0||(y==null?void 0:y.id)!==I)){let M=r.subtitleTracks.findIndex(({lang:U,name:H,type:z})=>U==y.language&&H===y.label&&z.toLowerCase()===y.kind);r.subtitleTrack=M}y&&(y==null?void 0:y.id)===I&&y.cues&&Array.from(y.cues).forEach(M=>{y.addCue(M)})};n.textTracks.addEventListener("change",o),r.on(Li.Events.CUES_PARSED,(v,{track:y,cues:I})=>{let M=n.textTracks.getTrackById(y);if(!M)return;let U=M.mode==="disabled";U&&(M.mode="hidden"),I.forEach(H=>{var z;(z=M.cues)!=null&&z.getCueById(H.id)||M.addCue(H)}),U&&(M.mode="disabled")}),r.once(Li.Events.DESTROYING,()=>{n.textTracks.removeEventListener("change",o),n.querySelectorAll("track[data-removeondestroy]").forEach(v=>{v.remove()})});let m=()=>{Array.from(n.textTracks).forEach(v=>{var y,I;if(!["subtitles","caption"].includes(v.kind)&&v.label==="thumbnails"){if(!((y=v.cues)!=null&&y.length)){let M=n.querySelector('track[label="thumbnails"]'),U=(I=M==null?void 0:M.getAttribute("src"))!=null?I:"";M==null||M.removeAttribute("src"),setTimeout(()=>{M==null||M.setAttribute("src",U)},0)}v.mode!=="hidden"&&(v.mode="hidden")}})};r.once(Li.Events.MANIFEST_LOADED,m),r.once(Li.Events.MEDIA_ATTACHED,m)}function lu(n,r,o,m,v){let y=document.createElement("track");return y.kind=r,y.label=o,m&&(y.srclang=m),v&&(y.id=v),y.track.mode=["subtitles","captions"].includes(r)?"disabled":"hidden",y.setAttribute("data-removeondestroy",""),n.append(y),y.track}function Cp(n,r){let o=Array.prototype.find.call(n.querySelectorAll("track"),m=>m.track===r);o==null||o.remove()}var Qs="cuepoints",zc=Object.freeze({label:Qs}),Qc=(n,{label:r=Qs}=zc)=>{var o;return(o=Array.from(n.querySelectorAll("track")).find(m=>m.track.label===r&&m.track.kind==="metadata"))==null?void 0:o.track};async function Xc(n,r,o=zc){let m=Qc(n,o);if(!m){let{label:v=Qs}=o;m=lu(n,"metadata",v),m.mode="hidden",await new Promise(y=>setTimeout(()=>y(void 0),0))}return m.mode!=="hidden"&&(m.mode="hidden"),[...r].sort(({time:v},{time:y})=>y-v).forEach(({time:v,value:y})=>{var I,M;let U=Array.prototype.findIndex.call(m==null?void 0:m.cues,se=>se.startTime>=v),H=(I=m==null?void 0:m.cues)==null?void 0:I[U],z=H?H.startTime:Number.isFinite(n.duration)?n.duration:Number.MAX_SAFE_INTEGER,J=(M=m==null?void 0:m.cues)==null?void 0:M[U-1];J&&(J.endTime=v);let Z=new VTTCue(v,z,JSON.stringify(y!=null?y:null));m.addCue(Z)}),m}var Mp=n=>({time:n.startTime,value:JSON.parse(n.text)});function xp(n,r={label:Qs}){let o=Qc(n,r);return o!=null&&o.cues?Array.from(o.cues,m=>Mp(m)):[]}function Zc(n,r={label:Qs}){var o,m;let v=Qc(n,r);if(!((o=v==null?void 0:v.activeCues)!=null&&o.length))return;let{currentTime:y}=n,I=Array.prototype.find.call((m=v.activeCues)!=null?m:[],({startTime:M,endTime:U})=>M<=y&&U>y);return Mp(I)}async function Uy(n,r=zc){return new Promise(o=>{er(n,"loadstart",async()=>{let m=await Xc(n,[],r);er(n,"cuechange",()=>{let v=Zc(n);if(v){let y=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:v});n.dispatchEvent(y)}},{},m),o(m)})})}function Pp(n,r){if(r){let o=r.playingDate;if(o!=null)return new Date(o.getTime()-n.currentTime*1e3)}return typeof n.getStartDate=="function"?n.getStartDate():new Date(NaN)}function Op(n,r){if(r&&r.playingDate)return r.playingDate;if(typeof n.getStartDate=="function"){let o=n.getStartDate();return new Date(o.getTime()+n.currentTime*1e3)}return new Date(NaN)}var By=async n=>fetch(n).then(r=>r.text()).then(r=>{let o=r.split(`
|
|
913
|
-
|
|
914
|
-
`))}),Hy=n=>{var r,o;let m=(o=((r=n.find(M=>M.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?r:"").split(":")[1])==null?void 0:o.trim(),v=Rp(m),y=Dp(m),I;if(v===gt.LIVE){let M=n.find(U=>U.startsWith("#EXT-X-PART-INF"));M?I=+M.split(":")[1].split("=")[1]*2:I=+n.find(U=>U.startsWith("#EXT-X-TARGETDURATION")).split(":")[1]*3}return{streamType:v,targetLiveWindow:y,liveEdgeStartOffset:I}},Gy=async(n,r)=>{if(r===la.MP4)return{streamType:gt.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(r===la.M3U8){let o=await By(n);return Hy(o)}return console.error(`Media type ${r} is an unrecognized or unsupported type for src ${n}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},_p=async(n,r,o=ou({src:n}))=>{var m,v,y;let{streamType:I,targetLiveWindow:M,liveEdgeStartOffset:U}=await Gy(n,o);((m=ii.get(r))!=null?m:{}).liveEdgeStartOffset=U,((v=ii.get(r))!=null?v:{}).targetLiveWindow=M,r.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((y=ii.get(r))!=null?y:{}).streamType=I,r.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},Vy=n=>{var r;let o=n.type,m=Rp(o),v=Dp(o),y,I=!!((r=n.partList)!=null&&r.length);return m===gt.LIVE&&(y=I?n.partTarget*2:n.targetduration*3),{streamType:m,targetLiveWindow:v,liveEdgeStartOffset:y,lowLatency:I}},Ky=(n,r,o)=>{var m,v,y,I,M,U,H,z;let{streamType:J,targetLiveWindow:Z,liveEdgeStartOffset:se,lowLatency:me}=Vy(n);if(J===gt.LIVE){me?(o.config.backBufferLength=(m=o.userConfig.backBufferLength)!=null?m:4,o.config.maxFragLookUpTolerance=(v=o.userConfig.maxFragLookUpTolerance)!=null?v:.001,o.config.abrBandWidthUpFactor=(y=o.userConfig.abrBandWidthUpFactor)!=null?y:o.config.abrBandWidthFactor):o.config.backBufferLength=(I=o.userConfig.backBufferLength)!=null?I:8;let Te=Object.freeze({get length(){return r.seekable.length},start(ge){return r.seekable.start(ge)},end(ge){var ye;return ge>this.length?r.seekable.end(ge):(ye=o.liveSyncPosition)!=null?ye:r.seekable.end(ge)}});((M=ii.get(r))!=null?M:{}).seekable=Te}((U=ii.get(r))!=null?U:{}).liveEdgeStartOffset=se,((H=ii.get(r))!=null?H:{}).targetLiveWindow=Z,r.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((z=ii.get(r))!=null?z:{}).streamType=J,r.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},Ap,Sp,Wy=(Sp=(Ap=globalThis==null?void 0:globalThis.navigator)==null?void 0:Ap.userAgent)!=null?Sp:"",qy=Wy.toLowerCase().indexOf("android")!==-1,ii=new WeakMap,Np="mux.com",kp,wp,Fp=(wp=(kp=Li).isSupported)==null?void 0:wp.call(kp),Yy=qy,Up=()=>su.default.utils.now(),$y=su.default.utils.generateUUID,Bp=(n,{domain:r=Np,maxResolution:o=""}={})=>{if(!n)return;let[m,v=""]=My(n),y=new URL(`https://stream.${r}/${m}.m3u8${v}`);return o&&y.searchParams.set("max_resolution",o),y.toString()},jy=n=>{if(!n)return;let[r]=n.split("?");return r||void 0},zy=n=>{if(!n||!n.startsWith("https://stream."))return;let[r]=new URL(n).pathname.slice(1).split(".m3u8");return r||void 0},Qy=n=>{var r,o,m;return(r=n==null?void 0:n.metadata)!=null&&r.video_id?n.metadata.video_id:$p(n)&&(m=(o=jy(n.playbackId))!=null?o:zy(n.src))!=null?m:n.src},Hp=n=>{var r;return(r=ii.get(n))==null?void 0:r.error},Gp=n=>{var r,o;return(o=(r=ii.get(n))==null?void 0:r.streamType)!=null?o:gt.UNKNOWN},Vp=n=>{var r,o;return(o=(r=ii.get(n))==null?void 0:r.targetLiveWindow)!=null?o:Number.NaN},Jc=n=>{var r,o;return(o=(r=ii.get(n))==null?void 0:r.seekable)!=null?o:n.seekable},Kp=n=>{var r;let o=(r=ii.get(n))==null?void 0:r.liveEdgeStartOffset;if(typeof o!="number")return Number.NaN;let m=Jc(n);return m.length?m.end(m.length-1)-o:Number.NaN},Xy=(n,r,o=.001)=>Math.abs(n-r)<=o,Wp=(n,r,o=.001)=>n>r||Xy(n,r,o),Zy=n=>n.paused&&Wp(n.currentTime,n.duration),eh=(n,r)=>n.loop||!!r?n.ended:n.ended||Zy(n),qp=(n,r,o)=>{th(r,o);let{metadata:m={}}=n,{view_session_id:v=$y()}=m,y=Qy(n);m.view_session_id=v,m.video_id=y,n.metadata=m,ii.set(r,{});let I=Jy(n,r);t0(n,r,I),i0(n,r,I),Uy(r);let M=Oy(n,r,I),U=Ny(n,r,I);return{engine:I,setAutoplay:M,setPreload:U}},th=(n,r)=>{let o=r==null?void 0:r.engine;o&&(o.detachMedia(),o.destroy()),(n==null?void 0:n.mux)&&!n.mux.deleted&&(n.mux.destroy(),delete n.mux),n&&(n.removeAttribute("src"),n.load(),n.removeEventListener("error",zp),n.removeEventListener("error",jc),n.removeEventListener("durationchange",jp),ii.delete(n),n.dispatchEvent(new Event("teardown")))};function Yp(n,r){var o;let m=ou(n);if(m!==la.M3U8)return!0;let v=!m||((o=r.canPlayType(m))!=null?o:!0),{preferPlayback:y}=n,I=y===Yi.MSE,M=y===Yi.NATIVE;return v&&(M||!(Fp&&(I||Yy)))}var Jy=(n,r)=>{let{debug:o,streamType:m,startTime:v=-1,metadata:y,preferCmcd:I}=n,M=ou(n)===la.M3U8,U=Yp(n,r);if(M&&!U&&Fp){let H={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},z=e0(m),J=I!==Yc.NONE?{useHeaders:I===Yc.HEADER,sessionId:y==null?void 0:y.view_session_id,contentId:y==null?void 0:y.video_id}:void 0;return new Li({debug:o,startPosition:v,cmcd:J,...H,...z})}},e0=n=>n===gt.LIVE?{backBufferLength:8}:{},$p=({playbackId:n,src:r,customDomain:o})=>{if(n)return!0;if(typeof r!="string")return!1;let m=window==null?void 0:window.location.href,v=new URL(r,m).hostname.toLocaleLowerCase();return v.includes(Np)||!!o&&v.includes(o.toLocaleLowerCase())},t0=(n,r,o)=>{var m;let{envKey:v}=n,y=$p(n);if(v||y){let{playerInitTime:I,playerSoftwareName:M,playerSoftwareVersion:U,beaconCollectionDomain:H,debug:z,disableCookies:J}=n,Z={...n.metadata,video_title:((m=n==null?void 0:n.metadata)==null?void 0:m.video_title)||void 0},se=me=>typeof me.player_error_code=="string"?!1:typeof n.errorTranslator=="function"?n.errorTranslator(me):me;su.default.monitor(r,{debug:z,beaconCollectionDomain:H,hlsjs:o,Hls:o?Li:void 0,automaticErrorTracking:!1,errorTranslator:se,disableCookies:J,data:{...v?{env_key:v}:{},player_software_name:M,player_software:M,player_software_version:U,player_init_time:I,...Z}})}},i0=(n,r,o)=>{var m;let v=Yp(n,r),{src:y}=n;if(r&&v){let I=ou(n);typeof y=="string"?(r.preload==="none"?er(r,"loadstart",()=>_p(y,r,I)):_p(y,r,I),r.setAttribute("src",y),n.startTime&&(((m=ii.get(r))!=null?m:{}).startTime=n.startTime,r.addEventListener("durationchange",jp,{once:!0}))):r.removeAttribute("src"),r.addEventListener("error",zp),r.addEventListener("error",jc),r.addEventListener("emptied",()=>{r.querySelectorAll("track[data-removeondestroy]").forEach(U=>{U.remove()})},{once:!0});let M=()=>{r.ended||!eh(r)||r.dispatchEvent(new Event("ended"))};er(r,"pause",M),er(r,"seeked",M),er(r,"play",()=>{r.ended||!Wp(r.currentTime,r.duration)||(r.currentTime=r.seekable.start(0))})}else o&&y?(o.once(Li.Events.LEVEL_LOADED,(I,M)=>{Ky(M.details,r,o)}),o.on(Li.Events.ERROR,(I,M)=>{let U={[Li.ErrorTypes.NETWORK_ERROR]:At.MEDIA_ERR_NETWORK,[Li.ErrorTypes.MEDIA_ERROR]:At.MEDIA_ERR_DECODE},H=new At("",U[M.type]);H.fatal=M.fatal,H.data=M,r.dispatchEvent(new CustomEvent("error",{detail:H}))}),r.addEventListener("error",jc),Fy(r,o),o.attachMedia(r)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function jp(n){var r;let o=n.target,m=(r=ii.get(o))==null?void 0:r.startTime;if(!!m&&Cy(o.seekable,o.duration,m)){let v=o.preload==="auto";v&&(o.preload="none"),o.currentTime=m,v&&(o.preload="auto")}}async function zp(n){if(!n.isTrusted)return;n.stopImmediatePropagation();let r=n.target;if(!(r!=null&&r.error))return;let{message:o,code:m}=r.error,v=new At(o,m);if(r.src&&(m!==At.MEDIA_ERR_DECODE||m!==void 0))try{let{status:y}=await fetch(r.src);v.data={response:{code:y}}}catch{}r.dispatchEvent(new CustomEvent("error",{detail:v}))}function jc(n){var r,o;if(!(n instanceof CustomEvent)||!(n.detail instanceof At))return;let m=n.target,v=n.detail;!v||!v.fatal||(((r=ii.get(m))!=null?r:{}).error=v,(o=m.mux)==null||o.emit("error",{player_error_code:v.code,player_error_message:v.message,player_error_context:v.context}))}var r0=Object.defineProperty,a0=(n,r,o)=>r in n?r0(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o,Yn=(n,r,o)=>(a0(n,typeof r!="symbol"?r+"":r,o),o),lh=(n,r,o)=>{if(!r.has(n))throw TypeError("Cannot "+o)},pe=(n,r,o)=>(lh(n,r,"read from private field"),o?o.call(n):r.get(n)),Ye=(n,r,o)=>{if(r.has(n))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(n):r.set(n,o)},mt=(n,r,o,m)=>(lh(n,r,"write to private field"),m?m.call(n,o):r.set(n,o),o),wt=(n,r,o)=>(lh(n,r,"access private method"),o),vu=class{addEventListener(){}removeEventListener(){}dispatchEvent(n){return!0}};if(typeof DocumentFragment=="undefined"){class n extends vu{}globalThis.DocumentFragment=n}var uh=class extends vu{},n0=class extends vu{},s0={get(n){},define(n,r,o){},upgrade(n){},whenDefined(n){return Promise.resolve(uh)}},uu,o0=class{constructor(n,r={}){Ye(this,uu,void 0),mt(this,uu,r==null?void 0:r.detail)}get detail(){return pe(this,uu)}initCustomEvent(){}};uu=new WeakMap;function l0(n,r){return new uh}var Jp={document:{createElement:l0},DocumentFragment,customElements:s0,CustomEvent:o0,EventTarget:vu,HTMLElement:uh,HTMLVideoElement:n0},ev=typeof window=="undefined"||typeof globalThis.customElements=="undefined",du=ev?Jp:globalThis,KS=ev?Jp.document:globalThis.document,u0=()=>{try{return"0.15.5"}catch{}return"UNKNOWN"},d0=u0(),c0=()=>d0,Qp=n=>{var r,o,m,v,y,I,M,U,H,z,J,Z,se,me,Te,ge,ye,Ee,de,Be,Ge,re,k,oe,q,Se,Xe,at,jt,it,B,di,zt,nt,ri,$e,Vt,Et,Mt,rr;return r=class extends n{constructor(){super(),Ye(this,Xe),Ye(this,jt),Ye(this,B),Ye(this,zt),Ye(this,ri),Ye(this,Vt),Ye(this,Mt),Yn(this,"castEnabled",!1),Ye(this,Ge,{paused:!1}),Ye(this,re,void 0),Ye(this,k,{}),Ye(this,oe,void 0),Ye(this,q,void 0),Ye(this,Se,void 0),r.instances.add(this),wt(this,ri,$e).call(this)}static get castElement(){return pe(r,o)}static get castEnabled(){return pe(r,m)}static get castState(){var te;return(te=pe(r,H,z))==null?void 0:te.getCastState()}static async exitCast(){try{await pe(r,H,z).endCurrentSession(!0)}catch(te){console.error(te);return}}get castPlayer(){if(r.castElement===this)return pe(this,re)}attributeChangedCallback(te){if(this.castPlayer)switch(te){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(te={}){var ke;wt(ke=r,de,Be).call(ke,te),mt(r,o,this),Object.entries(pe(this,k)).forEach(([st,Lt])=>{pe(this,re).controller.addEventListener(st,Lt)});try{await pe(r,H,z).requestSession()}catch{mt(r,o,void 0);return}pe(this,Ge).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(st){console.error(st)}}async load(){var te,ke;if(!this.castPlayer)return super.load();let st=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),Lt=[...this.querySelectorAll("track")].filter(({kind:Ze,src:vi})=>vi&&(Ze==="subtitles"||Ze==="captions")),Rt=[],ci=0;Lt.length&&(st.tracks=Lt.map(Ze=>{let vi=++ci;Rt.length===0&&Ze.track.mode==="showing"&&Rt.push(vi);let gi=new chrome.cast.media.Track(vi,chrome.cast.media.TrackType.TEXT);return gi.trackContentId=Ze.src,gi.trackContentType="text/vtt",gi.subtype=Ze.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,gi.name=Ze.label,gi.language=Ze.srclang,gi})),this.castStreamType==="live"?st.streamType=chrome.cast.media.StreamType.LIVE:st.streamType=chrome.cast.media.StreamType.BUFFERED,st.metadata=new chrome.cast.media.GenericMediaMetadata,st.metadata.title=this.title,st.metadata.images=[{url:this.poster}];let $i=new chrome.cast.media.LoadRequest(st);$i.currentTime=(te=super.currentTime)!=null?te:0,$i.autoplay=!pe(this,Ge).paused,$i.activeTrackIds=Rt,await((ke=pe(r,J,Z))==null?void 0:ke.loadMedia($i)),this.dispatchEvent(new Event("volumechange"))}play(){var te;if(this.castPlayer){this.castPlayer.isPaused&&((te=this.castPlayer.controller)==null||te.playOrPause());return}return super.play()}pause(){var te;if(this.castPlayer){this.castPlayer.isPaused||(te=this.castPlayer.controller)==null||te.playOrPause();return}super.pause()}get castSrc(){var te,ke,st;return(st=(ke=this.getAttribute("cast-src"))!=null?ke:(te=this.querySelector("source"))==null?void 0:te.src)!=null?st:this.currentSrc}set castSrc(te){this.castSrc!=te&&this.setAttribute("cast-src",`${te}`)}get castContentType(){var te;return(te=this.getAttribute("cast-content-type"))!=null?te:void 0}set castContentType(te){this.setAttribute("cast-content-type",`${te}`)}get castStreamType(){var te,ke;return(ke=(te=this.getAttribute("cast-stream-type"))!=null?te:this.streamType)!=null?ke:void 0}set castStreamType(te){this.setAttribute("cast-stream-type",`${te}`)}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 te;return this.castPlayer?(te=this.castPlayer)==null?void 0:te.isMuted:super.muted}set muted(te){var ke;if(this.castPlayer){(te&&!this.castPlayer.isMuted||!te&&this.castPlayer.isMuted)&&((ke=this.castPlayer.controller)==null||ke.muteOrUnmute());return}super.muted=te}get volume(){var te,ke;return this.castPlayer?(ke=(te=this.castPlayer)==null?void 0:te.volumeLevel)!=null?ke:1:super.volume}set volume(te){var ke;if(this.castPlayer){this.castPlayer.volumeLevel=te,(ke=this.castPlayer.controller)==null||ke.setVolumeLevel();return}super.volume=te}get duration(){var te,ke;return this.castPlayer&&pe(this,Xe,at)?(ke=(te=this.castPlayer)==null?void 0:te.duration)!=null?ke:NaN:super.duration}get currentTime(){var te,ke;return this.castPlayer&&pe(this,Xe,at)?(ke=(te=this.castPlayer)==null?void 0:te.currentTime)!=null?ke:0:super.currentTime}set currentTime(te){var ke;if(this.castPlayer){this.castPlayer.currentTime=te,(ke=this.castPlayer.controller)==null||ke.seek();return}super.currentTime=te}get onentercast(){return pe(this,oe)}set onentercast(te){pe(this,oe)&&(this.removeEventListener("entercast",pe(this,oe)),mt(this,oe,null)),typeof te=="function"&&(mt(this,oe,te),this.addEventListener("entercast",te))}get onleavecast(){return pe(this,q)}set onleavecast(te){pe(this,q)&&(this.removeEventListener("leavecast",pe(this,q)),mt(this,q,null)),typeof te=="function"&&(mt(this,q,te),this.addEventListener("leavecast",te))}get oncastchange(){return pe(this,Se)}set oncastchange(te){pe(this,Se)&&(this.removeEventListener("castchange",pe(this,Se)),mt(this,Se,null)),typeof te=="function"&&(mt(this,Se,te),this.addEventListener("castchange",te))}},o=new WeakMap,m=new WeakMap,v=new WeakMap,y=new WeakSet,I=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},M=new WeakSet,U=function(){return typeof cast!="undefined"&&cast.framework},H=new WeakSet,z=function(){if(pe(r,M,U))return cast.framework.CastContext.getInstance()},J=new WeakSet,Z=function(){var te;return(te=pe(r,H,z))==null?void 0:te.getCurrentSession()},se=new WeakSet,me=function(){var te;return(te=pe(r,J,Z))==null?void 0:te.getSessionObj().media[0]},Te=new WeakSet,ge=function(te){return new Promise((ke,st)=>{pe(r,se,me).editTracksInfo(te,ke,st)})},ye=new WeakSet,Ee=function(te){return new Promise((ke,st)=>{pe(r,se,me).getStatus(te,ke,st)})},de=new WeakSet,Be=function(te){return pe(r,H,z).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...te})},Ge=new WeakMap,re=new WeakMap,k=new WeakMap,oe=new WeakMap,q=new WeakMap,Se=new WeakMap,Xe=new WeakSet,at=function(){var te;return(te=this.castPlayer)==null?void 0:te.isMediaLoaded},jt=new WeakSet,it=function(){pe(r,o)===this&&(Object.entries(pe(this,k)).forEach(([te,ke])=>{pe(this,re).controller.removeEventListener(te,ke)}),mt(r,o,void 0),this.muted=pe(this,re).isMuted,this.currentTime=pe(this,re).savedPlayerState.currentTime,pe(this,re).savedPlayerState.isPaused===!1&&this.play())},B=new WeakSet,di=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:pe(r,H,z).getCastState()}))},zt=new WeakSet,nt=async function(){var te,ke;let{SESSION_RESUMED:st}=cast.framework.SessionState;if(pe(r,H,z).getSessionState()===st&&this.castSrc===((te=pe(r,se,me))==null?void 0:te.media.contentId)){mt(r,o,this),Object.entries(pe(this,k)).forEach(([Lt,Rt])=>{pe(this,re).controller.addEventListener(Lt,Rt)});try{await wt(ke=r,ye,Ee).call(ke,new chrome.cast.media.GetStatusRequest)}catch(Lt){console.error(Lt)}pe(this,k)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),pe(this,k)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},ri=new WeakSet,$e=function(){var te;!pe(r,M,U)||this.castEnabled||(this.castEnabled=!0,wt(te=r,de,Be).call(te),this.textTracks.addEventListener("change",wt(this,Mt,rr).bind(this)),wt(this,B,di).call(this),mt(this,re,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(pe(this,re)),mt(this,k,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:ke})=>{ke===!1&&wt(this,jt,it).call(this),this.dispatchEvent(new Event(ke?"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]:()=>{!pe(this,Xe,at)||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 ke,st;((ke=this.castPlayer)==null?void 0:ke.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"}[(st=this.castPlayer)==null?void 0:st.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!pe(this,Xe,at)||(await Promise.resolve(),wt(this,Vt,Et).call(this))}}))},Vt=new WeakSet,Et=function(){wt(this,Mt,rr).call(this)},Mt=new WeakSet,rr=async function(){var te,ke,st,Lt,Rt,ci;if(!this.castPlayer)return;let $i=((ke=(te=pe(this,re).mediaInfo)==null?void 0:te.tracks)!=null?ke:[]).filter(({type:ft})=>ft===chrome.cast.media.TrackType.TEXT),Ze=[...this.textTracks].filter(({kind:ft})=>ft==="subtitles"||ft==="captions"),vi=$i.map(({language:ft,name:nr,trackId:yr})=>{var $r;let{mode:xi}=($r=Ze.find(br=>br.language===ft&&br.label===nr))!=null?$r:{};return xi?{mode:xi,trackId:yr}:!1}).filter(Boolean),gi=vi.filter(({mode:ft})=>ft!=="showing").map(({trackId:ft})=>ft),ji=vi.find(({mode:ft})=>ft==="showing"),ar=(Rt=(Lt=(st=pe(r,J,Z))==null?void 0:st.getSessionObj().media[0])==null?void 0:Lt.activeTrackIds)!=null?Rt:[],Ei=ar;if(ar.length&&(Ei=Ei.filter(ft=>!gi.includes(ft))),ji!=null&&ji.trackId&&(Ei=[...Ei,ji.trackId]),Ei=[...new Set(Ei)],!((ft,nr)=>ft.length===nr.length&&ft.every(yr=>nr.includes(yr)))(ar,Ei))try{let ft=new chrome.cast.media.EditTracksInfoRequest(Ei);await wt(ci=r,Te,ge).call(ci,ft)}catch(ft){console.error(ft)}},Ye(r,y),Ye(r,M),Ye(r,H),Ye(r,J),Ye(r,se),Ye(r,Te),Ye(r,ye),Ye(r,de),Yn(r,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Yn(r,"instances",new Set),Ye(r,o,void 0),Ye(r,m,!1),Yn(r,"initCast",()=>{var te;pe(r,y,I)?pe(r,M,U)?pe(te=r,v).call(te,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var ke;return pe(ke=r,v).call(ke,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var ke;return pe(ke=r,v).call(ke,chrome.cast.isAvailable)})}}),Ye(r,v,te=>{if(te){mt(r,m,!0);let{CAST_STATE_CHANGED:ke}=cast.framework.CastContextEventType;pe(r,H,z).addEventListener(ke,Lt=>{r.instances.forEach(Rt=>{var ci;return wt(ci=Rt,B,di).call(ci,Lt)})});let{SESSION_STATE_CHANGED:st}=cast.framework.CastContextEventType;pe(r,H,z).addEventListener(st,Lt=>{r.instances.forEach(Rt=>{var ci;return wt(ci=Rt,zt,nt).call(ci,Lt)})}),r.instances.forEach(Lt=>{var Rt;return wt(Rt=Lt,ri,$e).call(Rt)})}}),r},rh=globalThis.HTMLVideoElement?Qp(HTMLVideoElement):Qp(Object);globalThis.customElements&&!globalThis.customElements.get("castable-video")&&(customElements.define("castable-video",rh,{extends:"video"}),globalThis.CastableVideoElement=rh);rh.initCast();var gu=["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"],Xp,ah=(Xp=globalThis.document)==null?void 0:Xp.createElement("template");ah&&(ah.innerHTML=`
|
|
885
|
+
<slot hidden name="captions-indicator">${sy}</slot>
|
|
886
|
+
`;var Em=(r,e)=>r.label===e.label&&r.language===e.language,Pd=class extends cm{constructor(){super({slotTemplate:_m}),Mr(this,Md),Mr(this,Fd),Mr(this,Tn),Mr(this,so),Mr(this,Is,[]),Mr(this,Ki,void 0),Mr(this,ni,void 0);let e=q.createElement("media-chrome-listitem");e.part.add("listitem"),e.value="off",e.textContent="Off",Or(this,Ki,e);let t=this.shadowRoot.querySelector('[name="captions-indicator"]');Or(this,ni,t.firstElementChild),t.addEventListener("slotchange",()=>{let i=t.assignedElements();if(i.length===1&&i[0].nodeName.toLowerCase()==="slot"){let s=i[0].assignedElements();s.length===0?Or(this,ni,i[0].firstElementChild):s.length===1&&Or(this,ni,s[0])}Ht(this,ni)||Or(this,ni,t.firstElementChild),Or(this,ni,Ht(this,ni).cloneNode(!0)),Ht(this,ni).removeAttribute("slot"),Ht(this,ni).setAttribute("style",Tm)})}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",R.MEDIA_SUBTITLES_LIST,R.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,i){if(e===R.MEDIA_SUBTITLES_LIST&&t!==i)Or(this,Is,Pr(this,Md,ym).call(this,i,Ht(this,Is))),Pr(this,Tn,ro).call(this);else if(e===R.MEDIA_SUBTITLES_SHOWING&&t!==i){let s=ls(i!=null?i:"")[0];Ht(this,Is).forEach(n=>{n.selected=n.language===s.language&&n.label===s.label}),Pr(this,Tn,ro).call(this)}else 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."));super.attributeChangedCallback(e,t,i)}connectedCallback(){Pr(this,Tn,ro).call(this),this.addEventListener("change",Pr(this,so,Od)),super.connectedCallback()}disconnectedCallback(){this.removeEventListener("change",Pr(this,so,Od)),super.disconnectedCallback()}};Is=new WeakMap;Ki=new WeakMap;ni=new WeakMap;Md=new WeakSet;ym=function(r,e){let t=r?ls(r!=null?r:""):[],i=[],s=[];return e.forEach(n=>{t.some(a=>Em(a,n))||i.push(n)}),t.forEach(n=>{e.some(a=>Em(a,n))||s.push(n)}),i.forEach(n=>n.el.remove()),e.filter(n=>!i.includes(n)).concat(s)};Fd=new WeakSet;bm=function(r){let e=this.shadowRoot.querySelector("ul slot");r.forEach(t=>{var i;let s=t.el,n=!0,a=(i=t.kind)!=null?i:"subs";if(!s){s=q.createElement("media-chrome-listitem"),n=!1,s.part.add("listitem"),s.value=Cl(t);let o=q.createElement("span");o.textContent=t.label,s.append(o),a==="captions"&&s.append(Ht(this,ni).cloneNode(!0))}t.selected?s.setAttribute("aria-selected","true"):s.setAttribute("aria-selected","false"),n||(e.append(s),t.el=s)})};Tn=new WeakSet;ro=function(){let r=this.shadowRoot.querySelector("ul slot");r.contains(Ht(this,Ki))||r.append(Ht(this,Ki)),this.hasAttribute(R.MEDIA_SUBTITLES_SHOWING)?(Ht(this,Ki).setAttribute("aria-selected","false"),Ht(this,Ki).setAttribute("tabindex","-1")):(Ht(this,Ki).setAttribute("aria-selected","true"),Ht(this,Ki).setAttribute("tabindex","0")),Pr(this,Fd,bm).call(this,Ht(this,Is))};so=new WeakSet;Od=function(){var r;let e=(r=this.selectedOptions[0])==null?void 0:r.value;if(Bi(this,!1),!e)return;let t=new N.CustomEvent(ne.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)};N.customElements.get("media-captions-listbox")||N.customElements.define("media-captions-listbox",Pd);var Ud=class extends gm{constructor(){super()}init(){let e=q.createElement("media-captions-button");e.part.add("button"),e.preventClick=!0;let t=q.createElement("media-captions-listbox");t.part.add("listbox"),t.setAttribute("exportparts","listitem");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)}};N.customElements.get("media-captions-selectmenu")||N.customElements.define("media-captions-selectmenu",Ud);var $o=Nv(Am(),1);function ny(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var up={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,u){if(u=u||{},l=l.trim(),d=d.trim(),!d){if(!u.alwaysNormalize)return l;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");return c.path=o.normalizePath(c.path),o.buildURLFromParts(c)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return u.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=u.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})()})(up);var ac=up.exports;function Sm(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 Yt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Sm(Object(t),!0).forEach(function(i){ay(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Sm(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}function ay(r,e,t){return e=ly(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function mt(){return mt=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},mt.apply(this,arguments)}function oy(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 ly(r){var e=oy(r,"string");return typeof e=="symbol"?e:String(e)}var le=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}({}),fe=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}({}),Fr=function(){},ou={trace:Fr,debug:Fr,log:Fr,warn:Fr,info:Fr,error:Fr},An=ou;function dy(r){let e=self.console[r];return e?e.bind(self.console,`[${r}] >`):Fr}function uy(r,...e){e.forEach(function(t){An[t]=r[t]?r[t].bind(r):dy(t)})}function cy(r,e){if(self.console&&r===!0||typeof r=="object"){uy(r,"debug","log","info","warn","error");try{An.log(`Debug logs enabled for "${e}" in hls.js version 1.4.8`)}catch{An=ou}}else An=ou}var C=An,hy=/^(\d+)x(\d+)$/,xm=/(.+?)=(".*?"|.*?)(?:,|$)/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=hy.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(xm.lastIndex=0;(t=xm.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 fy(r){return r!=="ID"&&r!=="CLASS"&&r!=="START-DATE"&&r!=="DURATION"&&r!=="END-DATE"&&r!=="END-ON-NEXT"}function my(r){return r==="SCTE35-OUT"||r==="SCTE35-IN"}var vo=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]){C.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=mt(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"]);le(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(le(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&&le(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}},Cs=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}}},$e={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Eo=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[$e.AUDIO]:null,[$e.VIDEO]:null,[$e.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=ac.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},Sn=class extends Eo{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 Cs,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||!le(this.programDateTime))return null;let e=le(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[$e.AUDIO]=null,e[$e.VIDEO]=null,e[$e.AUDIOVIDEO]=null}},lu=class extends Eo{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 Cs,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)}},py=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?le(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||py}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 oc(r){return Uint8Array.from(atob(r),e=>e.charCodeAt(0))}function gy(r){let e=cp(r).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function vy(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 Ey(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=oc(a)):t=gy(a)}}return t}function cp(r){return Uint8Array.from(unescape(encodeURIComponent(r)),e=>e.charCodeAt(0))}var tt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},qt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Im(r){switch(r){case qt.FAIRPLAY:return tt.FAIRPLAY;case qt.PLAYREADY:return tt.PLAYREADY;case qt.WIDEVINE:return tt.WIDEVINE;case qt.CLEARKEY:return tt.CLEARKEY}}var hp={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function yy(r){if(r===hp.WIDEVINE)return tt.WIDEVINE}function Lm(r){switch(r){case tt.FAIRPLAY:return qt.FAIRPLAY;case tt.PLAYREADY:return qt.PLAYREADY;case tt.WIDEVINE:return qt.WIDEVINE;case tt.CLEARKEY:return qt.CLEARKEY}}function $d(r){let{drmSystems:e,widevineLicenseUrl:t}=r,i=e?[tt.FAIRPLAY,tt.WIDEVINE,tt.PLAYREADY,tt.CLEARKEY].filter(s=>!!e[s]):[];return!i[tt.WIDEVINE]&&t&&i.push(tt.WIDEVINE),i}var fp=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function by(r,e,t,i){let s;switch(r){case tt.FAIRPLAY:s=["cenc","sinf"];break;case tt.WIDEVINE:case tt.PLAYREADY:s=["cenc"];break;case tt.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${r}`)}return Ty(s,e,t,i)}function Ty(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 Ur(r,e,t){return Uint8Array.prototype.slice?r.slice(e,t):new Uint8Array(Array.prototype.slice.call(r,e,t))}var lc=(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,mp=(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,yo=(r,e)=>{let t=e,i=0;for(;lc(r,e);){i+=10;let s=Uo(r,e+6);i+=s,mp(r,e+10)&&(i+=10),e+=i}if(i>0)return r.subarray(t,t+i)},Uo=(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},_y=(r,e)=>lc(r,e)&&Uo(r,e+6)+10<=r.length-e,Ay=r=>{let e=gp(r);for(let t=0;t<e.length;t++){let i=e[t];if(pp(i))return wy(i)}},pp=r=>r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp",Sy=r=>{let e=String.fromCharCode(r[0],r[1],r[2],r[3]),t=Uo(r,4),i=10;return{type:e,size:t,data:r.subarray(i,i+t)}},gp=r=>{let e=0,t=[];for(;lc(r,e);){let i=Uo(r,e+6);e+=10;let s=e+i;for(;e+8<s;){let n=Sy(r.subarray(e)),a=xy(n);a&&t.push(a),e+=n.size+10}mp(r,e)&&(e+=10)}return t},xy=r=>r.type==="PRIV"?Iy(r):r.type[0]==="W"?Ry(r):Ly(r),Iy=r=>{if(r.size<2)return;let e=Oi(r.data,!0),t=new Uint8Array(r.data.subarray(e.length+1));return{key:r.type,info:e,data:t.buffer}},Ly=r=>{if(r.size<2)return;if(r.type==="TXXX"){let t=1,i=Oi(r.data.subarray(t),!0);t+=i.length+1;let s=Oi(r.data.subarray(t));return{key:r.type,info:i,data:s}}let e=Oi(r.data.subarray(1));return{key:r.type,data:e}},Ry=r=>{if(r.type==="WXXX"){if(r.size<2)return;let t=1,i=Oi(r.data.subarray(t),!0);t+=i.length+1;let s=Oi(r.data.subarray(t));return{key:r.type,info:i,data:s}}let e=Oi(r.data);return{key:r.type,data:e}},wy=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)}},Oi=(r,e=!1)=>{let t=ky();if(t){let d=t.decode(r);if(e){let u=d.indexOf("\0");return u!==-1?d.substring(0,u):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},Gd;function ky(){return!Gd&&typeof self.TextDecoder!="undefined"&&(Gd=new self.TextDecoder("utf-8")),Gd}var wi={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}},bo=Math.pow(2,32)-1,Dy=[].push,vp={video:1,audio:2,id3:3,text:4};function xt(r){return String.fromCharCode.apply(null,r)}function Ep(r,e){let t=r[e]<<8|r[e+1];return t<0?65536+t:t}function Ee(r,e){let t=yp(r,e);return t<0?4294967296+t:t}function yp(r,e){return r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}function Hd(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 Me(r,e){let t=[];if(!e.length)return t;let i=r.byteLength;for(let s=0;s<i;){let n=Ee(r,s),a=xt(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=Me(r.subarray(s+8,o),e.slice(1));l.length&&Dy.apply(t,l)}s=o}return t}function Cy(r){let e=[],t=r[0],i=8,s=Ee(r,i);i+=4;let n=0,a=0;t===0?i+=8:i+=16,i+=2;let o=r.length+a,l=Ep(r,i);i+=2;for(let d=0;d<l;d++){let u=i,c=Ee(r,u);u+=4;let h=c&2147483647;if((c&2147483648)>>>31===1)return C.warn("SIDX has hierarchical references (not supported)"),null;let g=Ee(r,u);u+=4,e.push({referenceSize:h,subsegmentDuration:g,info:{duration:g/s,start:o,end:o+h-1}}),o+=h,u+=4,i=u}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function bp(r){let e=[],t=Me(r,["moov","trak"]);for(let s=0;s<t.length;s++){let n=t[s],a=Me(n,["tkhd"])[0];if(a){let o=a[0],l=o===0?12:20,d=Ee(a,l),u=Me(n,["mdia","mdhd"])[0];if(u){o=u[0],l=o===0?12:20;let c=Ee(u,l),h=Me(n,["mdia","hdlr"])[0];if(h){let m=xt(h.subarray(8,12)),g={soun:$e.AUDIO,vide:$e.VIDEO}[m];if(g){let E=Me(n,["mdia","minf","stbl","stsd"])[0],T;E&&(T=xt(E.subarray(12,16))),e[d]={timescale:c,type:g},e[g]={timescale:c,id:d,codec:T}}}}}}return Me(r,["moov","mvex","trex"]).forEach(s=>{let n=Ee(s,4),a=e[n];a&&(a.default={duration:Ee(s,12),flags:Ee(s,20)})}),e}function My(r,e){if(!r||!e)return r;let t=e.keyId;return t&&e.isCommonEncryption&&Me(r,["moov","trak"]).forEach(s=>{let a=Me(s,["mdia","minf","stbl","stsd"])[0].subarray(8),o=Me(a,["enca"]),l=o.length>0;l||(o=Me(a,["encv"])),o.forEach(d=>{let u=l?d.subarray(28):d.subarray(78);Me(u,["sinf"]).forEach(h=>{let m=Tp(h);if(m){let g=m.subarray(8,24);g.some(E=>E!==0)||(C.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${wi.hexDump(g)} -> ${wi.hexDump(t)}`),m.set(t,8))}})})}),r}function Tp(r){let e=Me(r,["schm"])[0];if(e){let t=xt(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return Me(r,["schi","tenc"])[0]}return C.error("[eme] missing 'schm' box"),null}function Oy(r,e){return Me(e,["moof","traf"]).reduce((t,i)=>{let s=Me(i,["tfdt"])[0],n=s[0],a=Me(i,["tfhd"]).reduce((o,l)=>{let d=Ee(l,4),u=r[d];if(u){let c=Ee(s,4);if(n===1){if(c===bo)return C.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;c*=bo+1,c+=Ee(s,8)}let h=u.timescale||9e4,m=c/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 Py(r,e){let t=0,i=0,s=0,n=Me(r,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=Me(o,["tfhd"])[0],d=Ee(l,4),u=e[d];if(!u)continue;let c=u.default,h=Ee(l,0)|(c==null?void 0:c.flags),m=c==null?void 0:c.duration;h&8&&(h&2?m=Ee(l,12):m=Ee(l,8));let g=u.timescale||9e4,E=Me(o,["trun"]);for(let T=0;T<E.length;T++){if(t=Ny(E[T]),!t&&m){let A=Ee(E[T],4);t=m*A}u.type===$e.VIDEO?i+=t/g:u.type===$e.AUDIO&&(s+=t/g)}}if(i===0&&s===0){let a=0,o=Me(r,["sidx"]);for(let l=0;l<o.length;l++){let d=Cy(o[l]);d!=null&&d.references&&(a+=d.references.reduce((u,c)=>u+c.info.duration||0,0))}return a}return i||s}function Ny(r){let e=Ee(r,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let i=0,s=Ee(r,4);for(let n=0;n<s;n++){if(e&256){let a=Ee(r,t);i+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return i}function Fy(r,e,t){Me(e,["moof","traf"]).forEach(i=>{Me(i,["tfhd"]).forEach(s=>{let n=Ee(s,4),a=r[n];if(!a)return;let o=a.timescale||9e4;Me(i,["tfdt"]).forEach(l=>{let d=l[0],u=Ee(l,4);if(d===0)u-=t*o,u=Math.max(u,0),Hd(l,4,u);else{u*=Math.pow(2,32),u+=Ee(l,8),u-=t*o,u=Math.max(u,0);let c=Math.floor(u/(bo+1)),h=Math.floor(u%(bo+1));Hd(l,4,c),Hd(l,8,h)}})})})}function Uy(r){let e={valid:null,remainder:null},t=Me(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=Ur(r,0,i.byteOffset-8),e.remainder=Ur(r,i.byteOffset-8),e}function Br(r,e){let t=new Uint8Array(r.length+e.length);return t.set(r),t.set(e,r.length),t}function Rm(r,e){let t=[],i=e.samples,s=e.timescale,n=e.id,a=!1;return Me(i,["moof"]).map(l=>{let d=l.byteOffset-8;Me(l,["traf"]).map(c=>{let h=Me(c,["tfdt"]).map(m=>{let g=m[0],E=Ee(m,4);return g===1&&(E*=Math.pow(2,32),E+=Ee(m,8)),E/s})[0];return h!==void 0&&(r=h),Me(c,["tfhd"]).map(m=>{let g=Ee(m,4),E=Ee(m,0)&16777215,T=(E&1)!==0,A=(E&2)!==0,L=(E&8)!==0,S=0,P=(E&16)!==0,k=0,$=(E&32)!==0,M=8;g===n&&(T&&(M+=8),A&&(M+=4),L&&(S=Ee(m,M),M+=4),P&&(k=Ee(m,M),M+=4),$&&(M+=4),e.type==="video"&&(a=By(e.codec)),Me(c,["trun"]).map(G=>{let W=G[0],O=Ee(G,0)&16777215,z=(O&1)!==0,j=0,be=(O&4)!==0,ge=(O&256)!==0,ve=0,Re=(O&512)!==0,Te=0,Q=(O&1024)!==0,ie=(O&2048)!==0,re=0,_e=Ee(G,4),Se=8;z&&(j=Ee(G,Se),Se+=4),be&&(Se+=4);let Ne=j+d;for(let ut=0;ut<_e;ut++){if(ge?(ve=Ee(G,Se),Se+=4):ve=S,Re?(Te=Ee(G,Se),Se+=4):Te=k,Q&&(Se+=4),ie&&(W===0?re=Ee(G,Se):re=yp(G,Se),Se+=4),e.type===$e.VIDEO){let H=0;for(;H<Te;){let Z=Ee(i,Ne);if(Ne+=4,$y(a,i[Ne])){let Ie=i.subarray(Ne,Ne+Z);_p(Ie,a?2:1,r+re/s,t)}Ne+=Z,H+=Z+4}}r+=ve/s}}))})})}),t}function By(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 $y(r,e){if(r){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function _p(r,e,t,i){let s=Ap(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 u=s.length-n;if(!l&&a===4&&n<s.length){if(l=!0,s[n++]===181){let h=Ep(s,n);if(n+=2,h===49){let m=Ee(s,n);if(n+=4,m===1195456820){let g=s[n++];if(g===3){let E=s[n++],T=31&E,A=64&E,L=A?2+T*3:0,S=new Uint8Array(L);if(A){S[0]=E;for(let P=1;P<L;P++)S[P]=s[n++]}i.push({type:g,payloadType:a,pts:t,bytes:S})}}}}}else if(a===5&&o<u){if(l=!0,o>16){let c=[];for(let g=0;g<16;g++){let E=s[n++].toString(16);c.push(E.length==1?"0"+E:E),(g===3||g===5||g===7||g===9)&&c.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:c.join(""),userData:Oi(m),userDataBytes:m})}}else if(o<u)n+=o;else if(o>u)break}}function Ap(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 Gy(r){let e=r[0],t="",i="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;xt(r.subarray(d,d+1))!=="\0";)t+=xt(r.subarray(d,d+1)),d+=1;for(t+=xt(r.subarray(d,d+1)),d+=1;xt(r.subarray(d,d+1))!=="\0";)i+=xt(r.subarray(d,d+1)),d+=1;i+=xt(r.subarray(d,d+1)),d+=1,s=Ee(r,12),n=Ee(r,16),o=Ee(r,20),l=Ee(r,24),d=28}else if(e===1){d+=4,s=Ee(r,d),d+=4;let c=Ee(r,d);d+=4;let h=Ee(r,d);for(d+=4,a=2**32*c+h,Number.isSafeInteger(a)||(a=Number.MAX_SAFE_INTEGER,C.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Ee(r,d),d+=4,l=Ee(r,d),d+=4;xt(r.subarray(d,d+1))!=="\0";)t+=xt(r.subarray(d,d+1)),d+=1;for(t+=xt(r.subarray(d,d+1)),d+=1;xt(r.subarray(d,d+1))!=="\0";)i+=xt(r.subarray(d,d+1)),d+=1;i+=xt(r.subarray(d,d+1)),d+=1}let u=r.subarray(d,r.byteLength);return{schemeIdUri:t,value:i,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:u}}function Hy(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 Vy(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),Hy([112,115,115,104],new Uint8Array([i,0,0,0]),r,n,s,a,t||new Uint8Array)}function Ky(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=wi.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 ao={},$r=class{static clearKeyUriToKeyIdMap(){ao={}}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 qt.FAIRPLAY:case qt.WIDEVINE:case qt.PLAYREADY:case qt.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&C.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let i=Wy(e);return new $r(this.method,this.uri,"identity",this.keyFormatVersions,i)}let t=Ey(this.uri);if(t)switch(this.keyFormat){case qt.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case qt.PLAYREADY:{let i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Vy(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 u=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(u){let c=oc(u).subarray(0,16);vy(c),this.keyId=c}}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=ao[this.uri];if(!i){let s=Object.keys(ao).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,s),ao[this.uri]=i}this.keyId=i}return this}};function Wy(r){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=r>>8*(15-t)&255;return e}var Sp=/\{\$([a-zA-Z0-9-_]+)\}/g;function wm(r){return Sp.test(r)}function Kt(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(Sp,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 km(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 qy(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 Bo(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}var Yy={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}},Dm=Bo();function jy(r,e){let t=Yy[e];return!!t&&t[r.slice(0,4)]===!0}function Vd(r,e){var t;return(t=Dm==null?void 0:Dm.isTypeSupported(`${e||"video"}/mp4;codecs="${r}"`))!=null?t:!1}var Cm=/#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,Mm=/#EXT-X-MEDIA:(.*)/g,zy=/^#EXT(?:INF|-X-TARGETDURATION):/m,Om=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Xy=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("|")),Qt=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 ac.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return zy.test(e)}static parseMasterPlaylist(e,t){let i=wm(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];Cm.lastIndex=0;let a;for(;(a=Cm.exec(e))!=null;)if(a[1]){var o;let d=new qe(a[1]);Kt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let u=uu(s,a[2]),c={attrs:d,bitrate:d.decimalInteger("AVERAGE-BANDWIDTH")||d.decimalInteger("BANDWIDTH"),name:d.NAME,url:Qt.resolve(u,t)},h=d.decimalResolution("RESOLUTION");h&&(c.width=h.width,c.height=h.height),Qy((d.CODECS||"").split(/[ ,]+/).filter(m=>m),c),c.videoCodec&&c.videoCodec.indexOf("avc1")!==-1&&(c.videoCodec=Qt.convertAVC1ToAVCOTI(c.videoCodec)),(o=c.unknownCodecs)!=null&&o.length||n.push(c),s.levels.push(c)}else if(a[3]){let d=a[3],u=a[4];switch(d){case"SESSION-DATA":{let c=new qe(u);Kt(s,c,["DATA-ID","LANGUAGE","VALUE","URI"]);let h=c["DATA-ID"];h&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[h]=c);break}case"SESSION-KEY":{let c=Pm(u,t,s);c.encrypted&&c.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(c)):C.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`);break}case"DEFINE":{{let c=new qe(u);Kt(s,c,["NAME","VALUE","QUERYPARAM"]),km(s,c,t)}break}case"CONTENT-STEERING":{let c=new qe(u);Kt(s,c,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:Qt.resolve(c["SERVER-URI"],t),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=Nm(u);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(Mm.lastIndex=0;(s=Mm.exec(e))!==null;){let d=new qe(s[1]),u=d.TYPE;if(u){let c=o[u],h=n[u]||[];n[u]=h,Kt(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:u,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:d.LANGUAGE,url:d.URI?Qt.resolve(d.URI,t):""};if(c!=null&&c.length){let g=Qt.findGroup(c,m.groupId)||c[0];Fm(m,g,"audioCodec"),Fm(m,g,"textCodec")}h.push(m)}}return n}static parseLevelPlaylist(e,t,i,s,n,a){let o=new du(t),l=o.fragments,d=null,u=0,c=0,h=0,m=0,g=null,E=new Sn(s,t),T,A,L,S=-1,P=!1;for(Om.lastIndex=0,o.m3u8=e,o.hasVariableRefs=wm(e);(T=Om.exec(e))!==null;){P&&(P=!1,E=new Sn(s,t),E.start=h,E.sn=u,E.cc=m,E.level=i,d&&(E.initSegment=d,E.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null));let G=T[1];if(G){E.duration=parseFloat(G);let W=(" "+T[2]).slice(1);E.title=W||null,E.tagList.push(W?["INF",G,W]:["INF",G])}else if(T[3]){if(le(E.duration)){E.start=h,L&&$m(E,L,o),E.sn=u,E.level=i,E.cc=m,E.urlId=n,l.push(E);let W=(" "+T[3]).slice(1);E.relurl=uu(o,W),Um(E,g),g=E,h+=E.duration,u++,c=0,P=!0}}else if(T[4]){let W=(" "+T[4]).slice(1);g?E.setByteRange(W,g):E.setByteRange(W)}else if(T[5])E.rawProgramDateTime=(" "+T[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),S===-1&&(S=l.length);else{if(T=T[0].match(Xy),!T){C.warn("No matches on slow regex match for level playlist!");continue}for(A=1;A<T.length&&typeof T[A]=="undefined";A++);let W=(" "+T[A]).slice(1),O=(" "+T[A+1]).slice(1),z=T[A+2]?(" "+T[A+2]).slice(1):"";switch(W){case"PLAYLIST-TYPE":o.type=O.toUpperCase();break;case"MEDIA-SEQUENCE":u=o.startSN=parseInt(O);break;case"SKIP":{let j=new qe(O);Kt(o,j,["RECENTLY-REMOVED-DATERANGES"]);let be=j.decimalInteger("SKIPPED-SEGMENTS");if(le(be)){o.skippedSegments=be;for(let ve=be;ve--;)l.unshift(null);u+=be}let ge=j.enumeratedString("RECENTLY-REMOVED-DATERANGES");ge&&(o.recentlyRemovedDateranges=ge.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(O),1);break;case"VERSION":o.version=parseInt(O);break;case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(O||z)&&E.tagList.push(z?[O,z]:[O]);break;case"DISCONTINUITY":m++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([W]);break;case"BITRATE":E.tagList.push([W,O]);break;case"DATERANGE":{let j=new qe(O);Kt(o,j,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Kt(o,j,j.clientAttrs);let be=new vo(j,o.dateRanges[j.ID]);be.isValid||o.skippedSegments?o.dateRanges[be.id]=be:C.warn(`Ignoring invalid DATERANGE tag: "${O}"`),E.tagList.push(["EXT-X-DATERANGE",O]);break}case"DEFINE":{{let j=new qe(O);Kt(o,j,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in j?qy(o,j,a):km(o,j,t)}break}case"DISCONTINUITY-SEQUENCE":m=parseInt(O);break;case"KEY":{let j=Pm(O,t,o);if(j.isSupported()){if(j.method==="NONE"){L=void 0;break}L||(L={}),L[j.keyFormat]&&(L=mt({},L)),L[j.keyFormat]=j}else C.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${O}"`);break}case"START":o.startTimeOffset=Nm(O);break;case"MAP":{let j=new qe(O);if(Kt(o,j,["BYTERANGE","URI"]),E.duration){let be=new Sn(s,t);Bm(be,j,i,L),d=be,E.initSegment=d,d.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=d.rawProgramDateTime)}else Bm(E,j,i,L),d=E,P=!0;break}case"SERVER-CONTROL":{let j=new qe(O);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(O);o.partTarget=j.decimalFloatingPoint("PART-TARGET");break}case"PART":{let j=o.partList;j||(j=o.partList=[]);let be=c>0?j[j.length-1]:void 0,ge=c++,ve=new qe(O);Kt(o,ve,["BYTERANGE","URI"]);let Re=new lu(ve,E,t,ge,be);j.push(Re),E.duration+=Re.duration;break}case"PRELOAD-HINT":{let j=new qe(O);Kt(o,j,["URI"]),o.preloadHint=j;break}case"RENDITION-REPORT":{let j=new qe(O);Kt(o,j,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(j);break}default:C.warn(`line parsed but not handled: ${T}`);break}}}g&&!g.relurl?(l.pop(),h-=g.duration,o.partList&&(o.fragmentHint=g)):o.partList&&(Um(E,g),E.cc=m,o.fragmentHint=E,L&&$m(E,L,o));let k=l.length,$=l[0],M=l[k-1];if(h+=o.skippedSegments*o.targetduration,h>0&&k&&M){o.averagetargetduration=h/k;let G=M.sn;o.endSN=G!=="initSegment"?G:0,o.live||(M.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,S>0&&Zy(l,S),o}};function Pm(r,e,t){var i,s;let n=new qe(r);Kt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(i=n.METHOD)!=null?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,u=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&C.error(`Invalid IV: ${n.IV}`);let c=o?Qt.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new $r(a,c,u,h,l)}function Nm(r){let t=new qe(r).decimalFloatingPoint("TIME-OFFSET");return le(t)?t:null}function Qy(r,e){["video","audio","text"].forEach(t=>{let i=r.filter(s=>jy(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 Fm(r,e,t){let i=e[t];i&&(r[t]=i)}function Zy(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 Um(r,e){r.rawProgramDateTime?r.programDateTime=Date.parse(r.rawProgramDateTime):e!=null&&e.programDateTime&&(r.programDateTime=e.endProgramDateTime),le(r.programDateTime)||(r.programDateTime=null,r.rawProgramDateTime=null)}function Bm(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 $m(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 Pe={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},me={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Gm(r){let{type:e}=r;switch(e){case Pe.AUDIO_TRACK:return me.AUDIO;case Pe.SUBTITLE_TRACK:return me.SUBTITLE;default:return me.MAIN}}function Kd(r,e){let t=r.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var cu=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:Pe.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:Pe.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:Pe.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:Pe.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){C.trace("[playlist-loader]: playlist request ongoing");return}C.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===Pe.MANIFEST?n=i.manifestLoadPolicy.default:n=mt({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part){let d;if(e.type===Pe.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Pe.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Pe.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){let u=d.partTarget,c=d.targetduration;if(u&&c){let h=Math.max(u*3,c*.8)*1e3;n=mt({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,u,c,h)=>{let m=this.getInternalLoader(c);this.resetInternalLoader(c.type);let g=d.data;if(g.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,c,new Error("no EXTM3U delimiter"),h||null,u);return}u.parsing.start=performance.now(),Qt.isMediaPlaylist(g)?this.handleTrackOrLevelPlaylist(d,u,c,h||null,m):this.handleMasterPlaylist(d,u,c,h)},onError:(d,u,c,h)=>{this.handleNetworkError(u,c,!1,d,h)},onTimeout:(d,u,c)=>{this.handleNetworkError(u,c,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,i,s){let n=this.hls,a=e.data,o=Kd(e,i),l=Qt.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,i,l.playlistParsingError,s,t);return}let{contentSteering:d,levels:u,sessionData:c,sessionKeys:h,startTimeOffset:m,variableList:g}=l;this.variableList=g;let{AUDIO:E=[],SUBTITLES:T,"CLOSED-CAPTIONS":A}=Qt.parseMasterPlaylistMedia(a,o,l);E.length&&!E.some(S=>!S.url)&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(C.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new qe({}),bitrate:0,url:""})),n.trigger(y.MANIFEST_LOADED,{levels:u,audioTracks:E,subtitles:T,captions:A,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:c,sessionKeys:h,startTimeOffset:m,variableList:g})}handleTrackOrLevelPlaylist(e,t,i,s,n){let a=this.hls,{id:o,level:l,type:d}=i,u=Kd(e,i),c=le(o)?o:0,h=le(l)?l:c,m=Gm(i),g=Qt.parseLevelPlaylist(e.data,u,h,m,c,this.variableList);if(d===Pe.MANIFEST){let E={attrs:new qe({}),bitrate:0,details:g,name:"",url:u};a.trigger(y.MANIFEST_LOADED,{levels:[E],audioTracks:[],url:u,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:fe.NETWORK_ERROR,details:B.MANIFEST_PARSING_ERROR,fatal:t.type===Pe.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===Pe.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Pe.AUDIO_TRACK||e.type===Pe.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);C.warn(`[playlist-loader]: ${a}`);let l=B.UNKNOWN,d=!1,u=this.getInternalLoader(e);switch(e.type){case Pe.MANIFEST:l=i?B.MANIFEST_LOAD_TIMEOUT:B.MANIFEST_LOAD_ERROR,d=!0;break;case Pe.LEVEL:l=i?B.LEVEL_LOAD_TIMEOUT:B.LEVEL_LOAD_ERROR,d=!1;break;case Pe.AUDIO_TRACK:l=i?B.AUDIO_TRACK_LOAD_TIMEOUT:B.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Pe.SUBTITLE_TRACK:l=i?B.SUBTITLE_TRACK_LOAD_TIMEOUT:B.SUBTITLE_LOAD_ERROR,d=!1;break}u&&this.resetInternalLoader(e.type);let c={type:fe.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:u,context:e,error:o,networkDetails:t,stats:n};if(s){let h=(t==null?void 0:t.url)||e.url;c.response=Yt({url:h,data:void 0},s)}this.hls.trigger(y.ERROR,c)}handlePlaylistLoaded(e,t,i,s,n,a){let o=this.hls,{type:l,level:d,id:u,groupId:c,deliveryDirectives:h}=s,m=Kd(t,s),g=Gm(s),E=typeof s.level=="number"&&g===me.MAIN?d:void 0;if(!e.fragments.length){let A=new Error("No Segments found in Playlist");o.trigger(y.ERROR,{type:fe.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:fe.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 Pe.MANIFEST:case Pe.LEVEL:o.trigger(y.LEVEL_LOADED,{details:e,level:E||0,id:u||0,stats:i,networkDetails:n,deliveryDirectives:h});break;case Pe.AUDIO_TRACK:o.trigger(y.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:i,networkDetails:n,deliveryDirectives:h});break;case Pe.SUBTITLE_TRACK:o.trigger(y.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:i,networkDetails:n,deliveryDirectives:h});break}}};function xp(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 Ip(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){C.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 ks(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=eb(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 Jy(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 eb(r,e,t){let i=[],s=Jy(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 mi={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},tb=.25;function fu(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var oo=(()=>{let r=fu();try{new r(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Wd(r,e){return r.getTime()/1e3-e}function ib(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||(ks(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 xp(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===mi.emsg&&!i||!s)continue;let d=gp(n[o].data);if(d){let u=n[o].pts,c=u+n[o].duration;c>oo&&(c=oo),c-u<=0&&(c=u+tb);for(let m=0;m<d.length;m++){let g=d[m];if(!pp(g)){this.updateId3CueEnds(u,l);let E=new a(u,c,"");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===oo&&(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=u=>u.type===mi.audioId3&&l:s==="video"?d=u=>u.type===mi.emsg&&o:d=u=>u.type===mi.audioId3&&l||u.type===mi.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 u=Object.keys(i).filter(c=>!a.includes(c));for(let c=u.length;c--;){let h=u[c];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||!le(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 u=0;u<a.length;u++){let c=a[u],h=n[c],m=i[c],g=(m==null?void 0:m.cues)||{},E=(m==null?void 0:m.durationKnown)||!1,T=Wd(h.startDate,l),A=oo,L=h.endDate;if(L)A=Wd(L,l),E=!0;else if(h.endOnNext&&!E){let P=a.reduce((k,$)=>{let M=n[$];return M.class===h.class&&M.id!==$&&M.startDate>h.startDate&&k.push(M),k},[]).sort((k,$)=>k.startDate.getTime()-$.startDate.getTime())[0];P&&(A=Wd(P.startDate,l),E=!0)}let S=Object.keys(h.attr);for(let P=0;P<S.length;P++){let k=S[P];if(!fy(k))continue;let $=g[k];if($)E&&!m.durationKnown&&($.endTime=A);else{let M=h.attr[k];$=new d(T,A,""),my(k)&&(M=ib(M)),$.value={key:k,data:M},$.type=mi.dateRange,$.id=c,this.id3Track.addCue($),g[k]=$}}i[c]={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 u=s,c=1;return d+Math.min(this.stallCount*c,u)}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&&C.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let 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 u=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}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],xn={No:"",Yes:"YES",v2:"v2"};function rb(r,e){let{canSkipUntil:t,canSkipDateRanges:i,endSN:s}=r,n=e!==void 0?e-s:0;return t&&n<t?i?xn.v2:xn.Yes:xn.No}var To=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}},Gr=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 qd(r,e){let t=e.startPTS;if(le(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 Lp(r,e,t,i,s,n){i-t<=0&&(C.warn("Fragment should have a positive duration",e),i=t+e.duration,n=s+e.duration);let o=t,l=i,d=e.startPTS,u=e.endPTS;if(le(d)){let T=Math.abs(d-t);le(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,u),i=Math.max(i,u),n=Math.max(n,e.endDTS)}let c=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--)qd(E[m],E[m-1]);for(m=g;m<E.length-1;m++)qd(E[m],E[m+1]);return r.fragmentHint&&qd(E[E.length-1],r.fragmentHint),r.PTSKnown=r.alignedSliding=!0,c}function sb(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(ob(r,e,(l,d)=>{l.relurl&&(s=l.cc-d.cc),le(l.startPTS)&&le(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 u;(!d.initSegment||d.initSegment.relurl===((u=t)==null?void 0:u.relurl))&&(d.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){C.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=nb(r.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));let a=e.fragments;if(s){C.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),ab(r.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?Lp(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):Rp(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 nb(r,e,t){let i=mt({},r);return t&&t.forEach(s=>{delete i[s]}),Object.keys(e).forEach(s=>{let n=new vo(e[s].attr,i[s]);n.isValid?i[s]=n:C.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),i}function ab(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 ob(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 u=l[a+d],c=o[d];i&&!c&&d<i&&(c=e.fragments[d]=u),u&&c&&t(u,c)}}function Rp(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 lb(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 db(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 Hm(r,e,t){var i;return r!=null&&r.details?wp((i=r.details)==null?void 0:i.partList,e,t):null}function wp(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 _o(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 Vm(r,e){let t=_o(e);return r.default[`${t?"timeout":"error"}Retry`]}function dc(r,e){let t=r.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*r.retryDelayMs,r.maxRetryDelayMs)}function Km(r){return Yt(Yt({},r),{errorRetry:null,timeoutRetry:null})}function Ao(r,e,t,i){return!!r&&e<r.maxNumRetry&&(ub(i)||!!t)}function ub(r){return r===0&&navigator.onLine===!1||!!r&&(r<400||r>499)}var kp={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 cb(r,e,t){if(e===null||!Array.isArray(r)||!r.length||!le(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(hb(e,t,a))return a}return null}function Rn(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=kp.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 hb(r,e,t){let i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>r}function fb(r,e){return kp.search(r,t=>t.cc<e?1:t.cc>e?-1:0)}var mb=3e5,Ot={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},ci={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=C.log.bind(C,"[info]:"),this.warn=C.warn.bind(C,"[warning]:"),this.error=C.error.bind(C,"[error]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(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)===me.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=Ot.SendAlternateToPenaltyBox;return}case B.LEVEL_EMPTY_ERROR:case B.LEVEL_PARSING_ERROR:{var a,o;let l=t.parent===me.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===Pe.AUDIO_TRACK&&n.groupId===l.audioGroupId||n.type===Pe.SUBTITLE_TRACK&&n.groupId===l.textGroupId)){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.loadLevel),t.errorAction.action=Ot.SendAlternateToPenaltyBox,t.errorAction.flags=ci.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:Ot.SendAlternateToPenaltyBox,flags:ci.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:Ot.DoNothing,flags:ci.None};return}if(t.type===fe.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=Vm(s.config.playlistLoadPolicy,e),a=this.playlistError++,o=(i=e.response)==null?void 0:i.code;if(Ao(n,a,_o(e),o))return{action:Ot.RetryRequest,flags:ci.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=Vm(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((c,h)=>c+h.fragmentError,0);if(s){var d;e.details!==B.FRAG_GAP&&s.fragmentError++;let c=(d=e.response)==null?void 0:d.code;if(Ao(o,l,_o(e),c))return{action:Ot.RetryRequest,flags:ci.None,retryConfig:o,retryCount:l}}let u=this.getLevelSwitchAction(e,i);return o&&(u.retryConfig=o,u.retryCount=l),u}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:u,maxAutoLevel:c}=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>=u&&T<=c&&l[T].loadError===0){let A=l[T];if(e.details===B.FRAG_GAP&&e.frag){let L=l[T].details;if(L){let S=Rn(e.frag,L.fragments,e.frag.start);if(S!=null&&S.gap)continue}}else{if(m===Pe.AUDIO_TRACK&&g===A.audioGroupId||m===Pe.SUBTITLE_TRACK&&g===A.textGroupId)continue;if(h===me.AUDIO&&s.audioGroupId===A.audioGroupId||h===me.SUBTITLE&&s.textGroupId===A.textGroupId)continue}o=T;break}}if(o>-1&&i.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:Ot.SendAlternateToPenaltyBox,flags:ci.None,nextAutoLevel:o}}return{action:Ot.SendAlternateToPenaltyBox,flags:ci.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case Ot.DoNothing:break;case Ot.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 ci.None:this.switchLevel(e,a);break;case ci.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(e));break;case ci.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===me.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,u=i[d];if(!u||pb(u,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(c=>{c.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 pb(r,e,t){if(performance.now()-r.lastErrorPerfMs>mb)return!0;let i=r.details;if(e.details===B.FRAG_GAP&&i&&e.frag){let s=e.frag.start,n=Rn(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 wn=class{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=C.log.bind(C,`${t}:`),this.warn=C.warn.bind(C,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t){let 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){C.warn(`Could not construct new URL for Rendition Report: ${l}`),o=a.URI||""}if(o===e){s=n;break}else o===e.substring(0,o.length)&&(s=n)}if(s!==-1){let n=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 To(a,o>=0?o:void 0,xn.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&&sb(i,s),!this.canLoad||!s.live)return;let l,d,u;if(s.canBlockReload&&s.endSN&&s.advanced){let T=this.hls.config.lowLatencyMode,A=s.lastPartSn,L=s.endSN,S=s.lastPartIndex,P=S!==-1,k=A===L,$=T?0:S;P?(d=k?L+1:A,u=k?$:S+1):d=L+1;let M=s.age,G=M+s.ageHeader,W=Math.min(G-s.partTarget,s.targetduration*1.5);if(W>0){if(i&&W>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${W} with playlist age: ${s.age}`),W=0;else{let O=Math.floor(W/s.targetduration);if(d+=O,u!==void 0){let z=Math.round(W%s.targetduration/s.partTarget);u+=z}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${M.toFixed(2)}s goal: ${W} skip sn ${O} to part ${u}`)}s.tuneInGoal=W}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u),T||!k){this.loadPlaylist(l);return}}else s.canBlockReload&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u));let c=this.hls.mainForwardBufferInfo,h=c?c.end-c.len:0,m=(s.edge-h)*1e3,g=lb(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=rb(e,i);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,s=t.part,n=xn.No),new To(i,s,n)}checkRetry(e){let t=e.details,i=_o(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===Ot.RetryRequest||!s.resolved&&n===Ot.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 u=dc(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),u),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${u}ms`)}e.levelRetry=!0,s.resolved=!0}return l}},Yd,bu=class extends wn{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&&(Yd||(Yd=/chrome|firefox/i.test(navigator.userAgent)),Yd&&(a.audioCodec=void 0));let{AUDIO:d,CODECS:u,"FRAME-RATE":c,"PATHWAY-ID":h,RESOLUTION:m,SUBTITLES:g}=l,T=`${`${h||"."}-`}${a.bitrate}-${m}-${c}-${u}`;n=s[T],n?n.addFallback(a):(n=new Gr(a),s[T]=n,i.push(n)),So(n,"audio",d),So(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||Vd(m,"audio"))&&(!g||Vd(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:fe.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||Vd(m.audioCodec,"audio")),Wm(i)),t.subtitles&&(s=t.subtitles,Wm(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 u=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){u=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===u){this._firstLevel=m,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${u.bitrate}`);break}let c=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:!c&&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 u=new Error("invalid level idx"),c=e<0;if(this.hls.trigger(y.ERROR,{type:fe.OTHER_ERROR,details:B.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:u,reason:u.message}),c)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=mt({},a,{level:e,maxBitrate:a.maxBitrate,attrs:a.attrs,uri:a.uri,urlId:a.urlId});delete l._attrs,delete l._urlId,this.hls.trigger(y.LEVEL_SWITCHING,l);let d=a.details;if(!d||d.live){let u=this.switchParams(a.uri,s==null?void 0:s.details);this.loadPlaylist(u)}}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===Pe.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(t!==void 0&&t.type===me.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 So(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 Wm(r){let e={};r.forEach(t=>{let i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}var bt={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 u=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return u&&this.removeFragment(o.body),u})})}detectPartialFragments(e){let t=this.timeRanges,{frag:i,part:s}=e;if(!t||i.sn==="initSegment")return;let n=Ls(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 u=t[l],c=o||d.partial===!0;a.range[l]=this.getBufferedTimes(i,s,c,u)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,a.body.endList&&(this.endListFragments[a.body.type]=a),lo(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=Ls(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 u=0;u<s.length;u++){let c=s.start(u)-this.bufferPadding,h=s.end(u)+this.bufferPadding;if(d>=c&&l<=h){n.time.push({startPTS:Math.max(a,s.start(u)),endPTS:Math.min(o,s.end(u))});break}else if(a<h&&o>c)n.partial=!0,n.time.push({startPTS:Math.max(a,s.start(u)),endPTS:Math.min(o,s.end(u))});else if(o<=c)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 u=l[d];!u||lo(u)&&(s=u.body.start-o,n=u.body.end+o,e>=s&&e<=n&&(i=Math.min(e-s,n-e),a<=i&&(t=u.body,a=i)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||lo(t))}getState(e){let t=Ls(e),i=this.fragments[t];return i?i.buffered?lo(i)?bt.PARTIAL:bt.OK:bt.APPENDING:bt.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=Ls(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=Ls(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=Ls(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 lo(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 Ls(r){return`${r.type}_${r.level}_${r.urlId}_${r.sn}`}var qm=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 fi({type:fe.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(jm(e));return}let d=this.loader=e.loader=n?new n(s):new a(s),u=Ym(e),c=Km(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:qm};e.stats=d.stats,d.load(u,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 fi({type:fe.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Yt({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 fi({type:fe.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 fi({type:fe.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(jm(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),u=Ym(e,t),c=Km(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:qm};t.stats=d.stats,d.load(u,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 fi({type:fe.NETWORK_ERROR,details:B.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Yt({url:u.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 fi({type:fe.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 fi({type:fe.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),c=(l-d)*Math.round(i.loaded/d);i.total=i.loaded+c}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 Ym(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(le(s)&&le(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 jm(r,e){let t=new Error(`GAP ${r.gap?"tag":"attribute"} found`),i={type:fe.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 fi(i)}var fi=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 fi({type:fe.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,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,m,g,E)=>{let{frag:T,keyInfo:A,url:L}=g;if(!T.decryptdata||A!==this.keyUriToKeyInfo[L])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,Yt({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,u,c)})}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(){}},gb={length:0,start:()=>0,end:()=>0},He=class{static isBuffered(e,t){try{if(e){let i=He.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=He.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,u){let c=d.start-u.start;return c||u.end-d.end});let s=[];if(i)for(let d=0;d<e.length;d++){let u=s.length;if(u){let c=s[u-1].end;e[d].start-c<i?e[d].end>c&&(s[u-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 u=s[d].start,c=s[d].end;if(t+i>=u&&t<c)o=u,l=c,n=l-t;else if(t+i<u){a=u;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return C.log("failed to get media.buffered",t),gb}}},kn=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=uo(),this.buffering={audio:uo(),video:uo(),audiovideo:uo()},this.level=e,this.sn=t,this.id=i,this.size=s,this.part=n,this.partial=a}};function uo(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Dp(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 vb(r,e,t){return!!(e.details&&(t.endCC>t.startCC||r&&r.cc<t.startCC))}function Eb(r,e,t=0){let i=r.fragments,s=e.fragments;if(!s.length||!i.length){C.log("No fragments to align");return}let n=Dp(i,s[0].cc);if(!n||n&&!n.startPTS){C.log("No frag in previous level to align on");return}return n}function zm(r,e){if(r){let t=r.start+e;r.start=r.startPTS=t,r.endPTS=t+r.duration}}function uc(r,e){let t=e.fragments;for(let i=0,s=t.length;i<s;i++)zm(t[i],r);e.fragmentHint&&zm(e.fragmentHint,r),e.alignedSliding=!0}function yb(r,e,t){!e||(bb(r,t,e),!t.alignedSliding&&e.details&&Tb(t,e.details),!t.alignedSliding&&e.details&&!t.skippedSegments&&Rp(e.details,t))}function bb(r,e,t){if(vb(r,t,e)){let i=Eb(t.details,e);i&&le(i.start)&&(C.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),uc(i.start,e))}}function Tb(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&&le(s)&&(C.log(`Adjusting PTS using programDateTime delta ${i-t}ms, sliding:${s.toFixed(3)} ${r.url} `),uc(s,r))}function Cp(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=Dp(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);uc(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 _b(r){let e=r.byteLength,t=e&&new DataView(r.buffer).getUint8(e-1);return t?Ur(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],u=l[1],c=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 L=m[g],S=m[L],P=m[S],k=m[A]*257^A*16843008;s[g]=k<<24|k>>>8,n[g]=k<<16|k>>>16,a[g]=k<<8|k>>>24,o[g]=k,k=P*16843009^S*65537^L*257^g*16843008,d[A]=k<<24|k>>>8,u[A]=k<<16|k>>>16,c[A]=k<<8|k>>>24,h[A]=k,g?(g=L^m[m[m[P^L]]],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),u=this.invKeySchedule=new Uint32Array(a),c=this.sBox,h=this.rcon,m=this.invSubMix,g=m[0],E=m[1],T=m[2],A=m[3],L,S;for(o=0;o<a;o++){if(o<n){L=d[o]=t[o];continue}S=L,o%n===0?(S=S<<8|S>>>24,S=c[S>>>24]<<24|c[S>>>16&255]<<16|c[S>>>8&255]<<8|c[S&255],S^=h[o/n|0]<<24):n>6&&o%n===4&&(S=c[S>>>24]<<24|c[S>>>16&255]<<16|c[S>>>8&255]<<8|c[S&255]),d[o]=L=(d[o-n]^S)>>>0}for(l=0;l<a;l++)o=a-l,l&3?S=d[o]:S=d[o-4],l<4||o<=4?u[l]=S:u[l]=g[c[S>>>24]]^E[c[S>>>16&255]]^T[c[S>>>8&255]]^A[c[S&255]],u[l]=u[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],u=o[2],c=o[3],h=this.uint8ArrayToUint32Array_(i),m=h[0],g=h[1],E=h[2],T=h[3],A=new Int32Array(e),L=new Int32Array(A.length),S,P,k,$,M,G,W,O,z,j,be,ge,ve,Re,Te=this.networkToHostOrderSwap;for(;t<A.length;){for(z=Te(A[t]),j=Te(A[t+1]),be=Te(A[t+2]),ge=Te(A[t+3]),M=z^n[0],G=ge^n[1],W=be^n[2],O=j^n[3],ve=4,Re=1;Re<s;Re++)S=l[M>>>24]^d[G>>16&255]^u[W>>8&255]^c[O&255]^n[ve],P=l[G>>>24]^d[W>>16&255]^u[O>>8&255]^c[M&255]^n[ve+1],k=l[W>>>24]^d[O>>16&255]^u[M>>8&255]^c[G&255]^n[ve+2],$=l[O>>>24]^d[M>>16&255]^u[G>>8&255]^c[W&255]^n[ve+3],M=S,G=P,W=k,O=$,ve=ve+4;S=a[M>>>24]<<24^a[G>>16&255]<<16^a[W>>8&255]<<8^a[O&255]^n[ve],P=a[G>>>24]<<24^a[W>>16&255]<<16^a[O>>8&255]<<8^a[M&255]^n[ve+1],k=a[W>>>24]<<24^a[O>>16&255]<<16^a[M>>8&255]<<8^a[G&255]^n[ve+2],$=a[O>>>24]<<24^a[M>>16&255]<<16^a[G>>8&255]<<8^a[W&255]^n[ve+3],L[t]=Te(S^m),L[t+1]=Te($^g),L[t+2]=Te(k^E),L[t+3]=Te(P^T),m=z,g=j,E=be,T=ge,t=t+4}return L.buffer}},Ab=16,Dn=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?_b(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=Br(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=Ur(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=>(C.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%Ab;return i!==e.length&&(t=Ur(e,0,i),this.remainderData=Ur(e,i)),t}logOnce(e){!this.logEnabled||(C.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},Sb={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}},K={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"},Cn=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=K.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=C.log.bind(C,`${s}:`),this.warn=C.warn.bind(C,`${s}:`),this.hls=e,this.fragmentLoader=new _u(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Dn(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=K.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 He.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===K.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=He.bufferInfo(s||i,a,e.maxBufferHole);if(this.log(`media seeking to ${le(a)?a.toFixed(3):a}, state: ${n}`),this.state===K.ENDED)this.resetLoadingState();else if(t){let l=e.maxFragLookUpTolerance,d=t.start-l,u=t.start+t.duration+l;if(!o.len||u<o.start||d>o.end){let c=a>u;(a<d||c)&&(c&&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=K.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===K.FRAG_LOADING||!this.fragCurrent&&a===K.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=K.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===K.STOPPED||this.state===K.ERROR||(this.warn(n),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:i}=this;if(i.getState(e)===bt.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)===bt.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:fe.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=K.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===K.STOPPED||this.state===K.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===me.MAIN?"level":"track"} ${e.level} (frag:[${((i=e.startPTS)!=null?i:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?Sb.toString(He.getBuffered(o)):"(detached)"})`),this.state=K.IDLE,o&&(!this.loadedmetadata&&e.type==me.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 kn(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=K.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(u=>{if(!this.fragContextChanged(u.frag))return this.hls.trigger(y.KEY_LOADED,u),this.state===K.KEY_LOADING&&(this.state=K.IDLE),u}),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 u=a.partList;if(u&&s){i>e.end&&a.fragmentHint&&(e=a.fragmentHint);let c=this.getNextPart(u,e,i);if(c>-1){let h=u[c];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${c}-${u.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=K.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(u,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))}`),le(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=K.FRAG_LOADING;let l=this.config.progressive,d;return l&&o?d=o.then(u=>!u||this.fragContextChanged(u==null?void 0:u.frag)?null:this.fragmentLoader.load(e,s)).catch(u=>this.handleFragLoadError(u)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([u])=>(!l&&u&&s&&s(u),u)).catch(u=>this.handleFragLoadError(u)),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,u=c=>{this.fragmentLoader.loadPart(e,c,s).then(h=>{l[c.index]=h;let m=h.part;this.hls.trigger(y.FRAG_LOADED,h);let g=Hm(i,e.sn,c.index+1)||wp(d,e.sn,c.index+1);if(g)u(g);else return n({frag:e,part:m,partsLoaded:l})}).catch(a)};u(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:fe.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!==K.PARSING){!this.fragCurrent&&this.state!==K.STOPPED&&this.state!==K.ERROR&&(this.state=K.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?Hm(o,n,a):null,d=l?l.fragment:db(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!==K.PARSING)return;let{data1:a,data2:o}=e,l=a;if(a&&o&&(l=Br(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(!He.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let i=t.currentTime,s=He.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 le(i)?this.getFwdBufferInfoAtPos(e,i,t):null}getFwdBufferInfoAtPos(e,t,i){let{config:{maxBufferHole:s}}=this,n=He.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 He.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=me.MAIN){let i=this.fragmentTracker.getAppendedFrag(e,me.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===bt.OK||i===bt.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 u=d.loaded;u?s=-1:(n||d.independent||a)&&d.fragment===t&&(s=o),n=u}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=cb(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=fb(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,u=i.partList,c=!!(s.lowLatencyMode&&u!=null&&u.length&&l);c&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){let m=e>t-d?0:d;h=Rn(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===bt.OK||g===bt.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!c||u[0].fragment.sn>h.sn)&&n&&h.level===n.level){let T=a[m+1];h.sn<o&&this.fragmentTracker.getState(T)!==bt.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,u=e.alignedSliding&&le(l);if(d||!u&&!l){yb(n,a,e);let c=e.fragments[0].start;return this.log(`Live playlist sliding: ${c.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${n?n.sn:"na"} fragments: ${o}`),c}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&&le(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!==K.FRAG_LOADING_WAITING_RETRY)&&(this.state=K.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let c=this.getCurrentContext(t.chunkMeta);c&&(t.frag=c.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===Ot.RetryRequest&&d){var u;this.resetStartWhenNotLoaded((u=this.levelLastLoaded)!=null?u:i.level);let c=dc(d,l);this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${c}ms`),a.resolved=!0,this.retryDate=self.performance.now()+c,this.state=K.FRAG_LOADING_WAITING_RETRY}else d&&a?(this.resetFragmentErrors(e),l<d.maxNumRetry?n||(a.resolved=!0):C.warn(`${t.details} reached or exceeded max retry (${l})`)):(a==null?void 0:a.action)===Ot.SendAlternateToPenaltyBox?this.state=K.WAITING_LEVEL:this.state=K.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===K.PARSING||this.state===K.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===me.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==K.STOPPED&&(this.state=K.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;let s=He.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,i),this.state===K.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=K.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 u=e.elementaryStreams[d];if(u){let c=u.endPTS-u.startPTS;if(c<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${c})`),l||!1;let h=s?0:Lp(a,e,u.startPTS,u.endPTS,u.startDTS,u.endDTS);return this.hls.trigger(y.LEVEL_PTS_UPDATED,{details:a,level:i,drift:h,type:d,frag:e,start:u.startPTS,end:u.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:fe.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=K.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 Mp(){return self.SourceBuffer||self.WebKitSourceBuffer}function xb(){let r=Bo();if(!r)return!1;let e=Mp(),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 Ib(){var r;let e=Mp();return typeof(e==null||(r=e.prototype)==null?void 0:r.changeType)=="function"}function Lb(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Rb(){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 wb(r){let e=new self.URL(r,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function ki(r="",e=9e4){return{type:r,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var xo=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=Br(this.cachedData,e),this.cachedData=null);let i=yo(e,0),s=i?i.length:0,n,a=this._audioTrack,o=this._id3Track,l=i?Ay(i):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&le(l))&&(this.basePTS=kb(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:mi.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){let u=this.appendFrame(a,e,s);u?(this.frameIndex++,this.lastPTS=u.sample.pts,s+=u.length,n=s):s=d}else _y(e,s)?(i=yo(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:mi.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,n=s):s++;if(s===d&&n!==d){let u=Ur(e,n);this.cachedData?this.cachedData=Br(this.cachedData,u):this.cachedData=u}}return{audioTrack:a,videoTrack:ki(),id3Track:o,textTrack:ki()}}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:ki(),id3Track:this._id3Track,textTrack:ki()}}destroy(){}},kb=(r,e,t)=>{if(le(r))return r*90;let i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};function Db(r,e,t,i){let s,n,a,o,l=navigator.userAgent.toLowerCase(),d=i,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;let c=(e[t+2]&60)>>>2;if(c>u.length-1){r.trigger(y.ERROR,{type:fe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${c}`});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,C.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(s=5,o=new Array(4),n=c-3):(s=2,o=new Array(2),n=c):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=c):(s=5,o=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&c>=6?n=c-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(c>=6&&a===1||/vivaldi/i.test(l))||!i&&a===1)&&(s=2,o=new Array(2)),n=c)),o[0]=s<<3,o[0]|=(c&14)>>1,o[1]|=(c&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:u[c],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d}}function Op(r,e){return r[e]===255&&(r[e+1]&246)===240}function Pp(r,e){return r[e+1]&1?7:9}function cc(r,e){return(r[e+3]&3)<<11|r[e+4]<<3|(r[e+5]&224)>>>5}function Cb(r,e){return e+5<r.length}function Io(r,e){return e+1<r.length&&Op(r,e)}function Mb(r,e){return Cb(r,e)&&Op(r,e)&&cc(r,e)<=r.length-e}function Ob(r,e){if(Io(r,e)){let t=Pp(r,e);if(e+t>=r.length)return!1;let i=cc(r,e);if(i<=t)return!1;let s=e+i;return s===r.length||Io(r,s)}return!1}function Np(r,e,t,i,s){if(!r.samplerate){let n=Db(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,C.log(`parsed codec:${r.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Fp(r){return 1024*9e4/r}function Pb(r,e){let t=Pp(r,e);if(e+t<=r.length){let i=cc(r,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function Up(r,e,t,i,s){let n=Fp(r.samplerate),a=i+s*n,o=Pb(e,t),l;if(o){let{frameLength:c,headerLength:h}=o,m=h+c,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 Ru=class extends xo{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=(yo(e,0)||[]).length;for(let s=e.length;i<s;i++)if(Ob(e,i))return C.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Mb(e,t)}appendFrame(e,t,i){Np(e,this.observer,t,i,e.manifestCodec);let s=Up(e,t,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},Nb=/\/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=ki("video",1),a=this.audioTrack=ki("audio",1),o=this.txtTrack=ki("text",1);if(this.id3Track=ki("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=bp(e);if(l.video){let{id:d,timescale:u,codec:c}=l.video;n.id=d,n.timescale=o.timescale=u,n.codec=c}if(l.audio){let{id:d,timescale:u,codec:c}=l.audio;a.id=d,a.timescale=u,a.codec=c}o.id=vp.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,Me(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=Br(this.remainderData,e));let o=Uy(i);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=i;let a=this.extractID3Track(s,t);return n.samples=Rm(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=Rm(e,t),{videoTrack:t,audioTrack:ki(),id3Track:s,textTrack:ki()}}extractID3Track(e,t){let i=this.id3Track;if(e.samples.length){let s=Me(e.samples,["emsg"]);s&&s.forEach(n=>{let a=Gy(n);if(Nb.test(a.schemeIdUri)){let o=le(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:mi.emsg,duration:l})}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},co=null,Fb=[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],Ub=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Bb=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],$b=[0,1,1,4];function Bp(r,e,t,i,s){if(t+24>e.length)return;let n=$p(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 $p(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=Fb[l*14+s-1]*1e3,c=Ub[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,m=Bb[t][i],g=$b[i],E=m*8*g,T=Math.floor(m*d/c+a)*g;if(co===null){let S=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);co=S?parseInt(S[1]):0}return!!co&&co<=87&&i===2&&d>=224e3&&o===0&&(r[e+3]=r[e+3]|128),{sampleRate:c,channelCount:h,frameLength:T,samplesPerFrame:E}}}function hc(r,e){return r[e]===255&&(r[e+1]&224)===224&&(r[e+1]&6)!==0}function Gp(r,e){return e+1<r.length&&hc(r,e)}function Gb(r,e){return hc(r,e)&&4<=r.length-e}function Hb(r,e){if(e+1<r.length&&hc(r,e)){let i=$p(r,e),s=4;i!=null&&i.frameLength&&(s=i.frameLength);let n=e+s;return n===r.length||Gp(r,n)}return!1}var Lo=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&&C.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?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),u=this.readUEG.bind(this),c=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 $=u();if($===3&&h(1),g(),g(),h(1),c())for(a=$!==3?8:12,o=0;o<a;o++)c()&&(o<6?E(16):E(64))}g();let A=u();if(A===0)u();else if(A===1)for(h(1),m(),m(),n=u(),o=0;o<n;o++)m();g(),h(1);let L=u(),S=u(),P=d(1);P===0&&h(1),h(1),c()&&(e=u(),t=u(),i=u(),s=u());let k=[1,1];if(c()&&c())switch(l()){case 1:k=[1,1];break;case 2:k=[12,11];break;case 3:k=[10,11];break;case 4:k=[16,11];break;case 5:k=[40,33];break;case 6:k=[24,11];break;case 7:k=[20,11];break;case 8:k=[32,11];break;case 9:k=[80,33];break;case 10:k=[18,11];break;case 11:k=[15,11];break;case 12:k=[64,33];break;case 13:k=[160,99];break;case 14:k=[4,3];break;case 15:k=[3,2];break;case 16:k=[2,1];break;case 255:{k=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((L+1)*16-e*2-t*2),height:(2-P)*(S+1)*16-(P?2:4)*(i+s),pixelRatio:k}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},ku=class{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Dn(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=Ap(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}}}},kt=188,Di=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=Di.syncOffset(e);return t>0&&C.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){let t=e.length,i=Math.min(kt*5,e.length-kt)+1,s=0;for(;s<i;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=kt)if(e[l]===71){if(o++,a===-1&&(a=l,a!==0&&(i=Math.min(a+kt*99,e.length-kt)+1)),n||(n=Du(e,l)===0),n&&o>1&&(a===0&&o>2||l+kt>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:vp[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=Di.createTrack("video"),this._audioTrack=Di.createTrack("audio",s),this._id3Track=Di.createTrack("id3"),this._txtTrack=Di.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,u=a.pid,c=a.pesData,h=o.pid,m=l.pid,g=o.pesData,E=l.pesData,T=null,A=this.pmtParsed,L=this._pmtId,S=e.length;if(this.remainderData&&(e=Br(this.remainderData,e),S=e.length,this.remainderData=null),S<kt&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let P=Math.max(0,Di.syncOffset(e));S-=(S-P)%kt,S<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,S,e.buffer.byteLength-S));let k=0;for(let M=P;M<S;M+=kt)if(e[M]===71){let G=!!(e[M+1]&64),W=Du(e,M),O=(e[M+3]&48)>>4,z;if(O>1){if(z=M+5+e[M+4],z===M+kt)continue}else z=M+4;switch(W){case u:G&&(c&&(n=Rs(c))&&this.parseAVCPES(a,d,n,!1),c={data:[],size:0}),c&&(c.data.push(e.subarray(z,M+kt)),c.size+=M+kt-z);break;case h:if(G){if(g&&(n=Rs(g)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break}g={data:[],size:0}}g&&(g.data.push(e.subarray(z,M+kt)),g.size+=M+kt-z);break;case m:G&&(E&&(n=Rs(E))&&this.parseID3PES(l,n),E={data:[],size:0}),E&&(E.data.push(e.subarray(z,M+kt)),E.size+=M+kt-z);break;case 0:G&&(z+=e[z]+1),L=this._pmtId=Vb(e,z);break;case L:{G&&(z+=e[z]+1);let j=Kb(e,z,this.typeSupported,i);u=j.avc,u>0&&(a.pid=u),h=j.audio,h>0&&(o.pid=h,o.segmentCodec=j.segmentCodec),m=j.id3,m>0&&(l.pid=m),T!==null&&!A&&(C.warn(`MPEG-TS PMT found at ${M} after unknown PID '${T}'. Backtracking to sync byte @${P} to parse all TS packets.`),T=null,M=P-188),A=this.pmtParsed=!0;break}case 17:case 8191:break;default:T=W;break}}else k++;if(k>0){let M=new Error(`Found ${k} TS packet/s that do not start with 0x47`);this.observer.emit(y.ERROR,y.ERROR,{type:fe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:M,reason:M.message})}a.pesData=c,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=Rs(a))?(this.parseAVCPES(i,n,d,!0),i.pesData=null):i.pesData=a,o&&(d=Rs(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break}t.pesData=null}else o!=null&&o.size&&C.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=Rs(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 ku(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&&(jd(a,e),a=this.avcSample=ho(!1,i.pts,i.dts,"")),n.forEach(d=>{switch(d.type){case 1:{o=!0,a||(a=this.avcSample=ho(!0,i.pts,i.dts,"")),a.frame=!0;let u=d.data;if(l&&u.length>4){let c=new Lo(u).readSliceType();(c===2||c===4||c===7||c===9)&&(a.key=!0)}break}case 5:o=!0,a||(a=this.avcSample=ho(!0,i.pts,i.dts,"")),a.key=!0,a.frame=!0;break;case 6:{o=!0,_p(d.data,1,i.pts,t.samples);break}case 7:if(o=!0,l=!0,!e.sps){let u=d.data,h=new Lo(u).readSPS();e.width=h.width,e.height=h.height,e.pixelRatio=h.pixelRatio,e.sps=[u],e.duration=this._duration;let m=u.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&&jd(a,e),a=this.avcSample=ho(!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&&(jd(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,u,c=-1,h=0;for(s===-1&&(c=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(c>=0){let m={data:t.subarray(c,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?(u=t[o]&31,c=o,h=u,s=0):s=-1}else s=0}if(c>=0&&s>=0){let m={data:t.subarray(c,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 c=s.missing,h=s.sample.unit.byteLength;if(c===-1){let m=new Uint8Array(h+n.byteLength);m.set(s.sample.unit,0),m.set(n,h),n=m}else{let m=h-c;s.sample.unit.set(n.subarray(0,c),m),e.samples.push(s.sample),i=s.missing}}let a,o;for(a=i,o=n.length;a<o-1&&!Io(n,a);a++);if(a!==i){let c,h=a<o-1;h?c=`AAC PES did not start with ADTS header,offset:${a}`:c="No ADTS header found in AAC PES";let m=new Error(c);if(C.warn(`parsing error: ${c}`),this.observer.emit(y.ERROR,y.ERROR,{type:fe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,levelRetry:h,error:m,reason:c}),!h)return}Np(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let c=Fp(e.samplerate);l=s.sample.pts+c}else{C.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,u;for(;a<o;)if(u=Up(e,n,a,l,d),a+=u.length,u.missing){this.aacOverFlow=u;break}else for(d++;a<o-1&&!Io(n,a);a++);}parseMPEGPES(e,t){let i=t.data,s=i.length,n=0,a=0,o=t.pts;if(o===void 0){C.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(Gp(i,a)){let l=Bp(e,i,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseID3PES(e,t){if(t.pts===void 0){C.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let i=mt({},t,{type:this._avcTrack?mi.emsg:mi.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}};function ho(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 Vb(r,e){return(r[e+10]&31)<<8|r[e+11]}function Kb(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){C.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:s.audio===-1&&(s.audio=l);break;case 21:s.id3===-1&&(s.id3=l);break;case 219:if(!i){C.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:s.avc===-1&&(s.avc=l);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?C.log("MPEG audio found, not supported in this browser"):s.audio===-1&&(s.audio=l,s.segmentCodec="mp3");break;case 36:C.warn("Unsupported HEVC stream type found");break}e+=((r[e+3]&15)<<8|r[e+4])+5}return s}function Rs(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&&(C.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=t[8];let u=s+9;if(r.size<=u)return null;r.size-=u;let c=new Uint8Array(r.size);for(let h=0,m=o.length;h<m;h++){t=o[h];let g=t.byteLength;if(u)if(u>g){u-=g;continue}else t=t.subarray(u),g-=u,u=0;c.set(t,e),e+=g}return i&&(i-=s+3),{data:c,pts:n,dts:a,len:i}}return null}function jd(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&&C.log(r.pts+"/"+r.dts+":"+r.debug)}var Cu=class extends xo{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=(yo(e,0)||[]).length;for(let s=e.length;i<s;i++)if(Hb(e,i))return C.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Gb(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return Bp(e,t,i,this.basePTS,this.frameIndex)}},Ro=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}}},ur=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/(ur+1)),s=Math.floor(t%(ur+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/(ur+1)),s=Math.floor(t%(ur+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,u=e.pixelRatio[0],c=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([u>>24,u>>16&255,u>>8&255,u&255,c>>24,c>>16&255,c>>8&255,c&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/(ur+1)),o=Math.floor(i%(ur+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/(ur+1)),a=Math.floor(t%(ur+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,u,c,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,u=l.size,c=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&240<<8,c.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 Hp=9e4;function fc(r,e,t=1,i=!1){let s=r*e*t;return i?Math.round(s):s}function Wb(r,e,t=1,i=!1){return fc(r,e,1/t,i)}function _n(r,e=!1){return fc(r,1e3,1/Hp,e)}function qb(r,e=1){return fc(r,Hp,1/e)}var Yb=10*1e3,Xm=1024,jb=1152,fo=null,zd=null,In=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,fo===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);fo=a?parseInt(a[1]):0}if(zd===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);zd=n?parseInt(n[1]):0}}destroy(){}resetTimeStamp(e){C.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){C.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){C.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let t=!1,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&&C.debug("PTS rollover detected"),i}remux(e,t,i,s,n,a,o,l){let d,u,c,h,m,g,E=n,T=n,A=e.pid>-1,L=t.pid>-1,S=t.samples.length,P=e.samples.length>0,k=o&&S>0||S>1;if((!A||P)&&(!L||k)||this.ISGenerated||o){this.ISGenerated||(c=this.generateIS(e,t,n,a));let M=this.isVideoContiguous,G=-1,W;if(k&&(G=zb(t.samples),!M&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,G>0){C.warn(`[mp4-remuxer]: Dropped ${G} out of ${S} video samples due to a missing keyframe`);let O=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(G),t.dropped+=G,T+=(t.samples[0].pts-O)/t.inputTimeScale,W=T}else G===-1&&(C.warn(`[mp4-remuxer]: No keyframe found out of ${S} video samples`),g=!1);if(this.ISGenerated){if(P&&k){let O=this.getVideoStartPts(t.samples),j=(ai(e.samples[0].pts,O)-O)/t.inputTimeScale;E+=Math.max(0,j),T+=Math.max(0,-j)}if(P){if(e.samplerate||(C.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,E,this.isAudioContiguous,a,L||k||l===me.AUDIO?T:void 0),k){let O=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(C.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,T,M,O)}}else k&&(d=this.remuxVideo(t,T,M,0));d&&(d.firstKeyFrame=G,d.independent=G!==-1,d.firstKeyFramePTS=W)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(m=Vp(i,n,this._initPTS,this._initDTS)),s.samples.length&&(h=Kp(s,n,this._initPTS))),{audio:u,video:d,initSegment:c,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,u=!d||s,c="audio/mp4",h,m,g;if(u&&(h=m=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(c="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break}l.audio={id:"audio",container:c,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):F.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(g=e.inputTimeScale,!d||g!==d.timescale?h=m=n[0].pts-Math.round(g*i):u=!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}},u))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 u=!1;if(Object.keys(l).length)return this.ISGenerated=!0,u?(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,u=this.nextAvcDts,c=8,h=this.videoSampleDuration,m,g,E=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,A=!1;if(!i||u===null){let Q=t*n,ie=a[0].pts-ai(a[0].dts,a[0].pts);u=Q-ie}let L=d.baseTime*n/d.timescale;for(let Q=0;Q<l;Q++){let ie=a[Q];ie.pts=ai(ie.pts-L,u),ie.dts=ai(ie.dts-L,u),ie.dts<a[Q>0?Q-1:Q].dts&&(A=!0)}A&&a.sort(function(Q,ie){let re=Q.dts-ie.dts,_e=Q.pts-ie.pts;return re||_e}),m=a[0].dts,g=a[a.length-1].dts;let S=g-m,P=S?Math.round(S/(l-1)):h||e.inputTimeScale/30;if(i){let Q=m-u,ie=Q>P,re=Q<-1;if((ie||re)&&(ie?C.warn(`AVC: ${_n(Q,!0)} ms (${Q}dts) hole between fragments detected, filling it`):C.warn(`AVC: ${_n(-Q,!0)} ms (${Q}dts) overlapping between fragments detected`),!re||u>=a[0].pts)){m=u;let _e=a[0].pts-Q;a[0].dts=m,a[0].pts=_e,C.log(`Video: First PTS/DTS adjusted: ${_n(_e,!0)}/${_n(m,!0)}, delta: ${_n(Q,!0)} ms`)}}m=Math.max(0,m);let k=0,$=0;for(let Q=0;Q<l;Q++){let ie=a[Q],re=ie.units,_e=re.length,Se=0;for(let Ne=0;Ne<_e;Ne++)Se+=re[Ne].data.length;$+=Se,k+=_e,ie.length=Se,ie.dts=Math.max(ie.dts,m),E=Math.min(ie.pts,E),T=Math.max(ie.pts,T)}g=a[l-1].dts;let M=$+4*k+8,G;try{G=new Uint8Array(M)}catch(Q){this.observer.emit(y.ERROR,y.ERROR,{type:fe.MUX_ERROR,details:B.REMUX_ALLOC_ERROR,fatal:!1,error:Q,bytes:M,reason:`fail allocating video mdat ${M}`});return}let W=new DataView(G.buffer);W.setUint32(0,M),G.set(F.types.mdat,4);let O=!1,z=Number.POSITIVE_INFINITY,j=Number.POSITIVE_INFINITY,be=Number.NEGATIVE_INFINITY,ge=Number.NEGATIVE_INFINITY;for(let Q=0;Q<l;Q++){let ie=a[Q],re=ie.units,_e=0;for(let ut=0,H=re.length;ut<H;ut++){let Z=re[ut],Ie=Z.data,je=Z.data.byteLength;W.setUint32(c,je),c+=4,G.set(Ie,c),c+=je,_e+=4+je}let Se;if(Q<l-1)h=a[Q+1].dts-ie.dts,Se=a[Q+1].pts-ie.pts;else{let ut=this.config,H=Q>0?ie.dts-a[Q-1].dts:P;if(Se=Q>0?ie.pts-a[Q-1].pts:P,ut.stretchShortVideoTrack&&this.nextAudioPts!==null){let Z=Math.floor(ut.maxBufferHole*n),Ie=(s?E+s*n:this.nextAudioPts)-ie.pts;Ie>Z?(h=Ie-H,h<0?h=H:O=!0,C.log(`[mp4-remuxer]: It is approximately ${Ie/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=H}else h=H}let Ne=Math.round(ie.pts-ie.dts);z=Math.min(z,h),be=Math.max(be,h),j=Math.min(j,Se),ge=Math.max(ge,Se),o.push(new wo(ie.key,h,_e,Ne))}if(o.length){if(fo){if(fo<70){let Q=o[0].flags;Q.dependsOn=2,Q.isNonSync=0}}else if(zd&&ge-j<be-z&&P/be<.025&&o[0].cts===0){C.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let Q=m;for(let ie=0,re=o.length;ie<re;ie++){let _e=Q+o[ie].duration,Se=Q+o[ie].cts;if(ie<re-1){let Ne=_e+o[ie+1].cts;o[ie].duration=Ne-Se}else o[ie].duration=ie?o[ie-1].duration:P;o[ie].cts=0,Q=_e}}}h=O||!h?P:h,this.nextAvcDts=u=g+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let ve=F.moof(e.sequenceNumber++,m,mt({},e,{samples:o})),Re="video",Te={data1:ve,data2:G,startPTS:E/n,endPTS:(T+h)/n,startDTS:m/n,endDTS:u/n,type:Re,hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Te}remuxAudio(e,t,i,s,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=e.segmentCodec==="aac"?Xm:jb,u=d*l,c=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,L=t*a,S=c.baseTime*a/c.timescale;if(this.isAudioContiguous=i=i||E.length&&A>0&&(s&&Math.abs(L-A)<9e3||Math.abs(ai(E[0].pts-S,L)-A)<20*u),E.forEach(function(Re){Re.pts=ai(Re.pts-S,L)}),!i||A<0){if(E=E.filter(Re=>Re.pts>=0),!E.length)return;n===0?A=0:s&&!g?A=Math.max(0,L):A=E[0].pts}if(e.segmentCodec==="aac"){let Re=this.config.maxAudioFramesDrift;for(let Te=0,Q=A;Te<E.length;Te++){let ie=E[Te],re=ie.pts,_e=re-Q,Se=Math.abs(1e3*_e/a);if(_e<=-Re*u&&g)Te===0&&(C.warn(`Audio frame @ ${(re/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*_e/a)} ms.`),this.nextAudioPts=A=Q=re);else if(_e>=Re*u&&Se<Yb&&g){let Ne=Math.round(_e/u);Q=re-Ne*u,Q<0&&(Ne--,Q+=u),Te===0&&(this.nextAudioPts=A=Q),C.warn(`[mp4-remuxer]: Injecting ${Ne} audio frame @ ${(Q/a).toFixed(3)}s due to ${Math.round(1e3*_e/a)} ms gap.`);for(let ut=0;ut<Ne;ut++){let H=Math.max(Q,0),Z=Ro.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Z||(C.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Z=ie.unit.subarray()),E.splice(Te,0,{unit:Z,pts:H}),Q+=u,Te++}}ie.pts=Q,Q+=u}}let P=null,k=null,$,M=0,G=E.length;for(;G--;)M+=E[G].unit.byteLength;for(let Re=0,Te=E.length;Re<Te;Re++){let Q=E[Re],ie=Q.unit,re=Q.pts;if(k!==null){let Se=m[Re-1];Se.duration=Math.round((re-k)/l)}else if(i&&e.segmentCodec==="aac"&&(re=A),P=re,M>0){M+=T;try{$=new Uint8Array(M)}catch(Se){this.observer.emit(y.ERROR,y.ERROR,{type:fe.MUX_ERROR,details:B.REMUX_ALLOC_ERROR,fatal:!1,error:Se,bytes:M,reason:`fail allocating audio mdat ${M}`});return}h||(new DataView($.buffer).setUint32(0,M),$.set(F.types.mdat,4))}else return;$.set(ie,T);let _e=ie.byteLength;T+=_e,m.push(new wo(!0,d,_e,0)),k=re}let W=m.length;if(!W)return;let O=m[m.length-1];this.nextAudioPts=A=k+l*O.duration;let z=h?new Uint8Array(0):F.moof(e.sequenceNumber++,P/l,mt({},e,{samples:m}));e.samples=[];let j=P/a,be=A/a,ve={data1:z,data2:$,startPTS:j,endPTS:be,startDTS:j,endDTS:be,type:"audio",hasAudio:!0,hasVideo:!1,nb:W};return this.isAudioContiguous=!0,ve}remuxEmptyAudio(e,t,i,s){let n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,u=d.baseTime*9e4/d.timescale,c=(l!==null?l:s.startDTS*n)+u,h=s.endDTS*n+u,m=o*Xm,g=Math.ceil((h-c)/m),E=Ro.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(C.warn("[mp4-remuxer]: remux empty Audio"),!E){C.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}let T=[];for(let A=0;A<g;A++){let L=c+A*m;T.push({unit:E,pts:L,dts:L})}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 zb(r){for(let e=0;e<r.length;e++)if(r[e].key)return e;return-1}function Vp(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 Kp(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 wo=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(My(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=bp(e);t||(t=Qm(s.audio,$e.AUDIO)),i||(i=Qm(s.video,$e.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"}:C.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:u}=this,c={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};le(u)||(u=this.lastEndTime=n||0);let h=t.samples;if(!(h!=null&&h.length))return c;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 C.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(m.tracks=this.initTracks,this.emitInitSegment=!1);let E=Py(h,g),T=Oy(g,h),A=T===null?n:T;(Xb(d,A,n,E)||m.timescale!==d.timescale&&a)&&(m.initPTS=A-n,d&&d.timescale===1&&C.warn(`Adjusting initPTS by ${m.initPTS-d.baseTime}`),this.initPTS=d={baseTime:m.initPTS,timescale:1});let L=e?A-d.baseTime/d.timescale:u,S=L+E;Fy(g,h,d.baseTime/d.timescale),E>0?this.lastEndTime=S:(C.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let P=!!g.audio,k=!!g.video,$="";P&&($+="audio"),k&&($+="video");let M={data1:h,startPTS:L,startDTS:L,endPTS:S,endDTS:S,type:$,hasAudio:P,hasVideo:k,nb:1,dropped:0};return c.audio=M.type==="audio"?M:void 0,c.video=M.type!=="audio"?M:void 0,c.initSegment=m,c.id3=Vp(i,n,d,d),s.samples.length&&(c.text=Kp(s,n,d)),c}};function Xb(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 Qm(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===$e.VIDEO?"avc1.42e01e":"mp4a.40.5"}var qi;try{qi=self.performance.now.bind(self.performance)}catch{C.debug("Unable to use Performance API on this environment"),qi=typeof self!="undefined"&&self.Date.now}var Xd=[{demux:wu,remux:Ou},{demux:Di,remux:In},{demux:Ru,remux:In},{demux:Cu,remux:In}],ko=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=qi();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);let{contiguous:d,discontinuity:u,trackSwitch:c,accurateTimeOffset:h,timeOffset:m,initSegmentChange:g}=s||o,{audioCodec:E,videoCodec:T,defaultInitPts:A,duration:L,initSegmentData:S}=l,P=Qb(a,t);if(P&&P.method==="AES-128"){let G=this.getDecrypter();if(G.isSync()){let W=G.softwareDecrypt(a,P.key.buffer,P.iv.buffer);if(i.part>-1&&(W=G.flush()),!W)return n.executeEnd=qi(),Qd(i);a=new Uint8Array(W)}else return this.decryptionPromise=G.webCryptoDecrypt(a,P.key.buffer,P.iv.buffer).then(W=>{let O=this.push(W,null,i);return this.decryptionPromise=null,O}),this.decryptionPromise}let k=this.needsProbing(u,c);if(k){let G=this.configureTransmuxer(a);if(G)return C.warn(`[transmuxer] ${G.message}`),this.observer.emit(y.ERROR,y.ERROR,{type:fe.MEDIA_ERROR,details:B.FRAG_PARSING_ERROR,fatal:!1,error:G,reason:G.message}),n.executeEnd=qi(),Qd(i)}(u||c||g||k)&&this.resetInitSegment(S,E,T,L,t),(u||g||k)&&this.resetInitialTimestamp(A),d||this.resetContiguity();let $=this.transmux(a,P,m,h,i),M=this.currentTransmuxState;return M.contiguous=!0,M.discontinuity=!1,M.trackSwitch=!1,n.executeEnd=qi(),$}flush(e){let t=e.transmuxing;t.executeStart=qi();let{decrypter:i,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=s;if(i){let c=i.flush();c&&a.push(this.push(c,null,e))}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=qi(),[Qd(e)];let u=l.flush(o);return go(u)?u.then(c=>(this.flushRemux(a,c,e),a)):(this.flushRemux(a,u,e),a)}flushRemux(e,t,i){let{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;C.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);let u=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:u,chunkMeta:i}),i.transmuxing.executeEnd=qi()}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 c=0,h=Xd.length;c<h;c++)if(Xd[c].demux.probe(e)){a=Xd[c];break}if(!a)return new Error("Failed to find demuxer by probing fragment data");let o=this.demuxer,l=this.remuxer,d=a.remux,u=a.demux;(!l||!(l instanceof d))&&(this.remuxer=new d(i,t,s,n)),(!o||!(o instanceof u))&&(this.demuxer=new u(i,t,s),this.probe=u.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Dn(this.config)),e}};function Qb(r,e){let t=null;return r.byteLength>0&&e!=null&&e.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var Qd=r=>({remuxResult:{},chunkMeta:r});function go(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}},Wp={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,u){this.fn=l,this.context=d,this.once=u||!1}function n(l,d,u,c,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var m=new s(u,c||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=[],u,c;if(this._eventsCount===0)return d;for(c in u=this._events)e.call(u,c)&&d.push(t?c.slice(1):c);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(u)):d},o.prototype.listeners=function(d){var u=t?t+d:d,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var h=0,m=c.length,g=new Array(m);h<m;h++)g[h]=c[h].fn;return g},o.prototype.listenerCount=function(d){var u=t?t+d:d,c=this._events[u];return c?c.fn?1:c.length:0},o.prototype.emit=function(d,u,c,h,m,g){var E=t?t+d:d;if(!this._events[E])return!1;var T=this._events[E],A=arguments.length,L,S;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,u),!0;case 3:return T.fn.call(T.context,u,c),!0;case 4:return T.fn.call(T.context,u,c,h),!0;case 5:return T.fn.call(T.context,u,c,h,m),!0;case 6:return T.fn.call(T.context,u,c,h,m,g),!0}for(S=1,L=new Array(A-1);S<A;S++)L[S-1]=arguments[S];T.fn.apply(T.context,L)}else{var P=T.length,k;for(S=0;S<P;S++)switch(T[S].once&&this.removeListener(d,T[S].fn,void 0,!0),A){case 1:T[S].fn.call(T[S].context);break;case 2:T[S].fn.call(T[S].context,u);break;case 3:T[S].fn.call(T[S].context,u,c);break;case 4:T[S].fn.call(T[S].context,u,c,h);break;default:if(!L)for(k=1,L=new Array(A-1);k<A;k++)L[k-1]=arguments[k];T[S].fn.apply(T[S].context,L)}}return!0},o.prototype.on=function(d,u,c){return n(this,d,u,c,!1)},o.prototype.once=function(d,u,c){return n(this,d,u,c,!0)},o.prototype.removeListener=function(d,u,c,h){var m=t?t+d:d;if(!this._events[m])return this;if(!u)return a(this,m),this;var g=this._events[m];if(g.fn)g.fn===u&&(!h||g.once)&&(!c||g.context===c)&&a(this,m);else{for(var E=0,T=[],A=g.length;E<A;E++)(g[E].fn!==u||h&&!g[E].once||c&&g[E].context!==c)&&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 u;return d?(u=t?t+d:d,this._events[u]&&a(this,u)):(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})(Wp);var Zb=Wp.exports,mc=ny(Zb),Zd=Bo()||{isTypeSupported:()=>!1},Do=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,u)=>{u=u||{},u.frag=this.frag,u.id=this.id,d===y.ERROR&&(this.error=u.error),this.hls.trigger(d,u)};this.observer=new mc,this.observer.on(y.FRAG_DECRYPTED,a),this.observer.on(y.ERROR,a);let o={mp4:Zd.isTypeSupported("video/mp4"),mpeg:Zd.isTypeSupported("audio/mpeg"),mp3:Zd.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"&&(n.workerPath||Lb())){try{n.workerPath?(C.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=wb(n.workerPath)):(C.log(`injecting Web Worker for "${t}"`),this.workerContext=Rb()),this.onwmsg=c=>this.onWorkerMessage(c);let{worker:u}=this.workerContext;u.addEventListener("message",this.onwmsg),u.onerror=c=>{let h=new Error(`${c.message} (${c.filename}:${c.lineno})`);n.enableWorker=!1,C.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(y.ERROR,{type:fe.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},u.postMessage({cmd:"init",typeSupported:o,vendor:l,id:t,config:JSON.stringify(n)})}catch(u){C.warn(`Error setting up "${t}" Web Worker, fallback to inline`,u),this.resetWorker(),this.error=null,this.transmuxer=new ko(this.observer,o,n,l,t)}return}this.transmuxer=new ko(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,u){var c,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),L=!(T&&d.level===T.level),S=T?d.sn-T.sn:-1,P=this.part?d.part-this.part.index:-1,k=S===0&&d.id>1&&d.id===(T==null?void 0:T.stats.chunkCount),$=!L&&(S===1||S===0&&(P===1||k&&P<=0)),M=self.performance.now();(L||S||n.stats.parsing.start===0)&&(n.stats.parsing.start=M),a&&(P||!$)&&(a.stats.parsing.start=M);let G=!(T&&((c=n.initSegment)==null?void 0:c.url)===((h=T.initSegment)==null?void 0:h.url)),W=new Nu(A,$,l,L,g,G);if(!$||A||G){C.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
|
|
887
|
+
discontinuity: ${A}
|
|
888
|
+
trackSwitch: ${L}
|
|
889
|
+
contiguous: ${$}
|
|
890
|
+
accurateTimeOffset: ${l}
|
|
891
|
+
timeOffset: ${g}
|
|
892
|
+
initSegmentChange: ${G}`);let O=new Pu(i,s,t,o,u);this.configureTransmuxer(O)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:E,chunkMeta:d,state:W},e instanceof ArrayBuffer?[e]:[]);else if(m){let O=m.push(e,E,d,W);go(O)?(m.async=!0,O.then(z=>{this.handleTransmuxComplete(z)}).catch(z=>{this.transmuxerError(z,d,"transmuxer-interface push error")})):(m.async=!1,this.handleTransmuxComplete(O))}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let i=t.flush(e);go(i)||t.async?(go(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:fe.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":C[t.data.logType]&&C[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,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)}},Jb=250,Jd=2,eT=.1,tT=.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;C.warn(`playback not stuck anymore @${a}, after ${Math.round(A)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!He.getBuffered(s).length)return;let u=He.bufferInfo(s,a,0),c=u.len>0,h=u.nextStart||0;if(!c&&!h)return;if(o){let A=u.len>Jd,L=!h||t&&t.start<=a||h-a>Jd&&!this.fragmentTracker.getPartialFragment(a);if(A||L)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var m;let A=Math.max(h,u.start||0)-a,L=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=(L==null||(m=L.details)==null?void 0:m.live)?L.details.targetduration*2:Jd,k=this.fragmentTracker.getPartialFragment(a);if(A>0&&(A<=P||k)){this._trySkipBufferHole(k);return}}let g=self.performance.now();if(n===null){this.stalled=g;return}let E=g-n;if(!o&&E>=Jb&&(this._reportStall(u),!this.media))return;let T=He.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&&(C.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)})`);C.warn(n.message),t.trigger(y.ERROR,{type:fe.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=He.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,u=o-n;if(u>0&&(l||d)){if(u>t.maxBufferHole){let{fragmentTracker:h}=this,m=!1;if(n===0){let g=h.getAppendedFrag(0,me.MAIN);g&&o<g.end&&(m=!0)}if(!m){let g=e||h.getAppendedFrag(n,me.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 c=Math.max(o+tT,n+eT);if(C.warn(`skipping hole, adjusting currentTime from ${n} to ${c}`),this.moved=!0,this.stalled=null,s.currentTime=c,e&&!e.gap){let h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${c}`);i.trigger(y.ERROR,{type:fe.MEDIA_ERROR,details:B.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return c}}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}`);C.warn(o.message),i.currentTime=a,t.trigger(y.ERROR,{type:fe.MEDIA_ERROR,details:B.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{let a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);C.error(a.message),t.trigger(y.ERROR,{type:fe.MEDIA_ERROR,details:B.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}},iT=100,Uu=class extends Cn{constructor(e,t,i){super(e,t,i,"[stream-controller]",me.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(iT),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=K.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=K.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case K.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=K.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=K.IDLE;break}break}case K.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=K.IDLE)}break}this.state===K.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=K.ENDED;return}e.loadLevel!==a&&e.manualLevel===-1&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=e.nextLoadLevel=a;let u=o.details;if(!u||this.state===K.WAITING_LEVEL||u.live&&this.levelLastLoaded!==a){this.level=a,this.state=K.WAITING_LEVEL;return}let c=l.len,h=this.getMaxBufferLength(o.maxBitrate);if(c>=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,u);if(this.couldBacktrack&&!this.fragPrevious&&g&&g.sn!=="initSegment"&&this.fragmentTracker.getState(g)!==bt.OK){var E;let A=((E=this.backtrackFragment)!=null?E:g).sn-u.startSN,L=u.fragments[A-1];L&&g.cc===L.cc&&(g=L,this.fragmentTracker.removeFragment(L))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(g&&this.isLoopLoading(g,m)){if(!g.gap){let A=this.audioOnly&&!this.altAudio?$e.AUDIO:$e.VIDEO,L=(A===$e.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;L&&this.afterBufferFlushed(L,A,me.MAIN)}g=this.getNextFragmentLoopLoading(g,u,l,me.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===bt.NOT_LOADED||s===bt.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,me.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,u=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*.5),d*.75));this.flushMainBuffer(u,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 K.KEY_LOADING:case K.FRAG_LOADING:case K.FRAG_LOADING_WAITING_RETRY:case K.PARSING:case K.PARSED:this.state=K.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;le(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&&!Ib(),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!==K.IDLE)return;let s=i[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(s.details))&&(this.state=K.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===K.FRAG_LOADING||this.state===K.FRAG_LOADING_WAITING_RETRY)&&(d.level!==t.level||d.urlId!==l.urlId)&&d.loader&&this.abortCurrentFrag();let u=0;if(a.live||(i=l.details)!=null&&i.live){if(a.fragments[0]||(a.deltaUpdateFailed=!0),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details)}if(l.details=a,this.levelLastLoaded=n,this.hls.trigger(y.LEVEL_UPDATED,{details:a,level:n}),this.state===K.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=K.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),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,u=l.PTSKnown||!l.live,c=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),m=this.transmuxer=this.transmuxer||new Do(this.hls,me.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=s?s.index:-1,E=g!==-1,T=new kn(i.level,i.sn,i.stats.chunkCount,n.byteLength,g,E),A=this.initPTS[i.cc];m.push(n,c,h,d,i,s,l.totalduration,u,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!==me.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===K.PARSED&&(this.state=K.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=K.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(me.MAIN,t);break;case B.LEVEL_LOAD_ERROR:case B.LEVEL_LOAD_TIMEOUT:case B.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===K.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===Pe.LEVEL&&(this.state=K.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||!He.getBuffered(e).length){let i=this.state!==K.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,i)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=K.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==$e.AUDIO||this.audioOnly&&!this.altAudio){let i=(t===$e.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,t,me.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=He.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=K.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:u}=o,{video:c,text:h,id3:m,initSegment:g}=n,{details:E}=u,T=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=K.PARSING,g){if(g!=null&&g.tracks){let P=l.initSegment||l;this._bufferInitSegment(u,g.tracks,P,a),s.trigger(y.FRAG_PARSING_INIT_SEGMENT,{frag:P,id:i,tracks:g.tracks})}let L=g.initPTS,S=g.timescale;le(L)&&(this.initPTS[l.cc]={baseTime:L,timescale:S},s.trigger(y.INIT_PTS_FOUND,{frag:l,id:i,initPTS:L,timescale:S}))}let A=l.sn!==(E==null?void 0:E.startSN);if(c&&n.independent!==!1){if(E){let{startPTS:L,endPTS:S,startDTS:P,endDTS:k}=c;if(d)d.elementaryStreams[c.type]={startPTS:L,endPTS:S,startDTS:P,endDTS:k};else if(c.firstKeyFrame&&c.independent&&a.id===1&&(this.couldBacktrack=!0),c.dropped&&c.independent){let $=this.getMainFwdBufferInfo(),M=($?$.end:this.getLoadPosition())+this.config.maxBufferHole,G=c.firstKeyFramePTS?c.firstKeyFramePTS:L;if(A&&M<G-this.config.maxBufferHole){this.backtrack(l);return}l.setElementaryStreamInfo(c.type,l.start,S,l.start,k,!0)}l.setElementaryStreamInfo(c.type,L,S,P,k),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,d,a)}}else if(A&&n.independent===!1){this.backtrack(l);return}if(T){let{startPTS:L,endPTS:S,startDTS:P,endDTS:k}=T;d&&(d.elementaryStreams[$e.AUDIO]={startPTS:L,endPTS:S,startDTS:P,endDTS:k}),l.setElementaryStreamInfo($e.AUDIO,L,S,P,k),this.bufferFragmentData(T,l,d,a)}if(E&&m!=null&&(t=m.samples)!=null&&t.length){let L={id:i,frag:l,details:E,samples:m.samples};s.trigger(y.FRAG_PARSING_METADATA,L)}if(E&&h){let L={id:i,frag:l,details:E,samples:h.samples};s.trigger(y.FRAG_PARSING_USERDATA,L)}}_bufferInitSegment(e,t,i,s){if(this.state!==K.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 u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(y.BUFFER_APPENDING,{type:l,data:u,frag:i,part:null,chunkMeta:s,parent:i.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,me.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=K.IDLE}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===!1){let i=e.currentTime;if(He.isBuffered(e,i)?t=this.getAppendedFrag(i):He.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&&le(t)&&le(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}},cr=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 cr(e),this.fast_=new cr(t),this.defaultTTFB_=s,this.ttfb_=new cr(e)}update(e,t){let{slow_:i,fast_:s,ttfb_:n}=this;i.halfLife!==e&&(this.slow_=new cr(e,i.getEstimate(),i.getTotalWeight())),s.halfLife!==t&&(this.fast_=new cr(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new cr(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;le(s)&&le(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 u=i.mainForwardBufferInfo;if(u===null)return;let c=this.bwEstimator.getEstimateTTFB(),h=Math.abs(n.playbackRate);if(d<=Math.max(c,1e3*(l/(h*2))))return;let m=u.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:L}=i,S=A[e.level],P=o.total||Math.max(o.loaded,Math.round(l*S.maxBitrate/8)),k=d-g;k<1&&E&&(k=Math.min(d,o.loaded*8/T));let $=E?o.loaded*1e3/k:0,M=$?(P-o.loaded)/$:P*8/T+c/1e3;if(M<=m)return;let G=$?$*8:T,W=Number.POSITIVE_INFINITY,O;for(O=e.level-1;O>L;O--){let z=A[O].maxBitrate;if(W=this.getTimeToLoadFrag(c/1e3,G,l*z,!A[O].details),W<m)break}W>=M||W>l*10||(i.nextLoadLevel=O,E?this.bwEstimator.sample(d-Math.min(c,g),o.loaded):this.bwEstimator.sampleTTFB(d),this.clearTimer(),C.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;
|
|
893
|
+
Time to underbuffer: ${m.toFixed(3)} s
|
|
894
|
+
Estimated load time for current fragment: ${M.toFixed(3)} s
|
|
895
|
+
Estimated load time for down switch fragment: ${W.toFixed(3)} s
|
|
896
|
+
TTFB estimate: ${g}
|
|
897
|
+
Current BW estimate: ${le(T)?(T/1024).toFixed(3):"Unknown"} Kb/s
|
|
898
|
+
New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
|
|
899
|
+
Aborting and switching to level ${O}`),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===me.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!==me.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,u=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,c=i.mainForwardBufferInfo,h=(c?c.len:0)/d,m=this.findBestLevel(u,a,s,h,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(m>=0)return m;C.trace(`[abr] ${h?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let g=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay,E=n.abrBandWidthFactor,T=n.abrBandWidthUpFactor;if(!h){let A=this.bitrateTestDelay;A&&(g=(l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay)-A,C.trace(`[abr] bitrate test took ${Math.round(1e3*A)}ms, set first fragment max fetchDuration to ${Math.round(1e3*g)} ms`),E=T=1)}return m=this.findBestLevel(u,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:u}=this,{levels:c}=this.hls,h=c[u],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,L=-1;for(let S=i;S>=t;S--){let P=c[S];if(!P||g&&P.codecSet!==g){P&&(A=Math.min(S,A),L=Math.max(S,L));continue}L!==-1&&C.trace(`[abr] Skipped level(s) ${A}-${L} with CODECS:"${c[L].attrs.CODECS}"; not compatible with "${h.attrs.CODECS}"`);let k=P.details,$=(d?k==null?void 0:k.partTarget:k==null?void 0:k.averagetargetduration)||E,M;S<=u?M=n*e:M=a*e;let G=c[S].maxBitrate,W=this.getTimeToLoadFrag(T,M,G*$,k===void 0);if(C.trace(`[abr] level:${S} adjustedbw-bitrate:${Math.round(M-G)} avgDuration:${$.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:${W.toFixed(1)}`),M>G&&(W===0||!le(W)||m&&!this.bitrateTestDelay||W<s))return S}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}},Co=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=rT(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}};function rT(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 Zm=100,Gu=class extends Cn{constructor(e,t,i){super(e,t,i,"[audio-stream-controller]",me.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===K.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=K.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(Zm),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=K.IDLE):(this.loadedmetadata=!1,this.state=K.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case K.IDLE:this.doTickIdle();break;case K.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=K.WAITING_INIT_PTS}break}case K.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=K.IDLE);break}case K.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=K.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=He.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=K.IDLE}}this.onTickEnd()}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=K.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=K.WAITING_TRACK;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,$e.AUDIO,me.AUDIO));let d=this.getFwdBufferInfo(l,me.AUDIO);if(d===null)return;let{bufferedTrack:u,switchingTrack:c}=this;if(!c&&this._streamEnded(d,o)){e.trigger(y.BUFFER_EOS,{type:"audio"}),this.state=K.ENDED;return}let h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,me.MAIN),m=d.len,g=this.getMaxBufferLength(h==null?void 0:h.len);if(m>=g&&!c)return;let T=o.fragments[0].start,A=d.end;if(c&&i){let k=this.getLoadPosition();u&&c.attrs!==u.attrs&&(A=k),o.PTSKnown&&k<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 L=this.getNextFragment(A,o),S=!1;if(L&&this.isLoopLoading(L,A)&&(S=!!L.gap,L=this.getNextFragmentLoopLoading(L,o,d,me.MAIN,g)),!L){this.bufferFlushed=!0;return}let P=h&&L.start>h.end+o.targetduration;if(P||!(h!=null&&h.len)&&d.len){let k=this.getAppendedFrag(L.start,me.MAIN);if(k===null||(S||(S=!!k.gap||!!P&&h.len===0),P&&!S||S&&d.nextStart&&d.nextStart<k.end))return}this.loadFragment(L,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 Gr(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(Zm):this.resetTransmuxer(),i?(this.switchingTrack=t,this.state=K.IDLE):(this.switchingTrack=null,this.bufferedTrack=t,this.state=K.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?(Cp(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===K.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=K.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 u=d.details;if(!u){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}let c=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new Do(this.hls,me.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,L=new kn(i.level,i.sn,i.stats.chunkCount,n.byteLength,T,A);h.push(n,g,c,"",i,s,u.totalduration,!1,L,m)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${u.startSN} ,${u.endSN}],track ${o}`);let{cache:E}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new Co,complete:!1};E.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=K.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!==me.AUDIO){if(!this.loadedmetadata&&i.type===me.MAIN){let n=this.videoBuffer||this.media;n&&He.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,Yt({},n)))}this.fragBufferedComplete(i,s)}onError(e,t){var i;if(t.fatal){this.state=K.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(me.AUDIO,t);break;case B.AUDIO_TRACK_LOAD_ERROR:case B.AUDIO_TRACK_LOAD_TIMEOUT:case B.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===K.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===Pe.AUDIO_TRACK&&(this.state=K.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===$e.AUDIO&&(this.bufferFlushed=!0,this.state===K.ENDED&&(this.state=K.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:u}=o,{details:c}=u,{audio:h,text:m,id3:g,initSegment:E}=n;if(this.fragContextChanged(l)||!c){this.fragmentTracker.removeFragment(l);return}if(this.state=K.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:L,endDTS:S}=h;d&&(d.elementaryStreams[$e.AUDIO]={startPTS:T,endPTS:A,startDTS:L,endDTS:S}),l.setElementaryStreamInfo($e.AUDIO,T,A,L,S),this.bufferFragmentData(h,l,d,a)}if(g!=null&&(t=g.samples)!=null&&t.length){let T=mt({id:i,frag:l,details:c},g);s.trigger(y.FRAG_PARSING_METADATA,T)}if(m){let T=mt({id:i,frag:l,details:c},m);s.trigger(y.FRAG_PARSING_USERDATA,T)}}_bufferInitSegment(e,t,i){if(this.state!==K.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===bt.NOT_LOADED||s===bt.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=K.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,Yt({},e))}},Hu=class extends wn{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===Pe.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,Yt({},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:fe.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 qp(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(!sT(r[t].attrs,e[t].attrs))return!1;return!0}function sT(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 Jm=500,Vu=class extends Cn{constructor(e,t,i){super(e,t,i,"[subtitle-stream-controller]",me.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=K.IDLE,this.setInterval(Jm),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=K.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,me.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===me.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)===me.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==K.STOPPED&&(this.state=K.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(qp(this.levels,t)){this.levels=t.map(i=>new Gr(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{let s=new Gr(i);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,me.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(Jm)}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 u=this.mainDetails;if(s.deltaUpdateFailed||!u)return;let c=u.fragments[0];l.details?(d=this.alignPlaylists(s,l.details),d===0&&c&&(d=c.start,vu(s,d))):s.hasProgramDateTime&&u.hasProgramDateTime?(Cp(s,u),d=s.fragments[0].start):c&&(d=c.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===K.IDLE&&(Rn(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:fe.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=K.IDLE})}}doTick(){if(!this.media){this.state=K.IDLE;return}if(this.state===K.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=He.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,me.MAIN),u=i.details,c=this.getMaxBufferLength(d==null?void 0:d.len)+u.levelTargetDuration;if(l>c)return;let h=u.fragments,m=h.length,g=u.edge,E=null,T=this.fragPrevious;if(o<g){let A=s.maxFragLookUpTolerance,L=o>g-A?0:A;E=Rn(T,h,Math.max(h[0].start,o),L),!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-u.startSN,L=h[A-1];L&&L.cc===E.cc&&this.fragmentTracker.getState(L)===bt.NOT_LOADED&&(E=L)}this.fragmentTracker.getState(E)===bt.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 wn{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=>{ks(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===Pe.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:u}=n;this.hls.trigger(y.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:u});let c=this.switchParams(n.url,t==null?void 0:t.details);this.loadPlaylist(c)}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){C.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),a.onError(o),s!=null&&s.updating||(n.shift(),this.executeNext(e))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}},ep=Bo(),tp=/([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;C.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=()=>{C.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{C.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{let{media:t,_objectUrl:i}=this;t&&t.src!==i&&C.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,C.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let i=this.media=t.media;if(i&&ep){let s=this.mediaSource=new ep;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(C.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){C.warn(`[buffer-controller]: onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),e.src===i?(e.removeAttribute("src"),e.load()):C.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(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){C.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:u}=t[s],c=(n.levelCodec||n.codec).replace(tp,"$1"),h=(l||o).replace(tp,"$1");if(c!==h){let m=`${d};codecs=${l||o}`;this.appendChangeType(s,m),C.log(`[buffer-controller]: switching codec ${c} to ${h}`),this.tracks[s]={buffer:n.buffer,codec:o,container:d,levelCodec:l,metadata:u,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&&(C.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),i.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{C.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:u}=t,c=u.buffering[o],h=self.performance.now();c.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||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);let A=l.start,L={execute:()=>{if(c.executeStart=self.performance.now(),T){let S=this.sourceBuffer[o];if(S){let P=A-S.timestampOffset;Math.abs(P)>=.1&&(C.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${A} (delta: ${P}) sn: ${l.sn})`),S.timestampOffset=A)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let S=self.performance.now();c.executeEnd=c.end=S,m.first===0&&(m.first=S),g&&g.first===0&&(g.first=S);let{sourceBuffer:P}=this,k={};for(let $ in P)k[$]=He.getBuffered(P[$]);this.appendError=0,this.hls.trigger(y.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:u,parent:l.type,timeRanges:k})},onError:S=>{C.error(`[buffer-controller]: Error encountered while trying to append to the ${o} SourceBuffer`,S);let P={type:fe.MEDIA_ERROR,parent:l.type,details:B.BUFFER_APPEND_ERROR,frag:l,part:d,chunkMeta:u,error:S,err:S,fatal:!1};S.code===DOMException.QUOTA_EXCEEDED_ERR?P.details=B.BUFFER_FULL_ERROR:(this.appendError++,P.details=B.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(C.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),P.fatal=!0)),i.trigger(y.ERROR,P)}};s.append(L,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=>{C.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[$e.AUDIOVIDEO]?n.push("audiovideo"):(a[$e.AUDIO]&&n.push("audio"),a[$e.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&&C.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,C.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),s&&!!(!a||a.ended)},!0)&&(C.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{let a=this.sourceBuffer[n];a&&(a.ending=!1)});let{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&C.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}C.log("[buffer-controller]: Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){!t.fragments.length||(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){let{hls:e,details:t,media: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(!le(a)||a<0)return;let o=i.currentTime,l=t.levelTargetDuration,d=Math.max(a,l),u=Math.floor(o/l)*l-d;n.forEach(c=>{let h=s[c];if(h){let m=He.getBuffered(h);if(m.length>0&&u>m.start(0)){if(e.trigger(y.BACK_BUFFER_REACHED,{bufferEnd:u}),t.live)e.trigger(y.LIVE_BACK_BUFFER_REACHED,{bufferEnd:u});else if(h.ended&&m.end(m.length-1)-o<l*2){C.info(`[buffer-controller]: Cannot flush ${c} back buffer while SourceBuffer is in ended state`);return}e.trigger(y.BUFFER_FLUSHING,{startOffset:0,endOffset:u,type:c})}}})}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=le(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(C.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!le(a))&&(C.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:fe.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}`;C.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){C.error(`[buffer-controller]: error while trying to add sourceBuffer: ${l.message}`),this.hls.trigger(y.ERROR,{type:fe.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`);C.error(`[buffer-controller]: ${i}`,t),this.hls.trigger(y.ERROR,{type:fe.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){C.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}let d=le(s.duration)?s.duration:1/0,u=le(n.duration)?n.duration:1/0,c=Math.max(0,t),h=Math.min(i,d,u);h>c&&!l.ending?(l.ended=!1,C.log(`[buffer-controller]: Removing [${c},${h}] from the ${e} SourceBuffer`),l.remove(c,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){let{operationQueue:i,sourceBuffer:s}=this,n=s[t];if(!n){C.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){C.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)})}},ip={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},Yp=function(e){let t=e;return ip.hasOwnProperty(e)&&(t=ip[e]),String.fromCharCode(t)},hi=15,Wi=100,nT={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},aT={17:2,18:4,21:6,22:8,23:10,19:13,20:15},oT={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},lT={25:2,26:4,29:6,30:8,31:10,27:13,28:15},dT=["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;C.log(`${this.time} [${e}] ${i}`)}}},Nr=function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t},Mo=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 Mo(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<Wi;t++)this.chars.push(new zu);this.logger=e,this.pos=0,this.currPenState=new Mo}equals(e){let t=!0;for(let i=0;i<Wi;i++)if(!this.chars[i].equals(e.chars[i])){t=!1;break}return t}copy(e){for(let t=0;t<Wi;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Wi;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>Wi&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Wi)}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=Yp(e);if(this.pos>=Wi){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<Wi;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<Wi;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)}},Ln=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<hi;t++)this.rows.push(new Xu(e));this.logger=e,this.currRow=hi-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<hi;e++)this.rows[e].clear();this.currRow=hi-1}equals(e){let t=!0;for(let i=0;i<hi;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<hi;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<hi;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<hi;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<hi;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(`
|
|
900
|
+
`)),i}getTextAndFormat(){return this.rows}},Oo=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 Ln(i),this.nonDisplayedMemory=new Ln(i),this.lastOutputScreen=new Ln(i),this.currRollUpRow=this.displayedMemory.rows[hi-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[hi-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))}},Po=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 Oo(e,t,s),new Oo(e+1,i,s)],this.cmdHistory=sp(),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,"["+Nr([t[o],t[o+1]])+"] -> ("+Nr([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 "+Nr([s,n])+" orig: "+Nr([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(rp(e,t,i))return ws(null,null,i),this.logger.log(3,"Repeated command ("+Nr([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),ws(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 ("+Nr([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(rp(e,t,s))return ws(null,null,s),!0;let o=e<=23?1:2;t>=64&&t<=95?i=o===1?nT[e]:oT[e]:i=o===1?aT[e]:lT[e];let l=this.channels[o];return l?(l.setPAC(this.interpretPAC(i,t)),ws(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 '"+Yp(a)+"' in channel "+i),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);if(s){let a=Nr(s);this.logger.log(3,"Char codes = "+a.join(",")),ws(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=dT[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),ws(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=sp()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let i=this.channels[t];i&&i.cueSplitAtTime(e)}}};function ws(r,e,t){t.a=r,t.b=e}function rp(r,e,t){return t.a===r&&t.b===e}function sp(){return{a:null,b:null}}var Ds=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}},pc=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 u=arguments[d];for(let c in u)o[c]=u[c]}return o}function a(o,l,d){let u=this,c={enumerable:!0};u.hasBeenReset=!1;let h="",m=!1,g=o,E=l,T=d,A=null,L="",S=!0,P="auto",k="start",$=50,M="middle",G=50,W="middle";Object.defineProperty(u,"id",n({},c,{get:function(){return h},set:function(O){h=""+O}})),Object.defineProperty(u,"pauseOnExit",n({},c,{get:function(){return m},set:function(O){m=!!O}})),Object.defineProperty(u,"startTime",n({},c,{get:function(){return g},set:function(O){if(typeof O!="number")throw new TypeError("Start time must be set to a number.");g=O,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",n({},c,{get:function(){return E},set:function(O){if(typeof O!="number")throw new TypeError("End time must be set to a number.");E=O,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",n({},c,{get:function(){return T},set:function(O){T=""+O,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",n({},c,{get:function(){return A},set:function(O){A=O,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",n({},c,{get:function(){return L},set:function(O){let z=i(O);if(z===!1)throw new SyntaxError("An invalid or illegal string was specified.");L=z,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",n({},c,{get:function(){return S},set:function(O){S=!!O,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",n({},c,{get:function(){return P},set:function(O){if(typeof O!="number"&&O!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");P=O,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",n({},c,{get:function(){return k},set:function(O){let z=s(O);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");k=z,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",n({},c,{get:function(){return $},set:function(O){if(O<0||O>100)throw new Error("Position must be between 0 and 100.");$=O,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",n({},c,{get:function(){return M},set:function(O){let z=s(O);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");M=z,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",n({},c,{get:function(){return G},set:function(O){if(O<0||O>100)throw new Error("Size must be between 0 and 100.");G=O,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",n({},c,{get:function(){return W},set:function(O){let z=s(O);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");W=z,this.hasBeenReset=!0}})),u.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 jp(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 zp(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 pc(0,0,""),mo=Ju.align==="middle"?"middle":"center";function uT(r,e,t){let i=r;function s(){let o=jp(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;zp(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",mo,"end"]);break;case"position":g=m.split(","),d.percent(h,g[0]),g.length===2&&d.alt("positionAlign",g[1],["start",mo,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,m);break;case"align":d.alt(h,m,["start",mo,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let u=d.get("line","auto");u==="auto"&&Ju.line===-1&&(u=-1),l.line=u,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",mo);let c=d.get("position","auto");c==="auto"&&Ju.position===50&&(c=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=c}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 Xp(r){return r.replace(/<br(?: \/)?>/gi,`
|
|
901
|
+
`)}var ec=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Qu,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=Xp(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
|
|
902
|
+
`;)++a;let o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
|
|
903
|
+
`&&++a,t.buffer=n.slice(a),o}function s(n){zp(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 pc(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{uT(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+=`
|
|
904
|
+
`),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+=`
|
|
905
|
+
|
|
906
|
+
`,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}},cT=/\r\n|\n\r|\n|\r/g,tu=function(e,t,i=0){return e.slice(i,i+t.length)===t},hT=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(!le(t)||!le(i)||!le(s)||!le(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*s,t+=60*60*1e3*n,t},iu=function(e){let t=5381,i=e.length;for(;i;)t=t*33^e.charCodeAt(--i);return(t>>>0).toString()};function gc(r,e,t){return iu(r.toString())+iu(e.toString())+iu(t)}var fT=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 mT(r,e,t,i,s,n,a){let o=new ec,l=Oi(new Uint8Array(r)).trim().replace(cT,`
|
|
907
|
+
`).split(`
|
|
908
|
+
`),d=[],u=e?qb(e.baseTime,e.timescale):0,c="00:00.000",h=0,m=0,g,E=!0;o.oncue=function(T){let A=t[i],L=t.ccOffset,S=(h-u)/9e4;if(A!=null&&A.new&&(m!==void 0?L=t.ccOffset=A.start:fT(t,i,S)),S){if(!e){g=new Error("Missing initPTS for VTT MPEGTS");return}L=S-t.presentationOffset}let P=T.endTime-T.startTime,k=ai((T.startTime+L-m)*9e4,s*9e4)/9e4;T.startTime=Math.max(k,0),T.endTime=Math.max(k+P,0);let $=T.text.trim();T.text=decodeURIComponent(encodeURIComponent($)),T.id||(T.id=gc(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(tu(T,"X-TIMESTAMP-MAP=")){E=!1,T.slice(16).split(",").forEach(A=>{tu(A,"LOCAL:")?c=A.slice(6):tu(A,"MPEGTS:")&&(h=parseInt(A.slice(7)))});try{m=hT(c)/1e3}catch(A){g=A}return}else T===""&&(E=!1);o.parse(T+`
|
|
909
|
+
`)}),o.flush()}var ru="stpp.ttml.im1t",Qp=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Zp=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,pT={left:"start",center:"center",right:"end",start:"start",end:"end"};function np(r,e,t,i){let s=Me(new Uint8Array(r),["mdat"]);if(s.length===0){i(new Error("Could not parse IMSC1 mdat"));return}let n=s.map(o=>Oi(o)),a=Wb(e.baseTime,1,e.timescale);try{n.forEach(o=>t(gT(o,a)))}catch(o){i(o)}}function gT(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((c,h)=>(c[h]=s.getAttribute(`ttp:${h}`)||n[h],c),{}),o=s.getAttribute("xml:space")!=="preserve",l=ap(su(s,"styling","style")),d=ap(su(s,"layout","region")),u=su(s,"body","[begin]");return[].map.call(u,c=>{let h=Jp(c,o);if(!h||!c.hasAttribute("begin"))return null;let m=au(c.getAttribute("begin"),a),g=au(c.getAttribute("dur"),a),E=au(c.getAttribute("end"),a);if(m===null)throw op(c);if(E===null){if(g===null)throw op(c);E=m+g}let T=new pc(m-e,E-e,h);T.id=gc(T.startTime,T.endTime,T.text);let A=d[c.getAttribute("region")],L=l[c.getAttribute("style")],S=vT(A,L,l),{textAlign:P}=S;if(P){let k=pT[P];k&&(T.lineAlign=k),T.align=P}return mt(T,S),T}).filter(c=>c!==null)}function su(r,e,t){let i=r.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function ap(r){return r.reduce((e,t)=>{let i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function Jp(r,e){return[].slice.call(r.childNodes).reduce((t,i,s)=>{var n;return i.nodeName==="br"&&s?t+`
|
|
910
|
+
`:(n=i.childNodes)!=null&&n.length?Jp(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function vT(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 op(r){return new Error(`Could not parse ttml timestamp ${r}`)}function au(r,e){if(!r)return null;let t=jp(r);return t===null&&(Qp.test(r)?t=ET(r,e):Zp.test(r)&&(t=yT(r,e))),t}function ET(r,e){let t=Qp.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 yT(r,e){let t=Zp.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 tc=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=lp(),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 Ds(this,"textTrack1"),i=new Ds(this,"textTrack2"),s=new Ds(this,"textTrack3"),n=new Ds(this,"textTrack4");this.cea608Parser1=new Po(1,t,i),this.cea608Parser2=new Po(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=TT(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,ks(i[e]),xp(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=>{ks(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=lp(),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++)ks(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(qp(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 u=null;for(let c=0;c<a.length;c++)if(bT(a[c],o)){u=a[c];break}u&&(d=u)}if(d)ks(d);else{let u=this._captionsOrSubtitlesFromCharacteristics(o);d=this.createTextTrack(u,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===me.MAIN){var o,l;let d=t.frag.sn,u=(o=t==null||(l=t.part)==null?void 0:l.index)!=null?o:-1;d===n+1||d===n&&u===a+1||(i.reset(),s.reset()),this.lastSn=d,this.lastPartIndex=u}}onFragLoaded(e,t){let{frag:i,payload:s}=t;if(i.type===me.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;np(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),i.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{C.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?Br(i.initSegment.data,new Uint8Array(s)):s;mT(d,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,u=>{this._appendCues(u,i.level),l.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},u=>{let c=u.message==="Missing initPTS for VTT MPEGTS";c?a.push(e):this._fallbackToIMSC1(i,s),C.log(`Failed to parse VTT cue: ${u}`),!(c&&o>i.cc)&&l.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:u})})}_fallbackToIMSC1(e,t){let i=this.tracks[e.level];i.textCodec||np(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=>Ip(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===me.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===me.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 u=3&a;(u===0||u===1)&&(t[u].push(o),t[u].push(l))}}return t}};function bT(r,e){return!!r&&r.label===e.name&&!(r.textTrack1||r.textTrack2)}function TT(r,e,t,i){return Math.min(e,i)-Math.max(r,t)}function lp(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var Mn=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,Mn.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}},ic=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 u=d.currentLevel;C.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=u)&&(u=u-1,d.trigger(y.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:d.currentLevel}),d.autoLevelCapping=u,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)}},po="[eme]",hr=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=hr.CDMCleanupPromise?[hr.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=C.debug.bind(C,po),this.log=C.log.bind(C,po),this.warn=C.warn.bind(C,po),this.error=C.error.bind(C,po),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===tt.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 u=d.shift();this.getMediaKeysPromise(u,s,n).then(c=>a({keySystem:u,mediaKeys:c})).catch(c=>{d.length?l(d):c instanceof Wt?o(c):o(new Wt({type:fe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_ACCESS,error:c,fatal:!0},c.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 fp===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=by(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(u=>(this.log(`Media-keys created for "${e}"`),d.then(c=>c?this.setMediaKeysServerCertificate(u,e,c):u))),o.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${wi.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 wi.hexDump(e.keyId)}updateKeySession(e,t){var i;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${wi.hexDump(((i=e.decryptdata)==null?void 0:i.keyId)||[])}
|
|
911
|
+
} (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=$d(this.config),n=e.map(Im).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=Lm(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 Wt?this.hls.trigger(y.ERROR,e.data):this.hls.trigger(y.ERROR,{type:fe.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=Im(e.keyFormat),n=s?[s]:$d(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=$d(this.config)),e.length===0)throw new Wt({type:fe.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[tt.FAIRPLAY]){let u=xt(new Uint8Array(i));try{let c=oc(JSON.parse(u).sinf),h=Tp(new Uint8Array(c));if(!h)return;s=h.subarray(8,24),n=tt.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{let u=Ky(i);if(u===null)return;u.version===0&&u.systemId===hp.WIDEVINE&&u.data&&(s=u.data.subarray(8,24)),n=yy(u.systemId)}if(!n||!s)return;let a=wi.hexDump(s),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this,d=o[a];for(let u=0;u<l.length;u++){let c=l[u],h=c.decryptdata;if(h.pssh||!h.keyId)continue;let m=wi.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(c,t,i,"encrypted-event-key-match"));break}}d||(d=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:u,mediaKeys:c})=>{var h;this.throwIfDestroyed();let m=new $r("ISO-23001-7",a,(h=Lm(u))!=null?h:"");return m.pssh=new Uint8Array(i),m.keyId=s,this.attemptSetMediaKeys(u,c).then(()=>{this.throwIfDestroyed();let g=this.createMediaKeySessionContext({decryptdata:m,keySystem:u,mediaKeys:c});return this.generateRequestWithPreferredKeySession(g,t,i,"encrypted-event-no-match")})})),d.catch(u=>this.handleError(u))}_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 u=new mc;e.mediaKeysSession.onmessage=h=>{let m=e.mediaKeysSession;if(!m){u.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),u.emit("error",T)}):g==="license-release"?e.keySystem===tt.FAIRPLAY&&(this.updateKeySession(e,cp("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},e.mediaKeysSession.onkeystatuseschange=h=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let g=e.keyStatus;u.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};let c=new Promise((h,m)=>{u.on("error",m),u.on("keyStatus",g=>{g.startsWith("usable")?h():g==="output-restricted"?m(new Wt({type:fe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?m(new Wt({type:fe.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 Wt({type:fe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_NO_SESSION,error:h,fatal:!1},`Error generating key-session request: ${h}`)}).then(()=>c).catch(h=>{throw u.removeAllListeners(),this.removeSession(e),h}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,i)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${wi.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${wi.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,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,m,g,E)=>{a(h.data)},onError:(h,m,g,E)=>{o(new Wt({type:fe.KEY_SYSTEM_ERROR,details:B.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:Yt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,m,g)=>{o(new Wt({type:fe.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,u,c)})):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 Wt({type:fe.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 Wt({type:fe.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(u){this.error(u)}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 Wt({type:fe.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 u=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} 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={},$r.clearKeyUriToKeyIdMap();let i=t.length;hr.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}`)})}}};hr.CDMCleanupPromise=void 0;var Wt=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}},_T=1,Vt={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},AT="h",Ci=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:Vt.MANIFEST,su:!this.initialized})}catch(n){C.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{let n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===Vt.VIDEO||o===Vt.AUDIO||o==Vt.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){C.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||Ci.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:_T,sf:AT,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){mt(t,this.createData());let i=t.ot===Vt.INIT||t.ot===Vt.VIDEO||t.ot===Vt.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=Ci.toHeaders(t);if(!Object.keys(s).length)return;e.headers||(e.headers={}),mt(e.headers,s)}else{let s=Ci.toQuery(t);if(!s)return;e.url=Ci.appendQueryToUri(e.url,s)}}getObjectType(e){let{type:t}=e;if(t==="subtitle")return Vt.TIMED_TEXT;if(e.sn==="initSegment")return Vt.INIT;if(t==="audio")return Vt.AUDIO;if(t==="main")return this.hls.audioTracks.length?Vt.VIDEO:Vt.MUXED}getTopBandwidth(e){let t=0,i,s=this.hls;if(e===Vt.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===Vt.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:He.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 u=e[d];if(!i(u)||d==="v"&&u===1||d=="pr"&&u===1)continue;let c=o[d];c&&(u=c(u));let h=typeof u,m;d==="ot"||d==="sf"||d==="st"?m=`${d}=${u}`:h==="boolean"?m=d:h==="number"?m=`${d}=${u}`:m=`${d}=${JSON.stringify(u)}`,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=Ci.serialize(n[o]);l&&(i[`CMCD-${s[o]}`]=l)}return i}static toQuery(e){return`CMCD=${encodeURIComponent(Ci.serialize(e))}`}static appendQueryToUri(e,t){if(!t)return e;let i=e.includes("?")?"&":"?";return`${e}${i}${t}`}},ST=3e5,rc=class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=C.log.bind(C,"[content-steering]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(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)===Ot.SendAlternateToPenaltyBox&&i.flags===ci.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]>ST&&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(u=>u.pathwayId===a))return;let d=this.getLevelsForPathway(o).map(u=>{let c=mt({},u);c.details=void 0,c.url=eg(u.uri,u.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l);let h=new qe(u.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),c.attrs=h;let E=new Gr(c);return So(E,"audio",m),So(E,"text",g),E});t.push(...d),dp(this.audioTracks,i,l,a),dp(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 u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+u)}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:(u,c,h,m)=>{this.log(`Loaded steering manifest: "${s}"`);let g=u.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:(u,c,h,m)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${c.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${c.url} no longer available`);return}let g=this.timeToLoad*1e3;if(u.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 ${c.url} rate limited`);return}this.scheduleRefresh(this.uri||c.url,g)},onTimeout:(u,c,h)=>{this.log(`Timeout loading steering manifest (${c.url})`),this.scheduleRefresh(this.uri||c.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 dp(r,e,t,i){!r||Object.keys(e).forEach(s=>{let n=r.filter(a=>a.groupId===s).map(a=>{let o=mt({},a);return o.details=void 0,o.attrs=new qe(o.attrs),o.url=o.attrs.URI=eg(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 eg(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 xT=/^age:\s*[\d.]+\s*$/im,No=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 Cs,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&&le(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 u=this.callbacks.onProgress;if(u&&u(i,e,l,t),!this.callbacks)return;let c={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(c,i,e,t)}else{let l=n.loadPolicy.errorRetry,d=i.retry;Ao(l,d,!1,a)?this.retry(l):(C.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(Ao(t,i,!0))this.retry(t);else{C.warn(`timeout while loading ${this.context.url}`);let s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:i}=this;this.retryDelay=dc(e,i.retry),i.retry++,C.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&&xT.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 IT(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var LT=/(\d+)-(\d+)\/(\d+)/,Fo=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||DT,this.controller=new self.AbortController,this.stats=new Cs}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=RT(e,this.controller.signal),a=i.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&le(d)?d:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(c=>{this.response=this.loader=c;let h=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,e,this.response)},u-(h-s.loading.start)),!c.ok){let{status:m,statusText:g}=c;throw new sc(g||"fetch, bad network response",m,c)}return s.loading.first=h,s.total=kT(c.headers)||s.total,a&&le(t.highWaterMark)?this.loadProgressively(c,s,e,t.highWaterMark,a):o?c.arrayBuffer():e.responseType==="json"?c.json():c.text()}).then(c=>{let{response:h}=this;self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);let m=c[l];m&&(s.loaded=s.total=m);let g={url:h.url,data:c,code:h.status};a&&!le(t.highWaterMark)&&a(s,e,c,h),i.onSuccess(g,s,e,h)}).catch(c=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;let h=c&&c.code||0,m=c?c.message:null;i.onError({code:h,text:m},e,c?c.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 Co,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 u=d.value,c=u.length;return t.loaded+=c,c<s||a.dataLength?(a.push(u),a.dataLength>=s&&n(t,i,a.flush(),e)):n(t,i,u,e),l()}).catch(()=>Promise.reject());return l()}};function RT(r,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(mt({},r.headers))};return r.rangeEnd&&t.headers.set("Range","bytes="+r.rangeStart+"-"+String(r.rangeEnd-1)),t}function wT(r){let e=LT.exec(r);if(e)return parseInt(e[2])-parseInt(e[1])+1}function kT(r){let e=r.get("Content-Range");if(e){let i=wT(e);if(le(i))return i}let t=r.get("Content-Length");if(t)return parseInt(t)}function DT(r,e){return new self.Request(r.url,e)}var sc=class extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}},CT=/\s/,MT={newCue(r,e,t,i){let s=[],n,a,o,l,d,u=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 c;for(let E=0;E<n.chars.length;E++)CT.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=Xp(d.trim()),g=gc(e,t,m);r!=null&&(c=r.cues)!=null&&c.getCueById(g)||(a=new u(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=>Ip(r,h))),s}},OT={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},PT=Yt(Yt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:No,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:$u,bufferController:Yu,capLevelController:Mn,errorController:yu,fpsController:ic,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:fp,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:OT},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},NT()),{},{subtitleStreamController:Vu,subtitleTrackController:Wu,timelineController:tc,audioStreamController:Gu,audioTrackController:Hu,emeController:hr,cmcdController:Ci,contentSteeringController:rc});function NT(){return{cueHandler:MT,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 FT(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=nc(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 u=`${n}Loading${d}`,c=e[u];if(c!==void 0&&o){l.push(u);let h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=c,h.maxTimeToFirstByteMs=c;break;case"MaxRetry":h.errorRetry.maxNumRetry=c,h.timeoutRetry.maxNumRetry=c;break;case"RetryDelay":h.errorRetry.retryDelayMs=c,h.timeoutRetry.retryDelayMs=c;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=c,h.timeoutRetry.maxRetryDelayMs=c;break}}}),l.length&&C.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),Yt(Yt({},t),e)}function nc(r){return r&&typeof r=="object"?Array.isArray(r)?r.map(nc):Object.keys(r).reduce((e,t)=>(e[t]=nc(r[t]),e),{}):r}function UT(r){let e=r.loader;e!==Fo&&e!==No?(C.log("[config]: Custom loader detected, cannot enable progressive streaming"),r.progressive=!1):IT()&&(r.loader=Fo,r.progressive=!0,r.enableSoftwareAES=!0,C.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Mi=class{static get version(){return"1.4.8"}static isSupported(){return xb()}static get Events(){return y}static get ErrorTypes(){return fe}static get ErrorDetails(){return B}static get DefaultConfig(){return Mi.defaultConfig?Mi.defaultConfig:PT}static set DefaultConfig(e){Mi.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new mc,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,cy(e.debug||!1,"Hls instance");let t=this.config=FT(Mi.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&UT(t);let{abrController:i,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new i(this),u=this.bufferController=new s(this),c=this.capLevelController=new n(this),h=new o(this),m=new cu(this),g=new mu(this),E=t.contentSteeringController,T=E?new E(this):null,A=this.levelController=new bu(this,T),L=new Tu(this),S=new Au(this.config),P=this.streamController=new Uu(this,L,S);c.setStreamController(P),h.setStreamController(P);let k=[m,A,P];T&&k.splice(1,0,T),this.networkControllers=k;let $=[d,u,c,h,g,L];this.audioTrackController=this.createController(t.audioTrackController,k);let M=t.audioStreamController;M&&k.push(new M(this,L,S)),this.subtitleTrackController=this.createController(t.subtitleTrackController,k);let G=t.subtitleStreamController;G&&k.push(new G(this,L,S)),this.createController(t.timelineController,$),S.emeController=this.emeController=this.createController(t.emeController,$),this.cmcdController=this.createController(t.cmcdController,$),this.latencyController=this.createController(pu,$),this.coreComponents=$,k.push(l);let W=l.onErrorOut;typeof W=="function"&&this.on(y.ERROR,W,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){C.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(y.ERROR,{type:fe.OTHER_ERROR,details:B.INTERNAL_EXCEPTION,fatal:!1,event:e,error:i})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){C.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){C.log("attachMedia"),this._media=e,this.trigger(y.MEDIA_ATTACHING,{media:e})}detachMedia(){C.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=ac.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});C.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){C.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){C.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){C.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){C.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){let e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){C.log(`set currentLevel:${e}`),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){C.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){C.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){C.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){C.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(C.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){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}};Mi.defaultConfig=void 0;var jt=Mi,On=class extends Error{constructor(r,e=On.MEDIA_ERR_CUSTOM,t,i){var s;super(r),this.name="MediaError",this.code=e,this.context=i,this.fatal=t!=null?t:e>=On.MEDIA_ERR_NETWORK&&e<=On.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(s=On.defaultMessages[this.code])!=null?s:"")}},Ze=On;Ze.MEDIA_ERR_ABORTED=1,Ze.MEDIA_ERR_NETWORK=2,Ze.MEDIA_ERR_DECODE=3,Ze.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Ze.MEDIA_ERR_ENCRYPTED=5,Ze.MEDIA_ERR_CUSTOM=100,Ze.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 BT=r=>r==null,og=(r,e)=>BT(e)?!1:r in e,Ec={ANY:"any",MUTED:"muted"},Ye={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},oi={MSE:"mse",NATIVE:"native"},yc={HEADER:"header",QUERY:"query",NONE:"none"},Ms=Object.values(yc),fr={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},bc={HLS:fr.M3U8},ZL=Object.keys(bc),JL=[...Object.values(fr),"hls","HLS"],pi=(r,e,t,i,s=r)=>{s.addEventListener(e,t,i),r.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function $T(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 GT=r=>{let e=r.indexOf("?");if(e<0)return[r];let t=r.slice(0,e),i=r.slice(e);return[t,i]},Go=r=>{let e=r.type;if(e){let i=e.toUpperCase();return og(i,bc)?bc[i]:e}let{src:t}=r;return t?HT(t):""},lg=r=>r==="VOD"?Ye.ON_DEMAND:Ye.LIVE,dg=r=>r==="EVENT"?Number.POSITIVE_INFINITY:r==="VOD"?Number.NaN:0,HT=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 og(i,fr)?fr[i]:""},VT=Object.values(Ec),tg=r=>typeof r=="boolean"||typeof r=="string"&&VT.includes(r),KT=({autoplay:r},e,t)=>{let i=!1,s=!1,n=tg(r)?r:!!r,a=()=>{i||pi(e,"playing",()=>{i=!0},{once:!0})};if(a(),pi(e,"loadstart",()=>{i=!1,a(),vc(e,n)},{once:!0}),pi(e,"loadstart",()=>{t||(s=!Number.isFinite(e.duration)),vc(e,n)},{once:!0}),t&&t.once(jt.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&&pi(e,"play",()=>{e.preload==="metadata"?t.once(jt.Events.LEVEL_UPDATED,o):o()},{once:!0})}return o=>{i||(n=tg(o)?o:!!o,vc(e,n))}},vc=(r,e)=>{if(!e)return;let t=r.muted,i=()=>r.muted=t;switch(e){case Ec.ANY:r.play().catch(()=>{r.muted=!0,r.play().catch(i)});break;case Ec.MUTED:r.muted=!0,r.play().catch(i);break;default:r.play().catch(()=>{});break}},WT=({preload:r,src:e},t,i)=>{let s=c=>{c!=null&&["","none","metadata","auto"].includes(c)?t.setAttribute("preload",c):t.removeAttribute("preload")};if(!i)return s(r),s;let n=!1,a=!1,o=i.config.maxBufferLength,l=i.config.maxBufferSize,d=c=>{s(c);let h=c!=null?c:t.preload;a||h==="none"||(h==="metadata"?(i.config.maxBufferLength=1,i.config.maxBufferSize=1):(i.config.maxBufferLength=o,i.config.maxBufferSize=l),u())},u=()=>{!n&&e&&(n=!0,i.loadSource(e))};return pi(t,"play",()=>{a=!0,i.config.maxBufferLength=o,i.config.maxBufferSize=l,u()},{once:!0}),d(r),d};function qT(r,e){e.on(jt.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:u,name:c,type:h})=>u==(l==null?void 0:l.lang)&&c===a.label&&h.toLowerCase()===a.kind);Ho(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:u})=>l==n.language&&d===n.label&&u.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(jt.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 u;(u=o.cues)!=null&&u.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(jt.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(jt.Events.MANIFEST_LOADED,i),e.once(jt.Events.MEDIA_ATTACHED,i)}function Ho(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 ug(r,e){let t=Array.prototype.find.call(r.querySelectorAll("track"),i=>i.track===e);t==null||t.remove()}var Pn="cuepoints",_c=Object.freeze({label:Pn}),Ac=(r,{label:e=Pn}=_c)=>{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 Sc(r,e,t=_c){let i=Ac(r,t);if(!i){let{label:s=Pn}=t;i=Ho(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],u=d?d.startTime:Number.isFinite(r.duration)?r.duration:Number.MAX_SAFE_INTEGER,c=(o=i==null?void 0:i.cues)==null?void 0:o[l-1];c&&(c.endTime=s);let h=new VTTCue(s,u,JSON.stringify(n!=null?n:null));i.addCue(h)}),i}var cg=r=>({time:r.startTime,value:JSON.parse(r.text)});function hg(r,e={label:Pn}){let t=Ac(r,e);return t!=null&&t.cues?Array.from(t.cues,i=>cg(i)):[]}function xc(r,e={label:Pn}){var t,i;let s=Ac(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 cg(a)}async function YT(r,e=_c){return new Promise(t=>{pi(r,"loadstart",async()=>{let i=await Sc(r,[],e);pi(r,"cuechange",()=>{let s=xc(r);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});r.dispatchEvent(n)}},{},i),t(i)})})}function fg(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 mg(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 jT=async r=>fetch(r).then(e=>e.text()).then(e=>{let t=e.split(`
|
|
912
|
+
`).find((i,s,n)=>s&&n[s-1].startsWith("#EXT-X-STREAM-INF"));return fetch(t).then(i=>i.text()).then(i=>i.split(`
|
|
913
|
+
`))}),zT=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=lg(i),n=dg(i),a;if(s===Ye.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}},XT=async(r,e)=>{if(e===fr.MP4)return{streamType:Ye.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===fr.M3U8){let t=await jT(r);return zT(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}},ig=async(r,e,t=Go({src:r}))=>{var i,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await XT(r,t);((i=It.get(e))!=null?i:{}).liveEdgeStartOffset=l,((s=It.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=It.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},QT=r=>{var e;let t=r.type,i=lg(t),s=dg(t),n,a=!!((e=r.partList)!=null&&e.length);return i===Ye.LIVE&&(n=a?r.partTarget*2:r.targetduration*3),{streamType:i,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},ZT=(r,e,t)=>{var i,s,n,a,o,l,d,u;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:m,lowLatency:g}=QT(r);if(c===Ye.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=It.get(e))!=null?o:{}).seekable=E}((l=It.get(e))!=null?l:{}).liveEdgeStartOffset=m,((d=It.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((u=It.get(e))!=null?u:{}).streamType=c,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},rg,sg,JT=(sg=(rg=globalThis==null?void 0:globalThis.navigator)==null?void 0:rg.userAgent)!=null?sg:"",e_=JT.toLowerCase().indexOf("android")!==-1,It=new WeakMap,pg="mux.com",ng,ag,gg=(ag=(ng=jt).isSupported)==null?void 0:ag.call(ng),t_=e_,vg=()=>$o.default.utils.now(),i_=$o.default.utils.generateUUID,Eg=(r,{domain:e=pg,maxResolution:t=""}={})=>{if(!r)return;let[i,s=""]=GT(r),n=new URL(`https://stream.${e}/${i}.m3u8${s}`);return t&&n.searchParams.set("max_resolution",t),n.toString()},r_=r=>{if(!r)return;let[e]=r.split("?");return e||void 0},s_=r=>{if(!r||!r.startsWith("https://stream."))return;let[e]=new URL(r).pathname.slice(1).split(".m3u8");return e||void 0},n_=r=>{var e,t,i;return(e=r==null?void 0:r.metadata)!=null&&e.video_id?r.metadata.video_id:Ig(r)&&(i=(t=r_(r.playbackId))!=null?t:s_(r.src))!=null?i:r.src},yg=r=>{var e;return(e=It.get(r))==null?void 0:e.error},bg=r=>{var e,t;return(t=(e=It.get(r))==null?void 0:e.streamType)!=null?t:Ye.UNKNOWN},Tg=r=>{var e,t;return(t=(e=It.get(r))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},Ic=r=>{var e,t;return(t=(e=It.get(r))==null?void 0:e.seekable)!=null?t:r.seekable},_g=r=>{var e;let t=(e=It.get(r))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let i=Ic(r);return i.length?i.end(i.length-1)-t:Number.NaN},a_=(r,e,t=.001)=>Math.abs(r-e)<=t,Ag=(r,e,t=.001)=>r>e||a_(r,e,t),o_=r=>r.paused&&Ag(r.currentTime,r.duration),Lc=(r,e)=>r.loop||!!e?r.ended:r.ended||o_(r),Sg=(r,e,t)=>{Rc(e,t);let{metadata:i={}}=r,{view_session_id:s=i_()}=i,n=n_(r);i.view_session_id=s,i.video_id=n,r.metadata=i,It.set(e,{});let a=l_(r,e);u_(r,e,a),c_(r,e,a),YT(e);let o=KT(r,e,a),l=WT(r,e,a);return{engine:a,setAutoplay:o,setPreload:l}},Rc=(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",Rg),r.removeEventListener("error",Tc),r.removeEventListener("durationchange",Lg),It.delete(r),r.dispatchEvent(new Event("teardown")))};function xg(r,e){var t;let i=Go(r);if(i!==fr.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||!(gg&&(a||t_)))}var l_=(r,e)=>{let{debug:t,streamType:i,startTime:s=-1,metadata:n,preferCmcd:a}=r,o=Go(r)===fr.M3U8,l=xg(r,e);if(o&&!l&&gg){let d={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},u=d_(i),c=a!==yc.NONE?{useHeaders:a===yc.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new jt({debug:t,startPosition:s,cmcd:c,...d,...u})}},d_=r=>r===Ye.LIVE?{backBufferLength:8}:{},Ig=({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(pg)||!!t&&s.includes(t.toLocaleLowerCase())},u_=(r,e,t)=>{var i;let{envKey:s}=r,n=Ig(r);if(s||n){let{playerInitTime:a,playerSoftwareName:o,playerSoftwareVersion:l,beaconCollectionDomain:d,debug:u,disableCookies:c}=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;$o.default.monitor(e,{debug:u,beaconCollectionDomain:d,hlsjs:t,Hls:t?jt:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:c,data:{...s?{env_key:s}:{},player_software_name:o,player_software:o,player_software_version:l,player_init_time:a,...h}})}},c_=(r,e,t)=>{var i;let s=xg(r,e),{src:n}=r;if(e&&s){let a=Go(r);typeof n=="string"?(e.preload==="none"?pi(e,"loadstart",()=>ig(n,e,a)):ig(n,e,a),e.setAttribute("src",n),r.startTime&&(((i=It.get(e))!=null?i:{}).startTime=r.startTime,e.addEventListener("durationchange",Lg,{once:!0}))):e.removeAttribute("src"),e.addEventListener("error",Rg),e.addEventListener("error",Tc),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(l=>{l.remove()})},{once:!0});let o=()=>{e.ended||!Lc(e)||e.dispatchEvent(new Event("ended"))};pi(e,"pause",o),pi(e,"seeked",o),pi(e,"play",()=>{e.ended||!Ag(e.currentTime,e.duration)||(e.currentTime=e.seekable.start(0))})}else t&&n?(t.once(jt.Events.LEVEL_LOADED,(a,o)=>{ZT(o.details,e,t)}),t.on(jt.Events.ERROR,(a,o)=>{let l={[jt.ErrorTypes.NETWORK_ERROR]:Ze.MEDIA_ERR_NETWORK,[jt.ErrorTypes.MEDIA_ERROR]:Ze.MEDIA_ERR_DECODE},d=new Ze("",l[o.type]);d.fatal=o.fatal,d.data=o,e.dispatchEvent(new CustomEvent("error",{detail:d}))}),e.addEventListener("error",Tc),qT(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 Lg(r){var e;let t=r.target,i=(e=It.get(t))==null?void 0:e.startTime;if(!!i&&$T(t.seekable,t.duration,i)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=i,s&&(t.preload="auto")}}async function Rg(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 Ze(t,i);if(e.src&&(i!==Ze.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 Tc(r){var e,t;if(!(r instanceof CustomEvent)||!(r.detail instanceof Ze))return;let i=r.target,s=r.detail;!s||!s.fatal||(((e=It.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 h_=Object.defineProperty,f_=(r,e,t)=>e in r?h_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Os=(r,e,t)=>(f_(r,typeof e!="symbol"?e+"":e,t),t),Pc=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},ee=(r,e,t)=>(Pc(r,e,"read from private field"),t?t.call(r):e.get(r)),Ae=(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)},Ve=(r,e,t,i)=>(Pc(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),it=(r,e,t)=>(Pc(r,e,"access private method"),t),Xo=class{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}};if(typeof DocumentFragment=="undefined"){class r extends Xo{}globalThis.DocumentFragment=r}var Nc=class extends Xo{},m_=class extends Xo{},p_={get(r){},define(r,e,t){},upgrade(r){},whenDefined(r){return Promise.resolve(Nc)}},Vo,g_=class{constructor(r,e={}){Ae(this,Vo,void 0),Ve(this,Vo,e==null?void 0:e.detail)}get detail(){return ee(this,Vo)}initCustomEvent(){}};Vo=new WeakMap;function v_(r,e){return new Nc}var Cg={document:{createElement:v_},DocumentFragment,customElements:p_,CustomEvent:g_,EventTarget:Xo,HTMLElement:Nc,HTMLVideoElement:m_},Mg=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Ko=Mg?Cg:globalThis,iR=Mg?Cg.document:globalThis.document,E_=()=>{try{return"0.15.6"}catch{}return"UNKNOWN"},y_=E_(),b_=()=>y_,wg=r=>{var e,t,i,s,n,a,o,l,d,u,c,h,m,g,E,T,A,L,S,P,k,$,M,G,W,O,z,j,be,ge,ve,Re,Te,Q,ie,re,_e,Se,Ne,ut;return e=class extends r{constructor(){super(),Ae(this,z),Ae(this,be),Ae(this,ve),Ae(this,Te),Ae(this,ie),Ae(this,_e),Ae(this,Ne),Os(this,"castEnabled",!1),Ae(this,k,{paused:!1}),Ae(this,$,void 0),Ae(this,M,{}),Ae(this,G,void 0),Ae(this,W,void 0),Ae(this,O,void 0),e.instances.add(this),it(this,ie,re).call(this)}static get castElement(){return ee(e,t)}static get castEnabled(){return ee(e,i)}static get castState(){var H;return(H=ee(e,d,u))==null?void 0:H.getCastState()}static async exitCast(){try{await ee(e,d,u).endCurrentSession(!0)}catch(H){console.error(H);return}}get castPlayer(){if(e.castElement===this)return ee(this,$)}attributeChangedCallback(H){if(this.castPlayer)switch(H){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(H={}){var Z;it(Z=e,S,P).call(Z,H),Ve(e,t,this),Object.entries(ee(this,M)).forEach(([Ie,je])=>{ee(this,$).controller.addEventListener(Ie,je)});try{await ee(e,d,u).requestSession()}catch{Ve(e,t,void 0);return}ee(this,k).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(Ie){console.error(Ie)}}async load(){var H,Z;if(!this.castPlayer)return super.load();let Ie=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),je=[...this.querySelectorAll("track")].filter(({kind:Zt,src:Ei})=>Ei&&(Zt==="subtitles"||Zt==="captions")),Tt=[],zt=0;je.length&&(Ie.tracks=je.map(Zt=>{let Ei=++zt;Tt.length===0&&Zt.track.mode==="showing"&&Tt.push(Ei);let yi=new chrome.cast.media.Track(Ei,chrome.cast.media.TrackType.TEXT);return yi.trackContentId=Zt.src,yi.trackContentType="text/vtt",yi.subtype=Zt.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,yi.name=Zt.label,yi.language=Zt.srclang,yi})),this.castStreamType==="live"?Ie.streamType=chrome.cast.media.StreamType.LIVE:Ie.streamType=chrome.cast.media.StreamType.BUFFERED,Ie.metadata=new chrome.cast.media.GenericMediaMetadata,Ie.metadata.title=this.title,Ie.metadata.images=[{url:this.poster}];let tr=new chrome.cast.media.LoadRequest(Ie);tr.currentTime=(H=super.currentTime)!=null?H:0,tr.autoplay=!ee(this,k).paused,tr.activeTrackIds=Tt,await((Z=ee(e,c,h))==null?void 0:Z.loadMedia(tr)),this.dispatchEvent(new Event("volumechange"))}play(){var H;if(this.castPlayer){this.castPlayer.isPaused&&((H=this.castPlayer.controller)==null||H.playOrPause());return}return super.play()}pause(){var H;if(this.castPlayer){this.castPlayer.isPaused||(H=this.castPlayer.controller)==null||H.playOrPause();return}super.pause()}get castSrc(){var H,Z,Ie;return(Ie=(Z=this.getAttribute("cast-src"))!=null?Z:(H=this.querySelector("source"))==null?void 0:H.src)!=null?Ie:this.currentSrc}set castSrc(H){this.castSrc!=H&&this.setAttribute("cast-src",`${H}`)}get castContentType(){var H;return(H=this.getAttribute("cast-content-type"))!=null?H:void 0}set castContentType(H){this.setAttribute("cast-content-type",`${H}`)}get castStreamType(){var H,Z;return(Z=(H=this.getAttribute("cast-stream-type"))!=null?H:this.streamType)!=null?Z:void 0}set castStreamType(H){this.setAttribute("cast-stream-type",`${H}`)}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 H;return this.castPlayer?(H=this.castPlayer)==null?void 0:H.isMuted:super.muted}set muted(H){var Z;if(this.castPlayer){(H&&!this.castPlayer.isMuted||!H&&this.castPlayer.isMuted)&&((Z=this.castPlayer.controller)==null||Z.muteOrUnmute());return}super.muted=H}get volume(){var H,Z;return this.castPlayer?(Z=(H=this.castPlayer)==null?void 0:H.volumeLevel)!=null?Z:1:super.volume}set volume(H){var Z;if(this.castPlayer){this.castPlayer.volumeLevel=H,(Z=this.castPlayer.controller)==null||Z.setVolumeLevel();return}super.volume=H}get duration(){var H,Z;return this.castPlayer&&ee(this,z,j)?(Z=(H=this.castPlayer)==null?void 0:H.duration)!=null?Z:NaN:super.duration}get currentTime(){var H,Z;return this.castPlayer&&ee(this,z,j)?(Z=(H=this.castPlayer)==null?void 0:H.currentTime)!=null?Z:0:super.currentTime}set currentTime(H){var Z;if(this.castPlayer){this.castPlayer.currentTime=H,(Z=this.castPlayer.controller)==null||Z.seek();return}super.currentTime=H}get onentercast(){return ee(this,G)}set onentercast(H){ee(this,G)&&(this.removeEventListener("entercast",ee(this,G)),Ve(this,G,null)),typeof H=="function"&&(Ve(this,G,H),this.addEventListener("entercast",H))}get onleavecast(){return ee(this,W)}set onleavecast(H){ee(this,W)&&(this.removeEventListener("leavecast",ee(this,W)),Ve(this,W,null)),typeof H=="function"&&(Ve(this,W,H),this.addEventListener("leavecast",H))}get oncastchange(){return ee(this,O)}set oncastchange(H){ee(this,O)&&(this.removeEventListener("castchange",ee(this,O)),Ve(this,O,null)),typeof H=="function"&&(Ve(this,O,H),this.addEventListener("castchange",H))}},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,u=function(){if(ee(e,o,l))return cast.framework.CastContext.getInstance()},c=new WeakSet,h=function(){var H;return(H=ee(e,d,u))==null?void 0:H.getCurrentSession()},m=new WeakSet,g=function(){var H;return(H=ee(e,c,h))==null?void 0:H.getSessionObj().media[0]},E=new WeakSet,T=function(H){return new Promise((Z,Ie)=>{ee(e,m,g).editTracksInfo(H,Z,Ie)})},A=new WeakSet,L=function(H){return new Promise((Z,Ie)=>{ee(e,m,g).getStatus(H,Z,Ie)})},S=new WeakSet,P=function(H){return ee(e,d,u).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...H})},k=new WeakMap,$=new WeakMap,M=new WeakMap,G=new WeakMap,W=new WeakMap,O=new WeakMap,z=new WeakSet,j=function(){var H;return(H=this.castPlayer)==null?void 0:H.isMediaLoaded},be=new WeakSet,ge=function(){ee(e,t)===this&&(Object.entries(ee(this,M)).forEach(([H,Z])=>{ee(this,$).controller.removeEventListener(H,Z)}),Ve(e,t,void 0),this.muted=ee(this,$).isMuted,this.currentTime=ee(this,$).savedPlayerState.currentTime,ee(this,$).savedPlayerState.isPaused===!1&&this.play())},ve=new WeakSet,Re=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:ee(e,d,u).getCastState()}))},Te=new WeakSet,Q=async function(){var H,Z;let{SESSION_RESUMED:Ie}=cast.framework.SessionState;if(ee(e,d,u).getSessionState()===Ie&&this.castSrc===((H=ee(e,m,g))==null?void 0:H.media.contentId)){Ve(e,t,this),Object.entries(ee(this,M)).forEach(([je,Tt])=>{ee(this,$).controller.addEventListener(je,Tt)});try{await it(Z=e,A,L).call(Z,new chrome.cast.media.GetStatusRequest)}catch(je){console.error(je)}ee(this,M)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),ee(this,M)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},ie=new WeakSet,re=function(){var H;!ee(e,o,l)||this.castEnabled||(this.castEnabled=!0,it(H=e,S,P).call(H),this.textTracks.addEventListener("change",it(this,Ne,ut).bind(this)),it(this,ve,Re).call(this),Ve(this,$,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(ee(this,$)),Ve(this,M,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:Z})=>{Z===!1&&it(this,be,ge).call(this),this.dispatchEvent(new Event(Z?"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]:()=>{!ee(this,z,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 Z,Ie;((Z=this.castPlayer)==null?void 0:Z.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"}[(Ie=this.castPlayer)==null?void 0:Ie.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!ee(this,z,j)||(await Promise.resolve(),it(this,_e,Se).call(this))}}))},_e=new WeakSet,Se=function(){it(this,Ne,ut).call(this)},Ne=new WeakSet,ut=async function(){var H,Z,Ie,je,Tt,zt;if(!this.castPlayer)return;let tr=((Z=(H=ee(this,$).mediaInfo)==null?void 0:H.tracks)!=null?Z:[]).filter(({type:Je})=>Je===chrome.cast.media.TrackType.TEXT),Zt=[...this.textTracks].filter(({kind:Je})=>Je==="subtitles"||Je==="captions"),Ei=tr.map(({language:Je,name:_r,trackId:Ks})=>{var Ws;let{mode:ea}=(Ws=Zt.find(qs=>qs.language===Je&&qs.label===_r))!=null?Ws:{};return ea?{mode:ea,trackId:Ks}:!1}).filter(Boolean),yi=Ei.filter(({mode:Je})=>Je!=="showing").map(({trackId:Je})=>Je),Zr=Ei.find(({mode:Je})=>Je==="showing"),Vs=(Tt=(je=(Ie=ee(e,c,h))==null?void 0:Ie.getSessionObj().media[0])==null?void 0:je.activeTrackIds)!=null?Tt:[],li=Vs;if(Vs.length&&(li=li.filter(Je=>!yi.includes(Je))),Zr!=null&&Zr.trackId&&(li=[...li,Zr.trackId]),li=[...new Set(li)],!((Je,_r)=>Je.length===_r.length&&Je.every(Ks=>_r.includes(Ks)))(Vs,li))try{let Je=new chrome.cast.media.EditTracksInfoRequest(li);await it(zt=e,E,T).call(zt,Je)}catch(Je){console.error(Je)}},Ae(e,n),Ae(e,o),Ae(e,d),Ae(e,c),Ae(e,m),Ae(e,E),Ae(e,A),Ae(e,S),Os(e,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Os(e,"instances",new Set),Ae(e,t,void 0),Ae(e,i,!1),Os(e,"initCast",()=>{var H;ee(e,n,a)?ee(e,o,l)?ee(H=e,s).call(H,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var Z;return ee(Z=e,s).call(Z,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var Z;return ee(Z=e,s).call(Z,chrome.cast.isAvailable)})}}),Ae(e,s,H=>{if(H){Ve(e,i,!0);let{CAST_STATE_CHANGED:Z}=cast.framework.CastContextEventType;ee(e,d,u).addEventListener(Z,je=>{e.instances.forEach(Tt=>{var zt;return it(zt=Tt,ve,Re).call(zt,je)})});let{SESSION_STATE_CHANGED:Ie}=cast.framework.CastContextEventType;ee(e,d,u).addEventListener(Ie,je=>{e.instances.forEach(Tt=>{var zt;return it(zt=Tt,Te,Q).call(zt,je)})}),e.instances.forEach(je=>{var Tt;return it(Tt=je,ie,re).call(Tt)})}}),e},kc=globalThis.HTMLVideoElement?wg(HTMLVideoElement):wg(Object);globalThis.customElements&&!globalThis.customElements.get("castable-video")&&(customElements.define("castable-video",kc,{extends:"video"}),globalThis.CastableVideoElement=kc);kc.initCast();var Qo=["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"],kg,Dc=(kg=globalThis.document)==null?void 0:kg.createElement("template");Dc&&(Dc.innerHTML=`
|
|
915
914
|
<style>
|
|
916
915
|
:host {
|
|
917
916
|
display: inline-block;
|
|
@@ -926,7 +925,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
|
|
|
926
925
|
}
|
|
927
926
|
</style>
|
|
928
927
|
<slot></slot>
|
|
929
|
-
`);var
|
|
928
|
+
`);var Dg,Cc=(Dg=globalThis.document)==null?void 0:Dg.createElement("template");Cc&&(Cc.innerHTML=`
|
|
930
929
|
<style>
|
|
931
930
|
:host {
|
|
932
931
|
display: inline-block;
|
|
@@ -948,8 +947,8 @@ svg, img, ::slotted(svg), ::slotted(img) {
|
|
|
948
947
|
}
|
|
949
948
|
</style>
|
|
950
949
|
<slot></slot>
|
|
951
|
-
`);var dh=(n,{tag:r,is:o})=>{var m,v,y,I,M,U,H,z,J,Z,se,me,Te;let ge=(m=globalThis.document)==null?void 0:m.createElement(r,{is:o}),ye=ge?h0(ge):[];return v=class extends n{constructor(){super(),Ye(this,z),Ye(this,Z),Ye(this,me),Ye(this,U,void 0),Ye(this,H,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var Ee,de,Be;return wt(Ee=v,I,M).call(Ee),[...(Be=(de=ge==null?void 0:ge.constructor)==null?void 0:de.observedAttributes)!=null?Be:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var Ee,de;return(de=(Ee=pe(this,H))!=null?Ee:this.shadowRoot.querySelector(r))!=null?de:this.querySelector(r)}set nativeEl(Ee){mt(this,H,Ee)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(Ee){this.toggleAttribute("muted",Boolean(Ee))}get src(){return this.getAttribute("src")}set src(Ee){this.setAttribute("src",`${Ee}`)}get preload(){var Ee,de;return(de=this.getAttribute("preload"))!=null?de:(Ee=this.nativeEl)==null?void 0:Ee.preload}set preload(Ee){this.setAttribute("preload",`${Ee}`)}attributeChangedCallback(Ee,de,Be){wt(this,z,J).call(this),wt(this,me,Te).call(this,Ee,de,Be)}connectedCallback(){wt(this,z,J).call(this)}},y=new WeakMap,I=new WeakSet,M=function(){if(pe(this,y))return;mt(this,y,!0);let Ee=new Set(this.observedAttributes);Ee.delete("muted");for(let de of ye)if(!(de in this.prototype))if(typeof ge[de]=="function")this.prototype[de]=function(...Be){return wt(this,z,J).call(this),(()=>this.call?this.call(de,...Be):this.nativeEl[de].apply(this.nativeEl,Be))()};else{let Be={get(){var Ge,re,k;wt(this,z,J).call(this);let oe=de.toLowerCase();if(Ee.has(oe)){let q=this.getAttribute(oe);return q===null?!1:q===""?!0:q}return(k=(Ge=this.get)==null?void 0:Ge.call(this,de))!=null?k:(re=this.nativeEl)==null?void 0:re[de]}};de!==de.toUpperCase()&&(Be.set=function(Ge){wt(this,z,J).call(this);let re=de.toLowerCase();if(Ee.has(re)){Ge===!0||Ge===!1||Ge==null?this.toggleAttribute(re,Boolean(Ge)):this.setAttribute(re,Ge);return}if(this.set){this.set(de,Ge);return}this.nativeEl[de]=Ge}),Object.defineProperty(this.prototype,de,Be)}},U=new WeakMap,H=new WeakMap,z=new WeakSet,J=function(){var Ee,de;if(pe(this,U))return;if(mt(this,U,!0),!this.nativeEl){let re=document.createElement(r,{is:o});re.part=r,this.shadowRoot.append(re)}this.nativeEl.muted=this.hasAttribute("muted");for(let re of ye)wt(this,Z,se).call(this,re);let Be=new Map,Ge=this.shadowRoot.querySelector("slot:not([name])");Ge==null||Ge.addEventListener("slotchange",()=>{let re=new Map(Be);Ge.assignedElements().filter(k=>["track","source"].includes(k.localName)).forEach(k=>{var oe,q;re.delete(k);let Se=Be.get(k);Se||(Se=k.cloneNode(),Be.set(k,Se)),(q=(oe=this.nativeEl).append)==null||q.call(oe,Se)}),re.forEach(k=>k.remove())});for(let re of this.constructor.Events)(de=(Ee=this.shadowRoot).addEventListener)==null||de.call(Ee,re,k=>{k.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(k.type,{detail:k.detail}))},!0)},Z=new WeakSet,se=function(Ee){if(Object.prototype.hasOwnProperty.call(this,Ee)){let de=this[Ee];delete this[Ee],this[Ee]=de}},me=new WeakSet,Te=function(Ee,de,Be){var Ge,re,k,oe;["id","class"].includes(Ee)||(Be===null?(re=(Ge=this.nativeEl).removeAttribute)==null||re.call(Ge,Ee):(oe=(k=this.nativeEl).setAttribute)==null||oe.call(k,Ee,Be))},Ye(v,I),Yn(v,"Events",gu),Yn(v,"template",r.endsWith("audio")?ah:nh),Ye(v,y,void 0),v};function h0(n){let r=[];for(let o=Object.getPrototypeOf(n);o&&o!==HTMLElement.prototype;o=Object.getPrototypeOf(o))r.push(...Object.getOwnPropertyNames(o));return r}var qS=globalThis.document?dh(HTMLElement,{tag:"video"}):class{},YS=globalThis.document?dh(HTMLElement,{tag:"audio"}):class{};gu.push("castchange","entercast","leavecast");var ih=dh(du.HTMLElement,{tag:"video",is:"castable-video"}),ne={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"},f0=Object.values(ne),m0=c0(),p0="mux-video",Br,Xs,cu,Zs,hu,fu,mu,pu,sh,oh=class extends ih{constructor(){super(),Ye(this,pu),Ye(this,Br,void 0),Ye(this,Xs,void 0),Ye(this,cu,void 0),Ye(this,Zs,{}),Ye(this,hu,void 0),Ye(this,fu,void 0),Ye(this,mu,void 0),mt(this,cu,Up())}static get observedAttributes(){var n;return[...f0,...(n=ih.observedAttributes)!=null?n:[]]}get preferCmcd(){var n;return(n=this.getAttribute(ne.PREFER_CMCD))!=null?n:void 0}set preferCmcd(n){n!==this.preferCmcd&&(n?qn.includes(n)?this.setAttribute(ne.PREFER_CMCD,n):console.warn(`Invalid value for preferCmcd. Must be one of ${qn.join()}`):this.removeAttribute(ne.PREFER_CMCD))}get playerInitTime(){return pe(this,cu)}get playerSoftwareName(){var n;return(n=pe(this,fu))!=null?n:p0}set playerSoftwareName(n){mt(this,fu,n)}get playerSoftwareVersion(){var n;return(n=pe(this,hu))!=null?n:m0}set playerSoftwareVersion(n){mt(this,hu,n)}get _hls(){var n;return(n=pe(this,Br))==null?void 0:n.engine}get mux(){return this.nativeEl.mux}get error(){var n;return(n=Hp(this.nativeEl))!=null?n:null}get errorTranslator(){return pe(this,mu)}set errorTranslator(n){mt(this,mu,n)}get src(){return this.getAttribute("src")}set src(n){n!==this.src&&(n==null?this.removeAttribute("src"):this.setAttribute("src",n))}get type(){var n;return(n=this.getAttribute(ne.TYPE))!=null?n:void 0}set type(n){n!==this.type&&(n?this.setAttribute(ne.TYPE,n):this.removeAttribute(ne.TYPE))}get autoplay(){let n=this.getAttribute("autoplay");return n===null?!1:n===""?!0:n}set autoplay(n){let r=this.autoplay;n!==r&&(n?this.setAttribute("autoplay",typeof n=="string"?n:""):this.removeAttribute("autoplay"))}get preload(){let n=this.getAttribute("preload");return n===""?"auto":["none","metadata","auto"].includes(n)?n:super.preload}set preload(n){n!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(n)?this.setAttribute("preload",n):this.removeAttribute("preload"))}get debug(){return this.getAttribute(ne.DEBUG)!=null}set debug(n){n!==this.debug&&(n?this.setAttribute(ne.DEBUG,""):this.removeAttribute(ne.DEBUG))}get disableCookies(){return this.hasAttribute(ne.DISABLE_COOKIES)}set disableCookies(n){n!==this.disableCookies&&(n?this.setAttribute(ne.DISABLE_COOKIES,""):this.removeAttribute(ne.DISABLE_COOKIES))}get startTime(){let n=this.getAttribute(ne.START_TIME);if(n==null)return;let r=+n;return Number.isNaN(r)?void 0:r}set startTime(n){n!==this.startTime&&(n==null?this.removeAttribute(ne.START_TIME):this.setAttribute(ne.START_TIME,`${n}`))}get playbackId(){var n;return(n=this.getAttribute(ne.PLAYBACK_ID))!=null?n:void 0}set playbackId(n){n!==this.playbackId&&(n?this.setAttribute(ne.PLAYBACK_ID,n):this.removeAttribute(ne.PLAYBACK_ID))}get maxResolution(){var n;return(n=this.getAttribute(ne.MAX_RESOLUTION))!=null?n:void 0}set maxResolution(n){n!==this.maxResolution&&(n?this.setAttribute(ne.MAX_RESOLUTION,n):this.removeAttribute(ne.MAX_RESOLUTION))}get customDomain(){var n;return(n=this.getAttribute(ne.CUSTOM_DOMAIN))!=null?n:void 0}set customDomain(n){n!==this.customDomain&&(n?this.setAttribute(ne.CUSTOM_DOMAIN,n):this.removeAttribute(ne.CUSTOM_DOMAIN))}get ended(){return eh(this.nativeEl,this._hls)}get envKey(){var n;return(n=this.getAttribute(ne.ENV_KEY))!=null?n:void 0}set envKey(n){n!==this.envKey&&(n?this.setAttribute(ne.ENV_KEY,n):this.removeAttribute(ne.ENV_KEY))}get beaconCollectionDomain(){var n;return(n=this.getAttribute(ne.BEACON_COLLECTION_DOMAIN))!=null?n:void 0}set beaconCollectionDomain(n){n!==this.beaconCollectionDomain&&(n?this.setAttribute(ne.BEACON_COLLECTION_DOMAIN,n):this.removeAttribute(ne.BEACON_COLLECTION_DOMAIN))}get streamType(){var n;return(n=this.getAttribute(ne.STREAM_TYPE))!=null?n:Gp(this.nativeEl)}set streamType(n){n!==this.streamType&&(n?this.setAttribute(ne.STREAM_TYPE,n):this.removeAttribute(ne.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(ne.TARGET_LIVE_WINDOW)?+this.getAttribute(ne.TARGET_LIVE_WINDOW):Vp(this.nativeEl)}set targetLiveWindow(n){n!=this.targetLiveWindow&&(n==null?this.removeAttribute(ne.TARGET_LIVE_WINDOW):this.setAttribute(ne.TARGET_LIVE_WINDOW,`${+n}`))}get liveEdgeStart(){var n,r;if(this.hasAttribute(ne.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:o}=this,m=(n=this.nativeEl.seekable.end(0))!=null?n:0,v=(r=this.nativeEl.seekable.start(0))!=null?r:0;return Math.max(v,m-o)}return Kp(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(ne.LIVE_EDGE_OFFSET))return+this.getAttribute(ne.LIVE_EDGE_OFFSET)}set liveEdgeOffset(n){n!=this.targetLiveWindow&&(n==null?this.removeAttribute(ne.LIVE_EDGE_OFFSET):this.setAttribute(ne.LIVE_EDGE_OFFSET,`${+n}`))}get seekable(){return Jc(this.nativeEl)}async addCuePoints(n){return Xc(this.nativeEl,n)}get activeCuePoint(){return Zc(this.nativeEl)}get cuePoints(){return xp(this.nativeEl)}getStartDate(){return Pp(this.nativeEl,this._hls)}get currentPdt(){return Op(this.nativeEl,this._hls)}get preferPlayback(){let n=this.getAttribute(ne.PREFER_PLAYBACK);if(n===Yi.MSE||n===Yi.NATIVE)return n}set preferPlayback(n){n!==this.preferPlayback&&(n===Yi.MSE||n===Yi.NATIVE?this.setAttribute(ne.PREFER_PLAYBACK,n):this.removeAttribute(ne.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(n=>n.startsWith("metadata-")&&![ne.METADATA_URL].includes(n)).reduce((n,r)=>{let o=this.getAttribute(r);return o!=null&&(n[r.replace(/^metadata-/,"").replace(/-/g,"_")]=o),n},{}),...pe(this,Zs)}}set metadata(n){mt(this,Zs,n!=null?n:{}),this.mux&&this.mux.emit("hb",pe(this,Zs))}load(){mt(this,Br,qp(this,this.nativeEl,pe(this,Br)))}unload(){th(this.nativeEl,pe(this,Br)),mt(this,Br,void 0)}attributeChangedCallback(n,r,o){var m,v;switch(ih.observedAttributes.includes(n)&&!["src","autoplay","preload"].includes(n)&&super.attributeChangedCallback(n,r,o),n){case ne.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=o!=null?o:void 0;break;case ne.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=o!=null?o:void 0;break;case"src":{let y=!!r,I=!!o;!y&&I?wt(this,pu,sh).call(this):y&&!I?this.unload():y&&I&&(this.unload(),wt(this,pu,sh).call(this));break}case"autoplay":if(o===r)break;(m=pe(this,Br))==null||m.setAutoplay(this.autoplay);break;case"preload":if(o===r)break;(v=pe(this,Br))==null||v.setPreload(o);break;case ne.PLAYBACK_ID:this.src=Bp(o!=null?o:void 0,{maxResolution:this.maxResolution,domain:this.customDomain});break;case ne.DEBUG:{let y=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=y);break}case ne.METADATA_URL:o&&fetch(o).then(y=>y.json()).then(y=>this.metadata=y).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${o}!`));break;case ne.STREAM_TYPE:(o==null||o!==r)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case ne.TARGET_LIVE_WINDOW:(o==null||o!==r)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}disconnectedCallback(){this.unload()}};Br=new WeakMap,Xs=new WeakMap,cu=new WeakMap,Zs=new WeakMap,hu=new WeakMap,fu=new WeakMap,mu=new WeakMap,pu=new WeakSet,sh=async function(){pe(this,Xs)||(await mt(this,Xs,Promise.resolve()),mt(this,Xs,null),this.load())};du.customElements.get("mux-video")||(du.customElements.define("mux-video",oh),du.MuxVideoElement=oh);var tv=oh;var v0="en",ja={code:v0};var iv="en";function Qe(n,r=!0){var v,y;let o=r&&(y=(v=ja)==null?void 0:v[n])!=null?y:n,m=r?ja.code:iv;return new ch(o,m)}var ch=class{constructor(r,o=(m=>(m=ja.code)!=null?m:iv)()){this.message=r,this.locale=o}format(r){return this.message.replace(/\{(\w+)\}/g,(o,m)=>{var v;return(v=r[m])!=null?v:""})}toString(){return this.message}};function rv(n){let r="";return Object.entries(n).forEach(([o,m])=>{m!=null&&(r+=`${Eu(o)}: ${m}; `)}),r?r.trim():void 0}function Eu(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function yu(n){return n.replace(/[-_]([a-z])/g,(r,o)=>o.toUpperCase())}function Hr(n){if(n==null)return;let r=+n;return Number.isNaN(r)?void 0:r}function bu(n){let r=g0(n).toString();return r?"?"+r:""}function g0(n){let r={};for(let o in n)n[o]!=null&&(r[o]=n[o]);return new URLSearchParams(r)}function ua(n){let r=(n!=null?n:"").split(".")[1];if(!r)return{};let o=r.replace(/-/g,"+").replace(/_/g,"/"),m=decodeURIComponent(atob(o).split("").map(function(v){return"%"+("00"+v.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(m)}var hh=(n,r)=>!n||!r?!1:n.contains(r)?!0:hh(n,r.getRootNode().host);var fh="mux.com",E0=()=>{try{return"1.11.3"}catch{}return"UNKNOWN"},y0=E0(),_u=()=>y0,mh=(n,{maxResolution:r,token:o,domain:m=fh}={})=>{let I=!!o?{token:o}:{redundant_streams:!0,...r?{max_resolution:r}:{}};return`https://stream.${m}/${n}.m3u8${bu(I)}`},av=(n,{token:r,thumbnailTime:o,domain:m=fh}={})=>{let v=r==null?o:void 0,{aud:y}=ua(r);if(!(r&&y!=="t"))return`https://image.${m}/${n}/thumbnail.webp${bu({token:r,time:v})}`},nv=(n,{token:r,domain:o=fh}={})=>{let{aud:m}=ua(r);if(!(r&&m!=="s"))return`https://image.${o}/${n}/storyboard.vtt${bu({token:r,format:"webp"})}`},Js=n=>{if(!!n){if([gt.LIVE,gt.ON_DEMAND].includes(n))return n;if(n!=null&&n.includes("live"))return gt.LIVE}};var b0={crossorigin:"crossOrigin",playsinline:"playsInline"};function sv(n){var r;return(r=b0[n])!=null?r:yu(n)}var za,Qa,mi,Tu=class{constructor(r,o){Ht(this,za,void 0);Ht(this,Qa,void 0);Ht(this,mi,[]);Gi(this,za,r),Gi(this,Qa,o)}[Symbol.iterator](){return ot(this,mi).values()}get length(){return ot(this,mi).length}get value(){var r;return(r=ot(this,mi).join(" "))!=null?r:""}set value(r){var o;r!==this.value&&(Gi(this,mi,[]),this.add(...(o=r==null?void 0:r.split(" "))!=null?o:[]))}toString(){return this.value}item(r){return ot(this,mi)[r]}values(){return ot(this,mi).values()}keys(){return ot(this,mi).keys()}forEach(r){ot(this,mi).forEach(r)}add(...r){var o,m;r.forEach(v=>{this.contains(v)||ot(this,mi).push(v)}),!(this.value===""&&!((o=ot(this,za))!=null&&o.hasAttribute(`${ot(this,Qa)}`)))&&((m=ot(this,za))==null||m.setAttribute(`${ot(this,Qa)}`,`${this.value}`))}remove(...r){var o;r.forEach(m=>{ot(this,mi).splice(ot(this,mi).indexOf(m),1)}),(o=ot(this,za))==null||o.setAttribute(`${ot(this,Qa)}`,`${this.value}`)}contains(r){return ot(this,mi).includes(r)}toggle(r,o){return typeof o!="undefined"?o?(this.add(r),!0):(this.remove(r),!1):this.contains(r)?(this.remove(r),!1):(this.add(r),!0)}replace(r,o){this.remove(r),this.add(o)}};za=new WeakMap,Qa=new WeakMap,mi=new WeakMap;var ov=`[mux-player ${_u()}]`;function da(...n){console.warn(ov,...n)}function tr(...n){console.error(ov,...n)}function ph(n){var o;let r=(o=n.message)!=null?o:"";if(n.context&&(r+=` ${n.context}`),n.file){let m="https://github.com/muxinc/elements/blob/main/errors/";r+=` ${Qe("Read more: ")}
|
|
952
|
-
${m}${n.file}`}da(r)}var ui={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},Xa={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},uv=Object.freeze({length:0,start(n){let r=n>>>0;if(r>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${r}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(n){let r=n>>>0;if(r>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${r}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),T0=gu.filter(n=>n!=="error"),_0=Object.values(ui).filter(n=>![ui.PLAYSINLINE].includes(n)),A0=Object.values(Xa);function dv(n){n.querySelectorAll(":scope > track").forEach(r=>{var o;(o=n.media)==null||o.append(r.cloneNode())}),T0.forEach(r=>{var o;(o=n.media)==null||o.addEventListener(r,m=>{n.dispatchEvent(new Event(m.type))})})}var vh=class extends Yt.HTMLElement{static get observedAttributes(){return[..._0,...A0]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(m=>{var v;(v=this.media)==null||v.append(m.cloneNode())});let r=m=>{for(let v of m)v.type==="childList"&&(v.removedNodes.forEach(y=>{var M,U;let I=(M=this.media)==null?void 0:M.querySelector(`track[src="${y.src}"]`);I&&((U=this.media)==null||U.removeChild(I))}),v.addedNodes.forEach(y=>{var I;(I=this.media)==null||I.append(y.cloneNode())}))};new MutationObserver(r).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(r,o,m){var v,y;switch(r){case Xa.MUTED:{this.media&&(this.media.muted=m!=null,this.media.defaultMuted=m!=null);return}case Xa.VOLUME:{let I=(v=Hr(m))!=null?v:1;this.media&&(this.media.volume=I);return}case Xa.PLAYBACKRATE:{let I=(y=Hr(m))!=null?y:1;this.media&&(this.media.playbackRate=I,this.media.defaultPlaybackRate=I);return}}}play(){var r,o;return(o=(r=this.media)==null?void 0:r.play())!=null?o:Promise.reject()}pause(){var r;(r=this.media)==null||r.pause()}requestCast(r){var o;return(o=this.media)==null?void 0:o.requestCast(r)}get media(){var r;return(r=this.shadowRoot)==null?void 0:r.querySelector("mux-video")}get paused(){var r,o;return(o=(r=this.media)==null?void 0:r.paused)!=null?o:!0}get duration(){var r,o;return(o=(r=this.media)==null?void 0:r.duration)!=null?o:NaN}get ended(){var r,o;return(o=(r=this.media)==null?void 0:r.ended)!=null?o:!1}get buffered(){var r,o;return(o=(r=this.media)==null?void 0:r.buffered)!=null?o:uv}get seekable(){var r,o;return(o=(r=this.media)==null?void 0:r.seekable)!=null?o:uv}get readyState(){var r,o;return(o=(r=this.media)==null?void 0:r.readyState)!=null?o:0}get videoWidth(){var r,o;return(o=(r=this.media)==null?void 0:r.videoWidth)!=null?o:0}get videoHeight(){var r,o;return(o=(r=this.media)==null?void 0:r.videoHeight)!=null?o:0}get currentTime(){var r,o;return(o=(r=this.media)==null?void 0:r.currentTime)!=null?o:0}set currentTime(r){this.media&&(this.media.currentTime=Number(r))}get volume(){var r,o;return(o=(r=this.media)==null?void 0:r.volume)!=null?o:1}set volume(r){this.media&&(this.media.volume=Number(r))}get playbackRate(){var r,o;return(o=(r=this.media)==null?void 0:r.playbackRate)!=null?o:1}set playbackRate(r){this.media&&(this.media.playbackRate=Number(r))}get defaultPlaybackRate(){var r;return(r=Hr(this.getAttribute(Xa.PLAYBACKRATE)))!=null?r:1}set defaultPlaybackRate(r){r!=null?this.setAttribute(Xa.PLAYBACKRATE,`${r}`):this.removeAttribute(Xa.PLAYBACKRATE)}get crossOrigin(){return eo(this,ui.CROSSORIGIN)}set crossOrigin(r){this.setAttribute(ui.CROSSORIGIN,`${r}`)}get autoplay(){return eo(this,ui.AUTOPLAY)!=null}set autoplay(r){r?this.setAttribute(ui.AUTOPLAY,typeof r=="string"?r:""):this.removeAttribute(ui.AUTOPLAY)}get loop(){return eo(this,ui.LOOP)!=null}set loop(r){r?this.setAttribute(ui.LOOP,""):this.removeAttribute(ui.LOOP)}get muted(){var r,o;return(o=(r=this.media)==null?void 0:r.muted)!=null?o:!1}set muted(r){this.media&&(this.media.muted=Boolean(r))}get defaultMuted(){return eo(this,ui.MUTED)!=null}set defaultMuted(r){r?this.setAttribute(ui.MUTED,""):this.removeAttribute(ui.MUTED)}get playsInline(){return eo(this,ui.PLAYSINLINE)!=null}set playsInline(r){tr("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(r){["","none","metadata","auto"].includes(r)?this.setAttribute(ui.PRELOAD,r):this.removeAttribute(ui.PRELOAD)}};function eo(n,r){return n.media?n.media.getAttribute(r):n.getAttribute(r)}var gh=vh;var S0=Object.defineProperty,k0=(n,r,o)=>r in n?S0(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o,w0=(n,r,o)=>(k0(n,typeof r!="symbol"?r+"":r,o),o),pv=(n,r,o)=>{if(!r.has(n))throw TypeError("Cannot "+o)},ze=(n,r,o)=>(pv(n,r,"read from private field"),o?o.call(n):r.get(n)),Er=(n,r,o)=>{if(r.has(n))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(n):r.set(n,o)},Gr=(n,r,o,m)=>(pv(n,r,"write to private field"),m?m.call(n,o):r.set(n,o),o),$n,Au,Za,to,ca,ha,fa,Ja,jn,Su,ir,cv=1,hv=0,L0=1,I0={processCallback(n,r,o){if(!!o){for(let[m,v]of r)if(m in o){let y=o[m];typeof y=="boolean"&&v instanceof pi&&typeof v.element[v.attributeName]=="boolean"?v.booleanValue=y:typeof y=="function"&&v instanceof pi?v.element[v.attributeName]=y:v.value=y}}}},Vr=class extends W.DocumentFragment{constructor(r,o,m=I0){var v;super(),Er(this,$n,void 0),Er(this,Au,void 0),this.append(r.content.cloneNode(!0)),Gr(this,$n,vv(this)),Gr(this,Au,m),(v=m.createCallback)==null||v.call(m,this,ze(this,$n),o),m.processCallback(this,ze(this,$n),o)}update(r){ze(this,Au).processCallback(this,ze(this,$n),r)}};$n=new WeakMap;Au=new WeakMap;var vv=(n,r=[])=>{let o,m;for(let v of n.attributes||[])if(v.value.includes("{{")){let y=new Eh;for([o,m]of mv(v.value))if(!o)y.append(m);else{let I=new pi(n,v.name,v.namespaceURI);y.append(I),r.push([m,I])}v.value=y.toString()}for(let v of n.childNodes)if(v.nodeType===cv&&!(v instanceof HTMLTemplateElement))vv(v,r);else if(v.nodeType===cv||v.data.includes("{{")){let y=[];if(v.data)for([o,m]of mv(v.data))if(!o)y.push(new Text(m));else{let I=new Kr(n);y.push(I),r.push([m,I])}else if(v instanceof HTMLTemplateElement){let I=new io(n,v);y.push(I),r.push([I.expression,I])}v.replaceWith(...y.flatMap(I=>I.replacementNodes||[I]))}return r},fv={},mv=n=>{let r="",o=0,m=fv[n],v=0,y;if(m)return m;for(m=[];y=n[v];v++)y==="{"&&n[v+1]==="{"&&n[v-1]!=="\\"&&n[v+2]&&++o==1?(r&&m.push([hv,r]),r="",v++):y==="}"&&n[v+1]==="}"&&n[v-1]!=="\\"&&!--o?(m.push([L0,r.trim()]),r="",v++):r+=y||"";return r&&m.push([hv,(o>0?"{{":"")+r]),fv[n]=m},R0=11,ku=class{get value(){return""}set value(r){}toString(){return this.value}},gv=new WeakMap,Eh=class{constructor(){Er(this,Za,[])}[Symbol.iterator](){return ze(this,Za).values()}get length(){return ze(this,Za).length}item(r){return ze(this,Za)[r]}append(...r){for(let o of r)o instanceof pi&&gv.set(o,this),ze(this,Za).push(o)}toString(){return ze(this,Za).join("")}};Za=new WeakMap;var pi=class extends ku{constructor(r,o,m){super(),Er(this,Ja),Er(this,to,""),Er(this,ca,void 0),Er(this,ha,void 0),Er(this,fa,void 0),Gr(this,ca,r),Gr(this,ha,o),Gr(this,fa,m)}get attributeName(){return ze(this,ha)}get attributeNamespace(){return ze(this,fa)}get element(){return ze(this,ca)}get value(){return ze(this,to)}set value(r){ze(this,to)!==r&&(Gr(this,to,r),!ze(this,Ja,jn)||ze(this,Ja,jn).length===1?r==null?ze(this,ca).removeAttributeNS(ze(this,fa),ze(this,ha)):ze(this,ca).setAttributeNS(ze(this,fa),ze(this,ha),r):ze(this,ca).setAttributeNS(ze(this,fa),ze(this,ha),ze(this,Ja,jn)))}get booleanValue(){return ze(this,ca).hasAttributeNS(ze(this,fa),ze(this,ha))}set booleanValue(r){if(!ze(this,Ja,jn)||ze(this,Ja,jn).length===1)this.value=r?"":null;else throw new DOMException("Value is not fully templatized")}};to=new WeakMap;ca=new WeakMap;ha=new WeakMap;fa=new WeakMap;Ja=new WeakSet;jn=function(){return gv.get(this)};var Kr=class extends ku{constructor(r,o){super(),Er(this,Su,void 0),Er(this,ir,void 0),Gr(this,Su,r),Gr(this,ir,o?[...o]:[new Text])}get replacementNodes(){return ze(this,ir)}get parentNode(){return ze(this,Su)}get nextSibling(){return ze(this,ir)[ze(this,ir).length-1].nextSibling}get previousSibling(){return ze(this,ir)[0].previousSibling}get value(){return ze(this,ir).map(r=>r.textContent).join("")}set value(r){this.replace(r)}replace(...r){let o=r.flat().flatMap(m=>m==null?[new Text]:m.forEach?[...m]:m.nodeType===R0?[...m.childNodes]:m.nodeType?[m]:[new Text(m)]);o.length||o.push(new Text),Gr(this,ir,D0(ze(this,ir)[0].parentNode,ze(this,ir),o,this.nextSibling))}};Su=new WeakMap;ir=new WeakMap;var io=class extends Kr{constructor(r,o){let m=o.getAttribute("directive")||o.getAttribute("type"),v=o.getAttribute("expression")||o.getAttribute(m)||"";v.startsWith("{{")&&(v=v.trim().slice(2,-2).trim()),super(r),w0(this,"directive"),this.expression=v,this.template=o,this.directive=m}};function D0(n,r,o,m=null){let v=0,y,I,M,U=o.length,H=r.length;for(;v<U&&v<H&&r[v]==o[v];)v++;for(;v<U&&v<H&&o[U-1]==r[H-1];)m=o[--H,--U];if(v==H)for(;v<U;)n.insertBefore(o[v++],m);if(v==U)for(;v<H;)n.removeChild(r[v++]);else{for(y=r[v];v<U;)M=o[v++],I=y?y.nextSibling:m,y==M?y=I:v<U&&o[v]==I?(n.replaceChild(M,y),y=I):n.insertBefore(M,y);for(;y!=m;)I=y.nextSibling,n.removeChild(y),y=I}return o}var Ev={string:n=>String(n)},Lu=class{constructor(r){this.template=r,this.state=void 0}},en=new WeakMap,tn=new WeakMap,yh={partial:(n,r)=>{r[n.expression]=new Lu(n.template)},if:(n,r)=>{var o;if(bv(n.expression,r))if(en.get(n)!==n.template){en.set(n,n.template);let m=new Vr(n.template,r,Iu);n.replace(m),tn.set(n,m)}else(o=tn.get(n))==null||o.update(r);else n.replace(""),en.delete(n),tn.delete(n)}},C0=Object.keys(yh),Iu={processCallback(n,r,o){var m,v;if(!!o)for(let[y,I]of r){if(I instanceof io){if(!I.directive){let U=C0.find(H=>I.template.hasAttribute(H));U&&(I.directive=U,I.expression=I.template.getAttribute(U))}(m=yh[I.directive])==null||m.call(yh,I,o);continue}let M=bv(y,o);if(M instanceof Lu){en.get(I)!==M.template?(en.set(I,M.template),M=new Vr(M.template,M.state,Iu),I.value=M,tn.set(I,M)):(v=tn.get(I))==null||v.update(M.state);continue}M?(I instanceof pi&&I.attributeName.startsWith("aria-")&&(M=String(M)),I instanceof pi?typeof M=="boolean"?I.booleanValue=M:typeof M=="function"?I.element[I.attributeName]=M:I.value=M:(I.value=M,en.delete(I),tn.delete(I))):I instanceof pi?I.value=void 0:(I.value=void 0,en.delete(I),tn.delete(I))}}},yv={"!":n=>!n,"!!":n=>!!n,"==":(n,r)=>n==r,"!=":(n,r)=>n!=r,">":(n,r)=>n>r,">=":(n,r)=>n>=r,"<":(n,r)=>n<r,"<=":(n,r)=>n<=r,"??":(n,r)=>n!=null?n:r,"|":(n,r)=>{var o;return(o=Ev[r])==null?void 0:o.call(Ev,n)}};function M0(n){return x0(n,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:r})=>r!=="ws")}function bv(n,r={}){var o,m,v,y,I,M,U;let H=M0(n);if(H.length===0||H.some(({type:z})=>!z))return ro(n);if(((o=H[0])==null?void 0:o.token)===">"){let z=r[(m=H[1])==null?void 0:m.token];if(!z)return ro(n);let J={...r};z.state=J;let Z=H.slice(2);for(let se=0;se<Z.length;se+=3){let me=(v=Z[se])==null?void 0:v.token,Te=(y=Z[se+1])==null?void 0:y.token,ge=(I=Z[se+2])==null?void 0:I.token;me&&Te==="="&&(J[me]=ao(ge,r))}return z}if(H.length===1)return wu(H[0])?ao(H[0].token,r):ro(n);if(H.length===2){let z=(M=H[0])==null?void 0:M.token,J=yv[z];if(!J||!wu(H[1]))return ro(n);let Z=ao(H[1].token,r);return J(Z)}if(H.length===3){let z=(U=H[1])==null?void 0:U.token,J=yv[z];if(!J||!wu(H[0])||!wu(H[2]))return ro(n);let Z=ao(H[0].token,r);if(z==="|")return J(Z,H[2].token);let se=ao(H[2].token,r);return J(Z,se)}}function ro(n){return console.warn(`Warning: invalid expression \`${n}\``),!1}function wu({type:n}){return["number","boolean","string","param"].includes(n)}function ao(n,r){let o=n[0],m=n.slice(-1);return n==="true"||n==="false"?n==="true":o===m&&["'",'"'].includes(o)?n.slice(1,-1):sl(n)?parseFloat(n):r[n]}function x0(n,r){let o,m,v,y=[];for(;n;){v=null,o=n.length;for(let I in r)m=r[I].exec(n),m&&m.index<o&&(v={token:m[0],type:I,matches:m.slice(1)},o=m.index);o&&y.push({token:n.substr(0,o),type:void 0}),v&&y.push(v),n=n.substr(o+(v?v.token.length:0))}return y}var P0=Object.defineProperty,O0=(n,r,o)=>r in n?P0(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o,so=(n,r,o)=>(O0(n,typeof r!="symbol"?r+"":r,o),o),kh=(n,r,o)=>{if(!r.has(n))throw TypeError("Cannot "+o)},_h=(n,r,o)=>(kh(n,r,"read from private field"),o?o.call(n):r.get(n)),no=(n,r,o)=>{if(r.has(n))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(n):r.set(n,o)},rn=(n,r,o,m)=>(kh(n,r,"write to private field"),m?m.call(n,o):r.set(n,o),o),bh=(n,r,o)=>(kh(n,r,"access private method"),o),zn,Ru,Qn,Ah,Tv,Du,Sh,Th={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},_v=ae.createElement("template");_v.innerHTML=`
|
|
950
|
+
`);var Fc=(r,{tag:e,is:t})=>{var i,s,n,a,o,l,d,u,c,h,m,g,E;let T=(i=globalThis.document)==null?void 0:i.createElement(e,{is:t}),A=T?T_(T):[];return s=class extends r{constructor(){super(),Ae(this,u),Ae(this,h),Ae(this,g),Ae(this,l,void 0),Ae(this,d,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var L,S,P;return it(L=s,a,o).call(L),[...(P=(S=T==null?void 0:T.constructor)==null?void 0:S.observedAttributes)!=null?P:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var L,S;return(S=(L=ee(this,d))!=null?L:this.shadowRoot.querySelector(e))!=null?S:this.querySelector(e)}set nativeEl(L){Ve(this,d,L)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(L){this.toggleAttribute("muted",Boolean(L))}get src(){return this.getAttribute("src")}set src(L){this.setAttribute("src",`${L}`)}get preload(){var L,S;return(S=this.getAttribute("preload"))!=null?S:(L=this.nativeEl)==null?void 0:L.preload}set preload(L){this.setAttribute("preload",`${L}`)}attributeChangedCallback(L,S,P){it(this,u,c).call(this),it(this,g,E).call(this,L,S,P)}connectedCallback(){it(this,u,c).call(this)}},n=new WeakMap,a=new WeakSet,o=function(){if(ee(this,n))return;Ve(this,n,!0);let L=new Set(this.observedAttributes);L.delete("muted");for(let S of A)if(!(S in this.prototype))if(typeof T[S]=="function")this.prototype[S]=function(...P){return it(this,u,c).call(this),(()=>this.call?this.call(S,...P):this.nativeEl[S].apply(this.nativeEl,P))()};else{let P={get(){var k,$,M;it(this,u,c).call(this);let G=S.toLowerCase();if(L.has(G)){let W=this.getAttribute(G);return W===null?!1:W===""?!0:W}return(M=(k=this.get)==null?void 0:k.call(this,S))!=null?M:($=this.nativeEl)==null?void 0:$[S]}};S!==S.toUpperCase()&&(P.set=function(k){it(this,u,c).call(this);let $=S.toLowerCase();if(L.has($)){k===!0||k===!1||k==null?this.toggleAttribute($,Boolean(k)):this.setAttribute($,k);return}if(this.set){this.set(S,k);return}this.nativeEl[S]=k}),Object.defineProperty(this.prototype,S,P)}},l=new WeakMap,d=new WeakMap,u=new WeakSet,c=function(){var L,S;if(ee(this,l))return;if(Ve(this,l,!0),!this.nativeEl){let $=document.createElement(e,{is:t});$.part=e,this.shadowRoot.append($)}this.nativeEl.muted=this.hasAttribute("muted");for(let $ of A)it(this,h,m).call(this,$);let P=new Map,k=this.shadowRoot.querySelector("slot:not([name])");k==null||k.addEventListener("slotchange",()=>{let $=new Map(P);k.assignedElements().filter(M=>["track","source"].includes(M.localName)).forEach(M=>{var G,W;$.delete(M);let O=P.get(M);O||(O=M.cloneNode(),P.set(M,O)),(W=(G=this.nativeEl).append)==null||W.call(G,O)}),$.forEach(M=>M.remove())});for(let $ of this.constructor.Events)(S=(L=this.shadowRoot).addEventListener)==null||S.call(L,$,M=>{M.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(M.type,{detail:M.detail}))},!0)},h=new WeakSet,m=function(L){if(Object.prototype.hasOwnProperty.call(this,L)){let S=this[L];delete this[L],this[L]=S}},g=new WeakSet,E=function(L,S,P){var k,$,M,G;["id","class"].includes(L)||(P===null?($=(k=this.nativeEl).removeAttribute)==null||$.call(k,L):(G=(M=this.nativeEl).setAttribute)==null||G.call(M,L,P))},Ae(s,a),Os(s,"Events",Qo),Os(s,"template",e.endsWith("audio")?Dc:Cc),Ae(s,n,void 0),s};function T_(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 sR=globalThis.document?Fc(HTMLElement,{tag:"video"}):class{},nR=globalThis.document?Fc(HTMLElement,{tag:"audio"}):class{};Qo.push("castchange","entercast","leavecast");var wc=Fc(Ko.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"},__=Object.values(Y),A_=b_(),S_="mux-video",Yi,Nn,Wo,Fn,qo,Yo,jo,zo,Mc,Oc=class extends wc{constructor(){super(),Ae(this,zo),Ae(this,Yi,void 0),Ae(this,Nn,void 0),Ae(this,Wo,void 0),Ae(this,Fn,{}),Ae(this,qo,void 0),Ae(this,Yo,void 0),Ae(this,jo,void 0),Ve(this,Wo,vg())}static get observedAttributes(){var r;return[...__,...(r=wc.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?Ms.includes(r)?this.setAttribute(Y.PREFER_CMCD,r):console.warn(`Invalid value for preferCmcd. Must be one of ${Ms.join()}`):this.removeAttribute(Y.PREFER_CMCD))}get playerInitTime(){return ee(this,Wo)}get playerSoftwareName(){var r;return(r=ee(this,Yo))!=null?r:S_}set playerSoftwareName(r){Ve(this,Yo,r)}get playerSoftwareVersion(){var r;return(r=ee(this,qo))!=null?r:A_}set playerSoftwareVersion(r){Ve(this,qo,r)}get _hls(){var r;return(r=ee(this,Yi))==null?void 0:r.engine}get mux(){return this.nativeEl.mux}get error(){var r;return(r=yg(this.nativeEl))!=null?r:null}get errorTranslator(){return ee(this,jo)}set errorTranslator(r){Ve(this,jo,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 Lc(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:bg(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):Tg(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 _g(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 Ic(this.nativeEl)}async addCuePoints(r){return Sc(this.nativeEl,r)}get activeCuePoint(){return xc(this.nativeEl)}get cuePoints(){return hg(this.nativeEl)}getStartDate(){return fg(this.nativeEl,this._hls)}get currentPdt(){return mg(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},{}),...ee(this,Fn)}}set metadata(r){Ve(this,Fn,r!=null?r:{}),this.mux&&this.mux.emit("hb",ee(this,Fn))}load(){Ve(this,Yi,Sg(this,this.nativeEl,ee(this,Yi)))}unload(){Rc(this.nativeEl,ee(this,Yi)),Ve(this,Yi,void 0)}attributeChangedCallback(r,e,t){var i,s;switch(wc.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?it(this,zo,Mc).call(this):n&&!a?this.unload():n&&a&&(this.unload(),it(this,zo,Mc).call(this));break}case"autoplay":if(t===e)break;(i=ee(this,Yi))==null||i.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=ee(this,Yi))==null||s.setPreload(t);break;case Y.PLAYBACK_ID:this.src=Eg(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()}};Yi=new WeakMap,Nn=new WeakMap,Wo=new WeakMap,Fn=new WeakMap,qo=new WeakMap,Yo=new WeakMap,jo=new WeakMap,zo=new WeakSet,Mc=async function(){ee(this,Nn)||(await Ve(this,Nn,Promise.resolve()),Ve(this,Nn,null),this.load())};Ko.customElements.get("mux-video")||(Ko.customElements.define("mux-video",Oc),Ko.MuxVideoElement=Oc);var Og=Oc;var x_="en",Hr={code:x_};var Pg="en";function Le(r,e=!0){var s,n;let t=e&&(n=(s=Hr)==null?void 0:s[r])!=null?n:r,i=e?Hr.code:Pg;return new Uc(t,i)}var Uc=class{constructor(e,t=(i=>(i=Hr.code)!=null?i:Pg)()){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 Ng(r){let e="";return Object.entries(r).forEach(([t,i])=>{i!=null&&(e+=`${Zo(t)}: ${i}; `)}),e?e.trim():void 0}function Zo(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Jo(r){return r.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function ji(r){if(r==null)return;let e=+r;return Number.isNaN(e)?void 0:e}function el(r){let e=I_(r).toString();return e?"?"+e:""}function I_(r){let e={};for(let t in r)r[t]!=null&&(e[t]=r[t]);return new URLSearchParams(e)}function mr(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 Bc=(r,e)=>!r||!e?!1:r.contains(e)?!0:Bc(r,e.getRootNode().host);var $c="mux.com",L_=()=>{try{return"1.11.4"}catch{}return"UNKNOWN"},R_=L_(),il=()=>R_,Gc=(r,{maxResolution:e,token:t,domain:i=$c}={})=>{let a=!!t?{token:t}:{redundant_streams:!0,...e?{max_resolution:e}:{}};return`https://stream.${i}/${r}.m3u8${el(a)}`},Fg=(r,{token:e,thumbnailTime:t,domain:i=$c}={})=>{let s=e==null?t:void 0,{aud:n}=mr(e);if(!(e&&n!=="t"))return`https://image.${i}/${r}/thumbnail.webp${el({token:e,time:s})}`},Ug=(r,{token:e,domain:t=$c}={})=>{let{aud:i}=mr(e);if(!(e&&i!=="s"))return`https://image.${t}/${r}/storyboard.vtt${el({token:e,format:"webp"})}`},Un=r=>{if(!!r){if([Ye.LIVE,Ye.ON_DEMAND].includes(r))return r;if(r!=null&&r.includes("live"))return Ye.LIVE}};var w_={crossorigin:"crossOrigin",playsinline:"playsInline"};function Bg(r){var e;return(e=w_[r])!=null?e:Jo(r)}var Vr,Kr,Pt,tl=class{constructor(e,t){lt(this,Vr,void 0);lt(this,Kr,void 0);lt(this,Pt,[]);ti(this,Vr,e),ti(this,Kr,t)}[Symbol.iterator](){return Oe(this,Pt).values()}get length(){return Oe(this,Pt).length}get value(){var e;return(e=Oe(this,Pt).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(ti(this,Pt,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return Oe(this,Pt)[e]}values(){return Oe(this,Pt).values()}keys(){return Oe(this,Pt).keys()}forEach(e){Oe(this,Pt).forEach(e)}add(...e){var t,i;e.forEach(s=>{this.contains(s)||Oe(this,Pt).push(s)}),!(this.value===""&&!((t=Oe(this,Vr))!=null&&t.hasAttribute(`${Oe(this,Kr)}`)))&&((i=Oe(this,Vr))==null||i.setAttribute(`${Oe(this,Kr)}`,`${this.value}`))}remove(...e){var t;e.forEach(i=>{Oe(this,Pt).splice(Oe(this,Pt).indexOf(i),1)}),(t=Oe(this,Vr))==null||t.setAttribute(`${Oe(this,Kr)}`,`${this.value}`)}contains(e){return Oe(this,Pt).includes(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};Vr=new WeakMap,Kr=new WeakMap,Pt=new WeakMap;var $g=`[mux-player ${il()}]`;function pr(...r){console.warn($g,...r)}function gi(...r){console.error($g,...r)}function Hc(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+=` ${Le("Read more: ")}
|
|
951
|
+
${i}${r.file}`}pr(e)}var Dt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},Wr={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},Hg=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}}),k_=Qo.filter(r=>r!=="error"),D_=Object.values(Dt).filter(r=>![Dt.PLAYSINLINE].includes(r)),C_=Object.values(Wr);function Vg(r){r.querySelectorAll(":scope > track").forEach(e=>{var t;(t=r.media)==null||t.append(e.cloneNode())}),k_.forEach(e=>{var t;(t=r.media)==null||t.addEventListener(e,i=>{r.dispatchEvent(new Event(i.type))})})}var Vc=class extends ht.HTMLElement{static get observedAttributes(){return[...D_,...C_]}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 Wr.MUTED:{this.media&&(this.media.muted=i!=null,this.media.defaultMuted=i!=null);return}case Wr.VOLUME:{let a=(s=ji(i))!=null?s:1;this.media&&(this.media.volume=a);return}case Wr.PLAYBACKRATE:{let a=(n=ji(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 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:Hg}get seekable(){var e,t;return(t=(e=this.media)==null?void 0:e.seekable)!=null?t:Hg}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=ji(this.getAttribute(Wr.PLAYBACKRATE)))!=null?e:1}set defaultPlaybackRate(e){e!=null?this.setAttribute(Wr.PLAYBACKRATE,`${e}`):this.removeAttribute(Wr.PLAYBACKRATE)}get crossOrigin(){return Bn(this,Dt.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(Dt.CROSSORIGIN,`${e}`)}get autoplay(){return Bn(this,Dt.AUTOPLAY)!=null}set autoplay(e){e?this.setAttribute(Dt.AUTOPLAY,typeof e=="string"?e:""):this.removeAttribute(Dt.AUTOPLAY)}get loop(){return Bn(this,Dt.LOOP)!=null}set loop(e){e?this.setAttribute(Dt.LOOP,""):this.removeAttribute(Dt.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 Bn(this,Dt.MUTED)!=null}set defaultMuted(e){e?this.setAttribute(Dt.MUTED,""):this.removeAttribute(Dt.MUTED)}get playsInline(){return Bn(this,Dt.PLAYSINLINE)!=null}set playsInline(e){gi("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(Dt.PRELOAD,e):this.removeAttribute(Dt.PRELOAD)}};function Bn(r,e){return r.media?r.media.getAttribute(e):r.getAttribute(e)}var Kc=Vc;var M_=Object.defineProperty,O_=(r,e,t)=>e in r?M_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,P_=(r,e,t)=>(O_(r,typeof e!="symbol"?e+"":e,t),t),jg=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},xe=(r,e,t)=>(jg(r,e,"read from private field"),t?t.call(r):e.get(r)),Pi=(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)=>(jg(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Ps,rl,qr,$n,gr,vr,Er,Yr,Ns,sl,vi,Kg=1,Wg=0,N_=1,F_={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 Nt&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof Nt?s.element[s.attributeName]=n:s.value=n}}}},Xi=class extends N.DocumentFragment{constructor(e,t,i=F_){var s;super(),Pi(this,Ps,void 0),Pi(this,rl,void 0),this.append(e.content.cloneNode(!0)),zi(this,Ps,zg(this)),zi(this,rl,i),(s=i.createCallback)==null||s.call(i,this,xe(this,Ps),t),i.processCallback(this,xe(this,Ps),t)}update(e){xe(this,rl).processCallback(this,xe(this,Ps),e)}};Ps=new WeakMap;rl=new WeakMap;var zg=(r,e=[])=>{let t,i;for(let s of r.attributes||[])if(s.value.includes("{{")){let n=new Wc;for([t,i]of Yg(s.value))if(!t)n.append(i);else{let a=new Nt(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===Kg&&!(s instanceof HTMLTemplateElement))zg(s,e);else if(s.nodeType===Kg||s.data.includes("{{")){let n=[];if(s.data)for([t,i]of Yg(s.data))if(!t)n.push(new Text(i));else{let a=new Qi(r);n.push(a),e.push([i,a])}else if(s instanceof HTMLTemplateElement){let a=new Gn(r,s);n.push(a),e.push([a.expression,a])}s.replaceWith(...n.flatMap(a=>a.replacementNodes||[a]))}return e},qg={},Yg=r=>{let e="",t=0,i=qg[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([Wg,e]),e="",s++):n==="}"&&r[s+1]==="}"&&r[s-1]!=="\\"&&!--t?(i.push([N_,e.trim()]),e="",s++):e+=n||"";return e&&i.push([Wg,(t>0?"{{":"")+e]),qg[r]=i},U_=11,nl=class{get value(){return""}set value(e){}toString(){return this.value}},Xg=new WeakMap,Wc=class{constructor(){Pi(this,qr,[])}[Symbol.iterator](){return xe(this,qr).values()}get length(){return xe(this,qr).length}item(e){return xe(this,qr)[e]}append(...e){for(let t of e)t instanceof Nt&&Xg.set(t,this),xe(this,qr).push(t)}toString(){return xe(this,qr).join("")}};qr=new WeakMap;var Nt=class extends nl{constructor(e,t,i){super(),Pi(this,Yr),Pi(this,$n,""),Pi(this,gr,void 0),Pi(this,vr,void 0),Pi(this,Er,void 0),zi(this,gr,e),zi(this,vr,t),zi(this,Er,i)}get attributeName(){return xe(this,vr)}get attributeNamespace(){return xe(this,Er)}get element(){return xe(this,gr)}get value(){return xe(this,$n)}set value(e){xe(this,$n)!==e&&(zi(this,$n,e),!xe(this,Yr,Ns)||xe(this,Yr,Ns).length===1?e==null?xe(this,gr).removeAttributeNS(xe(this,Er),xe(this,vr)):xe(this,gr).setAttributeNS(xe(this,Er),xe(this,vr),e):xe(this,gr).setAttributeNS(xe(this,Er),xe(this,vr),xe(this,Yr,Ns)))}get booleanValue(){return xe(this,gr).hasAttributeNS(xe(this,Er),xe(this,vr))}set booleanValue(e){if(!xe(this,Yr,Ns)||xe(this,Yr,Ns).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};$n=new WeakMap;gr=new WeakMap;vr=new WeakMap;Er=new WeakMap;Yr=new WeakSet;Ns=function(){return Xg.get(this)};var Qi=class extends nl{constructor(e,t){super(),Pi(this,sl,void 0),Pi(this,vi,void 0),zi(this,sl,e),zi(this,vi,t?[...t]:[new Text])}get replacementNodes(){return xe(this,vi)}get parentNode(){return xe(this,sl)}get nextSibling(){return xe(this,vi)[xe(this,vi).length-1].nextSibling}get previousSibling(){return xe(this,vi)[0].previousSibling}get value(){return xe(this,vi).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===U_?[...i.childNodes]:i.nodeType?[i]:[new Text(i)]);t.length||t.push(new Text),zi(this,vi,B_(xe(this,vi)[0].parentNode,xe(this,vi),t,this.nextSibling))}};sl=new WeakMap;vi=new WeakMap;var Gn=class extends Qi{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),P_(this,"directive"),this.expression=s,this.template=t,this.directive=i}};function B_(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 Qg={string:r=>String(r)},ol=class{constructor(e){this.template=e,this.state=void 0}},jr=new WeakMap,zr=new WeakMap,qc={partial:(r,e)=>{e[r.expression]=new ol(r.template)},if:(r,e)=>{var t;if(Jg(r.expression,e))if(jr.get(r)!==r.template){jr.set(r,r.template);let i=new Xi(r.template,e,ll);r.replace(i),zr.set(r,i)}else(t=zr.get(r))==null||t.update(e);else r.replace(""),jr.delete(r),zr.delete(r)}},$_=Object.keys(qc),ll={processCallback(r,e,t){var i,s;if(!!t)for(let[n,a]of e){if(a instanceof Gn){if(!a.directive){let l=$_.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(i=qc[a.directive])==null||i.call(qc,a,t);continue}let o=Jg(n,t);if(o instanceof ol){jr.get(a)!==o.template?(jr.set(a,o.template),o=new Xi(o.template,o.state,ll),a.value=o,zr.set(a,o)):(s=zr.get(a))==null||s.update(o.state);continue}o?(a instanceof Nt&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof Nt?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,jr.delete(a),zr.delete(a))):a instanceof Nt?a.value=void 0:(a.value=void 0,jr.delete(a),zr.delete(a))}}},Zg={"!":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=Qg[e])==null?void 0:t.call(Qg,r)}};function G_(r){return H_(r,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function Jg(r,e={}){var t,i,s,n,a,o,l;let d=G_(r);if(d.length===0||d.some(({type:u})=>!u))return Hn(r);if(((t=d[0])==null?void 0:t.token)===">"){let u=e[(i=d[1])==null?void 0:i.token];if(!u)return Hn(r);let c={...e};u.state=c;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==="="&&(c[g]=Vn(T,e))}return u}if(d.length===1)return al(d[0])?Vn(d[0].token,e):Hn(r);if(d.length===2){let u=(o=d[0])==null?void 0:o.token,c=Zg[u];if(!c||!al(d[1]))return Hn(r);let h=Vn(d[1].token,e);return c(h)}if(d.length===3){let u=(l=d[1])==null?void 0:l.token,c=Zg[u];if(!c||!al(d[0])||!al(d[2]))return Hn(r);let h=Vn(d[0].token,e);if(u==="|")return c(h,d[2].token);let m=Vn(d[2].token,e);return c(h,m)}}function Hn(r){return console.warn(`Warning: invalid expression \`${r}\``),!1}function al({type:r}){return["number","boolean","string","param"].includes(r)}function Vn(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):aa(r)?parseFloat(r):e[r]}function H_(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 V_=Object.defineProperty,K_=(r,e,t)=>e in r?V_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Wn=(r,e,t)=>(K_(r,typeof e!="symbol"?e+"":e,t),t),Zc=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)},zc=(r,e,t)=>(Zc(r,e,"read from private field"),t?t.call(r):e.get(r)),Kn=(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)},Xr=(r,e,t,i)=>(Zc(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Yc=(r,e,t)=>(Zc(r,e,"access private method"),t),Fs,dl,Us,Xc,e0,ul,Qc,jc={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},t0=q.createElement("template");t0.innerHTML=`
|
|
953
952
|
<style>
|
|
954
953
|
:host {
|
|
955
954
|
display: inline-block;
|
|
@@ -971,7 +970,7 @@ ${m}${n.file}`}da(r)}var ui={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:
|
|
|
971
970
|
display: none;
|
|
972
971
|
}
|
|
973
972
|
</style>
|
|
974
|
-
`;var
|
|
973
|
+
`;var Bs=class extends N.HTMLElement{constructor(){super(),Kn(this,Xc),Kn(this,ul),Wn(this,"renderRoot"),Wn(this,"renderer"),Kn(this,Fs,void 0),Kn(this,dl,void 0),Kn(this,Us,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());let e=new MutationObserver(t=>{t.some(i=>{let s=i.target;return s===this?!0:s.localName!=="media-controller"?!1:!!(jc[i.attributeName]||i.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),Yc(this,Xc,e0).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=zc(this,Fs))!=null?e:this.constructor.template}set template(e){Xr(this,Us,null),Xr(this,Fs,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})=>jc[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(let a of s){let o=(i=jc[a.name])!=null?i:Bh(a.name),{value:l}=a;l!=null?(aa(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,i){e==="template"&&t!=i&&Yc(this,ul,Qc).call(this)}connectedCallback(){Yc(this,ul,Qc).call(this)}createRenderer(){this.template&&this.template!==zc(this,dl)&&(Xr(this,dl,this.template),this.renderer=new Xi(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(t0.content.cloneNode(!0),this.renderer))}render(){var e;(e=this.renderer)==null||e.update(this.props)}};Fs=new WeakMap;dl=new WeakMap;Us=new WeakMap;Xc=new WeakSet;e0=function(r){if(Object.prototype.hasOwnProperty.call(this,r)){let e=this[r];delete this[r],this[r]=e}};ul=new WeakSet;Qc=function(){var r;let e=this.getAttribute("template");if(!e||e===zc(this,Us))return;let t=this.getRootNode(),i=(r=t==null?void 0:t.getElementById)==null?void 0:r.call(t,e);if(i){Xr(this,Us,e),Xr(this,Fs,i),this.createRenderer();return}W_(e)&&(Xr(this,Us,e),q_(e).then(s=>{let n=q.createElement("template");n.innerHTML=s,Xr(this,Fs,n),this.createRenderer()}).catch(console.error))};Wn(Bs,"template");Wn(Bs,"observedAttributes",["template"]);Wn(Bs,"processor",ll);function W_(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 q_(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()}N.customElements.get("media-theme")||N.customElements.define("media-theme",Bs);var i0=`:host {
|
|
975
974
|
--media-control-display: var(--controls);
|
|
976
975
|
--media-loading-indicator-display: var(--loading-indicator);
|
|
977
976
|
--media-dialog-display: var(--dialog);
|
|
@@ -1087,7 +1086,7 @@ media-theme {
|
|
|
1087
1086
|
--media-duration-display-display: var(--duration-display, var(--bottom-duration-display));
|
|
1088
1087
|
--media-title-display-display: var(--title-display, var(--bottom-title-display));
|
|
1089
1088
|
}
|
|
1090
|
-
`;var
|
|
1089
|
+
`;var r0=`<!-- prettier-ignore -->
|
|
1091
1090
|
<template id="media-theme-mux">
|
|
1092
1091
|
<style>
|
|
1093
1092
|
:host {
|
|
@@ -1851,7 +1850,7 @@ media-theme {
|
|
|
1851
1850
|
|
|
1852
1851
|
</media-controller>
|
|
1853
1852
|
</template>
|
|
1854
|
-
`;var
|
|
1853
|
+
`;var n0=`
|
|
1855
1854
|
:host {
|
|
1856
1855
|
z-index: 100;
|
|
1857
1856
|
display: var(--media-dialog-display, flex);
|
|
@@ -1903,17 +1902,17 @@ media-theme {
|
|
|
1903
1902
|
text-align: center;
|
|
1904
1903
|
line-height: 1.4;
|
|
1905
1904
|
}
|
|
1906
|
-
`,
|
|
1905
|
+
`,a0=Xt.createElement("template");a0.innerHTML=`
|
|
1907
1906
|
<style>
|
|
1908
|
-
${
|
|
1907
|
+
${n0}
|
|
1909
1908
|
</style>
|
|
1910
1909
|
|
|
1911
1910
|
<div class="dialog">
|
|
1912
1911
|
<slot></slot>
|
|
1913
1912
|
</div>
|
|
1914
|
-
`;var
|
|
1913
|
+
`;var yr=class extends ht.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})),s0(this)}close(){!this.hasAttribute("open")||(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),z_(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")&&s0(this)}};yr.styles=n0,yr.template=a0,yr.observedAttributes=["open"];function s0(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=o0(r.shadowRoot)),r._previouslyFocusedElement=Xt.activeElement,Xt.activeElement instanceof HTMLElement&&Xt.activeElement.blur(),r.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function o0(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=o0(s[n].shadowRoot),i));n++);}return i}function z_(r){r._previouslyFocusedElement instanceof HTMLElement&&r._previouslyFocusedElement.focus()}ht.customElements.get("media-dialog")||(ht.customElements.define("media-dialog",yr),ht.MediaDialog=yr);var Jc=yr;var l0=Xt.createElement("template");l0.innerHTML=`
|
|
1915
1914
|
<style>
|
|
1916
|
-
${
|
|
1915
|
+
${Jc.styles}
|
|
1917
1916
|
|
|
1918
1917
|
.close {
|
|
1919
1918
|
background: none;
|
|
@@ -1942,84 +1941,84 @@ media-theme {
|
|
|
1942
1941
|
</svg>
|
|
1943
1942
|
</button>
|
|
1944
1943
|
</slot>
|
|
1945
|
-
`;var
|
|
1944
|
+
`;var qn=class extends Jc{constructor(){var e,t;super(),(t=(e=this.shadowRoot)==null?void 0:e.querySelector(".close"))==null||t.addEventListener("click",()=>{this.close()})}};qn.template=l0;ht.customElements.get("mxp-dialog")||(ht.customElements.define("mxp-dialog",qn),ht.MxpDialog=qn);var Yn=new WeakMap,jn=class{constructor(e,t){this.element=e;this.type=t;this.element.addEventListener(this.type,this);let i=Yn.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=Yn.get(this.element);t&&t.delete(this.type)}}static for(e){Yn.has(e.element)||Yn.set(e.element,new Map);let t=e.attributeName.slice(2),i=Yn.get(e.element);return i&&i.has(t)?i.get(t):new jn(e.element,t)}};function X_(r,e){return r instanceof Nt&&r.attributeName.startsWith("on")?(jn.for(r).set(e),r.element.removeAttributeNS(r.attributeNamespace,r.attributeName),!0):!1}function Q_(r,e){return e instanceof cl&&r instanceof Qi?(e.renderInto(r),!0):!1}function Z_(r,e){return e instanceof DocumentFragment&&r instanceof Qi?(e.childNodes.length&&r.replace(...e.childNodes),!0):!1}function J_(r,e){if(r instanceof Nt){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 eA(r,e){if(r instanceof Nt&&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 tA(r,e){if(typeof e=="boolean"&&r instanceof Nt){let t=r.attributeNamespace,i=r.element.hasAttributeNS(t,r.attributeName);return e!==i&&(r.booleanValue=e),!0}return!1}function iA(r,e){return e===!1&&r instanceof Qi?(r.replace(""),!0):!1}function rA(r,e){eA(r,e)||tA(r,e)||X_(r,e)||iA(r,e)||Q_(r,e)||Z_(r,e)||J_(r,e)}var eh=new Map,d0=new WeakMap,u0=new WeakMap,cl=class{constructor(e,t,i){this.strings=e;this.values=t;this.processor=i;this.stringsKey=this.strings.join("")}get template(){if(eh.has(this.stringsKey))return eh.get(this.stringsKey);{let e=Xt.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((i,s,n)=>i+s+(n<t?`{{ ${n} }}`:""),""),eh.set(this.stringsKey,e),e}}renderInto(e){var s;let t=this.template;if(d0.get(e)!==t){d0.set(e,t);let n=new Xi(t,this.values,this.processor);u0.set(e,n),e instanceof Qi?e.replace(...n.children):e.appendChild(n);return}let i=u0.get(e);(s=i==null?void 0:i.update)==null||s.call(i,this.values)}},sA={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:"";rA(n,a)}}}};function Zi(r,...e){return new cl(r,e,sA)}function c0(r,e){r.renderInto(e)}var th=Xt.createElement("template");"innerHTML"in th&&(th.innerHTML=r0);var h0=r=>Zi`
|
|
1946
1945
|
<style>
|
|
1947
|
-
${
|
|
1946
|
+
${i0}
|
|
1948
1947
|
</style>
|
|
1949
|
-
${
|
|
1950
|
-
`,
|
|
1948
|
+
${aA(r)}
|
|
1949
|
+
`,nA=r=>{let e=r.hotKeys?`${r.hotKeys}`:"";return Un(r.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},aA=r=>{var e,t,i,s,n,a,o,l,d,u,c,h,m,g,E,T,A,L,S,P,k,$,M,G,W,O,z,j,be,ge,ve,Re,Te,Q,ie;return Zi`
|
|
1951
1950
|
<media-theme
|
|
1952
|
-
template="${(r
|
|
1953
|
-
defaultstreamtype="${(
|
|
1954
|
-
hotkeys="${
|
|
1955
|
-
nohotkeys="${
|
|
1956
|
-
noautoseektolive="${!!((
|
|
1957
|
-
novolumepref="${
|
|
1958
|
-
disabled="${!
|
|
1959
|
-
audio="${(
|
|
1960
|
-
style="${(
|
|
1961
|
-
defaultsubtitles="${!
|
|
1962
|
-
forwardseekoffset="${(
|
|
1963
|
-
backwardseekoffset="${(
|
|
1964
|
-
playbackrates="${(
|
|
1965
|
-
defaultshowremainingtime="${(
|
|
1966
|
-
hideduration="${(
|
|
1967
|
-
title="${(
|
|
1951
|
+
template="${(e=r.themeTemplate)!=null?e:th.content.children[0]}"
|
|
1952
|
+
defaultstreamtype="${(t=r.defaultStreamType)!=null?t:!1}"
|
|
1953
|
+
hotkeys="${nA(r)||!1}"
|
|
1954
|
+
nohotkeys="${r.noHotKeys||!r.hasSrc||r.isDialogOpen||!1}"
|
|
1955
|
+
noautoseektolive="${!!((i=r.streamType)!=null&&i.includes(Ye.LIVE))&&r.targetLiveWindow!==0}"
|
|
1956
|
+
novolumepref="${r.novolumepref||!1}"
|
|
1957
|
+
disabled="${!r.hasSrc||r.isDialogOpen}"
|
|
1958
|
+
audio="${(s=r.audio)!=null?s:!1}"
|
|
1959
|
+
style="${(n=Ng({"--media-primary-color":r.primaryColor,"--media-secondary-color":r.secondaryColor}))!=null?n:!1}"
|
|
1960
|
+
defaultsubtitles="${!r.defaultHiddenCaptions}"
|
|
1961
|
+
forwardseekoffset="${(a=r.forwardSeekOffset)!=null?a:!1}"
|
|
1962
|
+
backwardseekoffset="${(o=r.backwardSeekOffset)!=null?o:!1}"
|
|
1963
|
+
playbackrates="${(l=r.playbackRates)!=null?l:!1}"
|
|
1964
|
+
defaultshowremainingtime="${(d=r.defaultShowRemainingTime)!=null?d:!1}"
|
|
1965
|
+
hideduration="${(u=r.hideDuration)!=null?u:!1}"
|
|
1966
|
+
title="${(c=r.title)!=null?c:!1}"
|
|
1968
1967
|
exportparts="top, center, bottom, layer, media-layer, poster-layer, vertical-layer, centered-layer, gesture-layer, poster, live, play, button, seek-backward, seek-forward, mute, captions, airplay, pip, fullscreen, cast, playback-rate, volume, range, time, display"
|
|
1969
1968
|
>
|
|
1970
1969
|
<mux-video
|
|
1971
1970
|
slot="media"
|
|
1972
|
-
target-live-window="${(
|
|
1973
|
-
stream-type="${(
|
|
1974
|
-
crossorigin="${(
|
|
1971
|
+
target-live-window="${(h=r.targetLiveWindow)!=null?h:!1}"
|
|
1972
|
+
stream-type="${(m=Un(r.streamType))!=null?m:!1}"
|
|
1973
|
+
crossorigin="${(g=r.crossOrigin)!=null?g:""}"
|
|
1975
1974
|
playsinline
|
|
1976
|
-
autoplay="${(
|
|
1977
|
-
muted="${(
|
|
1978
|
-
loop="${(
|
|
1979
|
-
preload="${(
|
|
1980
|
-
debug="${(
|
|
1981
|
-
prefer-cmcd="${(
|
|
1982
|
-
disable-cookies="${(
|
|
1983
|
-
prefer-playback="${(
|
|
1984
|
-
start-time="${
|
|
1985
|
-
beacon-collection-domain="${(
|
|
1986
|
-
player-software-name="${(
|
|
1987
|
-
player-software-version="${(
|
|
1988
|
-
env-key="${(
|
|
1989
|
-
custom-domain="${(
|
|
1990
|
-
src="${
|
|
1991
|
-
cast-src="${
|
|
1975
|
+
autoplay="${(E=r.autoplay)!=null?E:!1}"
|
|
1976
|
+
muted="${(T=r.muted)!=null?T:!1}"
|
|
1977
|
+
loop="${(A=r.loop)!=null?A:!1}"
|
|
1978
|
+
preload="${(L=r.preload)!=null?L:!1}"
|
|
1979
|
+
debug="${(S=r.debug)!=null?S:!1}"
|
|
1980
|
+
prefer-cmcd="${(P=r.preferCmcd)!=null?P:!1}"
|
|
1981
|
+
disable-cookies="${(k=r.disableCookies)!=null?k:!1}"
|
|
1982
|
+
prefer-playback="${($=r.preferPlayback)!=null?$:!1}"
|
|
1983
|
+
start-time="${r.startTime!=null?r.startTime:!1}"
|
|
1984
|
+
beacon-collection-domain="${(M=r.beaconCollectionDomain)!=null?M:!1}"
|
|
1985
|
+
player-software-name="${(G=r.playerSoftwareName)!=null?G:!1}"
|
|
1986
|
+
player-software-version="${(W=r.playerSoftwareVersion)!=null?W:!1}"
|
|
1987
|
+
env-key="${(O=r.envKey)!=null?O:!1}"
|
|
1988
|
+
custom-domain="${(z=r.customDomain)!=null?z:!1}"
|
|
1989
|
+
src="${r.src?r.src:r.playbackId?Gc(r.playbackId,{maxResolution:r.maxResolution,domain:r.customDomain,token:r.tokens.playback}):!1}"
|
|
1990
|
+
cast-src="${r.src?r.src:r.playbackId?Gc(r.playbackId,{maxResolution:r.maxResolution,domain:r.customDomain,token:r.tokens.playback}):!1}"
|
|
1992
1991
|
exportparts="video"
|
|
1993
1992
|
>
|
|
1994
|
-
${
|
|
1993
|
+
${r.storyboard?Zi`<track label="thumbnails" default kind="metadata" src="${r.storyboard}" />`:Zi``}
|
|
1995
1994
|
</mux-video>
|
|
1996
1995
|
<media-poster-image
|
|
1997
1996
|
slot="poster"
|
|
1998
1997
|
part="poster"
|
|
1999
|
-
src="${
|
|
2000
|
-
placeholder-src="${(
|
|
1998
|
+
src="${r.poster===""?!1:(j=r.poster)!=null?j:!1}"
|
|
1999
|
+
placeholder-src="${(be=r.placeholder)!=null?be:!1}"
|
|
2001
2000
|
></media-poster-image>
|
|
2002
2001
|
<mxp-dialog
|
|
2003
2002
|
no-auto-hide
|
|
2004
|
-
open="${(
|
|
2005
|
-
onclose="${
|
|
2006
|
-
oninitfocus="${
|
|
2003
|
+
open="${(ge=r.isDialogOpen)!=null?ge:!1}"
|
|
2004
|
+
onclose="${r.onCloseErrorDialog}"
|
|
2005
|
+
oninitfocus="${r.onInitFocusDialog}"
|
|
2007
2006
|
>
|
|
2008
|
-
${(
|
|
2007
|
+
${(ve=r.dialog)!=null&&ve.title?Zi`<h3>${r.dialog.title}</h3>`:Zi``}
|
|
2009
2008
|
<p>
|
|
2010
|
-
${(
|
|
2011
|
-
${(
|
|
2012
|
-
href="${
|
|
2009
|
+
${(Re=r.dialog)==null?void 0:Re.message}
|
|
2010
|
+
${(Te=r.dialog)!=null&&Te.linkUrl?Zi`<a
|
|
2011
|
+
href="${r.dialog.linkUrl}"
|
|
2013
2012
|
target="_blank"
|
|
2014
2013
|
rel="external noopener"
|
|
2015
|
-
aria-label="${(
|
|
2016
|
-
>${(
|
|
2017
|
-
>`:
|
|
2014
|
+
aria-label="${(Q=r.dialog.linkText)!=null?Q:""} ${Le("(opens in a new window)")}"
|
|
2015
|
+
>${(ie=r.dialog.linkText)!=null?ie:r.dialog.linkUrl}</a
|
|
2016
|
+
>`:Zi``}
|
|
2018
2017
|
</p>
|
|
2019
2018
|
</mxp-dialog>
|
|
2020
2019
|
</media-theme>
|
|
2021
|
-
`};function Mu(n,r,o,m,v){var M,U,H;let y={},I={};switch(n.code){case At.MEDIA_ERR_NETWORK:{switch(y.title=Qe("Network Error",v),y.message=n.message,(M=n.data)==null?void 0:M.response.code){case 412:{y.title=Qe("Video is not currently available",v),y.message=Qe("The live stream or video file are not yet ready.",v),I.message=Qe("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",v),I.file="412-not-playable.md";break}case 404:{y.title=Qe("Video does not exist",v),y.message="",I.message=Qe("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",v),I.file="404-not-found.md";break}case 403:{if(y.title=Qe("Invalid playback URL",v),y.message=Qe("The video URL or playback-token are formatted with incorrect or incomplete information.",v),I.message=Qe("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",v),I.file="missing-signed-tokens.md",!m)break;let{exp:z,aud:J,sub:Z}=ua(m),se=Date.now()>z*1e3,me=Z!==o,Te=J!=="v",ge={timeStyle:"medium",dateStyle:"medium"};if(se){y.title=Qe("Video URL has expired",v),y.message=Qe("The video\u2019s secured playback-token has expired.",v),I.message=Qe("The video\u2019s secured playback-token has expired.",v),I.context=Qe("Expired at: {expiredDate}. Current time: {currentDate}.",v).format({expiredDate:new Intl.DateTimeFormat(ja.code,ge).format(z*1e3),currentDate:new Intl.DateTimeFormat(ja.code,ge).format(Date.now())}),I.file="403-expired-token.md";break}if(me){y.title=Qe("Video URL is formatted incorrectly",v),y.message=Qe("The video\u2019s playback ID does not match the one encoded in the playback-token.",v),I.message=Qe("The video\u2019s playback ID does not match the one encoded in the playback-token.",v),I.context=Qe("Specified playback ID: {playbackId} and the playback ID encoded in the playback-token: {tokenPlaybackId}",v).format({playbackId:o,tokenPlaybackId:Z}),I.file="403-playback-id-mismatch.md";break}if(Te){y.title=Qe("Video URL is formatted incorrectly",v),y.message=Qe("The playback-token is formatted with incorrect information.",v),I.message=Qe("The playback-token is formatted with incorrect information.",v),I.context=Qe("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",v).format({tokenType:J}),I.file="403-incorrect-aud-value.md";break}I.message=Qe("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",v),I.file="403-malformatted-token.md";break}}break}case At.MEDIA_ERR_DECODE:{let{message:z}=n;y={title:Qe("Media Error",v),message:z},I.file="media-decode-error.md";break}case At.MEDIA_ERR_SRC_NOT_SUPPORTED:{let z=(H=(U=n.data)==null?void 0:U.response)==null?void 0:H.code;if(z>=400&&z<500){n.code=At.MEDIA_ERR_NETWORK,n.data={response:{code:z}},{dialog:y,devlog:I}=Mu(n,r,o,m);break}y={title:Qe("Source Not Supported",v),message:n.message},I.file="media-src-not-supported.md";break}default:y={title:Qe("Error",v),message:n.message};break}return r&&(y={title:Qe("Your device appears to be offline",v),message:Qe("Check your internet connection and try reloading this video.",v)}),{dialog:y,devlog:I}}var qr={SRC:"src",POSTER:"poster"},ve={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"},Rh=["audio","backwardseekoffset","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function Z0(n,r){var m;return{src:!n.playbackId&&n.src,playbackId:n.playbackId,hasSrc:!!n.playbackId||!!n.src,poster:n.poster,storyboard:n.storyboard,storyboardSrc:n.getAttribute(ve.STORYBOARD_SRC),placeholder:n.getAttribute("placeholder"),themeTemplate:J0(n),thumbnailTime:!n.tokens.thumbnail&&n.thumbnailTime,autoplay:n.autoplay,crossOrigin:n.crossOrigin,loop:n.loop,noHotKeys:n.hasAttribute(ve.NOHOTKEYS),hotKeys:n.getAttribute(ve.HOTKEYS),muted:n.muted,paused:n.paused,preload:n.preload,envKey:n.envKey,preferCmcd:n.preferCmcd,debug:n.debug,disableCookies:n.disableCookies,tokens:n.tokens,beaconCollectionDomain:n.beaconCollectionDomain,maxResolution:n.maxResolution,metadata:n.metadata,playerSoftwareName:n.playerSoftwareName,playerSoftwareVersion:n.playerSoftwareVersion,startTime:n.startTime,preferPlayback:n.preferPlayback,audio:n.audio,defaultStreamType:n.defaultStreamType,targetLiveWindow:n.getAttribute(ne.TARGET_LIVE_WINDOW),streamType:Js(n.getAttribute(ne.STREAM_TYPE)),primaryColor:n.primaryColor,secondaryColor:n.secondaryColor,forwardSeekOffset:n.forwardSeekOffset,backwardSeekOffset:n.backwardSeekOffset,defaultHiddenCaptions:n.defaultHiddenCaptions,defaultShowRemainingTime:n.defaultShowRemainingTime,hideDuration:eb(n),playbackRates:n.getAttribute(ve.PLAYBACK_RATES),customDomain:(m=n.getAttribute(ne.CUSTOM_DOMAIN))!=null?m:void 0,title:n.getAttribute(ve.TITLE),novolumepref:n.hasAttribute(ve.NO_VOLUME_PREF),...r}}function J0(n){var o,m;let r=n.getAttribute(ve.THEME);if(r){let v=(m=(o=n.getRootNode())==null?void 0:o.getElementById)==null?void 0:m.call(o,r);if(v)return v;r.startsWith("media-theme-")||(r=`media-theme-${r}`);let y=Yt.customElements.get(r);if(y!=null&&y.template)return y.template}}function eb(n){var o;let r=(o=n.mediaController)==null?void 0:o.querySelector("media-time-display");return r&&getComputedStyle(r).getPropertyValue("--media-duration-display-display").trim()==="none"}function Pv(n){return n.getAttributeNames().filter(r=>r.startsWith("metadata-")).reduce((r,o)=>{let m=n.getAttribute(o);return m!==null&&(r[o.replace(/^metadata-/,"").replace(/-/g,"_")]=m),r},{})}var tb=Object.values(ne),ib=Object.values(qr),rb=Object.values(ve),ab=_u(),nb="mux-player",Ov={dialog:void 0,isDialogOpen:!1},ho,fo,Yr,mo,an,pa,Jn,xu,Nv,po,Dh,va,es,Pu,Fv,Ou,Uv,Nu,Bv,Fu,Hv,co=class extends gh{constructor(){super();Ht(this,pa);Ht(this,xu);Ht(this,po);Ht(this,va);Ht(this,Pu);Ht(this,Ou);Ht(this,Nu);Ht(this,Fu);Ht(this,ho,!1);Ht(this,fo,{});Ht(this,Yr,!0);Ht(this,mo,new Tu(this,"hotkeys"));Ht(this,an,{...Ov,onCloseErrorDialog:()=>Qt(this,po,Dh).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:o=>{hh(this,Mi.activeElement)||o.preventDefault()}});this.attachShadow({mode:"open"}),Qt(this,xu,Nv).call(this),this.isConnected&&Qt(this,pa,Jn).call(this)}static get observedAttributes(){var o;return[...(o=gh.observedAttributes)!=null?o:[],...ib,...tb,...rb]}get mediaTheme(){var o;return(o=this.shadowRoot)==null?void 0:o.querySelector("media-theme")}get mediaController(){var o,m;return(m=(o=this.mediaTheme)==null?void 0:o.shadowRoot)==null?void 0:m.querySelector("media-controller")}connectedCallback(){var m;let o=(m=this.shadowRoot)==null?void 0:m.querySelector("mux-video");o&&(o.metadata=Pv(this))}attributeChangedCallback(o,m,v){switch(Qt(this,pa,Jn).call(this),super.attributeChangedCallback(o,m,v),o){case ve.HOTKEYS:ot(this,mo).value=v;break;case ve.THUMBNAIL_TIME:{v!=null&&this.tokens.thumbnail&&da(Qe("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case ve.THUMBNAIL_TOKEN:{let{aud:I}=ua(v);v&&I!=="t"&&da(Qe("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:I}));break}case ve.STORYBOARD_TOKEN:{let{aud:I}=ua(v);v&&I!=="s"&&da(Qe("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:I}));break}case ne.PLAYBACK_ID:{v!=null&&v.includes("?token")&&tr(Qe("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:v}));break}case ne.STREAM_TYPE:v&&![gt.LIVE,gt.ON_DEMAND,gt.UNKNOWN].includes(v)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=v.includes("dvr")?Number.POSITIVE_INFINITY:0:ph({file:"invalid-stream-type.md",message:Qe("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):this.targetLiveWindow=v===gt.LIVE?0:Number.NaN}[ne.PLAYBACK_ID,qr.SRC,ve.PLAYBACK_TOKEN].includes(o)&&m!==v&&Gi(this,an,{...ot(this,an),...Ov}),Qt(this,va,es).call(this,{[sv(o)]:v})}get preferCmcd(){var o;return(o=this.getAttribute(ne.PREFER_CMCD))!=null?o:void 0}set preferCmcd(o){o!==this.preferCmcd&&(o?qn.includes(o)?this.setAttribute(ne.PREFER_CMCD,o):da(`Invalid value for preferCmcd. Must be one of ${qn.join()}`):this.removeAttribute(ne.PREFER_CMCD))}get hasPlayed(){var o,m;return(m=(o=this.mediaController)==null?void 0:o.hasAttribute("media-has-played"))!=null?m:!1}get inLiveWindow(){var o;return(o=this.mediaController)==null?void 0:o.hasAttribute("media-time-is-live")}get _hls(){var o;return(o=this.media)==null?void 0:o._hls}get mux(){var o;return(o=this.media)==null?void 0:o.mux}get theme(){var o;return(o=this.getAttribute(ve.THEME))!=null?o:""}set theme(o){this.setAttribute(ve.THEME,`${o}`)}get themeProps(){let o=this.mediaTheme;if(!o)return;let m={};for(let v of o.getAttributeNames()){if(Rh.includes(v))continue;let y=o.getAttribute(v);m[yu(v)]=y===""?!0:y}return m}set themeProps(o){var v,y;Qt(this,pa,Jn).call(this);let m={...this.themeProps,...o};for(let I in m){if(Rh.includes(I))continue;let M=o==null?void 0:o[I];typeof M=="boolean"||M==null?(v=this.mediaTheme)==null||v.toggleAttribute(Eu(I),Boolean(M)):(y=this.mediaTheme)==null||y.setAttribute(Eu(I),M)}}get playbackId(){var o;return(o=this.getAttribute(ne.PLAYBACK_ID))!=null?o:void 0}set playbackId(o){o?this.setAttribute(ne.PLAYBACK_ID,o):this.removeAttribute(ne.PLAYBACK_ID)}get src(){var o,m;return this.playbackId?(o=Zn(this,qr.SRC))!=null?o:void 0:(m=this.getAttribute(qr.SRC))!=null?m:void 0}set src(o){o?this.setAttribute(qr.SRC,o):this.removeAttribute(qr.SRC)}get poster(){var m;let o=this.getAttribute(qr.POSTER);if(o!=null)return o;if(this.playbackId&&!this.audio)return av(this.playbackId,{domain:this.customDomain,thumbnailTime:(m=this.thumbnailTime)!=null?m:this.startTime,token:this.tokens.thumbnail})}set poster(o){o||o===""?this.setAttribute(qr.POSTER,o):this.removeAttribute(qr.POSTER)}get storyboardSrc(){var o;return(o=this.getAttribute(ve.STORYBOARD_SRC))!=null?o:void 0}set storyboardSrc(o){o?this.setAttribute(ve.STORYBOARD_SRC,o):this.removeAttribute(ve.STORYBOARD_SRC)}get storyboard(){if(this.storyboardSrc&&!this.tokens.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[gt.LIVE,gt.UNKNOWN].includes(this.streamType)))return nv(this.playbackId,{domain:this.customDomain,token:this.tokens.storyboard})}get audio(){return this.hasAttribute(ve.AUDIO)}set audio(o){if(!o){this.removeAttribute(ve.AUDIO);return}this.setAttribute(ve.AUDIO,"")}get hotkeys(){return ot(this,mo)}get nohotkeys(){return this.hasAttribute(ve.NOHOTKEYS)}set nohotkeys(o){if(!o){this.removeAttribute(ve.NOHOTKEYS);return}this.setAttribute(ve.NOHOTKEYS,"")}get thumbnailTime(){return Hr(this.getAttribute(ve.THUMBNAIL_TIME))}set thumbnailTime(o){this.setAttribute(ve.THUMBNAIL_TIME,`${o}`)}get title(){var o;return(o=this.getAttribute(ve.TITLE))!=null?o:""}set title(o){o!==this.title&&(o?this.setAttribute(ve.TITLE,o):this.removeAttribute("title"),super.title=o)}get placeholder(){var o;return(o=Zn(this,ve.PLACEHOLDER))!=null?o:""}set placeholder(o){this.setAttribute(ve.PLACEHOLDER,`${o}`)}get primaryColor(){var m,v;let o=this.getAttribute(ve.PRIMARY_COLOR);if(o!=null||this.mediaTheme&&(o=(v=(m=Yt.getComputedStyle(this.mediaTheme))==null?void 0:m.getPropertyValue("--_primary-color"))==null?void 0:v.trim(),o))return o}set primaryColor(o){this.setAttribute(ve.PRIMARY_COLOR,`${o}`)}get secondaryColor(){var m,v;let o=this.getAttribute(ve.SECONDARY_COLOR);if(o!=null||this.mediaTheme&&(o=(v=(m=Yt.getComputedStyle(this.mediaTheme))==null?void 0:m.getPropertyValue("--_secondary-color"))==null?void 0:v.trim(),o))return o}set secondaryColor(o){this.setAttribute(ve.SECONDARY_COLOR,`${o}`)}get defaultShowRemainingTime(){return this.hasAttribute(ve.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(o){o?this.setAttribute(ve.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(ve.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(!!this.hasAttribute(ve.PLAYBACK_RATES))return this.getAttribute(ve.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(o=>Number(o)).filter(o=>!Number.isNaN(o)).sort((o,m)=>o-m)}set playbackRates(o){if(!o){this.removeAttribute(ve.PLAYBACK_RATES);return}this.setAttribute(ve.PLAYBACK_RATES,o.join(" "))}get forwardSeekOffset(){var o;return(o=Hr(this.getAttribute(ve.FORWARD_SEEK_OFFSET)))!=null?o:10}set forwardSeekOffset(o){this.setAttribute(ve.FORWARD_SEEK_OFFSET,`${o}`)}get backwardSeekOffset(){var o;return(o=Hr(this.getAttribute(ve.BACKWARD_SEEK_OFFSET)))!=null?o:10}set backwardSeekOffset(o){this.setAttribute(ve.BACKWARD_SEEK_OFFSET,`${o}`)}get defaultHiddenCaptions(){return this.hasAttribute(ve.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(o){o?this.setAttribute(ve.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(ve.DEFAULT_HIDDEN_CAPTIONS)}get playerSoftwareName(){var o;return(o=this.getAttribute(ne.PLAYER_SOFTWARE_NAME))!=null?o:nb}get playerSoftwareVersion(){var o;return(o=this.getAttribute(ne.PLAYER_SOFTWARE_VERSION))!=null?o:ab}get beaconCollectionDomain(){var o;return(o=this.getAttribute(ne.BEACON_COLLECTION_DOMAIN))!=null?o:void 0}set beaconCollectionDomain(o){o!==this.beaconCollectionDomain&&(o?this.setAttribute(ne.BEACON_COLLECTION_DOMAIN,o):this.removeAttribute(ne.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var o;return(o=this.getAttribute(ne.MAX_RESOLUTION))!=null?o:void 0}set maxResolution(o){o!==this.maxResolution&&(o?this.setAttribute(ne.MAX_RESOLUTION,o):this.removeAttribute(ne.MAX_RESOLUTION))}get customDomain(){var o;return(o=this.getAttribute(ne.CUSTOM_DOMAIN))!=null?o:void 0}set customDomain(o){o!==this.customDomain&&(o?this.setAttribute(ne.CUSTOM_DOMAIN,o):this.removeAttribute(ne.CUSTOM_DOMAIN))}get envKey(){var o;return(o=Zn(this,ne.ENV_KEY))!=null?o:void 0}set envKey(o){this.setAttribute(ne.ENV_KEY,`${o}`)}get noVolumePref(){return this.hasAttribute(ve.NO_VOLUME_PREF)}set noVolumePref(o){o?this.setAttribute(ve.NO_VOLUME_PREF,""):this.removeAttribute(ve.NO_VOLUME_PREF)}get debug(){return Zn(this,ne.DEBUG)!=null}set debug(o){o?this.setAttribute(ne.DEBUG,""):this.removeAttribute(ne.DEBUG)}get disableCookies(){return Zn(this,ne.DISABLE_COOKIES)!=null}set disableCookies(o){o?this.setAttribute(ne.DISABLE_COOKIES,""):this.removeAttribute(ne.DISABLE_COOKIES)}get streamType(){var o,m,v;return(v=(m=this.getAttribute(ne.STREAM_TYPE))!=null?m:(o=this.media)==null?void 0:o.streamType)!=null?v:gt.UNKNOWN}set streamType(o){this.setAttribute(ne.STREAM_TYPE,`${o}`)}get defaultStreamType(){var o,m,v;return(v=(m=this.getAttribute(ve.DEFAULT_STREAM_TYPE))!=null?m:(o=this.mediaController)==null?void 0:o.getAttribute(ve.DEFAULT_STREAM_TYPE))!=null?v:gt.ON_DEMAND}set defaultStreamType(o){o?this.setAttribute(ve.DEFAULT_STREAM_TYPE,o):this.removeAttribute(ve.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var o,m;return this.hasAttribute(ve.TARGET_LIVE_WINDOW)?+this.getAttribute(ve.TARGET_LIVE_WINDOW):(m=(o=this.media)==null?void 0:o.targetLiveWindow)!=null?m:Number.NaN}set targetLiveWindow(o){o!=this.targetLiveWindow&&(o==null?this.removeAttribute(ve.TARGET_LIVE_WINDOW):this.setAttribute(ve.TARGET_LIVE_WINDOW,`${+o}`))}get liveEdgeStart(){var o;return(o=this.media)==null?void 0:o.liveEdgeStart}get startTime(){return Hr(Zn(this,ne.START_TIME))}set startTime(o){this.setAttribute(ne.START_TIME,`${o}`)}get preferPlayback(){let o=this.getAttribute(ne.PREFER_PLAYBACK);if(o===Yi.MSE||o===Yi.NATIVE)return o}set preferPlayback(o){o!==this.preferPlayback&&(o===Yi.MSE||o===Yi.NATIVE?this.setAttribute(ne.PREFER_PLAYBACK,o):this.removeAttribute(ne.PREFER_PLAYBACK))}get metadata(){var o;return(o=this.media)==null?void 0:o.metadata}set metadata(o){if(Qt(this,pa,Jn).call(this),!this.media){tr("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...Pv(this),...o}}async addCuePoints(o){var m;if(Qt(this,pa,Jn).call(this),!this.media){tr("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(m=this.media)==null?void 0:m.addCuePoints(o)}get activeCuePoint(){var o;return(o=this.media)==null?void 0:o.activeCuePoint}get cuePoints(){var o,m;return(m=(o=this.media)==null?void 0:o.cuePoints)!=null?m:[]}getStartDate(){var o;return(o=this.media)==null?void 0:o.getStartDate()}get currentPdt(){var o;return(o=this.media)==null?void 0:o.currentPdt}get tokens(){let o=this.getAttribute(ve.PLAYBACK_TOKEN),m=this.getAttribute(ve.THUMBNAIL_TOKEN),v=this.getAttribute(ve.STORYBOARD_TOKEN);return{...ot(this,fo),...o!=null?{playback:o}:{},...m!=null?{thumbnail:m}:{},...v!=null?{storyboard:v}:{}}}set tokens(o){Gi(this,fo,o!=null?o:{})}get playbackToken(){var o;return(o=this.getAttribute(ve.PLAYBACK_TOKEN))!=null?o:void 0}set playbackToken(o){this.setAttribute(ve.PLAYBACK_TOKEN,`${o}`)}get thumbnailToken(){var o;return(o=this.getAttribute(ve.THUMBNAIL_TOKEN))!=null?o:void 0}set thumbnailToken(o){this.setAttribute(ve.THUMBNAIL_TOKEN,`${o}`)}get storyboardToken(){var o;return(o=this.getAttribute(ve.STORYBOARD_TOKEN))!=null?o:void 0}set storyboardToken(o){this.setAttribute(ve.STORYBOARD_TOKEN,`${o}`)}addTextTrack(o,m,v,y){var M;let I=(M=this.media)==null?void 0:M.nativeEl;if(!!I)return lu(I,o,m,v,y)}removeTextTrack(o){var v;let m=(v=this.media)==null?void 0:v.nativeEl;if(!!m)return Cp(m,o)}get textTracks(){var o;return(o=this.media)==null?void 0:o.textTracks}};ho=new WeakMap,fo=new WeakMap,Yr=new WeakMap,mo=new WeakMap,an=new WeakMap,pa=new WeakSet,Jn=function(){var o,m,v;if(!ot(this,ho)){Gi(this,ho,!0),Qt(this,va,es).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof Yt.HTMLElement))throw""}catch{tr("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof tv))throw""}catch{tr("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof Wd))throw""}catch{tr("<media-controller> failed to upgrade!")}dv(this),Qt(this,Pu,Fv).call(this),Qt(this,Ou,Uv).call(this),Qt(this,Nu,Bv).call(this),Gi(this,Yr,(m=(o=this.mediaController)==null?void 0:o.hasAttribute("userinactive"))!=null?m:!0),Qt(this,Fu,Hv).call(this),(v=this.media)==null||v.addEventListener("streamtypechange",()=>{Qt(this,va,es).call(this)})}},xu=new WeakSet,Nv=function(){var o,m;try{(o=window==null?void 0:window.CSS)==null||o.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(m=window==null?void 0:window.CSS)==null||m.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},po=new WeakSet,Dh=function(o){Object.assign(ot(this,an),o),Qt(this,va,es).call(this)},va=new WeakSet,es=function(o={}){Mv(xv(Z0(this,{...ot(this,an),...o})),this.shadowRoot)},Pu=new WeakSet,Fv=function(){let o=v=>{var M,U;if(!(v!=null&&v.startsWith("theme-")))return;let y=v.replace(/^theme-/,"");if(Rh.includes(y))return;let I=this.getAttribute(v);I!=null?(M=this.mediaTheme)==null||M.setAttribute(y,I):(U=this.mediaTheme)==null||U.removeAttribute(y)};new MutationObserver(v=>{for(let{attributeName:y}of v)o(y)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(o)},Ou=new WeakSet,Uv=function(){var m;let o=v=>{let{detail:y}=v;if(y instanceof At||(y=new At(y.message,y.code,y.fatal)),!(y!=null&&y.fatal)){da(y),y.data&&da(`${y.name} data:`,y.data);return}let{dialog:I,devlog:M}=Mu(y,!window.navigator.onLine,this.playbackId,this.playbackToken);M.message&&ph(M),tr(y),y.data&&tr(`${y.name} data:`,y.data),Qt(this,po,Dh).call(this,{isDialogOpen:!0,dialog:I})};this.addEventListener("error",o),this.media&&(this.media.errorTranslator=(v={})=>{var I,M,U;if(!(((I=this.media)==null?void 0:I.error)instanceof At))return v;let{devlog:y}=Mu((M=this.media)==null?void 0:M.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(U=this.media)==null?void 0:U.error.code,player_error_message:y.message?String(y.message):v.player_error_message,player_error_context:y.context?String(y.context):v.player_error_context}}),(m=this.media)==null||m.addEventListener("error",v=>{var I,M;let{detail:y}=v;if(!y){let{message:U,code:H}=(M=(I=this.media)==null?void 0:I.error)!=null?M:{};y=new At(U,H)}!(y!=null&&y.fatal)||this.dispatchEvent(new CustomEvent("error",{detail:y}))})},Nu=new WeakSet,Bv=function(){var m,v,y,I;let o=()=>Qt(this,va,es).call(this);(v=(m=this.media)==null?void 0:m.textTracks)==null||v.addEventListener("addtrack",o),(I=(y=this.media)==null?void 0:y.textTracks)==null||I.addEventListener("removetrack",o)},Fu=new WeakSet,Hv=function(){var z,J;let o=/.*Version\/.*Safari\/.*/.test(navigator.userAgent);if(!/Firefox/i.test(navigator.userAgent))return;let v,y=new WeakMap,I=()=>this.streamType===gt.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,M=(Z,se,me=!1)=>{if(I())return;Array.from(Z&&Z.activeCues||[]).forEach(ge=>{if(!(!ge.snapToLines||ge.line<-5||ge.line>=0&&ge.line<10))if(!se||this.paused){let ye=ge.text.split(`
|
|
2022
|
-
`).length,
|
|
2020
|
+
`};function hl(r,e,t,i,s){var o,l,d;let n={},a={};switch(r.code){case Ze.MEDIA_ERR_NETWORK:{switch(n.title=Le("Network Error",s),n.message=r.message,(o=r.data)==null?void 0:o.response.code){case 412:{n.title=Le("Video is not currently available",s),n.message=Le("The live stream or video file are not yet ready.",s),a.message=Le("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=Le("Video does not exist",s),n.message="",a.message=Le("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=Le("Invalid playback URL",s),n.message=Le("The video URL or playback-token are formatted with incorrect or incomplete information.",s),a.message=Le("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:u,aud:c,sub:h}=mr(i),m=Date.now()>u*1e3,g=h!==t,E=c!=="v",T={timeStyle:"medium",dateStyle:"medium"};if(m){n.title=Le("Video URL has expired",s),n.message=Le("The video\u2019s secured playback-token has expired.",s),a.message=Le("The video\u2019s secured playback-token has expired.",s),a.context=Le("Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat(Hr.code,T).format(u*1e3),currentDate:new Intl.DateTimeFormat(Hr.code,T).format(Date.now())}),a.file="403-expired-token.md";break}if(g){n.title=Le("Video URL is formatted incorrectly",s),n.message=Le("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.message=Le("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.context=Le("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=Le("Video URL is formatted incorrectly",s),n.message=Le("The playback-token is formatted with incorrect information.",s),a.message=Le("The playback-token is formatted with incorrect information.",s),a.context=Le("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",s).format({tokenType:c}),a.file="403-incorrect-aud-value.md";break}a.message=Le("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 Ze.MEDIA_ERR_DECODE:{let{message:u}=r;n={title:Le("Media Error",s),message:u},a.file="media-decode-error.md";break}case Ze.MEDIA_ERR_SRC_NOT_SUPPORTED:{let u=(d=(l=r.data)==null?void 0:l.response)==null?void 0:d.code;if(u>=400&&u<500){r.code=Ze.MEDIA_ERR_NETWORK,r.data={response:{code:u}},{dialog:n,devlog:a}=hl(r,e,t,i);break}n={title:Le("Source Not Supported",s),message:r.message},a.file="media-src-not-supported.md";break}default:n={title:Le("Error",s),message:r.message};break}return e&&(n={title:Le("Your device appears to be offline",s),message:Le("Check your internet connection and try reloading this video.",s)}),{dialog:n,devlog:a}}var Ji={SRC:"src",POSTER:"poster"},te={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"},ih=["audio","backwardseekoffset","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function oA(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(te.STORYBOARD_SRC),placeholder:r.getAttribute("placeholder"),themeTemplate:lA(r),thumbnailTime:!r.tokens.thumbnail&&r.thumbnailTime,autoplay:r.autoplay,crossOrigin:r.crossOrigin,loop:r.loop,noHotKeys:r.hasAttribute(te.NOHOTKEYS),hotKeys:r.getAttribute(te.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:Un(r.getAttribute(Y.STREAM_TYPE)),primaryColor:r.primaryColor,secondaryColor:r.secondaryColor,forwardSeekOffset:r.forwardSeekOffset,backwardSeekOffset:r.backwardSeekOffset,defaultHiddenCaptions:r.defaultHiddenCaptions,defaultShowRemainingTime:r.defaultShowRemainingTime,hideDuration:dA(r),playbackRates:r.getAttribute(te.PLAYBACK_RATES),customDomain:(i=r.getAttribute(Y.CUSTOM_DOMAIN))!=null?i:void 0,title:r.getAttribute(te.TITLE),novolumepref:r.hasAttribute(te.NO_VOLUME_PREF),...e}}function lA(r){var t,i;let e=r.getAttribute(te.THEME);if(e){let s=(i=(t=r.getRootNode())==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(s)return s;e.startsWith("media-theme-")||(e=`media-theme-${e}`);let n=ht.customElements.get(e);if(n!=null&&n.template)return n.template}}function dA(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 f0(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 uA=Object.values(Y),cA=Object.values(Ji),hA=Object.values(te),fA=il(),mA="mux-player",m0={dialog:void 0,isDialogOpen:!1},Xn,Qn,er,Zn,Qr,br,Gs,fl,p0,Jn,rh,Tr,Hs,ml,g0,pl,v0,gl,E0,vl,y0,zn=class extends Kc{constructor(){super();lt(this,br);lt(this,fl);lt(this,Jn);lt(this,Tr);lt(this,ml);lt(this,pl);lt(this,gl);lt(this,vl);lt(this,Xn,!1);lt(this,Qn,{});lt(this,er,!0);lt(this,Zn,new tl(this,"hotkeys"));lt(this,Qr,{...m0,onCloseErrorDialog:()=>Et(this,Jn,rh).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:t=>{Bc(this,Xt.activeElement)||t.preventDefault()}});this.attachShadow({mode:"open"}),Et(this,fl,p0).call(this),this.isConnected&&Et(this,br,Gs).call(this)}static get observedAttributes(){var t;return[...(t=Kc.observedAttributes)!=null?t:[],...cA,...uA,...hA]}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=f0(this))}attributeChangedCallback(t,i,s){switch(Et(this,br,Gs).call(this),super.attributeChangedCallback(t,i,s),t){case te.HOTKEYS:Oe(this,Zn).value=s;break;case te.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&pr(Le("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case te.THUMBNAIL_TOKEN:{let{aud:a}=mr(s);s&&a!=="t"&&pr(Le("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:a}));break}case te.STORYBOARD_TOKEN:{let{aud:a}=mr(s);s&&a!=="s"&&pr(Le("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")&&gi(Le("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&&![Ye.LIVE,Ye.ON_DEMAND,Ye.UNKNOWN].includes(s)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=s.includes("dvr")?Number.POSITIVE_INFINITY:0:Hc({file:"invalid-stream-type.md",message:Le("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):this.targetLiveWindow=s===Ye.LIVE?0:Number.NaN}[Y.PLAYBACK_ID,Ji.SRC,te.PLAYBACK_TOKEN].includes(t)&&i!==s&&ti(this,Qr,{...Oe(this,Qr),...m0}),Et(this,Tr,Hs).call(this,{[Bg(t)]:s})}get preferCmcd(){var t;return(t=this.getAttribute(Y.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?Ms.includes(t)?this.setAttribute(Y.PREFER_CMCD,t):pr(`Invalid value for preferCmcd. Must be one of ${Ms.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(te.THEME))!=null?t:""}set theme(t){this.setAttribute(te.THEME,`${t}`)}get themeProps(){let t=this.mediaTheme;if(!t)return;let i={};for(let s of t.getAttributeNames()){if(ih.includes(s))continue;let n=t.getAttribute(s);i[Jo(s)]=n===""?!0:n}return i}set themeProps(t){var s,n;Et(this,br,Gs).call(this);let i={...this.themeProps,...t};for(let a in i){if(ih.includes(a))continue;let o=t==null?void 0:t[a];typeof o=="boolean"||o==null?(s=this.mediaTheme)==null||s.toggleAttribute(Zo(a),Boolean(o)):(n=this.mediaTheme)==null||n.setAttribute(Zo(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=$s(this,Ji.SRC))!=null?t:void 0:(i=this.getAttribute(Ji.SRC))!=null?i:void 0}set src(t){t?this.setAttribute(Ji.SRC,t):this.removeAttribute(Ji.SRC)}get poster(){var i;let t=this.getAttribute(Ji.POSTER);if(t!=null)return t;if(this.playbackId&&!this.audio)return Fg(this.playbackId,{domain:this.customDomain,thumbnailTime:(i=this.thumbnailTime)!=null?i:this.startTime,token:this.tokens.thumbnail})}set poster(t){t||t===""?this.setAttribute(Ji.POSTER,t):this.removeAttribute(Ji.POSTER)}get storyboardSrc(){var t;return(t=this.getAttribute(te.STORYBOARD_SRC))!=null?t:void 0}set storyboardSrc(t){t?this.setAttribute(te.STORYBOARD_SRC,t):this.removeAttribute(te.STORYBOARD_SRC)}get storyboard(){if(this.storyboardSrc&&!this.tokens.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[Ye.LIVE,Ye.UNKNOWN].includes(this.streamType)))return Ug(this.playbackId,{domain:this.customDomain,token:this.tokens.storyboard})}get audio(){return this.hasAttribute(te.AUDIO)}set audio(t){if(!t){this.removeAttribute(te.AUDIO);return}this.setAttribute(te.AUDIO,"")}get hotkeys(){return Oe(this,Zn)}get nohotkeys(){return this.hasAttribute(te.NOHOTKEYS)}set nohotkeys(t){if(!t){this.removeAttribute(te.NOHOTKEYS);return}this.setAttribute(te.NOHOTKEYS,"")}get thumbnailTime(){return ji(this.getAttribute(te.THUMBNAIL_TIME))}set thumbnailTime(t){this.setAttribute(te.THUMBNAIL_TIME,`${t}`)}get title(){var t;return(t=this.getAttribute(te.TITLE))!=null?t:""}set title(t){t!==this.title&&(t?this.setAttribute(te.TITLE,t):this.removeAttribute("title"),super.title=t)}get placeholder(){var t;return(t=$s(this,te.PLACEHOLDER))!=null?t:""}set placeholder(t){this.setAttribute(te.PLACEHOLDER,`${t}`)}get primaryColor(){var i,s;let t=this.getAttribute(te.PRIMARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(i=ht.getComputedStyle(this.mediaTheme))==null?void 0:i.getPropertyValue("--_primary-color"))==null?void 0:s.trim(),t))return t}set primaryColor(t){this.setAttribute(te.PRIMARY_COLOR,`${t}`)}get secondaryColor(){var i,s;let t=this.getAttribute(te.SECONDARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(i=ht.getComputedStyle(this.mediaTheme))==null?void 0:i.getPropertyValue("--_secondary-color"))==null?void 0:s.trim(),t))return t}set secondaryColor(t){this.setAttribute(te.SECONDARY_COLOR,`${t}`)}get defaultShowRemainingTime(){return this.hasAttribute(te.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(t){t?this.setAttribute(te.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(te.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(!!this.hasAttribute(te.PLAYBACK_RATES))return this.getAttribute(te.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(te.PLAYBACK_RATES);return}this.setAttribute(te.PLAYBACK_RATES,t.join(" "))}get forwardSeekOffset(){var t;return(t=ji(this.getAttribute(te.FORWARD_SEEK_OFFSET)))!=null?t:10}set forwardSeekOffset(t){this.setAttribute(te.FORWARD_SEEK_OFFSET,`${t}`)}get backwardSeekOffset(){var t;return(t=ji(this.getAttribute(te.BACKWARD_SEEK_OFFSET)))!=null?t:10}set backwardSeekOffset(t){this.setAttribute(te.BACKWARD_SEEK_OFFSET,`${t}`)}get defaultHiddenCaptions(){return this.hasAttribute(te.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(t){t?this.setAttribute(te.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(te.DEFAULT_HIDDEN_CAPTIONS)}get playerSoftwareName(){var t;return(t=this.getAttribute(Y.PLAYER_SOFTWARE_NAME))!=null?t:mA}get playerSoftwareVersion(){var t;return(t=this.getAttribute(Y.PLAYER_SOFTWARE_VERSION))!=null?t:fA}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=$s(this,Y.ENV_KEY))!=null?t:void 0}set envKey(t){this.setAttribute(Y.ENV_KEY,`${t}`)}get noVolumePref(){return this.hasAttribute(te.NO_VOLUME_PREF)}set noVolumePref(t){t?this.setAttribute(te.NO_VOLUME_PREF,""):this.removeAttribute(te.NO_VOLUME_PREF)}get debug(){return $s(this,Y.DEBUG)!=null}set debug(t){t?this.setAttribute(Y.DEBUG,""):this.removeAttribute(Y.DEBUG)}get disableCookies(){return $s(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:Ye.UNKNOWN}set streamType(t){this.setAttribute(Y.STREAM_TYPE,`${t}`)}get defaultStreamType(){var t,i,s;return(s=(i=this.getAttribute(te.DEFAULT_STREAM_TYPE))!=null?i:(t=this.mediaController)==null?void 0:t.getAttribute(te.DEFAULT_STREAM_TYPE))!=null?s:Ye.ON_DEMAND}set defaultStreamType(t){t?this.setAttribute(te.DEFAULT_STREAM_TYPE,t):this.removeAttribute(te.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var t,i;return this.hasAttribute(te.TARGET_LIVE_WINDOW)?+this.getAttribute(te.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(te.TARGET_LIVE_WINDOW):this.setAttribute(te.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t;return(t=this.media)==null?void 0:t.liveEdgeStart}get startTime(){return ji($s(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(Et(this,br,Gs).call(this),!this.media){gi("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...f0(this),...t}}async addCuePoints(t){var i;if(Et(this,br,Gs).call(this),!this.media){gi("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(te.PLAYBACK_TOKEN),i=this.getAttribute(te.THUMBNAIL_TOKEN),s=this.getAttribute(te.STORYBOARD_TOKEN);return{...Oe(this,Qn),...t!=null?{playback:t}:{},...i!=null?{thumbnail:i}:{},...s!=null?{storyboard:s}:{}}}set tokens(t){ti(this,Qn,t!=null?t:{})}get playbackToken(){var t;return(t=this.getAttribute(te.PLAYBACK_TOKEN))!=null?t:void 0}set playbackToken(t){this.setAttribute(te.PLAYBACK_TOKEN,`${t}`)}get thumbnailToken(){var t;return(t=this.getAttribute(te.THUMBNAIL_TOKEN))!=null?t:void 0}set thumbnailToken(t){this.setAttribute(te.THUMBNAIL_TOKEN,`${t}`)}get storyboardToken(){var t;return(t=this.getAttribute(te.STORYBOARD_TOKEN))!=null?t:void 0}set storyboardToken(t){this.setAttribute(te.STORYBOARD_TOKEN,`${t}`)}addTextTrack(t,i,s,n){var o;let a=(o=this.media)==null?void 0:o.nativeEl;if(!!a)return Ho(a,t,i,s,n)}removeTextTrack(t){var s;let i=(s=this.media)==null?void 0:s.nativeEl;if(!!i)return ug(i,t)}get textTracks(){var t;return(t=this.media)==null?void 0:t.textTracks}};Xn=new WeakMap,Qn=new WeakMap,er=new WeakMap,Zn=new WeakMap,Qr=new WeakMap,br=new WeakSet,Gs=function(){var t,i,s;if(!Oe(this,Xn)){ti(this,Xn,!0),Et(this,Tr,Hs).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof ht.HTMLElement))throw""}catch{gi("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof Og))throw""}catch{gi("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof Gl))throw""}catch{gi("<media-controller> failed to upgrade!")}Vg(this),Et(this,ml,g0).call(this),Et(this,pl,v0).call(this),Et(this,gl,E0).call(this),ti(this,er,(i=(t=this.mediaController)==null?void 0:t.hasAttribute("userinactive"))!=null?i:!0),Et(this,vl,y0).call(this),(s=this.media)==null||s.addEventListener("streamtypechange",()=>{Et(this,Tr,Hs).call(this)})}},fl=new WeakSet,p0=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{}},Jn=new WeakSet,rh=function(t){Object.assign(Oe(this,Qr),t),Et(this,Tr,Hs).call(this)},Tr=new WeakSet,Hs=function(t={}){c0(h0(oA(this,{...Oe(this,Qr),...t})),this.shadowRoot)},ml=new WeakSet,g0=function(){let t=s=>{var o,l;if(!(s!=null&&s.startsWith("theme-")))return;let n=s.replace(/^theme-/,"");if(ih.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)},pl=new WeakSet,v0=function(){var i;let t=s=>{let{detail:n}=s;if(n instanceof Ze||(n=new Ze(n.message,n.code,n.fatal)),!(n!=null&&n.fatal)){pr(n),n.data&&pr(`${n.name} data:`,n.data);return}let{dialog:a,devlog:o}=hl(n,!window.navigator.onLine,this.playbackId,this.playbackToken);o.message&&Hc(o),gi(n),n.data&&gi(`${n.name} data:`,n.data),Et(this,Jn,rh).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 Ze))return s;let{devlog:n}=hl((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 Ze(l,d)}!(n!=null&&n.fatal)||this.dispatchEvent(new CustomEvent("error",{detail:n}))})},gl=new WeakSet,E0=function(){var i,s,n,a;let t=()=>Et(this,Tr,Hs).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)},vl=new WeakSet,y0=function(){var u,c;let t=/.*Version\/.*Safari\/.*/.test(navigator.userAgent);if(!/Firefox/i.test(navigator.userAgent))return;let s,n=new WeakMap,a=()=>this.streamType===Ye.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(`
|
|
2021
|
+
`).length,L=t?-2:-3;this.streamType===Ye.LIVE&&(L=t?-1:-2);let S=L-A;if(T.line===S&&!g)return;n.has(T)||n.set(T,T.line),T.line=S-1,T.line=S}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,Oe(this,er))};if(d(),(u=this.textTracks)==null||u.addEventListener("change",d),(c=this.textTracks)==null||c.addEventListener("addtrack",d),navigator.userAgent.includes("Chrome/")){let h=()=>{o(s,Oe(this,er),!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;Oe(this,er)!==h&&(ti(this,er,h),o(s,Oe(this,er)))})};function $s(r,e){return r.media?r.media.getAttribute(e):r.getAttribute(e)}ht.customElements.get("mux-player")||(ht.customElements.define("mux-player",zn),ht.MuxPlayerElement=zn);var Iw=zn;})();
|
|
2023
2022
|
/*!
|
|
2024
2023
|
* JavaScript Cookie v2.1.3
|
|
2025
2024
|
* https://github.com/js-cookie/js-cookie
|